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?
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?
You may want to search for Newton-Raphson's method which is known to quickly converge to solution with just a few iterations.
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
You could try typing this into Wolfram Alpha.
Solve[3x^5+4 x^3+5x^2==148,x]