# Why do I get error messages when I try to plot this function?

Question: Why do I get error messages such as "LessEqual::nord: Invalid comparison with 1. -1.59148 I attempted." when I try to plot the function f[z,k] defined below with for example the Plot invocation illustrated below?

f[z_, k_] := (
I E^(-((2 I \[Pi])/k))
HurwitzLerchPhi[E^(-((2 I \[Pi])/k)), 1, 1 + (I z)/(2 \[Pi])])/(
2 \[Pi])

Plot[{Abs@f[s, 2]}, {s, -10, 10}, GridLines -> Automatic]

• Cannot reproduce (10.4.1 for Microsoft Windows (64-bit)). – AccidentalFourierTransform Jun 20 '19 at 19:39
• I get two of those errors with 12.0.0 with a fresh notebook. Simplify doesn't help, ComplexExpand doesn't help – Bill Jun 20 '19 at 19:53
• Try adding the option Exclusions -> None. I'd say this is a (very minor) bug. The message should be turned off, while Plot is figuring out discontinuities. You should report it to WRI, imo. – Michael E2 Jun 20 '19 at 22:07

My best guess is that Plot is trying to do some fancy symbolic manipulation beforehand. I'm running V12.0.0 on macOS 10.14.5, and this worked for me, although make sure you use a fresh notebook or clear the definitions for f first.

f[z_?NumericQ, k_?NumericQ] :=
Abs[(I E^(-((2 I \[Pi])/k)) HurwitzLerchPhi[E^(-((2 I \[Pi])/k)), 1,
1 + (I z)/(2 \[Pi])])/(2 \[Pi])]
Plot[f[s, 2], {s, -10, 10}]


This forces Mathematica to only evaluate f when it receives a numerical argument.