Top
Best
New

Posted by fouronnes3 12/11/2025

Show HN: I made a spreadsheet where formulas also update backwards(victorpoughon.github.io)
Hello HN! I'm happy to release this project today. It's a bidirectional calculator (hence the name bidicalc).

I've been obsessed with the idea of making a spreadsheet where you can update both inputs and outputs, instead of regular spreadsheets where you can only update inputs.

Please let me know what you think! Especially if you find bugs or good example use cases.

252 points | 116 commentspage 3
deckar01 12/13/2025|
Sympy can (often) solve under constrained systems in terms of the free variables. The problem I run into is discrete constraints that make solving less closed form and more combinatorial search. When textbook amplifier formulas significantly diverge from physical reality I model the errors as linear correction factors and use gradient descent to correct it in a few experiments, but I’m curious if there is software that has solved this problem.
iamwil 12/13/2025||
Reminds me of functional logical programming languages like Verse. when you specify the output and ask for the inputs, you get all possible inputs.
Towaway69 12/13/2025|
Came here to say the same thing but with reference to Prolog.
1718627440 12/13/2025||
Sounds a bit like Prolog with a Spreadsheet UI?
throw310822 12/12/2025||
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 12/13/2025||
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 12/13/2025||
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 12/13/2025||
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 12/13/2025|||
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 12/13/2025|||
It is for fun. Commercial products do not support this because functions are generally not invertible.
dmurray 12/13/2025||
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 12/13/2025||
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 12/13/2025||
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.)

hallole 12/13/2025||
Phenomenal! This is a solid prototype, clean execution. I've had exactly this idea, too: I've already given the spreadsheet the relationships between these values, why can't it just work backwards when values change? That premise hides a ton of complexity, though, I'm sure. Lots of scary matrices.
fouronnes3 12/13/2025|
Thanks! Yes I loved the ratio of apparent simplicity to underlying complexity of this project. I have filled around 120 pages of draft and notes just for the math of the solver :)
WillAdams 12/12/2025||
Very cool!

I'd love to see a version where cells are "torn off" and named as they were in Lotus Improv and one had a "formula pane" where one could see all the formulae for a spreadsheet.

Would it be possible to create this in Python so that it could be a part of pyspread?

aatd86 12/13/2025||
LOL! Gemini suggested to implement this to me literally yesterday: bidirectional computations. The example was that given a temperature in Celsius and Fahrenheit, modifying either of them should update their counterpart. In angular that would be two linked signals for instance, but even that is a bit fringe. Gemini was going for something even more elaborated.

I told Gemini that spreadsheets were actually not doing that and that I had ways to implement that behavior without the complexity.

Just writing that to show the rabbit hole people are going to fall into if they let their llms go brrr. ;D

In any case, the problem is interesting. The point was to include bi-directionality inside a graph of computations so that we didn't get bogged down by cycles. The benefit being that it would handle float precision issues.

My more manual solution expect that floats precision issues are handled explicitly. I think that this level of explicitness is needed anyway for proper floating point error mitigation.

maplethorpe 12/13/2025|
That's weird, Gemini told me not to do this.
aatd86 12/13/2025||
To not do what, to not implement a constraint solver for bidirectional formulas? If you input my above comment it is for sure going to weigh the pros and cons. https://gemini.google.com/share/f40bf53d9c21

Excerpt from the initial convo with gemini: Thinking with 3 Pro December 11, 2025 at 09:59 PM

2. Propagators (Constraint Networks)The Problem: Your valueref binder and watch logic handle one-way data flow well. But complex forms (e.g., "Start Date must be before End Date," or "Fahrenheit <-> Celsius") require messy, cyclic event handlers to keep everything in sync.The Academic Concept: Propagators (Alexey Radul / Gerald Sussman, MIT).Instead of functions ($A \rightarrow B$), you define Constraints. A network of constraints seeks a consistent value for all connected nodes. It is "multi-directional" by design.

I see my message above being downvoted, I don't even know why ;D

In the end Gemini did agree that it was not necessary to introduce this level of complexity for my use case.

To be fair, Victor goes further because he adds a solver on top. In the research of a solution that might make sense. The issue in general is that not everything has a reverse operation so, in a sense, it is but an approximation.

injidup 12/13/2025||
A 2d sketcher with constraints is kind of similar. For example the equation

A = B + C

Where A, B, C are the lengths of 3 parallel lines. Within the sketcher you can drag the length of any one of those lines and the other two will adjust to keep the constraints.

fouronnes3 12/13/2025|
Yes! I'd really like to make something graphical in this same idea space next. See g9.js for example, or parametric CAD software like FredCAD which kinda does what you said.
koolala 12/13/2025|
Could this easily represent a Kalman filter and other typically complex control problems?

Makes me imagine plotting a inverted pendulum and other real time systems. Could a cell variable be set to Time?

More comments...