using ModelingToolkit
using Plots
using ImplicitEquations
@variables x y;
f(x,y)= sqrt((x^2+144)+(y^2+144))
let ex = Differential(x)(f(x, y))
func_ex = build_function(expand_derivatives(ex), x, y)
@eval ∂xf(x, y) = ($func_ex)(x,y)
end
using Plots
using ImplicitEquations
plot(∂xf ⩵ 0.1, xlims=(-10, 100), ylims=(-100, 100))
plot!(f ⩵ 0.1, xlims=(-10, 10), ylims=(-100, 100))
it doesn’t give me any error, but it won’t display function f. Not sure if I should put ImplcitEquations first (so it knows x and y are related), I thought I had it working before.
As Peter says this doesn’t run, but it looks off to me - f is a function so f == 1 will just return false, and plotting that presumably gives nothing (which is maybe what you’re getting when you say “it won’t display function f”)
julia> let ex = Differential(x)(f(x, y))
func_ex = build_function(expand_derivatives(ex), 1, 1)
@eval ∂xf(x, y) = ($func_ex)(x,y)
end
ERROR: UndefVarError: x not defined
fixed it, I had to add @variables to get ModelToolkit to work. It defines x as a symbol, all syms packages have a version of it. I’ve been working with people familiar with this packge, that would have spotted the mistake. Again, my bad.
you got the second plot to work? I remember having a parabola and that sideways parabola (perhaps you can show a pic). I’m not sure why it’s not working for me then.
Sorry, as mentioned by @nilshg, only the first plot works. It creates a sideways parabola.
There is some odd behavior, here. In the second plot, the command f == .1 returns false. It’s not doing anything with an implicit function.
However plots doesn’t error, and it does change the axes making it look like there is a new plot. This is weird, since you explicitely give it the axes.
Regardless, it should be clear why f == 0.1 doesn’t do what you think it’s doing. You haven’t done anything about derivatives of used ImplicitEquations with f. It’s just a normal function.
Have you ever used PackageCompiler.jl?
I guess it’s probably due to previous precompilation using PackageCompiler.jl (umm… just a guess without any clue ).
I’m now trying to re-precompile an image using PackageCompiler.jl.
If it works, I’ll share my result.
Your function f is never close to 0.1, it being smallest at (0,0), so there are no solutions to Eq(f(x,y),0.1) or f⩵ 0.1. Try again, with a bigger value?