0

All I know is that a single integer will surely accept it.

The equation is like : Ax^5 + Bx^3 + Cx^2 = D

I tried to brute force value of x , but was getting TLE , can I use an optimised binary search as I know only one root will be real?

  • 1
    You have to know much more about A, B, C, and D in order to say "one root will be real". What is "TLE"? It seems like you're getting this problem from somewhere, but are leaving out a lot of details. – Teepeemm Sep 26 '14 at 00:34
  • @Teepeemm I am guessing TLE stands for Time Limit Expired. – Keugyeol Sep 26 '14 at 04:55

3 Answers3

1

You may want to search for Newton-Raphson's method which is known to quickly converge to solution with just a few iterations.

Keugyeol
  • 2,355
  • 1
  • 28
  • 36
1

You're just asking to find the zeros of a function when you've been guaranteed that there's no more than one zero. To put it concretely, let's assume you have the following equation:

-15x^5 + 12x^3 - 203x^2 = -2.193113e+12

You could use the root-finding function from your favorite statistical software package to find the root. For instance, here's how you would do it with uniroot in R:

uniroot(function(x) -15*x^5 + 12*x^3 - 203*x^2 + 2.193113e+12, c(-1000, 1000))$root
# [1] 171
josliber
  • 43,891
  • 12
  • 98
  • 133
1

You could try typing this into Wolfram Alpha.

Solve[3x^5+4 x^3+5x^2==148,x]

enter image description here

Chris Degnen
  • 8,443
  • 2
  • 23
  • 40