# Optimising the NSolve

Suppose I have the following list of rational functions,

\[Xi]={(354.071 x + 1139.01 x^2 + 2301.83 x^3 + 3772.24 x^4 + 5368.18 x^5 +
6304.07 x^6 + 6705.82 x^7 + 6518.86 x^8 + 5439.16 x^9 +
4613.47 x^10 + 3459.79 x^11 + 2657.09 x^12 + 2099.23 x^13 +
1523.07 x^14 + 1077.78 x^15 + 754.676 x^16 + 480.121 x^17 +
262.326 x^18 + 206.457 x^19 + 109.126 x^20 + 55.8401 x^21 +
28.3189 x^22 + 28.2448 x^23 + 19.7196 x^24 + 5.61942 x^25 +
3.73647 x^26 + 0.931673 x^27 + 1.85847 x^28 + 2.7804 x^29 +
0.924375 x^30 + 1.84391 x^31)/(354 x + 1143 x^2 + 2320 x^3 +
3811 x^4 + 5441 x^5 + 6403 x^6 + 6829 x^7 + 6658 x^8 + 5571 x^9 +
4737 x^10 + 3560 x^11 + 2741 x^12 + 2174 x^13 + 1579 x^14 +
1120 x^15 + 789 x^16 + 502 x^17 + 275 x^18 + 215 x^19 +
117 x^20 + 59 x^21 + 30 x^22 + 30 x^23 + 21 x^24 + 6 x^25 +
4 x^26 + x^27 + 2 x^28 + 3 x^29 + x^30 + 2 x^31), (353.073 x +
1154.93 x^2 + 2345.48 x^3 + 3829.64 x^4 + 5408.65 x^5 +
6341.48 x^6 + 6682.26 x^7 + 6513.96 x^8 + 5379.58 x^9 +
4580.35 x^10 + 3446.19 x^11 + 2646.43 x^12 + 2083.77 x^13 +
1510.54 x^14 + 1077.78 x^15 + 742.21 x^16 + 483.947 x^17 +
258.511 x^18 + 200.749 x^19 + 111.973 x^20 + 55.8401 x^21 +
27.375 x^22 + 27.3033 x^23 + 19.7196 x^24 + 5.61942 x^25 +
3.73647 x^26 + 0.931673 x^27 + 1.85847 x^28 + 2.7804 x^29 +
0.924375 x^30 + 1.84391 x^31)/(354 x + 1143 x^2 + 2320 x^3 +
3811 x^4 + 5441 x^5 + 6403 x^6 + 6829 x^7 + 6658 x^8 + 5571 x^9 +
4737 x^10 + 3560 x^11 + 2741 x^12 + 2174 x^13 + 1579 x^14 +
1120 x^15 + 789 x^16 + 502 x^17 + 275 x^18 + 215 x^19 +
117 x^20 + 59 x^21 + 30 x^22 + 30 x^23 + 21 x^24 + 6 x^25 +
4 x^26 + x^27 + 2 x^28 + 3 x^29 + x^30 + 2 x^31)}


Note in reality my list is much larger. I want to solve these between 0 and 1 and so,

val = NSolve[# == 1 && 0 < x < 1] & /@ \[Xi] // Values;


this command on a large list takes a lot of time, I wonder if there is a faster way of doing this operation?

• You may simplify your expression first: val = NSolve[# == 1 && 0 < x < 1, x] & /@ (FullSimplify@\[Xi]) I get a performance boost from 86 secs to 0.25 secs. – gwr Jan 31 at 12:49
• Clearing denominators could help. – Daniel Lichtblau Jan 31 at 14:50
• @gwr I copied your expression exactly as in the comment by mine went down from 82 secs to 50secs, not 0.25 secs, am I missing something? – William Jan 31 at 15:38
• With RepeatedTiming[ val = NSolve[# == 1 && 0 < x < 1, x] & /@ (Simplify@\[Xi]);] I get {0.13, Null} and with FullSimplify (as above) it will give {0.257, Null} for me. – gwr Jan 31 at 15:46
• Maybe I have a faster Computer? If I do the WolframMark Benchmark I will get 1.72 (Help>System Information). What do you get? – gwr Jan 31 at 15:52