Question

Use a numerical solver and Euler's method to obtain a four-decimal approximation of the indicated value. First use

h = 0.1

and then use

h = 0.05.

y' = y − y2, y(0) = 0.3;    y(0.5)

4. 0/1 points Previous Answers ZillDiffEQ ModAp 11M 2.6.010. My Notes Ask Your Teacher Use a numerical solver and Eulers met

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

MATLAB Script:

close all
clear
clc

f = @(x,y) y - y^2; % Given ODE
x0 = 0; xf = 0.5; % Intervals of x
y0 = 0.3; % Initial condition

h1 = 0.1; % Step Size 1
y1 = euler(x0, y0, xf, h1, f);
fprintf('For h = 0.1, y(0.5) = %.4f\n', y1(end))

h2 = 0.05; % Step Size 2
y2 = euler(x0, y0, xf, h2, f);
fprintf('For h = 0.05, y(0.5) = %.4f\n', y2(end))

function y = euler(x0, y0, xf, h, f)
y(1) = y0;
x = x0:h:xf;
for i = 1:length(x)-1
f1 = f(x(i), y(i));
y(i+1) = y(i) + h*f1; % Euler's Update
end
end

Output:

For h = 0.1, y(0.5) = 0.4123
For h = 0.05, y(0.5) = 0.4132

Add a comment
Know the answer?
Add Answer to:
Use a numerical solver and Euler's method to obtain a four-decimal approximation of the indicated value....
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