mirror of
https://github.com/josdejong/mathjs.git
synced 2026-01-25 15:07:57 +00:00
No longer edit original complex argument.
This commit is contained in:
parent
f296fa2e55
commit
85c8f8efc0
@ -53,13 +53,15 @@ module.exports = function (math) {
|
||||
|
||||
// acoth(z) = -i*atanh(1/z)
|
||||
var den = x.re*x.re + x.im*x.im;
|
||||
if (den != 0) {
|
||||
x.re = x.re / den;
|
||||
x.im = -x.im / den;
|
||||
} else {
|
||||
x.re = (x.re != 0) ? (x.re / 0) : 0;
|
||||
x.im = (x.im != 0) ? -(x.im / 0) : 0;
|
||||
}
|
||||
x = (den != 0)
|
||||
? new Complex(
|
||||
x.re / den,
|
||||
-x.im / den
|
||||
)
|
||||
: new Complex(
|
||||
(x.re != 0) ? (x.re / 0) : 0,
|
||||
(x.im != 0) ? -(x.im / 0) : 0
|
||||
);
|
||||
|
||||
return math.atanh(x);
|
||||
}
|
||||
|
||||
@ -48,22 +48,26 @@ module.exports = function (math) {
|
||||
}
|
||||
|
||||
if (isComplex(x)) {
|
||||
if (x.im == 0) {
|
||||
x = (x.re != 0)
|
||||
? Math.log(x.re + Math.sqrt(x.re*x.re + 1))
|
||||
: Infinity;
|
||||
return new Complex(x, 0);
|
||||
}
|
||||
|
||||
// acsch(z) = -i*asinh(1/z)
|
||||
var den = x.re*x.re + x.im*x.im;
|
||||
if (den != 0) {
|
||||
x.re = x.re / den;
|
||||
x.im = -x.im / den;
|
||||
} else {
|
||||
x.re = (x.re != 0) ? (x.re / 0) : 0;
|
||||
x.im = (x.im != 0) ? -(x.im / 0) : 0;
|
||||
}
|
||||
x = (den != 0)
|
||||
? new Complex(
|
||||
x.re / den,
|
||||
-x.im / den
|
||||
)
|
||||
: new Complex(
|
||||
(x.re != 0) ? (x.re / 0) : 0,
|
||||
(x.im != 0) ? -(x.im / 0) : 0
|
||||
);
|
||||
|
||||
if (x.im) {
|
||||
return math.asinh(x);
|
||||
}
|
||||
|
||||
x = 1 / x.re;
|
||||
return new Complex(Math.log(x + Math.sqrt(x*x + 1)), 0);
|
||||
return math.asinh(x);
|
||||
}
|
||||
|
||||
if (isCollection(x)) {
|
||||
|
||||
@ -54,13 +54,15 @@ module.exports = function (math) {
|
||||
|
||||
// acsch(z) = -i*asinh(1/z)
|
||||
var den = x.re*x.re + x.im*x.im;
|
||||
if (den != 0) {
|
||||
x.re = x.re / den;
|
||||
x.im = -x.im / den;
|
||||
} else {
|
||||
x.re = (x.re != 0) ? (x.re / 0) : 0;
|
||||
x.im = (x.im != 0) ? -(x.im / 0) : 0;
|
||||
}
|
||||
x = (den != 0)
|
||||
? new Complex(
|
||||
x.re / den,
|
||||
-x.im / den
|
||||
)
|
||||
: new Complex(
|
||||
(x.re != 0) ? (x.re / 0) : 0,
|
||||
(x.im != 0) ? -(x.im / 0) : 0
|
||||
);
|
||||
|
||||
return math.acosh(x);
|
||||
}
|
||||
|
||||
@ -53,6 +53,11 @@ module.exports = function (math) {
|
||||
x.re = temp;
|
||||
|
||||
var asin = math.asin(x);
|
||||
|
||||
// restore original values
|
||||
x.re = -x.im;
|
||||
x.im = temp;
|
||||
|
||||
temp = asin.re;
|
||||
asin.re = -asin.im;
|
||||
asin.im = temp;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user