# Visualizing Imaginary Roots of $f(x) = \cos(x) + \cosh^2(x) = 0$

I was wondering if there is a way to show the four imaginary roots of the function

$$f(x) = \cos(x) + \cosh^2(x) = 0$$

We can find the four imaginary roots using

f[x_] := Cos[x] + Cosh[x]^2

Reduce[f[z] == 0 && Abs[z] < 2, z]


I have tried several things, but no luck so far, for example

ContourPlot[{y == Cosh[x], y == Sqrt[-Cos[x]], y == -Sqrt[-Cos[x]]}, {x, -6., 6.}, {y, -6.,6.}]


Is there any way to show these complex roots visually?

• Maybe ComplexPlot[f[z], {z, -2 - 2*I, 2 + 2*I}, ColorFunction -> "CyclicLogAbs"] Nov 28, 2022 at 22:25
• or ColorFunction -> "CyclicArg" Nov 28, 2022 at 22:28
• That provides more information than the existence of a zero it tells you the multiplicity of the zero according to cyclic frequency of the colors as explained in the details section of ComplexPlot Nov 28, 2022 at 22:29
• @userrandrand: That second plot is beautiful! I cannot believe I missed this command and the one in the answer! Thanks!
– Moo
Nov 28, 2022 at 22:30
• I also like how pretty they look (:. Thanks for giving me an excuse to look at one haha Nov 28, 2022 at 22:31

Clear["Global*"]

f[x_] := Cos[x] + Cosh[x]^2


The exact solutions are Root expressions

sol = {Reduce[f[z] == 0 && Abs[z] < 2, z] // ToRules}


Their approximate numeric values are

sol // N

(* {{z -> -1.02195 - 1.19864 I}, {z -> -1.02195 + 1.19864 I}, {z ->
1.02195 - 1.19864 I}, {z -> 1.02195 + 1.19864 I}} *)


Plotting,

ListPlot[ReIm[z] /. sol,
AxesLabel -> {Re, Im}]


EDIT: Use ComplexContourPlot

ComplexContourPlot[
ReIm[Cos[z] + Cosh[z]^2],
{z, -1.5 - 1.5 I, 1.5 + 1.5 I},
Contours -> {{0}, {0}},
PlotPoints -> 50,
MaxRecursion -> 5,
PlotLegends -> "Expressions",
Epilog -> {Red, AbsolutePointSize[4],
Point[ReIm /@ (z /. sol)]}]


• Thanks @BobHanlon, not exactly what I had in mind. I was hoping that we could have a graphical representation showing the functions and their intersections (like you see with real functions). Maybe that is just not possible, and this is the best that can be done. I was hoping I would have seen those intersections in the contour plot I drew, but no such luck. + 1
– Moo
Nov 28, 2022 at 20:58
• @Moo: It's possible. Consider the complex function $f(z)=\cos(z)+\cosh^2(z)$. Now plot separately, the real and imaginary surfaces of these two functions. That is, let $z=r e^{it}$. Next plot where they are both zero or intersecting the complex z-plane. This results in contour lines. Where the contour lines intersect are the zeros. Nice if you can plot the contour lines over each real and imaginary surface!
– josh
Nov 28, 2022 at 21:12
• @BobHanlon: Perfect! Thanks!
– Moo
Nov 28, 2022 at 21:54
• @josh you can also plot directly the phase using ComplexPlot[f[z], {z, -2 - 2*I, 2 + 2*I}, ColorFunction -> "CyclicLogAbs"]. At a zero or a pole f[z] behaves like $z^m$ (after shifting to the position of the pole or zero) and so $r^m e^{m i t}$ and thus as an oscillator with frequency m. That has the advantage that it also shows the multiplicity of the zero or pole (and it is nice eye candy to look at). Nov 28, 2022 at 22:39
• @josh Technically it should be ColorFunction -> "CyclicArg" according to what I said but I prefer the look of "CyclicLogAbs"` Nov 28, 2022 at 22:43