LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-28-2018, 03:46 AM   #1
sibelius
Member
 
Registered: Oct 2018
Location: Leura NSW Australia
Distribution: Linux Knoppix 8.1
Posts: 53

Rep: Reputation: 0
problem with GNUPLOT script


Hi everybody I have some issue with this script.
the porpoise of this code is to plot a function called sin(z) where z is the generic complex number x+iy.
the function does not appear, everything else (windows, x,,y,z range and so on is fine excepted the function).
if someone have some idea would be great.
thank you in advance.

that is the code
Code:
set title "seno di z complesso"

unset key

set xyplane at 0

set xlabel "Rez"; set ylabel "Imz"; set zlabel "sin(z)"

set xrange [-5.:5.]; set yrange [-5.:5.]; set zrange [-5.:5.]

set xtics 1.0; set ytics 1.0; set ztics 2.0

set sample 50,50; set isosamples 50,50

set pm3d depthorder hidden3d

unset colorbox

set view 60,60,1,1

set size square 1.0,1.0

#a(x,y) = x+y
#b(x,y) = x-y
#c(x,y) = x*x
#d(x,y) = x + {0,1}*y

z(x,y) = (x+{0,1}*y)*{0,1}	
w (x,y) = (-x +{0,-1}*y)*{0,1}

sinz(x,y) =  (exp(z(x,y)) - exp(w(x,y)))/(2*{0,1})

splot sinz(x,y) w pm3d

#splot a(x,y),b(x,y),c(x,y) w pm3d
#splot d(x,y) w pm3d
 
Old 10-28-2018, 02:02 PM   #2
Ragnathok
LQ Newbie
 
Registered: Oct 2013
Location: Québec, Canada
Distribution: Manjaro, Ubuntu, Arch
Posts: 25

Rep: Reputation: 26
As can be seen in your tests with the a, b, c and d functions, plotting with real numbers works fine while plotting with complex ones results in the function not appearing.

The function of a complex number is complex itself. Here, you are trying to map it on a single axis even though it has a real and an imaginary part. Thus, you need to plot them separately:

Code:
splot real(sinz(x,y)) w pm3d
for the real part and

Code:
splot imag(sinz(x,y)) w pm3d
for the imaginary part.

As a side note, directly plotting the sine function

Code:
i = {0.0, 1.0} #Define imaginary number
splot real(sin(x+i*y)) w pm3d #Real part
splot imag(sin(x+i*y)) w pm3d #Imaginary part
yields the same result as using the definition of the sine function with exponentials. In the code above, only the last plotted function will appear on screen. Comment the one you do not one to plot.
 
2 members found this post helpful.
Old 10-28-2018, 08:29 PM   #3
sibelius
Member
 
Registered: Oct 2018
Location: Leura NSW Australia
Distribution: Linux Knoppix 8.1
Posts: 53

Original Poster
Rep: Reputation: 0
thank you very much, everything is fine now, I haven't test my scrip yet but a much simple one
I plot the real part of a generic complex number z=x+iy and as I expected a plane came out.
very good.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] gnuplot basic graph problem - noob to gnuplot sudowtf Linux - General 2 04-02-2015 11:00 AM
imbedded gnuplot script problem sbgirl54 Linux - Software 4 08-20-2012 10:18 AM
Passing a path to a gnuplot script from bash script mystupidquestion Programming 2 10-11-2011 09:10 AM
[SOLVED] issue with gnuplot script Simon_6162 Linux - Software 4 07-08-2011 06:40 AM
gnuplot script gav251 Linux - Software 2 02-24-2010 05:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration