Suppose I have an equation relating a number of variables and I know the values of all but one of them. Using the equation and known values as input, is there a simple command (built-in or otherwise) to determine the missing value?
Original example:
Consider the formula for the area of a rectangle. I can write the formula as
area[length_, width_] := length*width
and plug in numbers for the dimensions and get the area. Also, I could write a formula for finding each specific dimension in terms of the remaining two. My question is this: Is there a way to write a single expression which will do the whole job, that is I can plug in any two of the components of the area formula and have Mathematica return the third?
So for instance, if
equation = area == area[length, width]
and let's say the area
is 5
and the length
is 2
. The output should be
{area -> 5, length -> 2, width -> 5/2}
or simply
width -> 5/2
Response to comment: I'm not sure what the syntax should look like. Preferably it would be expressive and natural (obviously). Maybe area -> 5
or area == 5
is a natural way to code a given value; or maybe even as an argument. [Edit note, Michael E2: I don't know what the OP had mind. I don't want to restrict the question too much here, esp. if someone has a really nice way of doing it. I hope it is sufficient that the equation and all but one value of the variables are known and can be used as input.]
Manipulate
. $\endgroup$