%% MATLAB code begins %%
% Test values
a_test = 0.25;
x0_test = 0;
eps_test = [15, 5, 2, 1];
% Testing
for a = a_test
for eps = eps_test
for x0 = x0_test
fprintf("For a = %f, eps = %f%%, x0 = %f, mysqrt(a) = %f\n", a,
eps, x0, mysqrt(a, eps, x0));
end
end
end
% Function
function [sqrta, n] = mysqrt(a, epsilon, x0)
if nargin == 2 %
If only 2 args,
x0 =
0; % set x0 to
default value
end
n =
0;
% number of iterations
sqrta =
x0; % initial
value
epsilon = epsilon / 100 *
sqrt(a); % Doing this will simplify
the while condition
while(abs(sqrt(a) - sqrta) >
epsilon) % While error is unacceptable
sqrta = sqrta^2 +
a; % Recurrence
relation
n = n +
1;
% One iteration done
end
end
%% MATLAB code ends %%
5.i) What will be the output of the script: for i-1:7 for j- 1:i fprintf(%d", j) end fprintf('\n') % start a new line. end 5 (i) For ax2 + bxc 0, the value of x is given by 2a Write a MATLAB function quadrasol () that will have three inputs ( a,b, and c) and two outputs corresponding to the solutions of the equation. It may be more compact if you defined another variable 'd' for the term inside the...
MATLAB WORK PLEASE Interest is accrued according to the following formula: A=P i(1 + i)" (1 + i)" – 1 where A is the annual payment, P is the present worth, i is the interest rate (not in percent), and n is the number of years. You decide to buy a $35,000 vehicle (P), but because you don't currently have the money to finance the entirety of the vehicle, you agree to pay $8,500 per year (A) for 7 years...
part b and c In class we derived a Fokker-Planck equation for the velocity distribution P(et) starting from the assumption of small random changes in velocity at each time step f.(t) where f(t) is chosen from a distribution WU: ). Einstein's original approach to Brownian motion had a different starting point, focusing on position differences at each time step x(t + Δt)-x(t) + E(t) where £(t) is a random displacement chosen from some distribution W(E). Underlying this ap- proach is...
What an Executive Summary Is An executive summary is a specific type of document that does two things: it summarizes a research article, and it offers recommendations as to how information from the article can be used. Some long reports can contain an executive summary section, as indicated in the Pearson handbook. Write a 2 pahe Executive Summary In business contexts, an executive summary is always written for a specific purpose: to explain the information in the article to a...