Solve for Variable Calculator: Plug In Values, Get the Unknown
Type any formula, leave one variable blank, and solve it numerically via Newton-Raphson.
Type any equation in the form 'lhs = rhs' with one variable left blank, fill in numeric values for everything else, and the solver finds the missing value by root-finding — there is no library of pre-programmed physics or finance formulas here, just a parser and a numerical solver that work on whatever algebra you type in.
How to solve a formula for any variable
- Type the formula with a single equals sign, such as P * V = n * R * T, or click one of the example chips: Ohm's law, ideal gas law, Newton's gravitation or kinetic energy.
- A labelled field appears for every variable the parser finds. Fill in a number for each one except the unknown.
- Leave exactly one field empty. As soon as the rest are valid numbers the solver runs, shows the answer in the results panel and marks that field as solved.
- Sanity-check the value against what you expect, especially for formulas with more than one root, then use Clear all values to start the next problem.
How an arbitrary formula gets solved
mathjs, the parsing library behind this tool, has no built-in equation solver — it can evaluate an expression but not solve one for an unknown. So the formula is rewritten internally as f(x) = lhs(x) - rhs(x), and the blank variable's value is whatever makes that difference zero, found with Newton-Raphson iteration starting from a short list of default guesses (1, -1, 0.5, -0.5, 10, -10, 100 and 0.01) until one of them converges.
Each Newton-Raphson step needs the derivative of f with respect to the unknown. Where mathjs can differentiate the expression symbolically, the solver uses that exact derivative; where it can't — an expression mathjs's differentiation rules don't cover — it falls back to a central-difference numerical estimate of the same derivative instead, so the solver keeps working even on expressions symbolic differentiation chokes on.
Formulas to try in the solve-for-variable calculator
- F = m*a: with F = 10 and a = 2, leave m blank to get 5.
- V = I*R: any one of the three can be the unknown, which covers the usual Ohm's-law triangle.
- P*V = n*R*T: the gas constant is not built in, so type R = 8.314 along with the other known values.
- E = 0.5*m*v^2: with E = 100 and m = 2, solving for v returns 10 — the positive root, because the first starting guess is positive.
- A = P*(1+r)^n: with A = 2000, P = 1000 and r = 0.05, solving for n gives about 14.21 compounding periods to double.
- x = cos(x): no algebraic rearrangement isolates x here, yet the solver converges on 0.7390851332 in a few iterations.
Parsing and variable rules
A formula has to contain exactly one equals sign; unbalanced parentheses, a missing or duplicated '=', or an operator mathjs doesn't recognize all produce a specific parse error rather than a silent wrong answer. Once parsed, every symbol referenced in the expression is collected as a candidate variable — except function names like sqrt used inside the formula, and a short list of reserved names (constants mathjs resolves on its own, like pi and e) that can never be treated as a solvable unknown.
Before solving, exactly one of the collected variables has to be left blank in the input fields — leaving two blank means the system is underdetermined, and leaving none blank means there's nothing to solve for, so both cases are rejected with an explanation instead of guessed at.
Formula notation the solver understands
- Operators + − * / and ^, with parentheses for grouping, and exactly one = sign per formula.
- mathjs functions such as sqrt, abs, exp, log (natural logarithm), sin, cos and tan; trigonometric functions work in radians.
- Variable names made of letters and digits, like m1, m2 or rho, each becoming its own input field.
- Reserved names that are never offered as unknowns because mathjs already gives them a value: pi, e, phi, tau, Infinity and NaN among them.
- Known values can be decimals or scientific notation, so the gravitational constant goes in as 6.674e-11.
When Newton-Raphson doesn't converge
- A formula with no real root for the values you entered — for example asking it to solve x^2 + 1 = 0 for a real x — will exhaust its guesses and report failure rather than returning a complex or nonsensical number.
- Multiple valid roots exist for plenty of formulas (a quadratic has two), and Newton-Raphson only ever finds the one closest to whichever starting guess converges first — if you need a specific root, checking the returned value against your own expectation matters more here than with a single-answer linear formula.
- A formula with a derivative that's zero or nearly zero right at one of the default starting guesses can fail to converge from that guess even though a solution exists nearby; the fallback list of eight guesses exists specifically to route around that, but it isn't exhaustive.
Questions people ask about Universal Multi-Variable Formula Solver
- Can I solve for any variable in a formula, or does it have to be isolated first?
- Any variable, in any position. Because the solver works by finding a root of lhs minus rhs rather than by algebraically rearranging the formula, you never need to isolate the unknown yourself — leave whichever variable you want solved blank and fill in numeric values for the rest.
- What happens if my formula genuinely has no solution for the numbers I entered?
- Newton-Raphson runs from each of its eight default starting guesses in turn, and if none of them converges to a real root, the solver reports that no solution was found rather than returning a made-up or complex value. That's the expected result for something like solving x^2 = -4 for a real x.
- Why did solving a formula with two possible answers only give me one?
- Newton-Raphson is a local method: it converges toward whichever root is nearest the starting guess that first works, not every root the equation has. A quadratic or similar formula with two valid solutions will only return the one its guess sequence happened to land near first, so it's worth sanity-checking the result against the problem you're actually solving.
- Are constants like pi and e reserved, or can I use them as variable names?
- They're reserved. Names that mathjs resolves automatically to a built-in value — pi and e among them — are excluded from the list of solvable variables specifically so the solver never mistakes a constant for something you meant to leave blank and solve for.
- Does it show the rearranged formula or algebra steps?
- No. The unknown is found numerically with Newton-Raphson, so the output is a single number shown to ten significant digits, not a rearranged equation. If you need the symbolic form, such as v = sqrt(2E/m), you still have to do that algebra by hand or with a computer algebra system.
- What notation does the solver accept?
- Ordinary calculator syntax parsed by mathjs: + − * / ^, parentheses, one equals sign and functions such as sqrt, sin or log. Variables can have several letters or trailing digits, while built-in constants like pi and e keep their fixed values.
Related tools on BrakeTools
- Interactive 2D/3D Graphing Calculator — Graph Cartesian, polar, parametric, and implicit curves with live sliders, roots, and tangents.
- Matrix & Linear Algebra Solver — Matrix multiply, invert, and solve linear systems with visible Gaussian-elimination pivot steps.
- Step-by-Step Symbolic Calculus Solver — See full step-by-step derivatives, integrals, and limits rendered in proper math notation.
- Universal Unit & Dimensional Converter — Convert between 160 units across 31 physical dimensions, with dimension-mismatched conversions made impossible.
Content reviewed 2026-09-27.