Wednesday, May 27, 2020

Initialization fix for an old simple square root algorithm


. . . it's multiple proven that in general situation the iteration formula :
\[\sqrt{A}\leftarrow a_{n+1}=\frac{\frac{A}{a_n}+a_n}2\]
gives the fastest convergence , initialization :
\[a_0=A\rightarrow a_1=a_{1_1}=\frac{A+1}2\]

however i just explored a different approach with iterative formula :
\[\sqrt{A}\leftarrow a_{n+1}=\frac{2Aa_n}{A+a_n^2}=\frac2{\frac1{a_n}+\frac{a_n}A}=\frac{2A}{\frac A{a_n}+a_n}=\frac A{\frac{\frac{A}{a_n}+a_n}2}\]
which has an initialization :
\[a_0=1\rightarrow a_1=a_{1_2}=\frac{2A}{A+1}=1+\frac{A-1}{A+1}\]

the "Old" initialization gives quite large positive error ... while my "Latest" initialization gives quite large negative error . . . however the both averaged gives more reasonable positive error , where the :
\[a_1=a_{1_3}=\frac{a_{1_1}+a_{1_2}}2=\frac{A+1}4+\frac{A}{A+1}\]

while for each \(a_n\) where \(n>1\) the first iteration formula on this page applies

...

yet a lesser negative error is got by combining the two first initializations as :
\[a_1=a_{1_4}=\frac{2a_{1_1}a_{1_2}}{a_{1_1}+a_{1_2}}=\frac1{\frac{A+1}{4A}+\frac1{A+1}}=\frac{A}{a_{1_3}}\]

...

+ yet a significantly lesser positive error is got by combining the two last initializations as :
\[a_1=a_{1_5}=\frac{a_{1_3}+a_{1_4}}2=\frac{a_{1_3}+\frac{A}{a_{1_3}}}2\]

the last formula is actually the value of \(a_2\) for \(a_{1_3}\) . . . so , . . .

. . . anyway it give us quite accurate estimation formula for the near A=1 , as :

\[\sqrt{A}≈a=\frac{\frac{A+1}4+\frac A{A+1}+\frac A{\frac{A+1}4+\frac A{A+1}}}2\]

the error ≤ about 5% - from \(\frac1{20}...20\)


[Eop]

Thursday, April 16, 2020

Right Triangle



\( α+ß=\frac{π}2=90°\ ,\ R=\frac{C}2 \)

\( r=\sqrt{{\left({\frac{C}2}\right)}^2+\frac{A·B}2}-\frac{C}2←\cases{A=r+x\\ B=r+y\\ C=x+y} \)

\( \frac{a}h=\frac{h}b=\frac{A}B=tan\ ß=\frac1{tan\ α}\)

\( a·b=h^2 \)

\( a+b=C \)

\( A^2+B^2=C^2={\left({a+b}\right)}^2=a^2+2·a·b+b^2 \)

\( A^2=a^2+h^2=a^2+a·b=a·\left({a+b}\right)=a·C \)

\( B^2=b^2+h^2=b^2+b·a=b·\left({b+a}\right)=b·C \)

\( a=\frac{A^2}C \)

\( b=\frac{B^2}C \)

\( h=\frac{A·B}C=\sqrt{a·b} \)

 \( S=\frac{A·B}2=\frac{\sqrt{a·C·b·C}}2=\frac{h·C}2=\frac{\frac{A·B}C·C}2 \)

 \( P=A+B+C=A+B+\sqrt{A^2+B^2}=\sqrt{a·C}+\sqrt{b·C}+\sqrt{C·C}=\sqrt{C}·\left({\sqrt{a}+\sqrt{b}+\sqrt{a+b}}\right) \)

\( b=h^2\ ,\ a=1\ →\ A^2=C=h^2+1\ ,\ B^2=b·A^2=b·C=h^2·\left({h^2+1}\right)\ ,\ R=\frac{C}2 \)


[Eop]

Wednesday, March 25, 2020

About the Quadratic Equation


Derivation of the solutions ::
\(x^2+px+q=0=\left({x-u}\right)\left({x-v}\right)=x^2-\left({u+v}\right)x+uv\)
\(p=2a\)
\(x^2+2ax+a^2-a^2+q=0\)
\(x+a=±\sqrt{a^2-q}\)
\(a=\frac p2\)
\(x=-\frac p2±\sqrt{{\left({\frac p2}\right)}^2-q}\)
\(x_1=-\frac p2-\sqrt{{\left({\frac p2}\right)}^2-q}\)
\(x_2=-\frac p2+\sqrt{{\left({\frac p2}\right)}^2-q}\)
\(x_2-x_1=2\sqrt{{\left({\frac p2}\right)}^2-q}\)
\(x_2+x_1=-p\)
\(x_2=-p-x_1\)
\(x_1=-p-x_2\)
\(x+p+\frac qx=0\)
\(\displaystyle{x=-p-\frac qx\quad \rightarrow \quad x_n=x_n+x_\overline{n}-\frac q{x_n}}\)
\(\displaystyle{x_n=\frac q{x_\overline{n}}\ \equiv\ x_nx_\overline{n}=q\ |\ about:\ q=uv}\)

