Question: PLEASE USE MATLAB!!!!! PLEASE DO NOT USE SOMEONE ELSES ANSWER!!! Here is some hints that we were given... % % % Use finite differences to

PLEASE USE MATLAB!!!!! PLEASE DO NOT USE SOMEONE ELSES ANSWER!!!
Here is some hints that we were given...
%%% Use finite differences to solve the BVP
%%% Be careful about the shape of the vectors, you may have to transpose to
%%% get the correct shape. It's a good idea to print the solutions out to
%%% make sure the shape is correct.
%%% Part 2: Shooting Method via Bisection
%%% Use the shooting method to solve the BVP
%%% It's a good idea to test out a few in the command window first to make
%%% sure that your initial conditions gets you to different sides of the right
%%% boundary condition.
%%% Use the plot to help you figure out what your choices of initial
%%% conditions should be
Consider the boundary value problem
x+x=5cos(4t), with x(0)=1 and x(6)=0.5.
The true solution to this boundary value problem is
x(t)=C1sin(t)+C2cos(t)-13cos(4t)
where
C1=12+13cos(24)-43cos(6)sin(6) and C2=43.
The solution looks like this:
(1) Following the finite difference process we used in lecture, use a second order difference scheme to
approximate x and rewrite this initial value problem as a linear system of equations Ax=b. Use
t=0.1. Note that there will be 61 total t-values, but we are only trying to approximate x at the
interior times. The matrix A should be NintNint, where Nint is the number of interior times, and
the vector b should be Nint1. Save a copy of A in a variable named A9. Save a copy of b in a
variable named A10.
Solve this linear system using Gaussian elimination (the backslash operator in MATLAB or the
solve function in python). Make a 611 column vector containing the x values at all times (including
the two boundary values) and save a copy of this vector in a variable named A11.(Hint: if A11 is
passing but A9 and A10 aren't, to be consistent with the autograder don't distribute the 1t.)
Find the maximum (in absolute value) error between this approximation and the true solution. Save
this error in a variable named A12.
(2) Now solve the problem using the shooting method. Remember, you need to convert this second order
ODE into a system of two first order ODEs. Apply a bisection scheme to the usual IVP solvers ode45
(MATLAB) or solve_ivp (Python) using t=0.1. For the second initial conditions, you can use the
plot to help you test out values that will get you on different sides of the right boundary condition.
Break out of the loop for bisection when the difference between your approximation at the right
boundary point and the exact value at the right boundary point is less than 1 e-8; i.e.,|xapprox(6)-
x(6)|=|xapprox(6)-0.5|10-8. Save the numerical solution as a 611 column vector A13 and the
maximum (in absolute value) error max|xapprox-x| as A14. Further save the maximum difference in
absolute value between the solution from part 1 and this solution as A15 A13- A11)
 PLEASE USE MATLAB!!!!! PLEASE DO NOT USE SOMEONE ELSES ANSWER!!! Here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!