Using NSolveValues on certain equations returns lists of solutions of the following kind:
For each of these rules I want to select only one value, namely the one absolutely closest to $2\pi/10$, but without selecting this manually. How would I find this?
Edit:
I have many of these equations which depend on a lot of different parameters, so I won't put all of that here. But the point is that I want to solve a large number of equations iteratively, where each equation depends on the solution of the previous one. However each equation results in a list ofinfinite solutions as above, but I only want to use the solution that is absolutely nearest to $2\pi/10$.
f[x_]:=ArcCos[0.5 (-0.00756467 +
0.749491 (0.287778 Cos[45. x] - 0.876915 Sin[45. x]) +
0.503279 (0.457042 Cos[45. x] - 0.227498 Sin[45. x]) +
0.538571 (0.876915 Cos[45. x] + 0.287778 Sin[45. x]) +
0.430085 (0.841604 Cos[45. x] + 0.423397 Sin[45. x]) -
0.0857465 (0.227498 Cos[45. x] + 0.457042 Sin[45. x]) -
0.838206 (-0.423397 Cos[45. x] +
0.841604 Sin[45. x]))] ((0.566265 (0. +
0.503279 (0.287778 Cos[45. x] - 0.876915 Sin[45. x]) -
0.749491 (0.457042 Cos[45. x] - 0.227498 Sin[45. x]) -
0.0857465 (0.876915 Cos[45. x] + 0.287778 Sin[45. x]) -
0.538571 (0.227498 Cos[45. x] +
0.457042 Sin[45. x])))/(\[Sqrt](Abs[
0. + 0.503279 (0.287778 Cos[45. x] - 0.876915 Sin[45. x]) -
0.749491 (0.457042 Cos[45. x] - 0.227498 Sin[45. x]) -
0.0857465 (0.876915 Cos[45. x] + 0.287778 Sin[45. x]) -
0.538571 (0.227498 Cos[45. x] + 0.457042 Sin[45. x])]^2 +
Abs[0.112051 +
0.430085 (0.457042 Cos[45. x] - 0.227498 Sin[45. x]) -
0.503279 (0.841604 Cos[45. x] + 0.423397 Sin[45. x]) -
0.838206 (0.227498 Cos[45. x] + 0.457042 Sin[45. x]) +
0.0857465 (-0.423397 Cos[45. x] + 0.841604 Sin[45. x])]^2 +
Abs[0.050167 -
0.430085 (0.287778 Cos[45. x] - 0.876915 Sin[45. x]) +
0.838206 (0.876915 Cos[45. x] + 0.287778 Sin[45. x]) +
0.749491 (0.841604 Cos[45. x] + 0.423397 Sin[45. x]) +
0.538571 (-0.423397 Cos[45. x] +
0.841604 Sin[45. x])]^2)) + (0.336803 (0.112051 +
0.430085 (0.457042 Cos[45. x] - 0.227498 Sin[45. x]) -
0.503279 (0.841604 Cos[45. x] + 0.423397 Sin[45. x]) -
0.838206 (0.227498 Cos[45. x] + 0.457042 Sin[45. x]) +
0.0857465 (-0.423397 Cos[45. x] +
0.841604 Sin[45. x])))/(\[Sqrt](Abs[
0. + 0.503279 (0.287778 Cos[45. x] - 0.876915 Sin[45. x]) -
0.749491 (0.457042 Cos[45. x] - 0.227498 Sin[45. x]) -
0.0857465 (0.876915 Cos[45. x] + 0.287778 Sin[45. x]) -
0.538571 (0.227498 Cos[45. x] + 0.457042 Sin[45. x])]^2 +
Abs[
0.112051 +
0.430085 (0.457042 Cos[45. x] - 0.227498 Sin[45. x]) -
0.503279 (0.841604 Cos[45. x] + 0.423397 Sin[45. x]) -
0.838206 (0.227498 Cos[45. x] + 0.457042 Sin[45. x]) +
0.0857465 (-0.423397 Cos[45. x] + 0.841604 Sin[45. x])]^2 +
Abs[0.050167 -
0.430085 (0.287778 Cos[45. x] - 0.876915 Sin[45. x]) +
0.838206 (0.876915 Cos[45. x] + 0.287778 Sin[45. x]) +
0.749491 (0.841604 Cos[45. x] + 0.423397 Sin[45. x]) +
0.538571 (-0.423397 Cos[45. x] +
0.841604 Sin[45. x])]^2)) - (0.752268 (0.050167 -
0.430085 (0.287778 Cos[45. x] - 0.876915 Sin[45. x]) +
0.838206 (0.876915 Cos[45. x] + 0.287778 Sin[45. x]) +
0.749491 (0.841604 Cos[45. x] + 0.423397 Sin[45. x]) +
0.538571 (-0.423397 Cos[45. x] +
0.841604 Sin[45. x])))/(\[Sqrt](Abs[
0. + 0.503279 (0.287778 Cos[45. x] - 0.876915 Sin[45. x]) -
0.749491 (0.457042 Cos[45. x] - 0.227498 Sin[45. x]) -
0.0857465 (0.876915 Cos[45. x] + 0.287778 Sin[45. x]) -
0.538571 (0.227498 Cos[45. x] + 0.457042 Sin[45. x])]^2 +
Abs[0.112051 +
0.430085 (0.457042 Cos[45. x] - 0.227498 Sin[45. x]) -
0.503279 (0.841604 Cos[45. x] + 0.423397 Sin[45. x]) -
0.838206 (0.227498 Cos[45. x] + 0.457042 Sin[45. x]) +
0.0857465 (-0.423397 Cos[45. x] + 0.841604 Sin[45. x])]^2 +
Abs[0.050167 -
0.430085 (0.287778 Cos[45. x] - 0.876915 Sin[45. x]) +
0.838206 (0.876915 Cos[45. x] + 0.287778 Sin[45. x]) +
0.749491 (0.841604 Cos[45. x] + 0.423397 Sin[45. x]) +
0.538571 (-0.423397 Cos[45. x] + 0.841604 Sin[45. x])]^2)))
NSolveValues[f[x] == 2 \[Pi]/10, x, Reals]
NearestTo
, but that doesn't work for the kind of object that I have fromNSolveValues
. $\endgroup$45. x
? $\endgroup$NSolveValues[{f[x] == 2 \[Pi]/10, (x - 2 Pi/10)^2 < .005}, x]
$\endgroup$