scicloj / wolframite

An interface between Clojure and Wolfram Language (the language of Mathematica)
Mozilla Public License 2.0
47 stars 2 forks source link

def= or equivalent. Way to define an equation for use and display #75

Open light-matters opened 2 months ago

light-matters commented 2 months ago

The idea is to make something like

(def= F (w/* 'm 'a))
(wl/eval (Something... F ...))

possible, where def= would act like Clojure's (def ...) and yet automatically assign a Wolfram equation (w/== 'F (w/* m a)) to the symbol F. Ideally, this would also store 'kind' data such that it could automatically be visualised by literate programming tools like clay.

holyjak commented 1 month ago

Excuse my clueless questions :) but what is a Wolf equation used for, and why would we want to assign it to a symbol? How/why is this useful?

light-matters commented 1 month ago

So a Wolfram equation is just Wolfram's way of writing mathematical equations. In Wolfram, I would write c^2 == a^2 + b^2 (if I was a friend of Pythagoras).

It's about user convenience. If I wanted to find 'a' then I would copy it across to a Solve function, i.e. Solve[c^2 == a^2 + b^2, a]. If I want to use it in many places then I would have to give the equation a name, e.g. ptheorem=c^2 == a^2 + b^2 and then use that: Solve[ptheorem, a]. In this case, there isn't really a problem but when you're working with lots of equations and different steps through them then having to name them individually becomes a bit of an anti-pattern.

It's also the case that there are different ways of representing such things. The solution above is given as a -> Sqrt[-b^2 + c^2], but you could equally write an actual equation, i.e. a== Sqrt[-b^2 + c^2]. You can see this in the cavity-physics ns where I have the symbol 'E4 and the expression E4 and at some point an equation, which is simply (w/== 'E4 E4).

It seems like it would be more efficient to have a single definition of an equation that covers all of these bases.