Can something like this be put into build_function?
yes. Any symbolic statement or arrays (of arrays or sparse matrices or etc.) of symbolic statements can.
1 Like
I thought it should be. I can’t tell now if there is a problem with what I’m trying to do, or just with syntax
@variables x y u μ t Δtx Δty
@derivatives δx'~x δy'~y δu'~u δμ'~μ
#declared variables and derivatives, unless I also need something in the let ex= row, to assign variables
let ex = "Δtx*(δu(sqrt(u))*δx(x^2+144)) +Δty*(δμ(sqrt(μ))*δy(y^2+144)))";
func_ex= build_function(expand_derivatives(Δtx*(δu(sqrt(u))*δx(x^2+144) +Δty*(δμ(sqrt(μ))*δy(y^2+144))))
@eval vb(x,y,Δtx,Δty) = ($func_ex)(x,y,Δx,Δy)
end
That’s not real syntax. You never declared the variables. You might want to look at the documentation or Mason’s example.
I edited my post, not sure if I found the issue, sorry it wasn’t an MWE
@variable x y t
@derivatives δx'~x δy'~y δt'~t
v(x,y,t)=sqrt(x^2+144)*+sqrt(y^2+144)
let ex = Differential(x)(v(x, y,t));
func_ex= build_function(expand_derivatives(δtx*(δu(sqrt(u))*δx(x^2+144) +δty*(δμ(sqrt(μ))*δy(y^2+144)))))
@eval ∂xf(x, y,t) = ($func_ex)(x,y,t)
end
Again, that’s not the syntax for build_function
.
I think I have something that’s closer.
v(x,y,t)=sqrt(x^2+144)*+sqrt(y^2+144)
let ex = Differential(x)(v(x, y,t));
func_ex= build_function(expand_derivatives(δtx*(δu(sqrt(u))*δx(x^2+144) +δty*(δμ(sqrt(μ))*δy(y^2+144))))x,y,t)
@eval δxf(x, y,t) = ($func_ex)(x,y,t)
end
How would I plot the original function on the same graph?
plot!(f(x,y))