# NSolve Having No Output

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]
• 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?
– Kray
Commented Mar 30, 2022 at 2:26
• 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
– bmf
Commented Mar 30, 2022 at 2:27
• 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.
– bmf
Commented Mar 30, 2022 at 2:32

Clear["Global*"]

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.9638893030565493112026426288561101269820.301029995663882}]}} *)

This is approximately

sol // First // N

(* {x -> 20.9639} *)