Exponential Function using Taylor series
Show older comments
Hi, I've been trying to write a code which has a row vector input of numbers (x in my code) and the output is row vector e^x (y in my code). e^x is given by the sum of: x^n/n! where n=0,1,2... I have to try and write an unbounded while loop with these conditions: n has a maximum of 50 and that y is more than 0.001 (if less than 0.001, sequence is terminated).
This is what I've done:
the problem is:
1)i've written a loop for the factorial function in a different script, how do i input that into this one?
2)my output is still less than 0.001 when it shouldn't have happened. when given this row vector: [-2 -1.5 -1] the output should be [0.1365 0.2232 0.3679] but I do not obtain these numbers. :(
Any help would be amazing! thanks :)
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!