Solve vs NSolve: Exact or Numeric in Wolfram Language
Choose between Solve and NSolve in Wolfram Language based on whether your engineering model needs exact structure or a numeric root, then verify by substitution.
23 Jan 2026, 08:43 UTC

You are sizing a pressure-relief valve and need the downstream pressure p for a given flow rate Q. The valve model is a cubic equation:
Q == k (p - p0) - c (p - p0)^3
You type Solve into a Wolfram Language notebook and either wait for a symbolic expression that fills the screen, or get an unevaluated result. Switching to NSolve gives a number immediately, but you cannot tell whether it found every physically meaningful root. The choice between exact and numeric solving is not about which function is superior. It is about whether your current design task needs structure or a value.
Takeaway: use Solve when the system is small, polynomial, and you need exact relationships you can inspect or reuse. Use NSolve when you need numeric roots quickly and can verify them by substitution. Always check the result by plugging it back into the original equation. Assumes Wolfram Language 13 or later.
1. What Solve returns
Solve attempts exact symbolic manipulation. For the valve equation above, calling it with symbolic parameters returns a list of replacement rules:
Solve[Q == k (p - p0) - c (p - p0)^3, p]
Each rule maps p to an exact expression in Q, k, c, and p0. Because the equation is cubic, the expressions may involve radicals or Root objects. That exactness is useful when you want to differentiate the result, substitute it into another equation, or see how pressure scales with flow rate without rounding error.
Run this in a Wolfram Notebook or save it as a .wl script and run it with wolframscript. No special permissions are required. The risk is expression swell: on higher-degree or coupled systems, Solve can consume minutes of CPU and return output too large to inspect.
2. When NSolve is the engineering choice
NSolve finds numerical approximations. For a design review where you need a pressure value to three significant figures, it is usually the right tool:
eq = Q == k (p - p0) - c (p - p0)^3;
params = {k -> 0.02, c -> 0.0005, p0 -> 100000, Q -> 0.03};
NSolve[eq /. params, p, Reals]
The Reals domain restriction discards complex roots that have no physical meaning here. NSolve returns rules mapping p to approximate real numbers. It is fast and predictable, but it is approximate: it may miss roots in ill-conditioned systems, and it does not show you the underlying relationship between variables.
3. Worked example: solve and verify
Here is a complete, checkable sequence. Do not treat the numbers below as a measured result; they illustrate the command shape.
(* Define the model *)
valveEq = Q == k (p - p0) - c (p - p0)^3;
(* Insert design parameters *)
designParams = {k -> 0.02, c -> 0.0005, p0 -> 100000, Q -> 0.03};
(* Numeric solution, real roots only *)
roots = NSolve[valveEq /. designParams, p, Reals];
(* Verify each root by substitution *)
verification = valveEq /. designParams /. roots
After running verification, expect a list of Boolean values such as {True} or values extremely close to True. Use Chop[verification] to remove residuals smaller than the numerical noise floor. If any entry is not True after chopping, the root is suspect or the equation is ill-conditioned.
For exact work, replace NSolve with Solve and inspect Length[sol] to count candidate solutions before substituting.
4. Limitations and how to check
Solvemay return unevaluated for transcendental equations or very high-degree polynomials.NSolveuses machine precision by default. AddWorkingPrecision -> 30if downstream calculations are sensitive to rounding.- Neither function solves differential equations; use
DSolveorNDSolvefor those.
Practical check: after obtaining roots, evaluate Max[Abs[valveEq /. designParams /. roots]]. A result near zero confirms the numeric solution satisfies the model within precision. For symbolic results, apply Simplify to the substituted expression and confirm it reduces to True.
Decision
Pick Solve when you need the shape of the answer. Pick NSolve when you need the number for a bill of materials or a controller setpoint. In either case, substitution back into the original equation is the only verification that matters.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.