# Diophantine equations 3-d plots

Hi all,

I see this equation and I want to plot it, but could not be able to do it:
z^{3} - z = (x^{3} - x) + (y^{3} - y)

This is my code:

using Plots
pyplot()

x=range(-2,stop=2,length=100)
y=range(sqrt(2),stop=2,length=100)
my_cg = cgrad([:green,:blue])

f(x,y) = ((x^(3) - x) + (y^(3) - y))^(0.5)

plot(x,y,f,st=:surface,c=my_cg,camera=(-30,30))


There is an error:
DomainError with -4.585786437626904:
Exponentiation yielding a complex result requires a complex argument.
Replace x^y with (x+0im)^y, Complex(x)^y, or similar.

Is the solutions involving complex numbers?
I choose to use f(x,y) first instead of the z^3 - z because it will be more difficult.

Plotting the solutions of such equations is the job of the Implicit3DPlots.jl package.

If you want to plot the surface S: f(x,y,z)=z^3+z-x^3-x-y^3-y=0, then since it is given by an implicit equation, you can use MarchingCubes.jl https://github.com/JuliaGeometry/MarchingCubes.jl. MarchingCubes returns a triangulation of this surface.
For x \in [-2, 2], y\in [\sqrt{2}, 2], z\in [-2,6], the surface looks like this:

3 Likes