(22) Initial Value Problems

(22) Initial Value Problems - InitialValueProblems...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
Initial Value Problems Nathan Friedman Fall, 2008
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2008 Initial Value Problems 2 Ordinary Differential  Equations In many areas of application we can measure  how things change in some process From these measurements we would like to find  the function that describes the process Examples: Change in concentrations during chemical reaction Heating or cooling of objects Current flow in electrical circuits Population dynamics
Background image of page 2
2008 Initial Value Problems 3 ODE’s If we let y(x) be the function we would like  to study, we are able to observe the rate of growth of the function This leads to equations of the form dy/dx = f(x,y)
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2008 Initial Value Problems 4 Analytic Solutions Some ODE’s have analytic solutions dy/dx = x + y - 1 Has the solution y(x) = e x – x Others have no analytic solution. For  example: dy/dx = x 2 + y 2
Background image of page 4
2008 Initial Value Problems 5 Initial Value Problems We use numerical methods to  approximate the solution The methods we consider are called initial  value problems since we must know the  value of the function,  y 0 , at some initial  point  x 0
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2008 Initial Value Problems 6 The Euler Method We “grow” the function from the starting  value one step at a time Think of the  dy/dx  in terms of discrete  steps,  delta_y  and  delta_x Then the derivative approximates the  ratio of these two values for small vaues  of delta_x
Background image of page 6
2008 Initial Value Problems 7 The Euler Method Multipling  dy/dx  by  delta_x  gives an  approximate value for  delta_y The Euler method increments the  independent variable by one stepsize,  delta_x , at a time Using the derivative, we approximate  delta_y  and then the value of the  function at the next step
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2008 Initial Value Problems 8 Euler Method We want to find an approximate solution to: dy/dx = f(x,y) y(x0) = y0 Now  f(x0,y0)  is the slope of the function at  (x0,y0) Approximate the function value at  x0+h  by            y0 + h*f(x0,y0) Repeat this process so that x_(n+1) = x_n + h y_(n+1) = y_n + hf(x_n,y_n)
Background image of page 8
2008 Initial Value Problems 9 A Simple Example #include <stdio.h> #include <math.h> #define H 0.1 int main() { double x,newx; double y,newy; int i,steps = 10; x = 0; y = 1; for (i = 0; i < steps; i++) { newx = x + H; newy = y + H * (x + y -1); x = newx; y = newy; printf (" %f %f %f\n", newx, newy,exp(x)-x); } return 0; }
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2008 Initial Value Problems 10 #define After the  #include  commands, we can  also define names using  #define In the program, the name is replaced by  the expression Note that the name is not a variable  (that is the name of a memory location) The name is just an alias for the value
Background image of page 10
Initial Value Problems 11 #define Syntax No ; at end
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 45

(22) Initial Value Problems - InitialValueProblems...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online