I am trying to solve a series of equations using the NSolve function, but am receiving no output. I tried to make the equations into a single equation, but this also doesn't work. I was hoping for critique on my formatting to see what I did wrong. Here is what I put (simplified, since the equations are much longer than this), the goal is to solve for x:

NSolve[{1 == 1/n*(g/(3*pi)^(1/2))*exp(-g/3), g == (16*pi*200)/(x^2), n == (4/3)*pi*r^3, 
r == 2/x}, x]
  • $\begingroup$ Thank you for this, this helps a lot. Is it possible to pre-define non-numerical parameters like g and n as variables prior to the calculation and have them be used within the parameters of NSolve or would it just be better to have an extensive equation with NSolve, even if they are a function of x themselves? $\endgroup$
    – Kray
    Commented Mar 30, 2022 at 2:26
  • $\begingroup$ In Mma this is the proper way to write Pi and Exp, i.e they should be capitalized. To answer to the comment, you can write for instance r := 2/x before the call of NSolve. See the docs for SetDelayed $\endgroup$
    – bmf
    Commented Mar 30, 2022 at 2:27
  • 1
    $\begingroup$ So, the code should look something like that: r := 2/x g := (16*Pi*200)/(x^2) n := (4/3)*Pi*r^3; and then you can call NSolve in the following manner: NSolve[1 == 1/n*(g/(3*Pi)^(1/2))*Exp[-g/3], x] to give you an answer and a complaint. $\endgroup$
    – bmf
    Commented Mar 30, 2022 at 2:32

1 Answer 1


Let x be positive, then the exact solution is a Root expression

(sol = Solve[{1 == 1/n*(g/(3*Pi)^(1/2))*E^(-g/3), 
  g == (16*Pi*200)/(x^2), n == (4/3)*Pi*r^3, 
    r == 2/x, x > 0}, x, {g, n, r}])

(* {{x -> Root[{-Sqrt[3*Pi] + (300*#1)/E^((3200*Pi)/(3*#1^2)) & , 
    20.96388930305654931120264262885611012698`20.301029995663882}]}} *)

This is approximately

sol // First // N

(* {x -> 20.9639} *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.