How to plot square root of solution to an ODE


I have an ODEProblem, let us say like the one in this example:

function parameterized_lorenz!(du,u,p,t)
 du[1] = p[1]*(u[2]-u[1])
 du[2] = u[1]*(p[2]-u[3]) - u[2]
 du[3] = u[1]*u[2] - p[3]*u[3]

u0 = [1.0,0.0,0.0]
tspan = (0.0,1.0)
p = [10.0,28.0,8/3]
prob = ODEProblem(parameterized_lorenz!,u0,tspan,p)

I solve this ODE using solve() and want to plot time versus square root of the second coordinate. How can I do this?

I managed to do this, but feels like a hack:


It’s mentioned in the plotting page:

1 Like

Thanks! That almost worked, I had to make a small change:

f(x,y) = return (x,sqrt(y))

since the compiler is expecting f to be a function of two variables here.

1 Like