Question

In: Advanced Math

Numerical Analysis: Make a matlab code that computes the Midpoint rule/method for a given function f'(t,y)...

Numerical Analysis:

Make a matlab code that computes the Midpoint rule/method for a given function f'(t,y) = y' =  t + y from 0 < t < 4 (inclusive) with h=0.5 and with initial condition y(0) = 0.
Please make output display in tabular form and not in a plot, that doesn't help show the actual values.

Solutions

Expert Solution

clc;
clear all;
f=@(t,y) t+y;% given function
h=0.5; %step length
a=0; % starting point
b=4; %ending point

N=(b-a)/h; % number of intervals
t=a:h:b;
y_mid(1)=0; %initial point

% Midpoint formula
for i=1:N
k(i)=y_mid(i)+(h/2)*f(t(i),y_mid(i));
y_mid(i+1)=y_mid(i)+h*f(t(i)+h/2,k(i));
end
disp('------------------------------')
disp( 'tn y_Midpoint ')
disp('-----------------------------')
for i=1:N+1
fprintf(' %f \t %15f \n',t(i),y_mid(i))
end

--------------------------------------
tn y_Midpoint
-------------------------------------
0.000000 0.000000
0.500000 0.125000
1.000000    0.640625
1.500000    1.791016
2.000000    3.972900
2.500000    7.830963
3.000000    14.412815
3.500000    25.420825
4.000000    43.621340


Related Solutions

The rule of the derivative of a function f is given. Find the location of all...
The rule of the derivative of a function f is given. Find the location of all local extrema. f'(x) = (x2- 1)(x - 2) Group of answer choices Local maxima at -1 and 2; local minimum at 1 Local maximum at 1; local minima at -1 and 2 Local maximum at -1; local minima at -2 and 1 Local maximum at 2 - ; local minimum at 2 +
1) The demand function for cheese is given by F(y) = 50 - y, and the...
1) The demand function for cheese is given by F(y) = 50 - y, and the cost functions of both firms is given by C(x) = 4x. A). What would be the output and price, considering the market for cheese is perfectly competitive? B). What is the market price, industry output, and each firms level of production if there are two cournot firms operating in the market? C). What is the industry output and market price if the two firms...
In MATLAB write a function secant.m to apply the secant method. function [x,i] = secant(f, x0,...
In MATLAB write a function secant.m to apply the secant method. function [x,i] = secant(f, x0, x1, tol, maxiters) [x,i] = secant(f, x0, x1, tol, maxiters) performs the secant method with f(x), starting at x_0 = x0 and x_1 = x1, and continuing until either |x_i+1 - x_i| <= tol, or maxiters iterations have been taken. The number of iterations, i, is also returned. An error is raised if the first input is not a function handle. A warning is...
On Matlab use BFGS Method to find the minimum of the following function: f(x) = x13...
On Matlab use BFGS Method to find the minimum of the following function: f(x) = x13 - 2x2x12 + x12 - x1using initial point (x0, y0) = (1, 2)T to start, and stop when f changes less than 0.0001
q1) using Matlab make a code that allows a user to enter a function like fractional...
q1) using Matlab make a code that allows a user to enter a function like fractional function and cubic liner function then the Matlab send a domain, range, continuity
q1) using Matlab make a code that allows a user to enter a function like fractional...
q1) using Matlab make a code that allows a user to enter a function like fractional function and cubic liner function then the Matlab send a domain, range, continuity
5) Let the function f : ℝ3 → ℝ3 be given by f(x, y, z) =...
5) Let the function f : ℝ3 → ℝ3 be given by f(x, y, z) = (2x + 2y, 2y + 2z, z + x). a) Prove that f is one to one and onto b) Find the inverse of f, i.e., f−1.
Please Consider the function f : R -> R given by f(x, y) = (2 -...
Please Consider the function f : R -> R given by f(x, y) = (2 - y, 2 - x). (a) Prove that f is an isometry. (b) Draw the triangle with vertices A = (1, 2), B = (3, 1), C = (3, 2), and the triangle with vertices f(A), f(B), f(C). (c) Is f a rotation, a translation, or a glide reflection? Explain your answer.
determine whether the given function is even, odd, or neither. Please write a code in MatLab...
determine whether the given function is even, odd, or neither. Please write a code in MatLab to solve this problem below: 1.f(x) = sin 3x please only use Matlab to solve this problem
Write a matlab code for given task Use your ‘sin’ or ‘cos’ function to generate a...
Write a matlab code for given task Use your ‘sin’ or ‘cos’ function to generate a sinusoid wave having two components as f1 = 3kHz and f2 = 5kHz and then sample it with fs = 10kHz. Calculate its fft with zero frequency component in the middle. Plot it on a properly scaled w-axis. Specify if there is aliasing or not? If there is aliasing specify which component is casing the aliasing
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT