Post Reply 
A little help understanding math....
08-29-2021, 12:20 AM
Post: #9
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)));
}
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: A little help understanding math.... - Albert Chan - 08-29-2021 12:20 AM



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