Why is `evalf` not working?

3.8k Views Asked by At

Why is evalf not changing $\pi$ and $e$ to floating point in the following:

h := proc (x) options operator, arrow; exp(x)*cos(x) end proc

Tay := taylor(h(x), x = (1/6)*pi, 2)

P2 := convert(Tay, polynom)

evalf(P2(.5))

The output is(exp((1/6)*Pi))(.5)*(cos((1/6)*Pi))(.5)+(-1.*(exp((1/6)*Pi))(.5)*(sin((1/6)*Pi))(.5)+(exp((1/6)*Pi))(.5)*(cos((1/6)*Pi))(.5))*(x(.5)-.1666666667*Pi(.5)). For my calculation, I need $\pi$ and $e$ to be approximations.

2

There are 2 best solutions below

0
On BEST ANSWER

To Maple, Pi is $\pi$, but pi is just a variable.

Also, seeing the result, I think you shouldn't do "evalf(P2(0.5))", but "evalf(subs(x=0.5,P2))".

0
On

You should use the capital letter for 'Pi-

Tay := taylor(h(x), x = (1/6) *Pi, 2);

It works.