Question

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

You will use programming as a great tool to solve academic problems more efficiently. Select the example of the program of th

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 = input( Ente

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 i <= t

e_taylor = e_taylor + x^(i-1)/factorial(i - 1);

i = i + 1;   % change the value of variable i

end

real_value = exp(x);

disp( 'Real Value' )

disp(real_value)

disp( 'Approximated value with Taylor series' )

disp(e_taylor)

disp( 'amount of iterations' )

disp(i)

disp( 'real error' )

E = abs(e_taylor - real_value);

disp(E)

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

x = input( 'Enter the value of x for e^x. x = ' );
imax =100; %imax variable =100
e_taylor = 0; % initializing the variable for the accumulator
real_value=exp(x); %real e^x value
tolerance=0.0001; %tolerance value

%for loop
for i=1:imax

e_taylor = e_taylor + x^(i-1)/factorial(i - 1);

if(abs(e_taylor-real_value)<=tolerance)
break
end

end

disp( 'Real Value' )

disp(real_value)

disp( 'Approximated value with Taylor series' )

disp(e_taylor)

disp( 'amount of iterations' )

disp(i)

disp( 'real error' )

E = abs(e_taylor - real_value);

disp(E)

C Computer Science questi x phpyDcl7s.png (1416×49 × 8 Octave Online Cloud ID x online matlab compiler e^x expansion - Google

Add a comment
Know the answer?
Add Answer to:
MATLAB ONLY!! PLEASE WRITE IN COMPUTER SO I CAN COPY PASTE!!! ANSWER COMPLETELY, USE FOR LOOPS....
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 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...

  • Please complete using matlab In this problem you will utilize a for loop to compute the...

    Please complete using matlab In this problem you will utilize a for loop to compute the an approximation of the value of using the Leibniz's formula for Pi. The formula uses a summation. Follow the instructions correctly and read the questions thoroughly. 1. Set up the initial number of iteration i to obtain six iterations. 2. The approximate value of it can be given by the following formula: Approximated = Enzo 2n+1 Where n is an integer starting at zero...

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

  • ANSWER PART B, I HAVE PART A. MATLAB ONLY!! WRITE IN COMPUTER SO I CAN COPY...

    ANSWER PART B, I HAVE PART A. MATLAB ONLY!! WRITE IN COMPUTER SO I CAN COPY PASTE!! The student must use the following case provided and apply most of the commands leared in the previous modules. You should use the command folder that you must be expanding with each module. Case (Gilat, 2015): The concentration of a drug in the body Cp can be modeled by the equation: Doka (e-ketek) Va (ka-k) Where Do is the dosage administrated (mg). Ve...

  • MATLAB ONLY!!! PLEASE WRITE IN COMPUTER SO I CAN COPY PASTE!!! ANSWER COMPLETELY, IS ONLY ONE...

    MATLAB ONLY!!! PLEASE WRITE IN COMPUTER SO I CAN COPY PASTE!!! ANSWER COMPLETELY, IS ONLY ONE PROGRAM!!! Body surface Area (Problem 6 Page 249). The body surface area (BSA) in m? of a person (used for determining dosage of medications) can be calculated by the formula (Du Bois formula): BSA = 0.007184 W0.425 H0.75 In which W is the mass in kg and H is the height in cm. Create a GUI to calculate the body surface area (BSA). The...

  • Solve the following problem in MATLAB. Use format compact for all work to suppress extra lines....

    Solve the following problem in MATLAB. Use format compact for all work to suppress extra lines. Show all work and add comments as needed to explain your logic/steps. 1. The function f(x) = e* can be approximated by the following Taylor series: n=0 The first few terms of the Taylor series are: e 1 + x + + + + ...... 2! 3! 4! Keep in mind that the "!" symbol denotes factorial. For example, the factorial of 4 =...

  • help me please , By using MATLAB How can I plot the solution of linear diffrential...

    help me please , By using MATLAB How can I plot the solution of linear diffrential system ? I want the code in general case We were unable to transcribe this imageclose all clear MATLAB Code: clc A= [1 0 1; 0 0 0;00-1]; % Coefficient Matrix Xo = [5 76]'; % Initial condition V, D = eig(A); % Get the Eigen values and Eigen vectors % General Solution: X=Sum of {c_i*exp(L_i*t) *V_i % where c_i are constants, L_i are...

  • Matlab problem using newton raphson to find square root of number

    Need help modifying my Matlab script below (myscript calculates the square root of a number. using a Newton-Raphson method with 1 as the initial guess, calculates true and estimated error, and shows each iteration).-I need to create three new functions each of which should be called in the main script. These functions are needed to replace code that is currently in my script shown below.-I need to create these functions:A function to find f(x)A function to find f '(x) ?A...

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

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