| 1959 | return this |
| 1960 | } |
| 1961 | log(base) { |
| 1962 | if (!base) { |
| 1963 | throw "[TheoremJS] Log: wrong base" |
| 1964 | } |
| 1965 | let a = this.a |
| 1966 | let b = this.b |
| 1967 | if (b.eq(0)) { |
| 1968 | this.a = this.t.log(a, base) |
| 1969 | |
| 1970 | return this |
| 1971 | } |
| 1972 | const asbs = a.times(a).plus(b.times(b)) |
| 1973 | const log = this.t.ln(asbs) |
| 1974 | const half = log.div(2) |
| 1975 | |
| 1976 | a = this.arg() |
| 1977 | b = half |
| 1978 | const c = this.t.ln(base) |
| 1979 | const d = new BigNumber(0) |
| 1980 | |
| 1981 | const c2d2 = c.times(c).plus(d.times(d)) // c^2 + d^2 |
| 1982 | |
| 1983 | const acbd = a.times(c).plus(b.times(d)) // a*c + b*d |
| 1984 | const bcad = b.times(c).minus(a.times(d)) // b*c - a*d |
| 1985 | |
| 1986 | const re = acbd.div(c2d2) |
| 1987 | const im = bcad.div(c2d2) |
| 1988 | |
| 1989 | this.a = im |
| 1990 | this.b = re |
| 1991 | |
| 1992 | return this |
| 1993 | } |
| 1994 | minus(complex) { |
| 1995 | if (!complex.isComplex) { |
| 1996 | throw "[TheoremJS]: Complex operation require complex numbers" |