Evaluate the explicit form of the Taylor polynomial of degree 2n-1 for arctan(x) with the point of approximation 0
1 view (last 30 days)
Show older comments
Write a Matlab code to evaluate the explicit form of the Taylor polynomial of degree 2n-1 for arctan(x) and the point of approximation 0.
So I tried to do this:
function value = polyeval(x, coeff);
n = length(coeff)
value = coeff(n)*taylor(arctan(x))
for i = n-1:-1:1
value = coeff(i) + x.*value;
end
But the teacher marked it as wrong. What would have been the correct way?
0 Comments
Accepted Answer
Walter Roberson
on 10 Sep 2022
You tried to take the arctan of the polynomial degree, rather than the arctan of x.
In MATLAB, arctan is written as atan() or atan2()
MATLAB does not permit implicit multiplication, not anywhere . 2n is invalid MATLAB syntax in all cases: you need to supply a multiplication operator.
Example use of taylor:
syms x x0
f = sin(x).^2 - cos(x).^2
taylor(f, x, x0, 'order', 5)
taylor(f, x, x0, 'order', 6)
taylor(f, x, x0, 'order', 7)
Your teacher expects you to figure out what the (2*n-1)'st term is of the taylor polynomial of arctan
More Answers (0)
See Also
Categories
Find more on Polynomials 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!

