A community for students.
Here's the question you clicked on:
 0 viewing
anonymous
 one year ago
I need help with a MATLAB problem.
Write a MATLAB function to compute the exponential function directly from the Taylor series: e^x=1+x+X^2/2!+x^3/3!.... The series should end when the last term is less than 10^6. Test your function against the built in function exp, but be careful not to make x too largethis could cause rounding error.
Can anyone help me??
anonymous
 one year ago
I need help with a MATLAB problem. Write a MATLAB function to compute the exponential function directly from the Taylor series: e^x=1+x+X^2/2!+x^3/3!.... The series should end when the last term is less than 10^6. Test your function against the built in function exp, but be careful not to make x too largethis could cause rounding error. Can anyone help me??

This Question is Open

mathmate
 one year ago
Best ResponseYou've already chosen the best response.0If we notice that the terms of the Taylor's series are such that the nth term is the previous term multiplied by x/n, considering the initial "1" as the zeroth term. This means that instead of calculating each term from scratch, we only need to multiply the previous term by x/n to get the present term. 1 (term zero) x (term zero * x /1 ) x^2/2! = x* (x/2) x^3/3! = x^2/2! * (x/3) ... the running sum calculated will be the various approximation for exp(x). A check should be incorporated to stop calculations when the term is less than 10^(6)

anonymous
 one year ago
Best ResponseYou've already chosen the best response.0I kind of understand what you are saying but I'm confused on how to write the actual code.

mathmate
 one year ago
Best ResponseYou've already chosen the best response.0Hint: Pseudocode: Function Exp(x) initialize term, sum, n while (term>10^(6)) term=term*(x/n) sum=sum+term n=n+1 end while return sum Give it a try with Matlab and post your code if you need help.

anonymous
 one year ago
Best ResponseYou've already chosen the best response.0OK thanks I will post my code if I need more help

anonymous
 one year ago
Best ResponseYou've already chosen the best response.0I am still having issues with this code. Can someone help me correct it so that I can run right. Thanks

mathmate
 one year ago
Best ResponseYou've already chosen the best response.0This is where defining variables (in English) is important when programming so that we do not confuse the values. In your code, y is used to return the value of the function, which is the sum of the series. That's ok. In the lines while y>10^6 y=y*(x/n); y represents the value of each term of the series, which is not the sum of the series. Also, y must assume a value before we can do the recursive statement y=y*(x/n) This initial value must be defined before entering the while loop. Similarly, n and sum must be initialized to appropriate values before entering the loop. (n=1, sum=0), Finally, y=sum (because y is the return value equal to sum) must be placed at the end. Try to make corrections and post if you can.
Ask your own question
Sign UpFind more explanations on OpenStudy
Your question is ready. Sign up for free to start getting answers.
spraguer
(Moderator)
5
→ View Detailed Profile
is replying to Can someone tell me what button the professor is hitting...
23
 Teamwork 19 Teammate
 Problem Solving 19 Hero
 Engagement 19 Mad Hatter
 You have blocked this person.
 ✔ You're a fan Checking fan status...
Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.