%Matlab code for RK4 solution
f1=@(t,x1,x2) x2;
f2=@(t,x1,x2) 2*x2-5*x1;
%all step size
h=-0.01;
%Initial conditions
x10=0; %x1(0)=0
x20=0.4; %x2(0)=0.4
%initial t
t0=0;
%t end values
tend=-2;
tn=t0:h:tend;
x1_rk(1)=x10; x2_rk(1)=x20; t_rk(1)=t0;
%Runge Kutta 4 iterations
for i=1:length(tn)-1
k0=h*f1(t_rk(i),x1_rk(i),x2_rk(i));
l0=h*f2(t_rk(i),x1_rk(i),x2_rk(i));
k1=h*f1(t_rk(i)+(1/2)*h,x1_rk(i)+(1/2)*k0,x2_rk(i)+(1/2)*l0);
l1=h*f2(t_rk(i)+(1/2)*h,x1_rk(i)+(1/2)*k0,x2_rk(i)+(1/2)*l0);
k2=h*f1(t_rk(i)+(1/2)*h,x1_rk(i)+(1/2)*k1,x2_rk(i)+(1/2)*l1);
l2=h*f2(t_rk(i)+(1/2)*h,x1_rk(i)+(1/2)*k1,x2_rk(i)+(1/2)*l1);
k3=h*f1(t_rk(i)+h,x1_rk(i)+k2,x2_rk(i)+l2);
l3=h*f2(t_rk(i)+h,x1_rk(i)+k2,x2_rk(i)+l2);
t_rk(i+1)=t0+i*h;
x1_rk(i+1)=double(x1_rk(i)+(1/6)*(k0+2*k1+2*k2+k3));
x2_rk(i+1)=double(x2_rk(i)+(1/6)*(l0+2*l1+2*l2+l3));
end
%plotting the result
figure(1)
plot(t_rk,x1_rk,'Linewidth',2)
xlabel('t')
ylabel('x(t)')
title('x(t) vs. t plot')
grid on
box on
%plotting the result
figure(2)
plot(t_rk,x2_rk,'Linewidth',2)
xlabel('t')
ylabel('dx(t)/dt')
title('dx(t)/dt vs. t plot')
grid on
box on
%%%%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%%%%%%
Using MATLAB Solve 2x5 5х, x(0)0, a(0) 0.4, on the interval [-2,0] Use Taylor series method...
Use fourth-order Runge-Kutta method Using MATLAB Solve x - 2t = 0, (0)0,(0) = 0.1, [0, 3] by any convenient method. Graph the solution on Using MATLAB Solve x - 2t = 0, (0)0,(0) = 0.1, [0, 3] by any convenient method. Graph the solution on
9) Using Euler method, solve this with following initial conditions that t = 0 when y = 1, for the range t = 0 to t = 1 with intervals of 0.25 dr + 2x2 +1=0.3 dt 1o) Using second order Taylor Series method, solve with following initial conditions to-0, xo-1 and h-0.24 11) x(1)-2 h-0.02 Solve the following system to find x(1.06) using 2nd, and 3rd and 4th order Runge-Kutta (RK2, RK3 and RK4)method +2x 2 +1-0.3 de sx)-cox(x/2)...
(Matlab) Use Matlab's built-in Runge-Kutta function ode45 to solve the problem 1010y -xz +28x - y 3 on the interval t є [0, 100 with initial condition (z(0), y(0),z(0)) = (1,1,25), and plot the trajectory of the solution ((t), (t)) forte [0, 100 (Matlab) Use Matlab's built-in Runge-Kutta function ode45 to solve the problem 1010y -xz +28x - y 3 on the interval t є [0, 100 with initial condition (z(0), y(0),z(0)) = (1,1,25), and plot the trajectory of the...
solve 2-3 1. Use a Taylor series to get the limit: In(x+3) 2. Use a Taylor series to get the derivative of f(x) = arctan x and check for the interval of convergence. Is the interval of convergence for f' the same as the interval for for different? Why? 3. Use a Taylor series to solve y' (t) - 3y = 10,y(0) = 2
Solve the ordinary differential equation below over the interval 0 sts 2s using two different methods: the Euler method and the second-order Runge-Kutta method (midpoint version). Begin by writing the state space representation of the equation. Use a time step of 1 s, and place a box around the values of x and x at t- 2 s obtained using each method. Show your work. 20d's +5dr +20x = 0 dt d x(0) = 1, x'(0) = 1 Solve the...
0 COMPLETE THE FOLLOWING USING MATLAB/EXCEL. HW3: Use the Taylor series to the fourth order to approximate the value of x = 3 in the function f(x) = 9x* + 6x3 + 3x2 + 5x + 25
(e) Consider the Runge-Kutta method in solving the following first order ODE: dy First, using Taylor series expansion, we have the following approximation of y evaluated at the time step n+1 as a function of y at the time step n: where h is the size of the time step. The fourth order Runge-Kutta method assumes the following form where the following approximations can be made at various iterations: )sh+รู้: ,f(t.ta, ),. Note that the first term is evaluated at...
Solve the Taylor Series. 1. (a) Use the root test to find the interval of convergence of-1)* に0 (b) Demonstrate that the above is the taylor series of f()- by writing a formula for f via taylor's theorem at α-0. That is write f(x)-P(z) + R(x) where P(r) is the nth order taylor polynomial centered at a point a and the remainder term R(x) = ((r - a)n+1 for some c between z and a where here a 0. Show...
Use this list of Basic Taylor Series to find the Taylor Series for f(x) = - based at 0. Give your answer using summation notation, write out the first three non-zero terms, and give the interval on which the series converges. (If you need to enter co, use the co button in CalcPad or type "infinity" in all lower-case.) The Taylor series for R(x) is: The Taylor series converges to f(x) for all x in the interval: -
Use this list of Basic Taylor Series to find the Taylor Series for tan-1(x) based at 0. Give your answer using summation notation, write out the first three non-zero terms, and give the interval on which the series converges. (if you need to enter 00, use the 00 button in CalcPad or type "infinity" in all lower-case.) The Taylor series for tan -1(x) is: The first three non-zero terms are: + + + The Taylor series converges to tan-1(x) for...