# NSolve does not calculate, just copies the input [duplicate]

I have encountered a strange problem, which is, the NSolve does not calcualte, but only reproduce what I have typed. Seems there is no typo in the code I input either. I have attached the code below:

 f1 = 0.73773921127552020799.089193376796182 Cos[Subscript[af,
2]] Sin[Subscript[af,
1]] + (-0.63443157009847254949.011997365861196 Cos[Subscript[
af, 1]] -
0.52182717849720727388.772545864993926 Sin[Subscript[af,
1]]) Sin[Subscript[af, 2]] == -(1/2);
f2 = 0.77297903132128164579.097780292912853 Cos[Subscript[af,
3]] Sin[Subscript[af,
2]] + (-0.60251543635991450828.971889083011506 Cos[Subscript[
af, 2]] -
0.50634442238788298058.750028023288934 Sin[Subscript[af,
2]]) Sin[Subscript[af, 3]] == -(1/2);
f3 = 1/2 + (0.79810722897867665549.0939821495743 Cos[Subscript[af,
1]] - 0.44449926280148921968.725562683371656 Sin[Subscript[
af, 1]]) Sin[Subscript[af, 3]] ==
0.67508581391299680999.050649491643144 Cos[Subscript[af, 3]] Sin[
Subscript[af, 1]];
eqs = {f1, f2, f3}
NSolve[eqs, {Subscript[af, 1], Subscript[af, 2], Subscript[af,
3]}, Reals]


the results are shown in Fig. . I have tried a different set of equations with those variables with subscript, so seems this is not the source of the problem. Could someone help me with this? Thanks a lot!

• FindRoot[eqs, {{Subscript[af, 1], 0}, {Subscript[af, 2], 0}, {Subscript[af, 3], 0}}] yields a solution – george2079 Feb 8 '17 at 21:44
• Maybe related to WorkingPrecision (see mathematica.stackexchange.com/questions/137240/…). Also, in general I would highly recommend to avoid subscript and superscript variables. It might look nice, but they are not atomic and often don't behave the way you would expect them to. – Felix Feb 8 '17 at 22:17
• NSolve definitely doesn't like the subscripts here. Switching to atomic symbols it no longer returns immediately, but is now taking a long time. I don't have high expectations that it will work on such transcendental equations. – george2079 Feb 8 '17 at 22:49
• @george2079 But I have tried a simpler set of equations with variables involving subscripts, which it solves, so I thought it is not the problem of them, but I have to think about it again now. The set of solution should yield at least 4 real solutions, which I have verified using another formulation. So is there anyway to find all the real solutions, even if not using the NSolve command? Thanks. – larry Feb 8 '17 at 23:06
• @Felix The reason I use subscript is that I had to use N[] to do the estimate in some previous steps, which somehow changes af etc. to af[1.0000..], which makes it difficult to delete duplicate solutions. However, if this does affect, I will change them all, though I have a large piece of code, which is gonna be a headache.. – larry Feb 8 '17 at 23:08

f1 = 0.73773921127552020799.089193376796182 Cos[af] Sin[
af] + (-0.63443157009847254949.011997365861196 Cos[af] -
0.52182717849720727388.772545864993926 Sin[af]) Sin[
af] == -(1/2);
f2 = 0.77297903132128164579.097780292912853 Cos[af] Sin[
af] + (-0.60251543635991450828.971889083011506 Cos[af] -
0.50634442238788298058.750028023288934 Sin[af]) Sin[
af] == -(1/2);
f3 = 1/2 + (0.79810722897867665549.0939821495743 Cos[af] -
0.44449926280148921968.725562683371656 Sin[af]) Sin[
af] ==
0.67508581391299680999.050649491643144 Cos[af] Sin[af];
eqs = {f1, f2, f3};

start = Range[0, 2 Pi, Pi/3];

