Question

In: Advanced Math

Problem 1: Consider the following Initial Value Problem (IVP) where ? is the dependent variable and...

Problem 1: Consider the following Initial Value Problem (IVP) where ? is the dependent variable and ? is the independent variable: ?′=sin(?)∗(1−?) with ?(0)=?0 and ?≥0
Note: the analytic solution for this IVP is: ?(?)=1+(?_0−1)?^cos(?)−1


Part 1A: Approximate the solution to the IVP using Euler’s method with the following conditions: Initial condition ?_0=−1/2; time step ℎ=1/16; and time interval ?∈[0,20]
+ Derive the recursive formula for Euler’s method applied to this IVP
+ Plot the Euler’s method approximation
+ Plot the absolute error between the approximation and the exact solution using a semilog plot

Coding errors, please type out.

Solutions

Expert Solution


%%Matlab code for Euler's forward
clear all
close all
%function for Euler equation solution
f=@(t,y) sin(t)*(1-y);
%displaying the function
fprintf('Function for which differential equation have to solve\n')
disp(f)
%Initial values
t0=0;
y0=-1/2;
%t_end values
t_end=0.4;

    %step size
    h=1/16;
    %x end values

    xn=t0:h:t_end;
    % Euler steps
    y_r(1)=y0;
    t_r(1)=t0;
    fprintf(' \nSolving Differential equation using Euler method for step size h=%f\n',h)
    fprintf(' Initial condition t=%f ; y_1= %f.\n',t_r(1),y_r(1))
        for i=1:length(xn)-1
          
            t_r(i+1)= t_r(i)+h;
            y_r(i+1)= y_r(i)+h*double(f(t_r(i),y_r(i)));         
          
        end     

%exact solution
syms y(t)
eqn = diff(y,t) == sin(t)*(1-y);
cond = y(0) == y0;
ySol(t) = dsolve(eqn,cond);

fprintf('\n\nExact solution is y(t)= ')
disp(ySol(t))

figure(1)
plot(t_r,y_r)
hold on
plot(t_r,ySol(t_r))
xlabel('t')
ylabel('y(t)')
title('y(t) vs. t plot')
legend('Euler method','Exact solution')

figure(2)
err=abs(ySol(t_r)-y_r);
semilogy(t_r,err)
title('semilog plot of Euler error')
xlabel('t')
ylabel('error')

%%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%%%%


Related Solutions

Problem 1: Consider the following Initial Value Problem (IVP) where ? is the dependent variable and...
Problem 1: Consider the following Initial Value Problem (IVP) where ? is the dependent variable and ? is the independent variable: ?′=sin(?)∗(1−?) with ?(0)=?0 and ? ≥ 0 Note: the analytic solution for this IVP is: y(t) = 1+(y_0 - 0)e^ cos(t)-1 Part 1B: Approximate the solution to the IVP using the Improved Euler’s method with the following conditions: Initial condition ?0=−1/2; time step ℎ=1/16; and time interval ?∈[0,20] + Derive the recursive formula for the Improved Euler’s method applied...
Problem 1: Consider the following Initial Value Problem (IVP) where ? is the dependent variable and...
Problem 1: Consider the following Initial Value Problem (IVP) where ? is the dependent variable and ? is the independent variable: ?′=sin(?)∗(1−?) with ?(0)=?0 and ?≥0 Note: the analytic solution for this IVP is: ?(?)=1+(?_0−1)?^cos(?)−1 Part 1A: Approximate the solution to the IVP using Euler’s method with the following conditions: Initial condition ?_0=−1/2; time step ℎ=1/16; and time interval ?∈[0,20] + Derive the recursive formula for Euler’s method applied to this IVP + Plot the Euler’s method approximation + Plot...
solve the given DE or IVP (Initial-Value Problem). a. 2y′ + y cot x = 8y-1...
solve the given DE or IVP (Initial-Value Problem). a. 2y′ + y cot x = 8y-1 cos3 x b. y′ = sin2 (3x − 3y + 1) c. xy′ + y ln x = y ln y d. x2 dy/dx = y2 + 5xy + 4x2
Consider the following initial value problem: ?? − 2?? = √? − 2? + 3 ??...
Consider the following initial value problem: ?? − 2?? = √? − 2? + 3 ?? ?(0) = 6 1. Write the equation in the form ?? ?? = ?(?? + ?? + ? ), where ?, ?, ??? ? are constants and ? is a function. 2. Use the substitution ? = ?? + ?? + ? to transfer the equation into the variables ? and ? only. 3. Solve the equation in (2). 4. Re-substitute ? = ??...
Solve the following initial value problem over the interval from t = 0 to 1 where...
Solve the following initial value problem over the interval from t = 0 to 1 where y(0) = 1 using the following methods with a step size of 0.25. dy/dt=(1+4t)*sqrt(y) a) Analytical method b) Euler's method c) Heun's method without iteration d) Ralston's method e) Fourth-order Runge-Kutta method f) Display all your results obtained above on the same graph
Problem 1 The dependent variable is assumed to be values of a land. a) Use the...
Problem 1 The dependent variable is assumed to be values of a land. a) Use the Excel regression tool to do the linear regression, and provide the “Line Fit Plots” (which is provided in the regression interface). (5 points) b) What can the plot tell you? E.g., does it show that the fitting is good? (5 points) c) Now check the output. c.1) What is the standard error of the estimate of the slope? (5 points) c.2) What is the...
Consider the following initial value problem to be solved by undetermined coefficients. y″ − 16y =...
Consider the following initial value problem to be solved by undetermined coefficients. y″ − 16y = 6, y(0) = 1, y′(0) = 0 Write the given differential equation in the form L(y) = g(x) where L is a linear operator with constant coefficients. If possible, factor L. (Use D for the differential operator.) ( )y = 16
Consider an initial value problem              ?′′ + 2? = ?(?) = cos? (0 ≤ ? <...
Consider an initial value problem              ?′′ + 2? = ?(?) = cos? (0 ≤ ? < ?) ,    0 (? ≥ ?) ?(0) = 0 and ?′(0) = 0 (a) Express ?(?) in terms of the unit step function. (b) Find the Laplace transform of ?(?). (c) Find ?(?) by using the Laplace transform method.
Solve the following initial value problem over the interval from t = 0 to 2 where...
Solve the following initial value problem over the interval from t = 0 to 2 where y(0) = 1 using the following methods. dy/dt=y*t^2−1.1y a) Analytical method b) Euler's method with h=0.5 at t=2 c) Euler's method with h=0.25 at t=2 d) Midpoint method with h=0.5 at t=2 e) Fourth-order Runge-Kutta method with h=0.5 at t=2 f) Display all yor results obtained above on the same graph
Consider the terms "independent variable" and "dependent variable," and explain the logic of their usage and...
Consider the terms "independent variable" and "dependent variable," and explain the logic of their usage and their relationship. What may be a reason to swap the variables? Would the results validate the same relationship?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT