Fitting a tangent curve by hand / on paper

mathematical modelingregressionsystems of equationstrigonometry

Sorry if anything is unclear or a bit of a stupid question my maths is nowhere near as advanced as yours, I searched quite extensively on stats.stackexchange and stackexchange and couldn't find or at least understand something that helped me do this.

I need to fit a single iteration of a transformed tangent function to this data as a form of regression and show how I did it manually. I did something similar with a cubic which was very simple. I've heard of different computational greedy algorithms to do this but I'd need to solve this by hand to show I understand the maths behind it.

The equation would be a generic $𝑦=𝐴\tan(𝐵𝑥+𝐶)+𝐷.$

If I understood correctly the difficulty in solving this is the fact that it includes unknown coefficients both inside and outside of the brackets. Is there a way for me to solve it with all four unknowns? If not I'd be ok with knowing how to estimate some of the unknowns on this data and then solving the rest based on those assumptions. It doesn't need to be perfect but I need to know the limitations of the method I use and it needs to be good enough to be representative of the data within the given domain of $0<x<5.34.$

I was able to do this in desmos with an $r^2$ of 0.9958. The equation I got was $$y=0.336305\tan(0.486962x+1.87644)+1.19392$$
which would be $a=0.336305, b=0.486962, c=1.87644, d=1.19392$

Essentially I need a model to fit this rotated s-shape. Doing the inverse and using a logistic function kind of works (see pictures attached) but it really wouldn't be ideal.

I look forward to any of your proposals, thank you for your time!

The tan regression is shown in blue and the inversed data with the logistif regression is shown in black.
Desmos tan and logistic regression:

Data:
https://pastebin.com/Frf6LZYR

Best Answer

I am not sure to well understand exactly what you are looking for. I suppose that you want to find the parameters $A,B,C,D$ without using a software for nonlinear regression. Nevertheless I suppose that it is allowed to use a PC for drawing the points and curve. I suppose also that "manually" means that a PC is allowed for elementary numerical calculus.

The first step in order to simplify the problem is to find the symetry center of the tangent curve. This can be roughly done graphically "by eye" (Next figure).

enter image description here

Still roughtly but slightly better consists in drawing the graph rotated of 180° and making fit at the best to the original graph by trial and error (next figure, the original in red and the rotated in blue).

enter image description here

This gives a rough estimate of the coordinates of the symetry center : $$\begin{cases} x_s\simeq 2.6\\ y_s\simeq 1.2 \end{cases}$$

Then we translate the axes with new coordinates : $$\begin{cases} X=x-x_s\\ Y=y-y_s \end{cases}$$ This transforms the original equation : $$y=A\tan(Bx+C)+D\quad\implies\quad Y+y_s=A\tan(B(X+x_s)+C+n\:\pi)+D$$ to the new equation : $$\boxed{Y=A\tan(BX)}$$ with $$D=y_s\simeq 1.2\tag 1$$ $$C=\pi-Bx_s\simeq 3.14-2.6B\tag 2$$

The problem is reduced to a simple tangent function fitting involving only two parameters.

If you don't want use a software for nonlinear regression you can proceed by trial and error. Of course this is tiresome and not accurate.

enter image description here

Related Question