Remember that when you write something like ar
with no space between, it is treated as a variable named ar
instead of a*r
. So let's add a space there:
func[a_,n_]:=M(r^6-n^6+15n^4r^2-15n^2r^4)-2M^2r(3r^4-
2n^2r^2+3n^4)-16n^4r^3+8a r^(3/2)(M(r^2-n^2)+2n^2r)^(3/2)+
a^2(M(n^4+6n^2r^2-3r^4)-8n^2r^3).
Also, it's generally a bad idea to use capital letters for variable names; many (Like N
, C
, etc.) are reserved for special purposes in mma. I would recommend using a different name for M
.
Let's define the equation you want to solve, and let's use exact numbers like 12/10 instead of 1.2:
forSolve = func[12 M/10, 1 M]
(*-16 M^4 r^3 - 2 M^2 r (3 M^4 - 2 M^2 r^2 + 3 r^4) +
M (-M^6 + 15 M^4 r^2 - 15 M^2 r^4 + r^6) +
48/5 M r^(3/2) (2 M^2 r + M (-M^2 + r^2))^(3/2) +
36/25 M^2 (-8 M^2 r^3 + M (M^4 + 6 M^2 r^2 - 3 r^4)) *)
Note that there is a symbolic parameter M
in forSolve
, so we should not use NSolve
which is a numerical method, and instead use Solve
:
solns = Solve[forSolve==0, r];
This generates a set of Root
objects that cannot be reduced ToRadicals
. We can however get numerical approximations of the roots:
solns // N
(*{{r -> 3.61787 M}, {r -> 11.4344 M}, {r -> (-2.07662 - 1.24017 I) M},...{}}*)
There is also the warning message generated by Solve
:
Solve::nongen: There may be values of the parameters for which some or all solutions are not valid.
Indeed, as the warning message hints at, some of the roots are not close to 0 when we plug them into the function with M=1
for example:
atRoot = forSolve /. solns;
N[atRoot /. M -> 1] // Chop
(*{0, 1.39961*10^6, 0, 0, 0, 0, 0.215596 + 0.262061 I,
0.215596 - 0.262061 I, -0.213027 + 0.18311 I, -0.213027 -
0.18311 I, 0, 0}}*)
So when using Solve
on this specific function, it's important to validate the roots by plugging them into the function.
Restricting Solve
to only look for roots in the Reals
yields one (hopefully valid) root (with the condition that M>0). I test it here for some values between M=0.1 and 2 and the values all appear to be generally close to 0:
realSolns = Solve[forSolve == 0, r, Reals];
atRealRoot = forSolve /. realSolns;
N[Table[atRealRoot /. M -> i, {i, 1/10, 2, 1/10}], 16] // Chop
(* {{0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, {0}, \
{0}, {0}, {0}, {0}, {0}, {0}, {0}}*)
Looking at this real root with high precision, we see it probably is a good candidate root for all values of M>0
:
N[Simplify[forSolve /. (realSolns // ToRadicals), M > 0], 128]
(*{0.*10^-174 M^7}*)
NSolve
solves numeric systems. This is one equation in two variables, hence has a (non-numeric) parameter. Not somethingNSolve
can handle. $\endgroup$