I see thanks, I get that. the problem is that I’m doing derivatives, and need symbols for that, so I’d like to be able to change symbols back to numbers, so that I can plot with them.

julia> using ModelingToolkit; @variables x y;
julia> f(x,y)= sqrt((x^2+144)+(y^2+144))
f (generic function with 1 method)
julia> 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
∂xf (generic function with 1 method)
julia> using Plots, ImplicitEquations
julia> plot(∂xf ⩵ 0.1, xlims=(0, 10), ylims=(-100, 100))

produces

In the future, people will have an easier time helping you if you actually show the code that produces the error. It’s a lot harder to help if we have to guess what you’re actually doing.

You’re not building the right function (or even using the right syntax for build_function). What Chris suggested was to use build_function to get a julia native function representation of the derivative, not the original function f.

Just a little nitpick, this will run eval every time you call g, so it is different from what I wrote in more than aesthetics. My version doesn’t use eval at runtime.

That simplify was not necessary, I just put it in there to check if expand_derivatives had any simplifications left over, but it didn’t. I forgot to remove it.

To answer your question though, simplify is exported by ModelingToolkit. The code I posted was self contained.