Example ::
\(\mathbf{p}\)\(\mathbf{q}\)\(\mathbf{x_n}\) \(\mathbf{x_1}\\ -p-x_2\\ \displaystyle{\frac q{x_\overline{n}}}\) \(\mathbf{x_2}\\ -p-x_1\\ \displaystyle{\frac q{x_\overline{n}}}\)
\(-1\)\(-1\) \(-\frac{-1}2±\sqrt{{\left({\frac{-1}2}\right)}^2-\left({-1}\right)}=\)
\(\frac{1±\sqrt{5}}2=\)
\(=\cases{-\frac{\sqrt{5}-1}2\\ \frac{\sqrt{5}+1}2}\)
\(=\cases{-\frac{5-1}{2\left({\sqrt{5}+1}\right)}\\ \frac{5-1}{2\left({\sqrt{5}-1}\right)}}\)
\(=\cases{\frac{-2}{\sqrt{5}+1}\\ \frac2{\sqrt{5}-1}}\)
\(\frac{-2}{\sqrt{5}+1}\mathbf{=}\)
\(\mathbf{=}-\left({-1}\right)-\frac{2}{\sqrt{5}-1}=\)
\(=1-\frac{\sqrt{5}+1}2=\)
\(=-\frac{-2+\sqrt{5}+1}2=\)
\(=-\frac{\sqrt{5}-1}2=\)
\(=-\frac2{\sqrt{5}+1}\)
\(\mathbf{=}\frac{-1}{\left({\frac2{\sqrt{5}-1}}\right)}=\)
\(=-\frac{\sqrt{5}-1}2=\)
\(=\frac{-2}{\sqrt{5}+1}\)
\(\frac2{\sqrt{5}-1}\mathbf{=}\)
\(\mathbf{=}-\left({-1}\right)-\frac{-2}{\sqrt{5}+1}=\)
\(=1+\frac{\sqrt{5}-1}2=\)
\(=\frac{2+\sqrt{5}-1}2=\)
\(=\frac{\sqrt{5}+1}2=\)
\(=\frac2{\sqrt{5}-1}\)
\(\mathbf{=}\frac{-1}{\left({\frac{-2}{\sqrt{5}+1}}\right)}=\)
\(=\frac{\sqrt{5}+1}2=\)
\(=\frac2{\sqrt{5}-1}\)

Tuesday, March 24, 2020

Dynamic Formulas for the Capacitor and for the Inductor


Charging the capacitor from the CV(=Vs) src. ::
The voltage drop on the series resistor \[V_R=V_S-V_C\]
\[t_{0_{↑}^{↑}→V_C}=-R·C·ln\left({1-\frac{V_C}{V_S}}\right)=R·C·ln\frac{V_S}{V_R}\]
\[t_{V_{1_C}{}_{↑}^{↑}→V_{2_C}}=R·C·ln\frac{V_S-V_{1_C}}{V_S-V_{2_C}}=R·C·ln\frac{V_{1_R}}{V_{2_R}}\]
Dis-charging the capacitor through a fixed value resistor ::
\[t_{V_{2_C}{}_{↓}^{↓}→V_{1_C}}=-R·C·ln\frac{V_{1_C}}{V_{2_C}}=R·C·ln\frac{V_{2_C}}{V_{1_C}}\]

"Charging" the inductor from the CV(=Vs) src. ::
The peak current \[I_{MAX}=\frac{V_S}R\]
\[t_{0_{↑}^{↑}→I_L}=-\frac LR·ln\left({1-\frac{I_L}{I_{MAX}}}\right)\]
\[t_{I_{1_L}{}_{↑}^{↑}→I_{2_L}}=\frac LR·ln\frac{I_{MAX}-I_{1_L}}{I_{MAX}-I_{2_L}}\]
"Dis-charging" the inductor through a fixed value resistor ::
\[t_{I_{2_L}{}_{↓}^{↓}→I_{1_L}}=\frac LR·ln\frac{I_{2_L}}{I_{1_L}}\]


[Eop]