I was trying to evaluate


The cell gives me:


However I wanted more precision digits. I tried to use:


But the result is the same. Interestingly, if I try with


The result showed significantly increased digits


Is there a way that we can evaluate LegendreP more accurately?

  • $\begingroup$ I have marked this as "already has an answer" -- please see the link inserted at the top of your post. Please also read: (55292) and the second part of (3153) $\endgroup$
    – Mr.Wizard
    Sep 13, 2014 at 7:02

1 Answer 1


The reason is that you're using machine-precision input, so the result you get will always be machine precision.

N[LegendreP[5, 0.1], 20]
Precision /@ {0.1, 0.17882875`}

{MachinePrecision, MachinePrecision}

To get result in arbitrary precision you can use exact input or non-machine precision input (which is what happened when you used the integer 1):

N[LegendreP[5, 1/10], 20]

Notice the following:

N[LegendreP[5, #], 18] & /@ {0.1000000000000000, 0.100000000000000000}
{0.17882875, 0.17882875000000000}

What happens here is that $MachinePrecision returns 15.9545898 on my machine, so any input with less than or equal to 16 digits will result in Mathematica using machine-precision for the computation, whereas anything greater is considered arbitrary precision and will be treated as such. Which is why the first input with 16 digits (machine precision) ignored our request for arbitrary precision output.


Not the answer you're looking for? Browse other questions tagged or ask your own question.