# How to make an interactive calculator for any mathematical relation? [closed]

I am wondering if there is a way to make a calculator for any relation that is interactive. First, I choose a relation with some variables in it. The user will input a value for all of the variables except for the one they wish to solve for. Some of the equations/relations I interested in applying this program to are the following physics equations (though there are many more present):

• Voltage=Current*Resistance

• Charge=Capacitance*Voltage

• Density=Mass/Volume

• Velocity=Distance/Speed

All of these involve only three variables but more complex relations should also be able to programmed into an interactive interface such as:

• (final velocity)^2=(velocity at time 0)^2+2accelerationdisplacement
• Impedance=Sqrt(Ressistance^2+(Inductive reactance-Capacitative
• reactance)^2) Magnetic Field=Permittivity of free Space *Number of coils * Current/Length of solenoid

My goal is take any relation and create a simple program where the user can input values into all of the fields except for one which they leave blank. The program will then solve for that value. I contacted Wolfram Support for help and they said I had to pay to Technical Consulting if I wanted to develop such a program and am wondering if there is any easy workaround. An example of a program of this sort can be seen at https://www.emathhelp.net/calculators/differential-equations/half-life-calculator/

Here is my code:

How should I add numeric input to my Manipulate program?

• Yeah, we have a close reason, "The answer to this question requires...the services of a professional consultant." Yours is a project that's rather broad and seems to call out for a consultant to do the work or work with you. Not sure why someone thought the question deserves an upvote. Maybe they will answer for you. (1) I can point you to Variables[] for determining the variables in the equation the user types. (2) You have a parsing problem: Mathematica naturally interprets "final velocity" as "final" times "velocity". It would be an easier thing to program if you required Mma syntax. Nov 5 '21 at 13:23
• I can make the request specific. Given a relation with N variables X1.....XN, how can I make a calculator like emathhelps or WolframAlpha's Web Apps calculators to output a value? For a similar question see mathematica.stackexchange.com/questions/253772/…. Nov 5 '21 at 13:25
• You have to start somewhere. Try typing your ideas in Mathematica and ask specific questions. At the moment your post does not contain even a single line of code that we can work on. Nov 5 '21 at 13:27

Here's a quick and dirty version that I think should come close to what you're asking for. The handling of the variables and their localisation is not very sophisticated, but it should work for simple formulas:

Clear[a, b, c]
eq = c^2 == a^2 + b^2;
vars = ReduceFreeVariables[eq]
sol = "";
Manipulate[
Evaluate@Column@{HoldForm[Evaluate@eq], eq, Dynamic[sol]},
Evaluate@Grid[
Append[
{HoldForm[#],
InputField[
Dynamic[#,
Function[{val, expr},
sol = "";
If[val === Null, Clear[#], # = val]
]
], Number]} & /@ vars,
With[{vars = vars, eq = eq},
{
Button["Solve",
If[Count[vars, _Symbol] === 1,
sol = Flatten@Solve[eq],
sol = ""
],
ImageSize -> Automatic,
Method -> "Queued"
],
SpanFromLeft
}
]
]
]
]


To use it, give all input fields numerical values except for one. Then press solve.

Clear["Global*"]

\$Version

(* "12.3.1 for Mac OS X x86 (64-bit) (June 19, 2021)" *)


Enter equation to be used (equation must use Equal (==) rather than Set (=))

eqn = (Voltage == Current*Resistance);

vars = Variables[Level[eqn, {-1}]];

Manipulate[
Column[{
StringForm["Equation: ", eqn], "",
Reduce[eqn, var, domain],
Manipulate @@ {
Reduce[eqn, var, domain],
Sequence @@ ({#, 1} & /@ DeleteCases[vars, var]),
Paneled -> False,
AppearanceElements -> None}}],
Row[{
Control[{{var, vars[[1]], "Solve for"}, vars}],
Spacer[25],
Control[{{domain, Reals, "Domain"}, {PositiveReals, NonNegativeReals,
Reals, Complexes, PositiveIntegers, NonNegativeIntegers, Integers}}]}]]