Hi, I'm trying to wrap my head around Symbolics.jl and figure out if it's a good fit for my use case.
Basically I have an application that receives a few data points every hour (say x_t, y_t
) and I need to calculate a large number of values derived from those, with some dependencies. For example:
c(x) = a(x) + b(x)
b(x) = 2*a(x)
a(x) = exp(x)
d(y) = y^2
Here, a naive approach might calculate a(x)
twice, whereas I'd like to do the computation once. I'd also ideally like to calculate d(y)
and c(x)
in parallel. The actual update step is of course much more complex, with a few thousand functions where the dependencies are very difficult to keep track of.
Is Symbolics a good approach for this? On the one hand, substitute
and simplify
look really helpful, but I have a hard time telling from the documentation whether Symbolics actually does this reuse & parallelization.
I'm not an expert on this. So, you might need a combination of two things: 1) solve the system for a,b,c,d (treating) exp(x), etc as constants. 2) efficient way to compute the solution for given input.
Is you system always linear wrt a,b,c,d? How large is the set of equations?
If you are after code generation, dependencies are exploited in https://github.com/chakravala/Reduce.jl
julia> Algebra.optimize(:(z = a^2*b^2+10*a^2*m^6+a^2*m^2+2ab*m^4+2*b^2*m^6+b^2*m^2))
quote
g40 = b * a
g44 = m * m
g41 = g44 * b * b
g42 = g44 * a * a
g43 = g44 * g44
z = g41 + g42 + g40 * (2g43 + g40) + g43 * (2g41 + 10g42)
end
Last updated: Nov 06 2024 at 04:40 UTC