Question
MATLAB help!
I have some MATLAB Assignment to do, the proffesor requires all the small parts in order to get full credit. Help me out, thank you
f LAB SECTION NAME HW6P3 (30 points) following are infinite series representations of the function, un pra i a script file HW
AME LAB SECTION iascalar (3 pts) You must notice that the number of iterations will be another with the same tolerance. The p
0 0
Add a comment Improve this question Transcribed image text
Answer #1

clc
clear
format long
x=input('Value at which function will be determined= ');
tol=input('Enter a tolarance value= ');
if tol<=0||tol>1e-2
error('Invalid entry,please re-enter tolerance,0<Tolerance<=10^-2')
end
err=1;
n=0;
while err>tol
s(n+1)=(n+1)*x^n/factorial(n);
err=abs(((1+x)*exp(x))-sum(s));
n=n+1;
if n>50
break
end
fprintf('Iteration=%i , (1+%g)exp(%g)=%.10f\n',n,x,x,sum(s))
end

Add a comment
Know the answer?
Add Answer to:
MATLAB help! I have some MATLAB Assignment to do, the proffesor requires all the small parts...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • This is a matlab HW that I need the code for, if someone could help me figure this out it would b...

    This is a matlab HW that I need the code for, if someone could help me figure this out it would be appreciated. The value of t can be estimated from the following equation: in your script file, estimate the value of π for any number of terms. You must ask the user for the desired number of terms and calculate the absolute error/difference between your calculation and the built-in MATLAB value ofpi. Display your results with the following message...

  • Programming Language: MATLAB Problem 3: (5 Points) Write a function with the header: function [R] -myNewtonRaphson...

    Programming Language: MATLAB Problem 3: (5 Points) Write a function with the header: function [R] -myNewtonRaphson (f, fp, x0, tol) which takes as input f: a function handle fp: a function handle to the derivative of f (note how I do it in the test case). x0: the initial guess of the root tol: a tolerance above which the algorithm will keep iterating. Tips: . Be sure to include an iteration counter which will stop the while-loop if the number...

  • clearvars close all clc tol = 0.0001; % this is the tolerance for root identification xold...

    clearvars close all clc tol = 0.0001; % this is the tolerance for root identification xold = 0.5; % this is the initial guess test = 1; % this simply ensures we have a test value to enter the loop below. %If we don't preallocate this, MATLAB will error when it trys to start the %while loop below k = 1; %this is the iteration counter. Similar to "test" we need to preallocate it %to allow the while loop to...

  • I'm working on the newton's method on matlab, could someone help me and show what two...

    I'm working on the newton's method on matlab, could someone help me and show what two lines are needed to be added in the codes in order to make this function work? function sample_newton(f, xc, tol, max_iter) % sample_newton(f, xc, tol, max_iter) % finds a root of the given function f over the interval [a, b] using Newton-Raphson method % IN: % f - the target function to find a root of % function handle with two outputs, f(x), f'(x)...

  • [USING R] Write a function bisect(f, lower, upper, tol = 1e-6) to find the root of...

    [USING R] Write a function bisect(f, lower, upper, tol = 1e-6) to find the root of the univariate function f on the interval [lower, upper] with precision tolerance =< tol (defaulted to be 10-6 ) via bisection, which returns a list consisting of root, f.root (f evaluated at root), iter (number of iterations) and estim.prec (estimated precision). Apply it to the function f(x) = x3 - x - 1 on [1, 2] with precision tolerance 10-6 . Compare it with...

  • MATLAB ONLY!! PLEASE WRITE IN COMPUTER SO I CAN COPY PASTE!!! ANSWER COMPLETELY, USE FOR LOOPS....

    MATLAB ONLY!! PLEASE WRITE IN COMPUTER SO I CAN COPY PASTE!!! ANSWER COMPLETELY, USE FOR LOOPS. THE PROGRAM TO BE MODIFIED IS THE NEXT ONE: clc clear % Approximate the value of e ^ x using the Taylor Series x = input( 'Enter the value of x for e^x. x = ' ); t = input( 'Enter the amount of desired terms. t = ' ); i = 1; e_taylor = 0; % initializing the variable for the accumulator while...

  • Part 2 to the problem in matlabthis is the hint that came with the problem

    part 2 to the problem in matlabthis is the hint that came with the problem The value of T can be estimated from the following equation: In your script file, estimate the value of t for any number of terms. You must ask the user for the desired number of terms and calculate the absolute error/difference between your calculation and the built-in MATLAB value ofpi. Display your results with the following message (including the asterisks) where II is the number...

  • THE CODE NEEDS TO BE ON MATLAB 2. Exercise (a) Let's write a script file that...

    THE CODE NEEDS TO BE ON MATLAB 2. Exercise (a) Let's write a script file that calculates exp(2) by a Maclaurin series using a while loop exp x )=-+-+-+-+ The while loop should add each of the series terms. The program error as defined below is smaller than 0.01. Error is the exact value (i.e. exp(2)), minus the approximate value (i.e., the current series sum) should exit the loop when the absolute absolute error-lexact-approx Use fprintf within the loop such...

  • Please help me fix this halleyroot funtion , in matlab function [x, er, n] = Halleyroot(fun,x1,maxtol,maxitr)...

    Please help me fix this halleyroot funtion , in matlab function [x, er, n] = Halleyroot(fun,x1,maxtol,maxitr) if (nargin < 5), maxitr = 25; end if (nargin < 4), maxtol = 1e-4; end k = 0; er = 1; x = x1; funder= derivative(fun); while er >= maxtol && k < maxitr k = k+1; % increment the iteration number xold = x; x = xold-fun(xold)/funder(xold); er = abs((x-xold)/x); fprintf('iter = %i\t x = %f\t f(x) = %f\t er = %f...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT