Post Reply 
A little help understanding math....
08-26-2021, 06:16 PM
Post: #8
RE: A little help understanding math....
We can reuse previous post acos(z) = u+i*v result for asin(z)

Naive implementation is with identity asin(z) = pi/2 - acos(z) = (pi/2-u) - i*v
But, we could avoid cancellation errors of real part.

a = √(1+z) = √((1+U)*(V+1)/2) + i*s*√((1−U)*(V−1)/2)
b = √(1−z) = √((1−U)*(V+1)/2) − i*s*√((1+U)*(V−1)/2)

+Real(a) * Real(b) = (V+1)/2 * √(1-U*U)       ..... (4)
-Imag(a) * Imag(b) = (V-1)/2 * √(1-U*U)       ..... (5)

With V=cosh(v) ≥ 1, both (4) and (5) are non-negative.
Summing them is safe from cancellation error.

(4)+(5)       → S = V * √(1-U*U)

x/S = (U*V) / (V*√(1-U*U)) = cos(u) / |sin(u)| = sign(x) * |tan(pi/2 - u)|

sign(x) should match sign(pi/2-u), we have pi/2-u = atan(x/S)

Except for sign flip, imaginery part of asin(z) and acos(z) are the same.
So, I just copy/paste from acos() code, for the imaginery part.
Code:
Complex Casin(Complex z)
{
  Complex a = csqrt(1+z), b = csqrt(1-z);
  double x2 = atan(Real(z) / (Real(a)*Real(b) - Imag(a)*Imag(b)));
  double y2 = asinh(Real(a)*Imag(b) - Imag(a)*Real(b));
  return CMPLX(copysign(x2, Real(z)), copysign(y2, 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-26-2021 06:16 PM



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