Trigonometry: Least square of a tangent function

261 Views Asked by At

I have two vectors $x_n$ and $y_n$, when sorted forms a tangent function of $y_n = a\cdot \tan(b\cdot x_n + c) + d$, and I wondered if it was possible to use the least square method, or another method, to make a approximate function and if so how?

1

There are 1 best solutions below

0
On BEST ANSWER

The usual way is to use a nonlinear regression method of fitting. They are several softwares. The calculus is iterative starting from "guessed" values of the parameters. Sometimes the numerical calculus fails due to bad initial guessed values and/or not convergent iteration.

The principle of a non conventional method (no iteration, no initial guess) is explained in this paper : https://fr.scribd.com/doc/14674814/Regressions-et-equations-integrales , partially translated in : https://scikit-guess.readthedocs.io/en/latest/appendices/references.html. An application to the case of tangent function is shown below.

enter image description here

Numerical example :

enter image description here

If a well defined criteria for fitting is specified ( least mean absolute deviation or least relative deviation or others) the above method is not sufficient. An iterative process is required with guessed values to start. The above calculus can be used to get a set of good initial values.

CAUTION :

In the above method numerical integrations are carried out for the computation of $S_k$ and $T_k$. Such a simplified process cannot be used if the function tends to infinity around a point on the range of the data $(x_k\, ,\,y_k)$. For example if the points are distributed as on the next figure the above method will not be convenient.

enter image description here

FOR INFORMATION :

An integral equation to which $\quad y(x)=a\tan(bx+c)+d\quad$ is solution is : $$y(x)=\frac{b}{a}\int (y(x))^2dx-2\frac{bd}{a}\int y(x)\,dx+\left(\frac{b\,d^2}{a}+ab\right)x+\text{constant}$$ This allows the linearisation of the regression and the construction of the first 4x4 matrix.