0
$\begingroup$

Possibly related to this question, but it seems slightly different:

Strange behaviour of PolyLog Function

Wikipedia says that for real s, z<1 should be real. So I was confused when MMa returned:

PolyLog[0.5, -2.35]
-0.962331 + 1.96262*10^-17 I

Which, to be fair, has a teensy imaginary part. But still enough to mess up functions expecting only real values.

To get a better idea, I did

Plot[Im@PolyLog[.5, x], {x, -5, .5}]

Which gave me this plot:

enter image description here

So it seems to oscillate between 4 values for the imaginary part.

Can I just use Re[] to get rid of this part safely, i.e., is it just some artifact of the function? I don't need insane accuracy or anything, so as long as the real part is close to what it should be, it's alright.

$\endgroup$
3
  • 1
    $\begingroup$ Looks like floating point errors. Assuming PolyLog is working correctly and should ideally be real-valued, it should be safe to apply Re, if a purely real output is desired. $\endgroup$ Jan 19, 2015 at 18:34
  • 1
    $\begingroup$ Try: Plot[PolyLog[1/2, x], {x, -5, 5}, WorkingPrecision -> 20] $\endgroup$
    – Mr.Wizard
    Jan 19, 2015 at 19:15
  • 1
    $\begingroup$ Proposed duplicates: (3152), (71675) $\endgroup$
    – Mr.Wizard
    Jan 19, 2015 at 19:16

0

Browse other questions tagged or ask your own question.