# Solving single-variable fractional equation

Can anyone advise how this nonlinear equation with a single variable $$x$$ can be solved as a closed form? $${\left(\frac{x}{1-x}\right)}^2.{\left(\frac{x-C}{\left(1-x\right)-N}\right)}^2=H.\frac{2x-C}{2\left(1-x\right)-N}$$ where $$C$$, $$N$$ and $$H$$ are real and positive values. I only know that $$0.

Please also guide me on what the best way to solve it computationally is.

I cannot speak to a closed form solution, but I can address the possibility of a numeric approach. To solve the equation, we will look for a root in $$(0, 1)$$ of the function $$f(x) = {\left(\frac{x}{1-x}\right)}^2 \cdot {\left(\frac{x-C}{\left(1-x\right)-N}\right)}^2 - H\cdot \frac{2x-C}{2\left(1-x\right)-N}.$$

First note that $$f(x)\rightarrow \infty$$ as $$x\rightarrow 1,$$ so you will need to bound the upper limit of the search interval for $$x$$ strictly below 1. Second, there may be more than one root of $$f$$ in the unit interval.

I did some quick numerical experiments, and it appears that $$f$$ can a bit volatile (very steep in places), making numeric methods a bit tricky. You could, for instance, try Newton's method, starting from some value inside the unit interval (maybe 0.5, maybe a different value), either using an explicit formula for the derivative $$f^\prime(x)$$ ($$f$$ is not too hard to differentiate) or using numerical approximations for the derivative. If Newton's method fails to converge to a root, you can retry with a different starting point. Depending on what your preferred programming language is, you may be able to find third party libraries that support Newton (also known as Newton-Raphson) or other root finding methods.

A lower tech, fairly easy approach to program is bisection search. Start by defining a sequence of grid points $$x_0 = 0 < x_1 < x_2 < \dots < x_n < 1$$ and evaluate $$f(x_i)$$ for each $$i$$. Find an index $$i$$ such that $$f$$ changes sign between $$x_i$$ and $$x_{i+1}.$$ Evaluate $$f$$ at the midpoint of the interval $$[x_i, x_{i + 1}],$$ replace the endpoint having the same sign for $$f$$ as the midpoint with the midpoint, and repeat until the width of the interval is small enough that you will accept the last midpoint as your estimate of the root of $$f.$$

• This is very helpful. Thank you so much. The equation can be converted to a degree 5 polynomial. But my understanding is that normally close-form roots for such an equation cannot be obtained. However, theoretically, we can have up to 5 roots for such an equation. Can we prove that only one root falls between 0 and 1? Then, your suggested algorithm can search the ]0,1[ interval. Feb 21 at 23:08
• I ran some test computations, in which I found two roots in $(0, 1)$ (and might possibly have missed some). So in general the answer is no, we cannot prove there is a single root in the interval.
– prubin
Feb 22 at 4:21

Using Mathematica or Wolfram Engine, you could do something like this. Hope this helps.

In[11]:= NSolve[{((C - x)^2*x^2)/((-1 + x)^2*(-1 + N + x)^2) == (H*(C - 2*x))/(-2 + N + 2*x), x > 0, x < 1, N == 123, H
== 12, C == 321}]

Out[11]= {{C -> 321., H -> 12., N -> 123., x -> 0.681967}}
$$$$
`
• Thanks a million! It is highly appreciated. Feb 22 at 14:34
• Feb 22 at 14:39