Scalar functions#
Real and complex sine#
- ctxlib.sin(x)#
where
ctxisctx_pm(see Python contexts for details),ctx53,ctxcpp,ctxflint(see .NET contexts for details). The correspondingctxpython lists arectxlistrealandctxlistcplx.Returns the sine of \(x\), \(\sin(x)\). See also Wikipedia [1350], MathWorld [947], NIST [517], Ehrhardt [309] (4.2.55), Flint [812], Flint [802], Mpmath [584].
Quadratic equation#
- ctx.eval_quadratic(x, A, B, C)#
Returns the value of a quadratic polynomial, \(A x^2 + B x + C\).
- ctx.quadratic_equation(A, B, C)#
Returns the roots \(x_1, x_2\) of the quadratic equation \(A x^2 + B x + C = 0\). See also Wikipedia [1189], Press et al. [499].
See also: https://dlmf.nist.gov/1.11#iii
\[x_1 = \frac{Q}{A}, \quad x_2 = \frac{C}{Q}, \quad \text{where } Q = -\frac{1}{2} \left(B + \sqrt{B^2 - 4AC}) \right)\]The sign of the square root is chosen so as to make \(\displaystyle \Re(B^* \sqrt{B^2 - 4AC}) \ge 0\), where the asterisk denotes complex conjugation.
An example with real input:
>>> from xlcalcnet import dec, mpm, ipm >>> mpm.dps = 40; x = '125'; n = '3' >>> \mathrm{d}x = dec.nthroot(x, n); mx = mpm.nthroot(x, n); ix = ipm.nthroot(x, n) >>> mpm.show([\mathrm{d}x, mx, ix]) dec: 5.000000000000000000000000000000000000000E+0 mpm: 5.000000000000000000000000000000000000000e+0 ipm: 5.000000000000000000000000000000000000000e+0 (2.755e-39%) >>> from xlcalcnet import mpm, fpm, gmp, apm >>> mpm.dps = 40; x = '125'; n = '3' >>> fx = fpm.nthroot(x, n); gx = gmp.nthroot(x, n); ax = apm.nthroot(x, n) >>> mpm.show([fx, gx, ax]) fpm: 5.00000000000000E+00 gmp: 5.000000000000000000000000000000000000000E+00 apm: 5.000000000000000000000000000000000000002e+0 (3.673e-39%)
Monic cubic equation#
- ctx.eval_monic_cubic(x, a, b, c)#
Returns the value of a monic cubic polynomial, \(x^3 + a x^2 + b x + c\).
- ctx.cubic_equation_monic(a, b, c)#
Returns the roots \(x_1, x_2, x_3\) of the monic cubic equation \(x^3 + a x^2 + b x + c = 0\). See also Wikipedia [1180], Press et al. [499].
See also: https://dlmf.nist.gov/1.11#iii
\[Q = \frac{a^2 - 3b}{9}, \quad R = \frac{2a^3 - 9ab + 27c}{54}.\]If \(Q\) and \(R\) are real and \(R^2 < Q^3\), then the cubic equation has three real roots, with \(\displaystyle \theta = \arccos \left( R Q^{-3/2} \right)\):
\[x_1 = -2 \sqrt{Q} \cos \left( \frac{\theta}{3} \right) - \frac{a}{3}, \quad x_2 = -2 \sqrt{Q} \cos \left( \frac{\theta + 2\pi}{3} \right) - \frac{a}{3}, \quad x_3 = -2 \sqrt{Q} \cos \left( \frac{\theta - 2\pi}{3} \right) - \frac{a}{3}.\]Otherwise, \(\displaystyle A = - \left(R + \sqrt{R^2 - Q^3}) \right)^{1/3}\), where the sign of the square root is chosen so as to make \(\displaystyle \Re(R^* \sqrt{R^2 - Q^3}) \ge 0\), and the asterisk denotes complex conjugation. Define \(B = 0\) if \(A = 0\) and \(B = Q / A\) if \(A \ne 0\). Then the three roots are given by
\[x_1 = (A + B) - \frac{a}{3}, \quad x_2 = -\frac{1}{2} (A + B) - \frac{a}{3} + i \frac{\sqrt{3}}{2} (A - B), \quad x_3 = -\frac{1}{2} (A + B) - \frac{a}{3} - i \frac{\sqrt{3}}{2} (A - B).\]Note that \(x_1\) is real if \(a, b, c\) are real.
An example with real input:
>>> from xlcalcnet import dec, mpm, ipm >>> mpm.dps = 40; x = '125'; n = '3' >>> \mathrm{d}x = dec.nthroot(x, n); mx = mpm.nthroot(x, n); ix = ipm.nthroot(x, n) >>> mpm.show([\mathrm{d}x, mx, ix]) dec: 5.000000000000000000000000000000000000000E+0 mpm: 5.000000000000000000000000000000000000000e+0 ipm: 5.000000000000000000000000000000000000000e+0 (2.755e-39%) >>> from xlcalcnet import mpm, fpm, gmp, apm >>> mpm.dps = 40; x = '125'; n = '3' >>> fx = fpm.nthroot(x, n); gx = gmp.nthroot(x, n); ax = apm.nthroot(x, n) >>> mpm.show([fx, gx, ax]) fpm: 5.00000000000000E+00 gmp: 5.000000000000000000000000000000000000000E+00 apm: 5.000000000000000000000000000000000000002e+0 (3.673e-39%)
Cubic equation#
- ctx.eval_cubic(x, A, B, C, D)#
Returns the value of a cubic polynomial, \(A x^3 + B x^2 + C x + D\).
- ctx.cubic_equation(A, B, C, D)#
Returns the roots \(x_1, x_2, x_3\) of the cubic equation \(A x^3 + B x^2 + C x + D = 0\). See also Wikipedia [1180], Press et al. [499].
See also: https://dlmf.nist.gov/1.11#iii
This just calls CubicEquationMonicRoots(z, a, b, c) with \(a = B / A, b = C / A, c = D / A\).
An example with real input:
>>> from xlcalcnet import dec, mpm, ipm >>> mpm.dps = 40; x = '125'; n = '3' >>> \mathrm{d}x = dec.nthroot(x, n); mx = mpm.nthroot(x, n); ix = ipm.nthroot(x, n) >>> mpm.show([\mathrm{d}x, mx, ix]) dec: 5.000000000000000000000000000000000000000E+0 mpm: 5.000000000000000000000000000000000000000e+0 ipm: 5.000000000000000000000000000000000000000e+0 (2.755e-39%) >>> from xlcalcnet import mpm, fpm, gmp, apm >>> mpm.dps = 40; x = '125'; n = '3' >>> fx = fpm.nthroot(x, n); gx = gmp.nthroot(x, n); ax = apm.nthroot(x, n) >>> mpm.show([fx, gx, ax]) fpm: 5.00000000000000E+00 gmp: 5.000000000000000000000000000000000000000E+00 apm: 5.000000000000000000000000000000000000002e+0 (3.673e-39%)
Quartic equation#
- ctx.eval_quartic(x, A, B, C, D, E)#
Returns the value of a quartic polynomial, \(A x^4 + B x^3 + C x^2 + D x + E\).
- ctx.quartic_equation(A, B, C, D, E)#
Returns the roots \(x_1, x_2, x_3, x_4\) of the quartic equation \(A x^4 + B x^3 + C x^2 + D x + E = 0\). See also Wikipedia [1190].
See also: https://dlmf.nist.gov/1.11#iii
Define \(\displaystyle a = \frac{-3 B^2}{8 A^2} + \frac{C}{A}, \quad b = \frac{ B^3}{8 A^3} - \frac{BC}{2 A^2} + \frac{D}{A}, \quad c = \frac{-3 B^4}{256 A^4} + \frac{CB^2}{16 A^3} - \frac{BD}{4 A^2} + \frac{E}{A}, \quad V = \frac{B}{4 A}\).
If \(b = 0\) then
\(\displaystyle x_1 = V + Z_1, \quad x_2 = V - Z_1, \quad x_3 = V + Z_2, \quad x_4 = V - Z_2\),
where \(\displaystyle W = \sqrt{a^2 - 4c}, \quad Z_1 = \sqrt{\tfrac{1}{2}(-a + W)}, \quad Z_2 = \sqrt{\tfrac{1}{2}(-a - W)}\).
If \(b \ne 0\) then
\(\displaystyle x_1 = V + \tfrac{1}{2}(W + Z_1), \quad x_2 = V + \tfrac{1}{2}(W - Z_1), \quad x_3 = V - \tfrac{1}{2}(W + Z_2), \quad x_4 = V -\tfrac{1}{2}(W - Z_2)\),
where \(\displaystyle W = \sqrt{a + 2y}, \quad Z_1 = \sqrt{-3a - 2y - \frac{2b}{W}}, \quad Z_2 = \sqrt{-3a - 2y + \frac{2b}{W}}\),
and \(y\) is any root of the monic cubic equation \(\displaystyle y^3 + ey^2+ fy + g =0\), with \(\displaystyle e = \frac{5a}{2}, \quad f = 2 a^2 -c, \quad g = \frac{a^3}{2} - \frac{a c}{2} - \frac{b^2}{8}\);
\(y\) is calculated as the first root returned by CubicEquationMonicRoots(y, e, f, g).
An example with real input:
>>> from xlcalcnet import dec, mpm, ipm >>> mpm.dps = 40; x = '125'; n = '3' >>> \mathrm{d}x = dec.nthroot(x, n); mx = mpm.nthroot(x, n); ix = ipm.nthroot(x, n) >>> mpm.show([\mathrm{d}x, mx, ix]) dec: 5.000000000000000000000000000000000000000E+0 mpm: 5.000000000000000000000000000000000000000e+0 ipm: 5.000000000000000000000000000000000000000e+0 (2.755e-39%) >>> from xlcalcnet import mpm, fpm, gmp, apm >>> mpm.dps = 40; x = '125'; n = '3' >>> fx = fpm.nthroot(x, n); gx = gmp.nthroot(x, n); ax = apm.nthroot(x, n) >>> mpm.show([fx, gx, ax]) fpm: 5.00000000000000E+00 gmp: 5.000000000000000000000000000000000000000E+00 apm: 5.000000000000000000000000000000000000002e+0 (3.673e-39%)
Transscribed from Julia: complex elliptic functions in double precision#
Text describing functions
Speeedups for iterative algorithms which require an initial guess#
Text describing functions
Inverses of cdfs: inverses of noncentral functions
inverses livk gamma_inva
Examples for matrix functions#
Text describing functions
Descriptive statistics via numpy in multiple precision
Multiple linear regression via numpy in multiple precision
Canonical correlation via numpy in multiple precision
Descriptive statistics via Eigen in multiple precision
Multiple linear regression via Eigen in multiple precision
Canonical correlation via Eigen in multiple precision
Levenberg-Marquardt algorithm via Eigen in multiple precision
L-BFGS algorithm via Eigen in multiple precision