A little help understanding math....
08-29-2021, 12:20 AM (This post was last modified: 01-26-2024 03:19 PM by Albert Chan.)
Post: #9
 Albert Chan Senior Member Posts: 2,619 Joined: Jul 2018
RE: A little help understanding math....
Prove: if 0 ≤ θ < pi/2, Re(atan(exp(i*θ))) = pi/4

atan(z) = atanh(z*i)/i = ln((1+i*z)/(1-i*z)) / (2*i)

Let z = exp(i*θ) = cos(θ) + i*sin(θ)

(1+i*z)/(1-i*z)
= ((1-sin(θ)) + i*cos(θ)) / ((1+sin(θ)) - i*cos(θ))
= i * cos(θ) / (1 + sin(θ)) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ // flip sin/cos
= i * sin(pi/2-θ) / (1 + cos(pi/2-θ)) ﻿ ﻿ ﻿ ﻿ ﻿ ﻿ // tan(α/2) = sin(α) / (1 + cos(α))
= i * tan(pi/4-θ/2)

For 0 ≤ θ < pi/2, imaginery part is positive.

Re(atan(exp(i*θ))) = arg(i*tan(pi/4-θ/2)) / 2 = pi/4

With signed zero, we have atan(±0 + i) = ±pi/4 + Inf*i

Code:
Complex Catan(Complex z) {   double x = fabs(Real(z));   double y = fabs(Imag(z));   if (x >= 0x1p27 || y >= 0x1p27) { // atan(1/z) ~= 1/z     Complex t = -1/(x+y*I);         // atan(x+y*I) ~= pi/2 + t     x = Real(t) + M_PI_2;           // |re(t^3/3)/re(t)| <= 0x1p-54     y = Imag(t);                    // |im(t^3/3)/im(t)| <= 0x1p-54   } else {     double x2 = x*x, ym = 1-y;     double u = (1+y)*ym - x2;       // 0 implied z on unit circle     x = atan2(2*x + (u==0), u) * 0.5;     y = log1p(4*y / (ym*ym + x2)) * 0.25;   }   return CMPLX(copysign(x, Real(z)), copysign(y, Imag(z))); }

Top branch, atan(t = -1/z) ≈ t - t^3/3 + t^5/5 - ... ≈ t, is because of trig identities.

S2k+1 = sin((2k+1)θ)/sin(θ) = 2 cos((2k)θ) + 2 cos((2k-2)θ) + 2 cos((2k-4)θ) + ... + 1
C2k+1 = cos((2k+1)θ)/cos(θ) = 2 cos((2k)θ) - 2 cos((2k-2)θ) + 2 cos((2k-4)θ) − ... + (-1)^k

--> |S2k+1| ≤ 2k+1
--> |C2k+1| ≤ 2k+1

t = ε * cis(θ)
t^n/n = ε^n/n * cis(nθ)

|re(t^3/3)/re(t)| = ε^2 * |C3|/3 ≤ ε^2
|im(t^3/3)/im(t)| = ε^2 * |S3|/3 ≤ ε^2

|re(t^5/5)/re(t)| = ε^4 * |C5|/5 ≤ ε^4
|im(t^5/5)/im(t)| = ε^4 * |S5|/5 ≤ ε^4

...

ε^2 below machine epsilon --> t - t^3/3 + t^5/5 - ... ≈ t
 « Next Oldest | Next Newest »

 Messages In This Thread A little help understanding math.... - Thomas Klemm - 12-16-2013, 11:56 PM RE: A little help understanding math.... - Paul Dale - 12-17-2013, 10:19 AM RE: A little help understanding math.... - Namir - 12-17-2013, 01:17 PM RE: A little help understanding math.... - Thomas Klemm - 12-17-2013, 03:04 PM RE: A little help understanding math.... - Albert Chan - 08-15-2021, 03:48 AM RE: A little help understanding math.... - Albert Chan - 08-15-2021, 12:25 PM RE: A little help understanding math.... - Albert Chan - 08-26-2021, 02:31 PM RE: A little help understanding math.... - Albert Chan - 08-26-2021, 06:16 PM RE: A little help understanding math.... - Albert Chan - 08-29-2021 12:20 AM RE: A little help understanding math.... - Albert Chan - 06-14-2023, 04:55 PM

User(s) browsing this thread: 1 Guest(s)