# What is the best method for fitting a curve that has the dependent variable on both sides of the equation?

I am trying to fit a curve to a set of measured data. Similar studies have been done, and the resulting curve fit is usually of the following form.

$$\frac{1}{\sqrt{Y}}=a \log{\left(X \sqrt{Y}\right)}-b$$

I need to find the $$a$$ and $$b$$ that will result in the least error; I think maximizing $$R^2$$ would suffice.

The method to do this is not clear to me, as $$Y$$ is found on both sides of the equation with no obvious way to simplify. Is iteratively solving a system of equations (left and right sides) my best option?

I currently have the data in excel, which provided me a power fit that is not sufficiently accurate. Equations of the form above have a more accurate trend. I plan to do this new curve fitting in python, as it would probably be a pain in excel.

Ideally I would simplify this equation to be of the form $$Y=f(X)$$, as it is the $$Y$$ that I need to calculate from the $$X$$ when using my model. I just don't know a good way to do that.

• Can you supply a reference where this has been used? There is a way to isolate y one just one side of the equation so I’m a bit suspicious as to the claim that someone started with the equation in this form.
– JimB
Aug 28, 2022 at 18:25
• A good method will pay close attention to the nature and magnitudes of the measurement errors. What can you tell us about them? There are subtleties with such fits, even when the implicit equation defines a line or circle. One of them is that even with nice data and compact curves the confidence regions for the fits can be unbounded. Another is that the best maximum likelihood fit might deviate much further from the data than an obvious visual fit. For an extended account of those issues, see Chernov, Circular and Linear Regression.
– whuber
Aug 28, 2022 at 18:30
• Solving for $y$ results in $y= \frac{1}{a^2 W\left(\frac{x e^{-\frac{b}{a}}}{a}\right)^2}$ where $W$ represents the Lambert $W$ function (en.wikipedia.org/wiki/Lambert_W_function). If you don't know what error structure is appropriate a priori, then looking at the residuals after trying an additive error is then especially necessary.
– JimB
Aug 28, 2022 at 20:00
• @JimB equations of this form are used for the Darcy friction factor. Aug 28, 2022 at 20:46
• Thanks. That helps because it's not just about the numbers and equations but very much so about the subject matter.
– JimB
Aug 28, 2022 at 20:53

For each couple $$(X,Y)$$ compute $$x=\log( X \times \sqrt{Y} )$$ and $$y=1/\sqrt Y.$$
Then the data is the couple $$(x,y)$$ related as $$y=a \cdot x - b.$$
$$a$$ and $$b$$ are obtained thanks to linear regression.