Search code examples
gnuplot

How to draw a cosine curve with complex numver in gnuplot?


How to draw a cosine curve with complex exponentials using gnuplot?

enter image description here

I tried to draw them using this script, but the graph is not drew.

set parametric
i = {0.0,1.0}
set size ratio -1
plot real(1/2*(exp(i*t)+exp(-i*t))), imag(1/2*(exp(i*t)+exp(-i*t)))

but I got nothing on the graph.

Example, circle in complex number

set parametric
i = {0.0,1.0}
set size ratio -1
plot real(1/2*(exp(i*t)+exp(-i*t))), imag(1/2*(exp(i*t)+exp(-i*t)))

Solution

  • You need the correct functions.

    plot t, cos(t)
    

    If you want to use exponentials

    plot t, exp(i*t) + exp(-i*t)
    

    You can see this with eulers equation.

    exp(i*t) = cos(t) + isin(t)
    

    Then the sum reduces to

    exp(i*t) + exp(-i*t) = 2*cos(t)
    

    No imaginary component.