Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

SHOW OUTPUTS Using Matlab solve the Questions You are to create a script in Matlab that will estimate the solution for an ordinary differential equation

image text in transcribed

SHOW OUTPUTS

Using Matlab solve the Questions You are to create a script in Matlab that will estimate the solution for an ordinary differential equation using the RK4 method outlined above. Below is some code to help you get started: 2) 2RRK4 clearvars Kalways helpful to have so natlab does.n't remenber past thingsl f8(t,y)(24t4ym2); Kdefine function, e.g. your y3 whthe ln1+1l cond 1+10ns 1. Using the RK4 method, give the numerical approximation for the IVP: y=ty; y(0)=e; with a step size of h=0.5 for the point at t=20. How does this compare to Euler's Method (e.g. simply using the k1 values to approximate this ODE)? 2. The exact solution to the IVP above is y(t)=et2/2+1. In a single figure, plot the results of RK4, Euler methods and the exact function (thus, your plot sbould contain 3 lines). To show the full Y-range, the Y-axis should be plotted using a log-scale, however the X-axis should remain linear. To do this, type "set(gca, 'YScale',' log ')" on the line below that used to create the plot. Make sure that your figure has a legend that describes what each line corresponds to. RK4 METHOD Suppose we have the initial value problem (IVP): y=f(t,y);y(t0)=y where y is the time derivative of the function y, i.e. y=didy. y is an unknown function of time t, which we would like to approximate; we are told that y, the rate at which y changes, is a function of t and of y itself. At the initial time t0 the corresponding y value is y0 - The function f and the data t0y0 are given. We want to 'step' through the function to find a numerical approximation at some time, t. Choose a step size, h, such that h>0 and define: yn+1=yn+6h(k1+2k2+2k3+k4)tn+1=tn+ for n=0,1,2,3,, using: k1=f(tn,yn)k2=f(tn+2h,yn+2hk1)k3=f(tn+2h,yn+2hk2)k4=f(tn+h,yn+hk3) Here yn+1 is the RK4 approximation of y(tn+1), and the next value (yn+1) is determined by the present value (yn) plus the weighted average of four increments, where each increment is the product of the size of the interval, h, and an estimated slope specified by function f on the right-hand side of the differential equation. - k1 is the increment based on the slope at the beginning of the interval, using y. - k2 is the increment based on the slope at the midpoint of the interval, using y+h2k1; - k3 is again the increment based on the slope at the midpoint, but now using y+2hk2; - k4 is the increment based on the slope at the end of the interval, using y+hk3

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions