2
$\begingroup$

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?

$\endgroup$
7
  • 1
    $\begingroup$ Maybe ComplexPlot[f[z], {z, -2 - 2*I, 2 + 2*I}, ColorFunction -> "CyclicLogAbs"] $\endgroup$ Commented Nov 28, 2022 at 22:25
  • 1
    $\begingroup$ or ColorFunction -> "CyclicArg" $\endgroup$ Commented Nov 28, 2022 at 22:28
  • 1
    $\begingroup$ 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 $\endgroup$ Commented Nov 28, 2022 at 22:29
  • 1
    $\begingroup$ @userrandrand: That second plot is beautiful! I cannot believe I missed this command and the one in the answer! Thanks! $\endgroup$
    – Moo
    Commented Nov 28, 2022 at 22:30
  • 1
    $\begingroup$ I also like how pretty they look (:. Thanks for giving me an excuse to look at one haha $\endgroup$ Commented Nov 28, 2022 at 22:31

1 Answer 1

5
$\begingroup$
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}

enter image description here

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}]

enter image description here

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)]}]

enter image description here

$\endgroup$
5
  • $\begingroup$ 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 $\endgroup$
    – Moo
    Commented Nov 28, 2022 at 20:58
  • 1
    $\begingroup$ @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! $\endgroup$
    – josh
    Commented Nov 28, 2022 at 21:12
  • $\begingroup$ @BobHanlon: Perfect! Thanks! $\endgroup$
    – Moo
    Commented Nov 28, 2022 at 21:54
  • 2
    $\begingroup$ @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). $\endgroup$ Commented Nov 28, 2022 at 22:39
  • 1
    $\begingroup$ @josh Technically it should be ColorFunction -> "CyclicArg" according to what I said but I prefer the look of "CyclicLogAbs" $\endgroup$ Commented Nov 28, 2022 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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