# Can I use the least square fitting to obtain a real solution of a complex equation?

I am trying to solve the following equation:

$$\omega^{1/3} = p_l \omega_l^{1/3} + (1-p_l)\omega_{\omega}^{1/3} \tag{1}$$

$$\omega$$, $$\omega_l$$, and $$\omega_w$$ are complex numbers and $$p_l$$ must be real (it represents a percentage).

$$\omega$$ is a vertical array of 200 values and $$\omega_l$$ is a constant single number, as well as $$\omega_w$$. Therefore, I should be able to obtain 200 different values for $$p_l$$.

I have been told that I could use the least-square fitting to solve this and obtain my 200 values for $$p_l$$, but I am not certain as to how to.

What I have done so far:

• I have previously simply tried to manipulate the equation so as to isolate $$p_l$$ but all the results I obtained were complex numbers, which cannot happen in this case.

• I have started by separating the real and complex parts of $$(1)$$, and obtained the values for $$p_l$$ from these two equations: $$p_l = \frac{real(\omega) - real(\omega_w)}{real(\omega_l) - real(\omega_w)}$$ and $$p_l = \frac{imag(\omega) - imag(\omega_w)}{imag(\omega_l) - imag(\omega_w)}$$, but I do not know if there is any information to obtain from this, and if there is I do not know how to obtain it.

Can I use the least-square fitting to solve this equation and obtain real values for $$p_l$$?

• Couldn't you just solve for $p_l$ and substitute in the final formula 200 times? That being said, if $p_l$ is real, then $\frac{\omega^{1/3}-\omega_\omega^{1/3}}{\omega_l^{1/3}-\omega_\omega^{1/3}}$ must be real as well so not all $\omega$ values will do. Maybe some more context about what you are trying to model here? Commented Sep 28, 2023 at 16:14
• Thanks for your help @DinosaurEgg but as I stated above, I have done what you have stated but unfortunately the equation only results in complex solutions (which makes sense mathematically), but I should also be able to obtain the real number, as it could also be fitted into that equation. I am modelling permittivity , $\omega$, over water content $\p_l$. Commented Sep 29, 2023 at 10:07
• So there is some noise in the data that makes $p_l$ acquire an imaginary part? If so, you need to understand how sensitive the real part is to that noise somehow. Commented Sep 29, 2023 at 16:25

There is a variety of ways one can obtain an estimate for the real part of $$p_l$$. I will mention one here that is in the spirit of least squares and does not require any other inputs but the measurements. Assuming that the quantity $$Q=||\omega^{1/3}-\omega^{1/3}_\omega+p_l(\omega^{1/3}_l-\omega^{1/3}_\omega)||$$ is normally distributed with probability distribution $$\mathcal{N}(0,\sigma^2)$$, we can find the maximum likehlihood estimate for this quantity by minimizing the quadratic loss function
$$\mathcal{L}=\sum_{k}Q_k^2=\sum_k (X_k-a-cp_l)^2+(Y_k-b-dp_l)^2$$
where the sum is performed over the different observations of the experiment and we have denoted the observations $$\omega_k^{1/3}=X_k+iY_k$$ and $$\omega_\omega^{1/3}=a+bi~~,~ \omega_l^{1/3}-\omega_\omega^{1/3}=c+di$$. The function is quadratic and hence has a unique minimum. Finding the minimum yields the estimate
$$\frac{d\mathcal{L}}{dp_l}=0\Rightarrow\hat{p_l}=\frac{c\langle X \rangle+d \langle Y\rangle}{c^2+d^2}-\frac{ac+bd}{c^2+d^2}$$
where $$\langle R\rangle=\sum_k {R_k}/n.$$ The estimate is by definition real.