title: Finding upper or lower limits given one of the limits and the solution (area under the curve) on a discrete point "curve"
body: <p>I have an x vs y data. I made the non-linear estimation of that data and the resulting function looks like the below:
  <a href="https://i.stack.imgur.com/k9svX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k9svX.png" alt="enter image description here" /></a>
  and the estimated function is: 25342<em>^9 −155900^8+409218^7 − 599317^6 + 537190^5 − 303116</em>^4 + ... + 274</p>
  <p>I used <a href="https://stackoverflow.com/a/61324165/15428146">this answer's</a> suggestion to find the upper limit of my integral by using the below code:</p>
  <pre class="lang-py prettyprint-override"><code>p_optimal = estimate_function_from_data_points()
  </code></pre>
  <pre class="lang-py prettyprint-override"><code>from sympy import integrate, solve
  from sympy.abc import x, u
  f = 25342.695344882944*x**9 - 155900.56387247072*x**8 + 409218.9290579793*x**7 - 599317.5264117827*x**6 + 537190.6784517929*x**5 - 303116.0648042093*x**4 + 105493.81468203208*x**3 - 20422.11374996729*x**2 + 1263.9293528900394*x + 274.55521542679185
  lower = 0.0925 # Initial
  upper = u
  eq = integrate(f, (x, lower, upper))
  eq, solve(eq + 100, u)
  
  Out: [-0.114399781774514 - 0.112912224139529*I,
   -0.114399781774514 + 0.112912224139529*I,
   0.145632609024802 - 0.532284754794354*I,
   0.145632609024802 + 0.532284754794354*I,
   0.646926125977188 - 0.679233975801008*I,
   0.646926125977188 + 0.679233975801008*I,
   1.20499184950745 - 0.534200757552949*I,
   1.20499184950745 + 0.534200757552949*I,
   1.53445822404458 - 0.201823934360761*I,
   1.53445822404458 + 0.201823934360761*I]
  </code></pre>
  <p>I get 9 results (as expected because it's 9th order function) and all of them are complex numbers because I don't have a nice function as given on the answer. What methods can I use to get a real number solution?</p>
  <p>Edit: When I run the below code, I get 100 as a result of the integral. So, the upper limit should be around 0.945</p>
  <pre class="lang-py prettyprint-override"><code>lower = 0.0925 # Initial 
  upper = 0.945
  integrate(f, (x, lower, upper)).evalf()
  
  Out: 100.016292426307
  </code></pre>