Remix.run Logo
throw310822 a day ago

Hm? I don't get it.

What's the point of calculating backwards non-invertible operations such as addition? Isn't the result just arbitrary?

fouronnes3 a day ago | parent | next [-]

I made this mostly as a fun challenge :)

You are right that there is some arbitrariness involved when picking a solution, however it's a bit more subtle than that.

Let's say our problem has N free variables.

Step 1 is finding the subset of R^N that is the solution to the root finding problem. If this subset is a point, we are done (return that point). Note that if there is no solution at all bidicalc should correctly report it.

Step 2 is if the solution subset is not a point. Then there is multiple (maybe even an infinity of) solutions, and picking one is indeed arbitrary.

kolarski a day ago | parent [-]

does the algorithm tries to make minimal changes to the free variables ? If we have 1 + 1 = 2 and change 2 -> 4 then -100000 + 100004 = 4 is also a valid solution. When I tried it it changed it to 2 + 2 so perhaps there is optimization but also a valid optimization can be minimal free variable changes in which case it would be 1+3 = 4 and we update 1 free variable instead of 2. I have no idea which is better just curios how it works. I like the idea very much.

fouronnes3 a day ago | parent [-]

The actual heuristic used to pick a solution from an infinite solution subspace is a bit too complex to explain in a comment. I really need a blackboard :D The main goal was actually to find a solution, any solution at all, and fast. I wanted the backwards update to be very fast to feel as magic as possible. So the heuristic is pretty simple and could definitely be improved!

generalizations a day ago | parent | prev | next [-]

They said this:

> Even a normal spreadsheet is fairly complex beast. But the novel thing about bidicalc is the backwards solver. Mathematically, updating a spreadsheet "backward" is a (potentially underdetermined) root finding problem, because we are trying to find a vector of unknowns such that , where F is the function computed by the cells formulas, and G is the objective value entered in the cell. Note that F is not necessarily a single formula, but the result of composing an upstream graph of cells into a single function.

> The actual root-finding solver is a custom algorithm that I made. It a general purpose algorithm that will find one root of any continuous-almost-everywhere function for which a complete syntactic expression is known. It uses a mix of continuous constraint propagation on interval union arithmetic , directional Newton's method and dichotomic search. It is of course limited by floating point precision and available computation time.

But that really doesn't answer your question. I see no reason why the solver wouldn't decide every time it had a two-variable summation that ADD(X+Y) doesn't reverse to X=-90 and Y=100.

esafak a day ago | parent | prev | next [-]

It is for fun. Commercial products do not support this because functions are generally not invertible.

dmurray 21 hours ago | parent [-]

I would expect the opposite.

Commercial products are run by product managers: they do whatever the business needs that day, and if it doesn't work for most inputs, "that's fine, our users will only ever need addition". Fun open source projects, run by the same programmer who does the implementation, obsess over finding the generic solution to inverting a function and end up with a version that isn't useful for anyone's specific case.

esafak 15 hours ago | parent [-]

You can't even invert addition. If A+B=C and you change C, you can not infer A and B without making assumptions, like scaling them equally.

nrhrjrjrjtntbt a day ago | parent | prev [-]

You could add hints as a feature to this. E.g. interest = rate × principle

The user hints principle is preferred fixed so they can see what rate is needed for a givem amount of interest.

Hints could have a precedence order (then prefer to fix earlier terms on an operation on a tie breaker.)