Data Editing - functions such as z=f(x,y) or y = f(x)

Beta releases, announcements and anything else that doesn't fit below. Please read the <B>Welcome</B> topic.

Moderator: DPlotAdmin

Post Reply
mjzoccoli
Posts: 8
Joined: Wed Sep 06, 2006 3:14 pm

Data Editing - functions such as z=f(x,y) or y = f(x)

Post by mjzoccoli »

Hello all - I am a new user of DPLOT, so my questions may seem basic...

Here goes....In a function such as z = sqrt (x, y) how can I eliminate the occurrence of a negative square root? For example, EXCEL would show #NUM! when such a value occurs in a data matrix. I can then reassign that value as appropriate before/ during the creation of a chart. But in DPLOT (so far!) I just get the message that a negative square root has been found at some location....and the plot of the z=f(x,y) goes no further.

So how do I get past this point?

Thanx for your anticipated reply.......Mike Z

ps My first inclination is to weave in a logical IF statement to first query the data...
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

An IF statement (which DPlot does support) is the logical choice; unfortunately it doesn't work especially well in DPlot right now.

For example

IF(x^2+y^2<=25,sqrt(25-x^2-y^2),0)

should plot a hemisphere with radius 5. Unfortunately the way DPlot implements IF is a bit of a hack. IF(a,b,c) is translated to

(a*b+(1-a)*c), where the inequality "a" is 1 if true, 0 if false. The trouble is both b and c get evaluated regardless of whether a is true or not. This has needed work for a while.

Until this is fixed the only way to get around the limitation is to use an equation that won't blow up, then modify z to get the real answer. In the above example you could use

z=IF(x^2+y^2<=25,25-x^2-y^2,0)

then use Edit>Operate on Z with Z=sqrt(Z).
Visualize Your Data
support@dplot.com
mjzoccoli
Posts: 8
Joined: Wed Sep 06, 2006 3:14 pm

Questions re z=f(x,y) - when a neg sqrt is encountered

Post by mjzoccoli »

Thank you for the prompt and helpful reply David -

I still have some additional comments on this topic, but I need to do some work first, along the lines of your suggestion.

Regards Mike Z
mjzoccoli
Posts: 8
Joined: Wed Sep 06, 2006 3:14 pm

re Negative SQRT Problem in Functions such as z=f(x,y)

Post by mjzoccoli »

Hello again...first, my sincere thanks to David Hyde for his excellent assistance to me on this basic issue. So, I think we might summarize, and also test my understanding of how to get around this problem - ie, exection of z=f(x,y) stops upon detection of a negative square root.

Pls consider the following equation:

z = sqrt(9 + y^2 +6*y - x^2 - 4*x)...<<One-sheeted hyperboloid of revolution>>

The approach is to calculate z^2 first, by using a logical IF statement, and then to OPERATE on Z with z=sqrt(z).

I used the following:
if( ( x^2 + 4*x -y^2 - 6*y)<9, 9-(x^2+4*x-y^2-6*y), 0 )

That seemed to work, as it weeded out any negative values under the square root. Last step is to then OPERATE with Z=sqrt(z).

I verified the results by plotting the same equation in EXCEL - apart from scaling the x&y axes, the results seem to agree.

My thanx again - comments welcome
Post Reply