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 large-this could cause rounding error.
Can anyone help me??
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
If 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)
I kind of understand what you are saying but I'm confused on how to write the actual code.
initialize term, sum, n
Give it a try with Matlab and post your code if you need help.
This 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
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
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.
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.