A little help understanding math....
08-26-2021, 06:16 PM
Post: #8
 Albert Chan Senior Member Posts: 2,142 Joined: Jul 2018
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))); }
 « 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

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