Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw a function given by a system of equations involving an implicit function

I need to draw a graph of a function like this:

enter image description here

What is the most elegant way to do it?

like image 753
Anton Degterev Avatar asked Dec 07 '25 11:12

Anton Degterev


1 Answers

You could use the substitution x = cos(t) to parameterise your set of equations for t ∈ [0, 2π) as x = cos(t), y = sin(t), z = 2x.

In Julia, you can use Plots.jl to plot this as follows:

using Plots
t = 0:0.01:2*pi
x = cos.(t)
y = sin.(t)
z = 2 .* x

plot(x, y, z)

A slightly neater trick is to use parametric plotting, where we can just pass functions (x(t), y(t), z(t)) and specify the range of the parameter t:

plot(cos, sin, x -> 2 * cos(x), 0, 2π, xlabel="x", ylabel="y", zlabel="z", label="f")
like image 85
htl Avatar answered Dec 09 '25 17:12

htl