Question

Use python (spi.RK45 )to code the Runge Kutta method to approximate/plot the solution the following initial-value...

Use python (spi.RK45 )to code the Runge Kutta method to approximate/plot the solution the following initial-value

?′=1+(?−?)2, 2<?<3, ?(2)=1y′=1+(t−y)2, 2

Homework Answers

Answer #1
def dydx(t, y): 
    return 1+(t-y)*2 

def rungeKutta(x0, y0, x, h): 
    # Count number of iterations using step size or 
    # step height h 
    n = (int)((x - x0)/h)  
    # Iterate for number of iterations 
    y = y0 
    for i in range(1, n + 1): 
        "Apply Runge Kutta Formulas to find next value of y"
        k1 = h * dydx(x0, y) 
        k2 = h * dydx(x0 + 0.5 * h, y + 0.5 * k1) 
        k3 = h * dydx(x0 + 0.5 * h, y + 0.5 * k2) 
        k4 = h * dydx(x0 + h, y + k3) 
  
        # Update next value of y 
        y = y + (1.0 / 6.0)*(k1 + 2 * k2 + 2 * k3 + k4) 
  
        # Update next value of x 
        x0 = x0 + h 
    return y 
  
# Driver method 
x0 = 0
y = 1
t = 2
h = 0.2
print ('The value of y at x is:', rungeKutta(x0, y, x, h))
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Use C++ in Solving Ordinary Differential Equations using a Fourth-Order Runge-Kutta of Your Own Creation Assignment:...
Use C++ in Solving Ordinary Differential Equations using a Fourth-Order Runge-Kutta of Your Own Creation Assignment: Design and construct a computer program in C++ that will illustrate the use of a fourth-order explicit Runge-Kutta method of your own design. In other words, you will first have to solve the Runge-Kutta equations of condition for the coefficients of a fourth-order Runge-Kutta method.   See the Mathematica notebook on solving the equations for 4th order RK method.   That notebook can be found at...
Use​ Euler's method with step size h=0.2 to approximate the solution to the initial value problem...
Use​ Euler's method with step size h=0.2 to approximate the solution to the initial value problem at the points x=4.2 4.4 4.6 4.8 round to two decimal y'=3/x(y^2+y), y(4)=1
Given (dy/dx)=(3x^3+6xy^2-x)/(2y) with y=0.707 at x= 0, h=0.1 obtain a solution by the fourth order Runge-Kutta...
Given (dy/dx)=(3x^3+6xy^2-x)/(2y) with y=0.707 at x= 0, h=0.1 obtain a solution by the fourth order Runge-Kutta method for a range x=0 to 0.5
Problem 6. Use Euler’s Method to approximate the particular solution of this initial value problem (IVP):...
Problem 6. Use Euler’s Method to approximate the particular solution of this initial value problem (IVP): dydx=√y+x satisfying the initial condition y(0)=1 on the interval [0,0.4] with h = 0.1. Round ?? to 4 decimal places.
Use Euler's method to approximate y(0.2), where y(x) is the solution of the initial-value problem y''...
Use Euler's method to approximate y(0.2), where y(x) is the solution of the initial-value problem y'' − 4y' + 4y = 0,  y(0) = −3,  y'(0) = 1. Use h = 0.1. Find the analytic solution of the problem, and compare the actual value of y(0.2) with y2. (Round your answers to four decimal places.) y(0.2) ≈     (Euler approximation) y(0.2) = -2.3869 (exact value) I'm looking for the Euler approximation number, thanks.
Use Euler's method to approximate y(1.2), where y(x) is the solution of the initial-value problem x2y''...
Use Euler's method to approximate y(1.2), where y(x) is the solution of the initial-value problem x2y'' − 2xy' + 2y = 0,  y(1) = 9,  y'(1) = 9, where x > 0. Use h = 0.1. Find the analytic solution of the problem, and compare the actual value of y(1.2) with y2. (Round your answers to four decimal places.) y(1.2) ≈     (Euler approximation) y(1.2) =     (exact value)
Use Euler's method to approximate y(0.7), where y(x) is the solution of the initial-value problem y''...
Use Euler's method to approximate y(0.7), where y(x) is the solution of the initial-value problem y'' − (2x + 1)y = 1, y(0) = 3, y'(0) = 1. First use one step with h = 0.7. (Round your answer to two decimal places.) y(0.7) = ? Then repeat the calculations using two steps with h = 0.35. (Round your answers to two decimal places.) y(0.35) = ? y(0.7) =?
PLEASE USE PYTHON CODE 8. Use Neville's method to determine the equation of quadratic that passes...
PLEASE USE PYTHON CODE 8. Use Neville's method to determine the equation of quadratic that passes through the points x = -1, 1, 3 y = 17, -7, -15
10.16: Write a user-defined MATLAB function that solves a first-order ODE by applying the midpoint method...
10.16: Write a user-defined MATLAB function that solves a first-order ODE by applying the midpoint method (use the form of second-order Runge-Kutta method, Eqs(10.65),(10.66)). For function name and arguments use [x,y]=odeMIDPOINT(ODE,a,b,h,yINI). The input argument ODE is a name for the function that calculates dy/dx. It is a dummy name for the function that is imported into odeMIDPOINT. The arguments a and b define the domain of the solution, h is step size; yINI is initial value. The output arguments, x...
dy/dx = x^4/y^2 initial condition y(1)= 1 a) use eulers method to approximate the solution at...
dy/dx = x^4/y^2 initial condition y(1)= 1 a) use eulers method to approximate the solution at x=1.6 and a step size od delta x = 0.2 b) solve the differential equation exactly using seperation variabled and the intial condtion y(1)=1. c) what is the exact value of y(1.6) for your solution from part b.
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT