1
$\begingroup$

So recently, I asked this question on Math.SE on if my thought process on how to solve the limit $\lim_{x\to(\pi/2)^-}\tan(x)^{\cos(x)}$ was correct, and actually, while I was solving this, I was trying to plot the imaginary part of said equation in Mathematica for practice.

I do have code for plotting the real-value part

Plot[Tan[x]^Cos[x],{x,-5,5}]

which does work as intended, however I'm confused as to how to get the imaginary plot of this function.

I have tried using

ComplexPlot[Tan[x]^Cos[x],{x,-5,5}]

but it returns the following errors:

ComplexPlot: Corners for x in {x,-5,5} must have distinct machine-precision real and imaginary parts.
ComplexPlot: Corners for x in {x,-5,5} must have distinct machine-precision real and imaginary parts.
ComplexPlot: Corners for x in {x,-5,5} must have distinct machine-precision real and imaginary parts.
General: Further output of ComplexPlot::plld will be suppressed during this calculation.
ComplexPlot: Corners for x in {x,-5,5} must have distinct machine-precision real and imaginary parts.
ComplexPlot: Corners for x in {x,-5,5} must have distinct machine-precision real and imaginary parts.
Out[6]= ComplexPlot[Tan[x]^Cos[x],{x,-5,5}]

enter image description here

I managed to fix this by adding an imaginary part to my bounds (my current code so far)

ComplexPlot[Tan[x]^Cos[x],{x,-5-5i,5+5i}]

which returns this

enter image description here

which looks cool, but it's not what I'm trying to do.

What I'm trying to do is this is plot the imaginary part of $\tan(x)^{\cos(x)}$ on the $xy$-plane like this (ignore the blue line):

enter image description here

although I don't know how to fix my code from here. So my question is:

How do I plot the imaginary part of $\tan(x)^{\cos(x)}$ on the $xy$-plane?

$\endgroup$

2 Answers 2

4
$\begingroup$
Plot[Evaluate[ReIm[Tan[x]^Cos[x]]], {x, -5, 5}, 
 PlotRange -> {All, {-5, 5}}]

enter image description here

$\endgroup$
1
  • 3
    $\begingroup$ Enough Plot[Im[Tan[x]^Cos[x]], {x, 0, 2*Pi}]. $\endgroup$
    – user64494
    Dec 11, 2023 at 20:16
2
$\begingroup$

Since V 12.0 there is ReImPlot

ReImPlot[Tan[x]^Cos[x], {x, -5, 5},
 GridLines -> Automatic,
 PlotLegends -> {"Expressions", "ReIm"},
 PlotRange -> {All, {-5, 5}}]

enter image description here

We also have AbsArgPlot which generates a plot of Abs[f] colored by Arg[f]

AbsArgPlot[Tan[x]^Cos[x], {x, -5, 5},
 Epilog ->
  {Dashed,
   {InfiniteLine[{Pi, 0}, {Pi, 1000}],
    InfiniteLine[{-Pi, 0}, {-Pi, 1000}]}},
 GridLines -> Automatic,
 PlotLegends -> Automatic]

enter image description here

$\endgroup$

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.