1

I have 2 functions declared in wxmaxima: f1(x, y) and f2(x, y). Both contain if-then-else statements and basic arithmetic operations: addition, subtraction, multiplication and division. For example (just an example, real functions look much more complicated):

f1(x, y) := block([],
    if x * y < 123 then x + y
    else if x / y > 7 then x - y
);

In both functions x and y change from 0.1 to 500000. I need a 3D plot (graph) of the following points:

(x, y, z), where f1(x, y) == f2(z, x)

Note that it's impossible to extract z out from the equation above (and get a new shiny function f3(x, y)), since f1 and f2 are too complex.

Is this something possible to achieve using any computational software?

Thanks in advance!

EDIT: What I need is the plot for

F(x, y, z) = 0

where

F(x, y, z) = f1(x, y) - f2(z, x)
Cimbali
  • 11,012
  • 1
  • 39
  • 68
haykart
  • 957
  • 5
  • 14
  • 34
  • Have you tried just generating the values and placing them in a list `{{x1,y1,z1},...,{xn,yn,zn}}` then using the function [`ListPlot3D[]`](http://reference.wolfram.com/language/ref/ListPlot3D.html) ? – Felix Castor Dec 18 '14 at 16:44
  • Unfortunately, I cannot generate values. The only thing I know is that `x` and `y` change from 0.1 to 500000. I know nothing about `z`. – haykart Dec 19 '14 at 09:31
  • So is f1(x,y) giving values of z? Furthermore, is f2(z,x) giving values of y? If this is the case, wouldn't you have 0 or more crossings on the z = y line extending -inf < x < inf. – Felix Castor Dec 19 '14 at 20:31
  • Is it fair to assume you could evaluate the function `f2(f1(x,y),x) == f1(x,y)`? So essentially `z = f1(x,y); return f2(z,x) == z`. I think you really need to post the equations. – Felix Castor Dec 19 '14 at 20:39

2 Answers2

1

For Maxima, try implicit_plot(f1(x, y) = f2(x, y), [x, <x0>, <x1>], [y, <y0>, <y1>]) where <x0>, <x1>, <y0>, <y1> are some floating point numbers which are the range of the plot. Note that load(implicit_plot) is needed since implicit_plot is not loaded by default.

As an aside, I see that your function f1 has the form if <condition1> then ... else if <condition2> then ... and that's all. That means if both <condition1> and <condition2> are false, then the function will return false, not a number. Either you must ensure that the conditions are exhaustive, or put else ... at the end of the if so that it will return a number no matter what the input.

Robert Dodier
  • 16,905
  • 2
  • 31
  • 48
0
 set = Table[{i,j,0},{i,1,10},{j,0,10}];

Gives a list of desired x and y values and use those with a replace all /.

 set =  set /.{a_ ,b_ ,c_} -> {a,b, f1[a,b] - f2[a,b]} (*Simplified of course*)

Set is a 2d list of lists so it needs to be flattened by 1 dimension.

 set = Flatten[set,1];

 ListPlot3D[set (*add plot options*)]
Felix Castor
  • 1,598
  • 1
  • 18
  • 39