Example Solve the initial value problem: = + 2y, = 0 numerically (Euler), finding a value for the solution at = x y(0) x y′ 1, and using steps of size = 0.25. h = + xn+1 xn h = + yn+1 yn h f(xn, yn) (0,0) 1. point (0.25, 0) 2. point = + 0.25 x1 xo h = = + = + (xo + 2yo) = 0 + 0.25 (0 + 2*0) = 0 y1 yo h f(xo, yo) yo h (0.5, 0.0625) 3. point = + x2 x1 h = 0.5 = + (x1, = + (x1 + 2y1) = 0 + 0.25 (0.25 + 2*0) = 0.0625 y2 y1 h f y1) y1 h (0.75, 0.21875) 4. point = + x3 x2 h = 0.75 = + (x2, = + (x2 + 2y2) = 0.0625+0.25 (0.5+2*0.0625) = 0.21875 y3 y2 h f y2) y2 h (1, 0.515625) 5. point = + = 1 x4 x3 h = + (x3, = + (x3 + 2y3)= 0.21875+0.25 (0.75+2*0.21875) = 0.515625 y4 y3 h f y3) y3 h How accurate is this solution: NOT VERY!!! Analytically: = + 2y, = 0 y′ x y(0) linear differential equation of order 1: Comparison of analytical (blue) and numerical solutions (red) with steps 0.25 and 0.02. The numerical solution gets worse and worse as we move further to the right, and becomes more accurate with the smaller steps. This method is one that truly belongs on a computer! Slope Fields Purpose: To graphically express a differential equation using slope fields.
Example Solve the initial value problem: y′ = x + 2y, y(0) = 0 numerically (Euler), finding a value for the solution at x = 1, and using steps of size h = 0.25. xn+1 = xn + h yn+1 = yn + h f(xn, yn) 1. point (0,0) 2. point (0.25, 0) x1 = xo + h = 0.25 y1 = yo + h f(xo, yo) = yo + h (xo + 2yo) = 0 + 0.25 (0 + 2*0) = 0 3. point (0.5, 0.0625) x2 = x1 + h = 0.5 y2 = y1 + h f (x1, y1) = y1 + h (x1 + 2y1) = 0 + 0.25 (0.25 + 2*0) = 0.0625 4. point (0.75, 0.21875) x3 = x2 + h = 0.75 y3 = y2 + h f (x2, y2) = y2 + h (x2 + 2y2) = 0.0625+0.25 (0.5+2*0.0625) = 0.21875 5. point (1, 0.515625) x4 = x3 + h = 1 y4 = y3 + h f (x3, y3) = y3 + h (x3 + 2y3)= 0.21875+0.25 (0.75+2*0.21875) = 0.515625 How accurate is this solution: NOT VERY!!! Analytically: y′ = x + 2y, y(0) = 0 linear differential equation of order 1: Comparison of analytical (blue) and numerical solutions (red) with steps 0.25 and 0.02. The numerical solution gets worse and worse as we move further to the right, and becomes more accurate with the smaller steps. This method is one that truly belongs on a computer! Slope Fields Purpose: To graphically express a differential equation using slope fields.
EULER%20and%20SLOPE%20FIELDS-HANDOUT.docx