# Diophantine equations 3-d plots

**URL:** https://discourse.julialang.org/t/diophantine-equations-3-d-plots/85727
**Category:** General Usage
**Tags:** plotting, implicit-equation
**Created:** [August 14, 2022, 2:10pm UTC](https://discourse.julialang.org/t/diophantine-equations-3-d-plots/85727 "2022-08-14T14:10:48Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Freya\_the\_Goddess](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/freya_the_goddess/32/36835_2.png) [@Freya\_the\_Goddess](https://discourse.julialang.org/u/Freya_the_Goddess)
#### Post date: [August 14, 2022, 2:10pm UTC](https://discourse.julialang.org/t/diophantine-equations-3-d-plots/85727/1 "2022-08-14T14:10:48Z")

</div>

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:

```julia
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.

---

<div class="post-metadata">

### Author: ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)
#### Post date: [August 14, 2022, 3:45pm UTC](https://discourse.julialang.org/t/diophantine-equations-3-d-plots/85727/2 "2022-08-14T15:45:30Z")

</div>

Plotting the solutions of such equations is the job of the [Implicit3DPlots.jl](https://docs.juliahub.com/Implicit3DPlotting/tCQxM/0.1.7/) package.

---

<div class="post-metadata">

### Author: ![empet](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/empet/32/221303_2.png) [@empet](https://discourse.julialang.org/u/empet)
#### Post date: [August 14, 2022, 3:53pm UTC](https://discourse.julialang.org/t/diophantine-equations-3-d-plots/85727/3 "2022-08-14T15:53:36Z")

</div>

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](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:  
 ![implicit-surface](https://global.discourse-cdn.com/julialang/original/3X/8/b/8b042f8f1594eef0841d047730123990901cdbc9.png)
