Question

Solve the following problem in MATLAB. Use format compact for all work to suppress extra lines. Show all work and add comment

0 0
Add a comment Improve this question Transcribed image text
Answer #1

%Matlab script to input the value of x and calculate the value of exp(x)
% to a precision of 6 decimal places
format compact;
% input of x
x = input('Enter the value of x for calculation of exp(x) : ');
n = 0; % set n=0
% set initial approx value to 0
approx = 0;
% set actual value to exp(x) % actual e^x value
actual = exp(x);
% calculate the absolute difference between the calculateed and approximate
% value
eps = abs(approx-actual);
% loop that continues till the approx value matched the actual value upto 6
% decimal places
while eps > 10^-7
% calculate approx for (n+1)th term
approx = approx + (x^n/factorial(n));
n = n+1; % increment n
% calculate the difference
eps = abs(approx-actual);
end
% display the approximate value upto 6 decimal places
fprintf('The approximate value of e^x is %.6f \n',approx);
%end of script

Output:

Enter the value of x for calculation of exp (x) : 23 The approximate value of enx is 9744803446.248903

Add a comment
Know the answer?
Add Answer to:
Solve the following problem in MATLAB. Use format compact for all work to suppress extra lines....
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
  • MATLAB Use the Taylor series cos(x)-1-to compute cos(x) to four decimal places (by comparing the value...

    MATLAB Use the Taylor series cos(x)-1-to compute cos(x) to four decimal places (by comparing the value with the matlab built-in function for cos). How many iterations does it take to get to 4- decimal place agreement? (hint: help factorial) 2! 4! 6!

  • 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...

  • Please use matlab to solve the question. 1. The following infinite series can be used to...

    Please use matlab to solve the question. 1. The following infinite series can be used to approximate e*: 2 3! n! Prove that this Maclaurin series expansion is a special case of the Taylor series (Eq. 4.13) with Xi = 0 and h a) x. b) Use the Taylor series to estimate f(x) e* at xH1 1 for x-0.25. Employ the zero-, first-, second- and third-order versions and compute the letlfor each case. Take the true value of e10.367879 for...

  • Hello! i need help with a problem in this textbook, Essential MATLAB, 6th edition. Question 8.11:...

    Hello! i need help with a problem in this textbook, Essential MATLAB, 6th edition. Question 8.11: Use the Taylor Series, cosx=1- (x2/2!)+(x4/4!)-(x6/6!)+......... To write a program to compute cosx correct to 4 decimal places )x is in radians). see how many terms are needed to get 4 figure agreement with the MATLAB function cos. Dont make x too large; that could cause rounding errors. I can get an out put correct up to about only 10 radians, but then it...

  • solve with matlab Given the function: f(x) x2 + 4x + et and the point f(1)...

    solve with matlab Given the function: f(x) x2 + 4x + et and the point f(1) = 7.7183 use Taylor series to compute the second order approximation to find the value off (1.5). Input your answer up to 4 decimal places.

  • A. Show that all derivatives d"f/dx of f(x)e are equal to each other and use this to b. Evaluate ...

    a. Show that all derivatives d"f/dx of f(x)e are equal to each other and use this to b. Evaluate the derivatives d" f/da of f(x)with a a constant and use this to write c. Prove that the Taylor series in part (b) for f(x)-ea converges for all . Explain explicitly d. How many terms in the Taylor series for єェwith Zo = 0 does it take to approximate the write down the Taylor series for e" about an arbitrary point...

  • Submission Items: (1) A Word document in which you: a. Describe in brief the problem you...

    Submission Items: (1) A Word document in which you: a. Describe in brief the problem you are solving and the numerical method used. b. Snapshot of the output, when you run the program for the conditions mentioned in the questions. c. Discuss your results. (2) MATLAB code (m) file() Question 1: [10 points) Write a MATLAB function that calculates the approximate value of arctan(x) using the Maclaurin series approximation: arctan(x) = x- + +... The function should accept 3 parameters:...

  • 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...

  • Problem 1 MATLAB A Taylor series is a series expansion of a function f()about a given point a. For one-dimensional real...

    Problem 1 MATLAB A Taylor series is a series expansion of a function f()about a given point a. For one-dimensional real-valued functions, the general formula for a Taylor series is given as ia) (a) (z- a) (z- a)2 + £(a (r- a) + + -a + f(x)(a) (1) A special case of the Taylor series (known as the Maclaurin series) exists when a- 0. The Maclaurin series expansions for four commonly used functions in science and engineering are: sin(x) (-1)"...

  • MATLAB help! I have some MATLAB Assignment to do, the proffesor requires all the small parts...

    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 HW6P3 that determines the value of the function from the sum of the series for a given value of x. The program (1 pt) must prompt the user to enter a value...

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
Active Questions
ADVERTISEMENT