Re: avoid double function evaluation on '+' special file

Ethan Merritt <[email protected]> Sun, 21 Apr 2024 11:54:42 -0700
Newsgroups gmane.comp.graphics.gnuplot.user
Message-ID <CAGRdh4vg+NNnbW32Ma7n0eTsnDGcRg59ZvK3+9fJSMewgaEdmw@mail.gmail.com>
On Sun, Apr 21, 2024 at 6:31 AM <[email protected]> wrote:

> Dear Gnuplot Users,
>
> suppose the following simple gnuplot example snippet which is used to
> plot a complex valued function:
>
>    w = 5
>    r = 3
>    f(t) = r * exp(I * w * t)
>    plot sample [t=0:1] '+' u (real(f(t))):(imag(f(t))) w l
>
> here the function f(t) is evaluated twice - not desirable because of
> performance. How can this be done with only one evaluation of f(t)?
>

    plot sample [t=0:1] '+' u (temp=f(t),real(temp)):(imag(temp)) w l


>
> Thanks for any advice and best regards
>
> Torsten
>

_______________________________________________
gnuplot-info mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info