Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

If anyone could walk me through this, I\'d appreciate it. I need help and am not

ID: 2844145 • Letter: I

Question

If anyone could walk me through this, I'd appreciate it. I need help and am not sure how to start the problems on Matlab. Thanks.


1. mypw(a,b) which takes two inputs:

a: A positive integer.

b: A positive integer.

Returns: If a > b then return the value 1. If a < b then return the value ?1. If a = b then return the

value 0.


2. mytaylor(f,a,b,n) which takes 4 inputs:

f: A function handle.

a: A real number.

b: A real number assumed to be close to a.

n: A positive integer.

Approximates f(b) using Pn(b) where Pn(x) is the nthTaylor Polynomial about x = a. This Taylor

Polynomial should be found using a for loop to sum the appropriate terms. Do not use any sneaky

Matlab function shortcuts.

Returns: The answer.


3. mynewton(f,a,n) which takes three inputs:

f: A function handle.

a: A real number.

n: A positive integer.

Approximates an x-intercept of f(x) using a as the starting approximation and proceeding using

Newton-Raphson proceeding through n steps.

Returns: The final approximation.


4. myintegralapprox(f,a,b,tol) which takes four inputs:

f: A function handle.

a: A real number.

b: A real number assumed to be greater than a.

tol: A real number assumed to be positive and quite small.

Approximates the integral of f(x) dx from a to b. The way this should work is as follows: Start by setting a variable n = 1. A

for loop on the inside should calculate the left sum using n intervals and a while loop on the outside

should test successive left sums until two successive sums differ by less than tol. Each time the value

of n should increase by 1.

Returns: The final value.

Explanation / Answer

I am giving you only thr first and third answers. Rest i will complete soon.

first: the code starts

function mypw

a = input('enter a positive integer a = ');

b = input('enter a positive integer b = ');

if a>b

disp('1')

elseif a<b

disp('-1')

else

disp('0')

end


code ends here

third:code starts here

function mynewton

format Long;

syms x;

f(x) = input('function handler = ');

a = input('real number a = ');

n = input('positive integer n = ');

h(x)=diff(f);

i=1;

xi=a;

while i<n+1

xn = xi-(f(xi)/h(xi));

xi=xn;

i=i+1;

end

an=xn*1;

disp(an)


code ends here

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote