Search code examples
gnuplot

Plot the Kampyle of Eudoxus with gnuplot


I wish to generate the Kampyle of Eudoxus with Gnuplot:

plot x*x*x*x = x*x + y*y

This code should do the trick. However, it returns me the following error:

plot x*x*x*x=x*x+y*y
            ^
"file.plt", line 1: unexpected or unrecognized token

Is there a way to plot this?


Solution

  • If you check the gnuplot FAQs you will find a note that you cannot plot implicit defined graphs directly, however, a workaround is described.

    Default samples is 100. So, in order to increase precision set samples 1000 and set isosamples 1000.

    Script:

    ### plot implicit graph
    reset session
    
    f(x,y) = x**4 - a*(x**2 + y**2)
    a = 1
    
    set samples    1000
    set isosamples 1000
    set contour base
    set cntrparam levels discrete 0.0
    unset surface
    set table $CONTOUR
        splot f(x,y)
    unset table
    set key top center
    
    plot $CONTOUR w l lc "red" ti sprintf("\n\nKampyle of Eudoxus\nx^4 = a*(x^2 + y^2)\na = %g",a)
    ### end of script
    

    Result:

    enter image description here