Question

Given the initial-value problem y'=2-2tyt2+1,          0 ≤t≤1,        y0=1 With exact solution yt= 2t+1t2+1 Using MATLAB use...

Given the initial-value problem

y'=2-2tyt2+1,          0 ≤t≤1,        y0=1

With exact solution

yt= 2t+1t2+1

Using MATLAB use Euler’s method with h = 0.1 to approximate the solution of y

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

i use 'x' in replace of 't'

clear all

clc

f=@(x,y)(2-2.*x.*y)./(x.^2+1); %Write your f(x,y) function, where dy/dx=f(x,y), x(x0)=y0.

x0=input('\n Enter initial value of x i.e. x0: '); %example x0=0

y0=input('\n Enter initial value of y i.e. y0: '); %example y0=0.5

xn=input('\n Enter the final value of x: ');% where we need to find the value of y

%example x=2

h=input('\n Enter the step length h: '); %example h=0.2

%Formula: y1=y0+h/2*[f(x0,y0)+f(x1,y1*)] where y1*=y0+h*f(x0,y0);

fprintf('\n x y ');

while x0<=xn

fprintf('\n%4.3f %4.3f ',x0,y0);%values of x and y

k=y0+h*f(x0,y0);

x1=x0+h;

y1=y0+h/2*(f(x0,y0)+f(x1,k));

x0=x1;

y0=y1;

end

1) 86% (4) Sat 2:25 PM Q E G do 5 C O Q Search Documentation Log In 3 D e Run Section 6 RUN Workspace Name Í MATLAB Window He-sexdlice X-2 Command Window Enter initial value of x i.e. x0: 0 Enter initial value of y i.e. yo: 1 Enter the final value of

Add a comment
Know the answer?
Add Answer to:
Given the initial-value problem y'=2-2tyt2+1,          0 ≤t≤1,        y0=1 With exact solution yt= 2t+1t2+1 Using MATLAB use...
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