Answered step by step
Verified Expert Solution
Question
1 Approved Answer
WRITE MATLAB CODE TO SOLVE, NEED TO KNOW HOW TO ANSWER THESE IN A MATLAB FUNCTION PLEASE Question 1: Apply the Euler method to solve
WRITE MATLAB CODE TO SOLVE, NEED TO KNOW HOW TO ANSWER THESE IN A MATLAB FUNCTION PLEASE
Question 1: Apply the Euler method to solve
Question 2 The Euler method is an example of a first order method. This means that the error is proportional to h, so that doubling the number of points roughly cuts the error roughly by a factor of two.
Your assignment One of the real power of numerical methods is that it allows you to see what the solution looks like, even if you can't solve it exactly. The problem below is an example of a Bernoulli differential equation. These can be solved but require more advanced methods. Question 1: Apply the Euler method to solve dy 8 - (1+1)y2 y(0) = 1 from t=0 to t = 5. Your code should use a function, just as in the code I used to find z(t) in the most recent section. Modify the above code (using a function f) so that it solves this ODE Note that this problem has exact solution 1017 + 18 y(t) = (t + 1) 10 + 9 Then do the following: Figure out what is the minimum value of N that you need such that the maximum error is smaller than 0.01. Do this by experimenting with N until you get a small enough error. Plot the computed and exact solution using this value of N. Show the method is approximately first order by doubling N and computing the ratio of the errors. Doing so may require a much larger value of N, especially in the two further questions below. You should find that the solution has exactly one local maximum. y(tmax) = Ymax. Use the max function to find approximations to both tax and ymax - To do this, you need to call the function with two output arguments. Look at the help for the function max by typing doc max at the Matlab >> prompt. Print out these values and, if possible, plot this point with a marker on your plot of y(t). You should hand in a printout of your code, any figures you print, and a report of a few sentences answering all the questions. Question 2 The Euler method is an example of a first order method. This means that the error is proportional to h, so that doubling the number of points roughly cuts the error roughly by a factor of two. The improved Euler method is what's known as a two-step method. It requires two evaluations of the function per time step. At each step, we define two extra quantities before computing Yn+1 ki = f (y) kz = f(t,+h, y,+ hk) Vn+1 = y + (k, +k;). The payoff for using this more complicated method is that it is second order! This means that each time you double the number of time steps the error goes down by a factor of four. This is a big deal. Program this method to solve the same problem from Question 1 and Determine how large N needs to be get a maximum error error less than 0.01. Show the method is second order by doubling N and seeing that the error has gone down by a factor of four. Here we see the payoff of defining f(t,y) in a separate function. The standard method most people use for general purposes is called fourth-order Rung-Kutta. It uses four evaluations at each step, and the method's total error scales like h+For certain applications, such as computing spacecraft trajectories, scientists are likely to use methods that are of much higher order, even 12th order! function yprime=f(t,y) yprime = (sin(t)+1/(1+t))*y; endStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started