Stream: helpdesk (published)

Topic: Does Symbolics avoid repeat computation?


view this post on Zulip Satvik Souza Beri (Jun 02 2021 at 20:12):

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.

view this post on Zulip Steffen Plunder (Jun 18 2021 at 06:40):

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?

view this post on Zulip Bardo (Jan 15 2022 at 09:02):

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: Oct 02 2023 at 04:34 UTC