MATLAB HELP - Maclaurin series

In summary, the conversation is about a person seeking help with using MATLAB to solve two problems. The first problem involves estimating the value of cos(pi/3) using the Maclaurin series expansion and calculating the true and approximate errors. The second problem involves using a centered difference approximation to estimate the second derivative of a given function at a specific value of x. The person is seeking assistance with writing a .m file for the second problem.
  • #1
figgy111
2
0
MATLAB HELP! -- Maclaurin series

Hi, i have absolutely no programming experience with MATLAB and really need it. We have been assigned 2 problems using MATLAB and a bunch of others that don't need matlab. I was wondering if someone could show me what to do for the two needed to be done in MATLAB (or send a .m file if you have one/could create one); the questions are:

The Maclaurin series expansion for cos (x) is:

cosx = 1 - (x^2)/2 + (x^4)/4! - (x^6)/6! + (x^8)/8! - ...

Starting with the simplest version, cosx = 1, add terms one at a time to estimate cos(pi/3). After each term is added, compute the true and approximate percent relative errors. Use your pocket calculator to determine the true value. Add terms until the absolute value of the approximate error estimate falls below an error criterion conforming to two significant figures.

The other question is:

Use a centered difference approximation of O(h^2) to estimate the second derivative of the function f(x) = 25x^3 - 6x^2 + 7x - 88. Perform the evaluation at x = 2 using step sizes of h = 0.25 and 0.125. Compare your estimates with the true value of the second derivative. Interpret your results on the basis of the remainder term of the taylor series expansion.

THANK YOU SO MUCH PLEASE HELP!
 
Physics news on Phys.org
  • #2
figgy111 said:
Hi, i have absolutely no programming experience with MATLAB and really need it. We have been assigned 2 problems using MATLAB and a bunch of others that don't need matlab. I was wondering if someone could show me what to do for the two needed to be done in MATLAB (or send a .m file if you have one/could create one); the questions are:

The Maclaurin series expansion for cos (x) is:

cosx = 1 - (x^2)/2 + (x^4)/4! - (x^6)/6! + (x^8)/8! - ...

Starting with the simplest version, cosx = 1, add terms one at a time to estimate cos(pi/3). After each term is added, compute the true and approximate percent relative errors. Use your pocket calculator to determine the true value. Add terms until the absolute value of the approximate error estimate falls below an error criterion conforming to two significant figures.

The other question is:

Use a centered difference approximation of O(h^2) to estimate the second derivative of the function f(x) = 25x^3 - 6x^2 + 7x - 88. Perform the evaluation at x = 2 using step sizes of h = 0.25 and 0.125. Compare your estimates with the true value of the second derivative. Interpret your results on the basis of the remainder term of the taylor series expansion.

THANK YOU SO MUCH PLEASE HELP!
You don't need MatLab. You have just have to add the first few terms. You do this by replacing x by [itex]\pi/3[/itex] in the MacLaurin/Taylor series expansion and calculating the first few terms on a calculator. Calculate [itex]cos(\pi/3)[/itex] on a calculator. Compare the two. If the difference is less than .005 then you have the answer to two significant figures. If not, keep adding more terms until you get the difference down to less than .005.

AM
 
  • #3
and if you're required to use matlab, what are you having trouble with? Do you understand AM's logic? Do you need help with the commands for the .m file?

I took a MATLAB class and I still use the program once in a while, if you can aska specific question, or PASTE your .m file here, I'll see what I can help you with.
 
  • #4
yes we are required to use matlab

i did the first one alright the second one i had some trouble with. here is my .m file for that one i know its a little of but let me know. thanks in advance
 

Attachments

  • p47.m
    422 bytes · Views: 1,472

1. What is a Maclaurin series in MATLAB?

A Maclaurin series in MATLAB is a representation of a function as an infinite sum of terms, where each term is a polynomial function. It is centered at the origin, and the coefficients of the terms are determined by taking derivatives of the function at the origin.

2. How do I find the Maclaurin series of a function in MATLAB?

To find the Maclaurin series of a function in MATLAB, you can use the "taylor" function. This function takes in the function, the number of terms to include in the series, and the variable for the series. For example, to find the Maclaurin series of the function f(x) = sin(x), you can use the command "taylor(f, 5, 'x')" to find the first 5 terms of the series.

3. Can I plot a Maclaurin series in MATLAB?

Yes, you can plot a Maclaurin series in MATLAB by using the "ezplot" function. This function takes in the series, the range of values for the variable, and the number of points to plot. For example, to plot the Maclaurin series of f(x) = sin(x), you can use the command "ezplot(f, [-pi, pi], 100)" to plot 100 points within the range of -pi to pi.

4. How can I use a Maclaurin series to approximate a function in MATLAB?

You can use a Maclaurin series to approximate a function in MATLAB by truncating the series to a certain number of terms. The more terms you include, the closer the approximation will be to the actual function. You can also use the "subplot" function to plot the original function and the Maclaurin series on the same graph for comparison.

5. Are there any limitations to using Maclaurin series in MATLAB?

One limitation of using Maclaurin series in MATLAB is that it can only approximate smooth, well-behaved functions. If the function is not smooth, the series may not converge or may not provide an accurate approximation. Additionally, the more terms you include in the series, the more computationally intensive the calculations become.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
4K
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
Back
Top