sol = ({af, af, af} /.
Select[Outer[FindRoot[eqs,
{{af, #1, 0, 2 Pi},
{af, #2, 0, 2 Pi},
{af, #3, 0, 2 Pi}}] &,
start, start, start] // Flatten[#, 2] &,
And @@ (eqs /. #) &]) //
Round[#, 10.^-5] & // Union //
Quiet

(*  {{0.61065, 3.04504, 5.03029}, {1.52516, 3.49629, 5.94345}, {1.7364,
1.69935, 1.67172}, {2.94679, 4.8352, 0.45597}, {3.75224, 6.18663,
1.8887}, {4.66676, 0.3547, 2.80186}, {4.87799, 4.84094,
4.81331}, {6.08838, 1.69361, 3.59756}}  *)


I'd go about it the same was as is shown here. Also I change naming to avoid subscripts. The idea is to turn into explicit polynomials in the trigs, add appropriate algebraic relations linking cosines to sines, and solve.

Set up:

f1 = 0.73773921127552020799.089193376796182 Cos[af] Sin[
af] + (-0.63443157009847254949.011997365861196 Cos[af] -
0.52182717849720727388.772545864993926 Sin[af]) Sin[
af] == -(1/2);
f2 = 0.77297903132128164579.097780292912853 Cos[af] Sin[
af] + (-0.60251543635991450828.971889083011506 Cos[af] -
0.50634442238788298058.750028023288934 Sin[af]) Sin[
af] == -(1/2);
f3 = 1/2 + (0.79810722897867665549.0939821495743 Cos[af] -
0.44449926280148921968.725562683371656 Sin[af]) Sin[
af] ==
0.67508581391299680999.050649491643144 Cos[af] Sin[af];
eqs = {f1, f2, f3};
exprs = Apply[Subtract, eqs, {1}];
subs = {Cos[a_] :> c[a], Sin[a_] :> s[a]};
tpolys = exprs /. subs;
cosvars = Cases[Variables[tpolys], c[_]];
defpolys = Map[#^2 + s[#[]]^2 - 1 &, cosvars];
allpolys = Join[tpolys, defpolys]


Solve:

AbsoluteTiming[
solns = NSolve[allpolys, Method -> "EndomorphismMatrix"];]
realsols = Select[solns, FreeQ[#, Complex] &]
(* Out= {0.166695, Null}

Out= {{c[af] -> -0.81927821, c[af] -> 0.99534234,
c[af] -> -0.31257383, s[af] -> -0.57339621,
s[af] -> -0.096403411,
s[af] -> 0.94989347}, {c[af] -> -0.81927821,
c[af] -> 0.99534234, c[af] -> -0.31257383,
s[af] -> -0.57339621, s[af] -> -0.096403411,
s[af] -> 0.94989347}, {c[af] -> 0.81927821,
c[af] -> -0.99534234, c[af] -> 0.31257383,
s[af] -> 0.57339621, s[af] -> 0.096403411,
s[af] -> -0.94989347}, {c[af] -> 0.81927821,
c[af] -> -0.99534234, c[af] -> 0.31257383,
s[af] -> 0.57339621, s[af] -> 0.096403411,
s[af] -> -0.94989347}, {c[af] -> 0.98108617,
c[af] -> -0.12250217, c[af] -> -0.89783451,
s[af] -> -0.19357149, s[af] -> 0.99246825,
s[af] -> -0.44033304}, {c[af] -> 0.98108617,
c[af] -> -0.12250217, c[af] -> -0.89783451,
s[af] -> -0.19357149, s[af] -> 0.99246825,
s[af] -> -0.44033304}, {c[af] -> -0.98108617,
c[af] -> 0.12250217, c[af] -> 0.89783451,
s[af] -> 0.19357149, s[af] -> -0.99246825,
s[af] -> 0.44033304}, {c[af] -> -0.98108617,
c[af] -> 0.12250217, c[af] -> 0.89783451,
s[af] -> 0.19357149, s[af] -> -0.99246825,
s[af] -> 0.44033304}, {c[af] -> -0.16484943,
c[af] -> -0.12819639, c[af] -> -0.10075124,
s[af] -> 0.98631874, s[af] -> 0.99174880,
s[af] -> 0.99491165}, {c[af] -> -0.16484943,
c[af] -> -0.12819639, c[af] -> -0.10075124,
s[af] -> 0.98631874, s[af] -> 0.99174880,
s[af] -> 0.99491165}, {c[af] -> 0.16484943,
c[af] -> 0.12819639, c[af] -> 0.10075124,
s[af] -> -0.98631874, s[af] -> -0.99174880,
s[af] -> -0.99491165}, {c[af] -> 0.16484943,
c[af] -> 0.12819639, c[af] -> 0.10075124,
s[af] -> -0.98631874, s[af] -> -0.99174880,
s[af] -> -0.99491165}} *)
`

Now can use multiple-valued inverses, that is, arctrigs plus suitable integer multiples of Pi, to recover results in the original variables.