# how can I express this equation in gnuplot?

In gnuplot, how would I express something like this:

## Answers

To express inequality, we'll use the ternary operator, where (in pseudocode)

if CONDITION: DO_A else: DO_B

is expressed as

CONDITION ? DO_A : DO_B

so in our case,

if a != x: f(x) = (a - x)**(0.04) else: f(x) = 0

is expressed as

f(x,a) = (a != x) ? (a - x)**(0.04) : 0

Note that we are expressing the 25th-root, or n^(1/25), as n^(0.04).

Plotting this equation will look something like the following:

reset f(x,y) = (y != x) ? (y - x)**(0.04) : 0 unset colorbox set isosample 300, 300 set xlabel 'x' set ylabel 'y' set title '(y - x)^{0.04} != 0' set sample 300 set pm3d map splot [-500:500] [-500:500] f(x,y)

Another way to express this is to simply do

reset f(x,y) = (y - x)**(0.04) != 0 unset colorbox set isosample 300, 300 set xlabel 'x' set ylabel 'y' set title '(y - x)^{0.04} != 0' set sample 300 set pm3d map splot [-500:500] [-500:500] f(x,y)

In this second image, Gnuplot is plotting the imaginary part of the equation (i.e., when x > a).