Question

2. Use a MATLAB built-in solver to numerically solve: yr 1.5y for 0 s ar S 3 with y (0) 2 dar Make a plot of the numerical solution as a solid red line and the exact solution as green circles as shown 22 The exact solution is y 2e Use a MATLAB built-in function to numerically calculate the area of the solution. Use the text command to plot the area. with 2-digits of precision as shown

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution: For dy/dx yx 2+ 1.5y: func-6(x,y) -y * x^2 + 1.5 * y; using the ode45 built in solver, initial condition y (0)-2 wiSample Output: The area of calculation is: θ.ee, Θ.13 6.26, θ.39 0.54, Θ.70 0.88, 1.05 1.21, 1.36 1.54, 1.66 1.79, 1.90 2.01,6 0.5 1.5 2.5 For exact solution y = 2en_(2x13-9s)/6: 8x value that is 0< x<-3 x-0:0.1:3; 8y value that is exact solution y 2Sample Output: The area of calculation is: 6.33 0.13 0.05 0.01 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.Copyable Code:

For dy/dx = -yx^2 + 1.5y:

func = @(x,y) -y * x^2 + 1.5 * y;
%using the ode45 built in solver, initial condition y(0)=2 with interval [0, 3]
[xValue,yValue] = ode45(func,[0,3],2);
fprintf('The area of calculation is:\n')
%for area with 2-digits precision
fprintf('%.2f, %.2f\n',xValue, yValue)
%plot the graph with solid red line
plot(xValue,yValue,'r-')

For exact solution y = 2e^-(2 x ^3-9x)/6:

%x value that is 0<=x<=3
x=0:0.1:3;
%y value that is exact solution
y=2*exp(-2*x.^3-9*x)/6;
fprintf('The area of calculation is:\n')
%for area with 2-digits precision
fprintf('%.2f\n',y)
%plot the graph with green circle
plot(x,y,'go-')

Add a comment
Know the answer?
Add Answer to:
Use a MATLAB built-in solver to numerically solve: dy/dx = -yx^2 + 1.5y for 0 lessthanorequalto...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT