Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Problem 1 [10 marks] This is the same problem you solved in Assignment 1 *** The Maclaurin Series of the Exponential function ex is given
Problem 1 [10 marks] This is the same problem you solved in Assignment 1 *** The Maclaurin Series of the Exponential function ex is given by: exn=0n!xn=0!x0+1!x1+2!x2+3!x3+4!x4+5!x5++n!xn Recall that this series allows one to calculate the approximation of a function for input values close to zero. Address the following: a) In a new MATLAB script named Q1.m, generate an expression that calculates the value of any term n in the above expression, where n is the term number referenced above ranging from 0 to n. Be sure to define the value of n and store it to a variable named ' n ' as well as the value of x and store it to a variable named ' x '. Store the resulting term value to a variable named 'termVal'. (3 marks) Hint: the factorial of a number can be found using the factorial () function. b) Now, populate an array named 'expansion' that contains all of the terms of the above equation up to the number of desired terms as specified in the ' n ' variable for the value of x stored in ' x '. (3 marks) Hint: This is easily done using vectorization or a for loop. c) Now, calculate the sum of the resulting 'expansion' array which represents the numerical estimation of the true exponential function value. Store the result in a variable named 'estimated'. (1 mark) d) Calculate the true value of ex and store this to a variable named 'true'. (1 mark) e) Calculate the \% error of the estimated value compared to the true value using the equation below. Store the result in a variable named 'error'. (2 marks) error=trueestimatedtrue100
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started