Hi Stefano,

That's great to hear you've got a symbolic solver up and running as well!
Some of the details I'm sure are trade secrets, but if you're willing to
chat I think it would be interesting to talk about things a bit, and to get
things started below is a quick overview of what I'm up to.

I chose to base my symbolic system on how I can see Mathematica represents
things: an n-ary expression tree, which is working out well for me. I'm
using a sorted n-ary tree structure where each node has a "head" saying
what the node is and a set of links to other nodes. I use these
fundamental mathematical operations: Add, Times, Power, but derive
subtraction and division from them: a - b  = add(a, times(-1 ,b)), a / b =
times(a, power(b, -1)), which really helps when doing simplifications, and
is how Mathematica does things. Another powerful concept in Mathematica are
"rules" for pattern matching and expressions manipulation, for example
a_*b_ +  a_*c_ -> a_*(b_ + c_), where the a_ means "any expressions" and
something like a_Integer, or a_Symbol just means a single integer or
variable respectively. Finder matching sub expressions, including negative
ones, is still something I want to optimise further.

I think it's an interesting optimization problem to solve these systems
efficiently, that from my point of view looks NP-Hard, much like the
traveling salesman problem. The problem statement goes something like:
"Solve A.x = z for x (x and z being vectors of length n, and A being an n
by n matrix) in the least "cost" in fundamental operations =, +, -, *, /
where the cost of operations are zero for =, one for + - *, and some higher
number for eg 5 for /. The resultant solution will usually can be written
as a series of assignments of temporary variables to (possibly common)
sub-expressions of the final solution, ending with assignments to the n
elements of x being the solution to the system of linear equations.

I'm surprised, given the usefulness, that there aren't more papers
published in this area, perhaps I just don't know what to look for!

Cheers,

Andy Simper



On Mon, 4 Dec 2023 at 05:40, Stefano D'Angelo <[email protected]>
wrote:

> Hi,
>
> FWIW, I second to everything Andy said.
>
> However, this caught my attention:
>
> Il 01/12/23 10:11, Andrew Simper ha scritto:
> > I've simulated a similar circuit in full: Ibanez Tube Scream. To do so
> > I've written a c++ based symbolic circuit solver that optimises the
> > equations and generates c++ production ready code. Getting to this
> > point has taken around 10 years, but ultimately, if you're serious
> > about doing this stuff, you'll need to automate the process. I chose
> > c++ since I'm most familiar with it, and it runs the fastest, but I
> > did tinker around with Mathematica, Python, and Julia first. Julia
> > would have probably been a better choice if I was more fluent with how
> > to manipulate the expression trees, since it also has some really
> > handy dynamic code compilation stuff in there.
>
> In our company we have also created something similar, a
> semi-interactive tool that takes you from a SPICE netlist to C++ or
> Matlab code, written in JavaScript and based on a symbolic math library
> we have also developed ourselves.
>
> I am also aware of PyPHS (https://github.com/pyphs/pyphs), which I
> however never really used. Not to mention the various WDF libraries
> around (e.g., https://github.com/RT-WDF,
> https://github.com/Chowdhury-DSP/chowdsp_wdf,
> https://github.com/droosenb/faust-wdf-library).
>
> I wonder how many such things exist.
>
> Best,
>
> Stefano
>

Reply via email to