billyauhk / bc_elliptic_lawden

Recreating code for reproducing Mathematical Tables at the back of Lawden's elliptical function book.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Aim

  • Recreating code for reproducing Mathematical Tables at the back of Lawden's elliptical function book in 1989.

Status

  • Currently, code could be used to reproduce all the tables.
  • BC is used to gain arbitrary precision capability on nearly all platforms, as BC is available all nearly all Unix.
  • Not meant to be fast. Those need performance should check fredrik-johansson/mpmath.
  • Accuracy and speed of the functions inside the code varies, but given a good enough (high enough) scale value and time, it could reproduce the numbers.

To-Do

  • Making more rigorous check against cancellation error or precision loss due to divisions.
  • Fixing coding style and comments

History

  • Before git repository created in the morning of 29May2022, this piece of work starts from the theta functions which are defined in Chapter 1 on 12Oct2021.
  • Originally for implementing some of the mathematics needed by other works which required me to study elliptic function + integral from scratch.
  • Later agree (with myself) to reproduce all Mathematical Tables at the end of the book first, making sure I could get the numbers whenever I need.
  • Sometimes numbers are checked against Mathematica on a Raspberry Pi (always thanks Wolfram for making that available).

License

Copyright retained until further notice (or change of this line).

Files

File Uses
README.md This markdown README file.
lawden.bc The single file which contains all stuff for computations. Table-making codes are split into other files.
elliptic.bc DLMF-based implementation of Legendre's incomplete integrals of 1st and 2nd kind for Table D, replacing slow methods Lawden book recommends.
table_A_termio.bc Computes Table A. Default takes ~1.31 sec.
table_B_termio.bc Computes Table B. Default takes ~6.93 sec.
table_C_termio.bc Computes Table C. Default takes ~8.27 sec.
table_D_termio.bc Computes Table D. Default takes ~1.05 sec which uses Carlson integrals and formula on DLMF. Takes ~609.308 sec if use what the Lawden book described and too slow.
table_E_termio.bc Computes Table E. Default takes ~5.26 sec.
table_F_termio.bc Computes Table F. Default takes ~0.75 sec.
table_G_termio.bc Computes Table G. Default takes ~1.90 sec.
table_H_termio.bc Computes Table H. Default takes ~225.79 sec. (Need debug as there are two functions doing the same thing and both are not fully correct over all inputs.)
table_I_termio.bc Computes Table I. Default takes ~75.40 sec.
table_J_termio.bc Computes Table J. Default takes ~1.20 sec.
table_K_termio.bc Computes Table K. Default takes ~2.78 sec.
table_L_termio.bc Computes Table L. Default takes ~71.99 sec.
table_M_termio.bc Computes Table M. Default takes ~21.60 sec.

Functions inside Lawden.bc

For obvious reason, the mathematical notation used in the description will stick to notations used in Lawden's book. Ordered by the order of appearance in the code.

Name and Arguments Description
abs(x) Returns absolute value of $x$.
rad(x) Returns $x$ degree in unit of radian.
sqr(x) Returns $x^2$. Only occasionally used.
theta1(z,q) Returns $\theta_1(z,q)$ where $z$ in radian and $q$ is the real-valued nome.
theta3(z,q) Returns $\theta_3(z,q)$ where $z$ in radian and $q$ is the real-valued nome.
theta2(z,q) A lazy implementation of $\theta_2(z,q)$ based on $\theta_1(z,q)$.
theta4(z,q) A lazy implementation of $\theta_4(z,q)$ based on $\theta_3(z,q)$.
theta1deg(x,q) A wrapped function for Table A.
theta2deg(x,q) A wrapped function for Table A.
theta3deg(x,q) A wrapped function for Table A.
theta4deg(x,q) A wrapped function for Table A.
theta1_dz(z,q) Returns $\theta_1'(z,q)$.
theta1_dz2(z,q) Returns $\theta_1''(z,q)$.
theta2_dz(z,q) A lazy implementation of $\theta_2'(z,q)$. Probably not the principal branch.
theta2_dz2(z,q) A lazy implementation of $\theta_2''(z,q)$. Probably not the principal branch.
theta1_dz3(z,q) Returns $\theta_1^{(3)}(z,q)$.
theta3_dz(z,q) Returns $\theta_3'(z,q)$.
theta4_dz(z,q) A lazy implementation of $\theta_4'(z,q)$. Probably not the principal branch.
theta3_dz2(z,q) Returns $\theta_3''(z,q)$.
theta4_dz2(z,q) A lazy implementation of $\theta_4''(z,q)$. Probably not the principal branch.
k2q(k) Returns nome $q$ given modulus $k$. Implemented via bisection method, world be slow.
sn(u,k) Returns Jacobi's elliptic function $\operatorname{sn} u$. Appears in Table C.
cn(u,k) Returns Jacobi's elliptic function $\operatorname{cn} u$. Appears in Table C.
dn(u,k) Returns Jacobi's elliptic function $\operatorname{dn} u$. Appears in Table C.
smallk2bigk(k) Given modulus $k$, returns complete elliptic integral of the 1st kind $K$. For Table B.
smallk2bige(k) Given modulus $k$, returns complete elliptic integral of the 2nd kind $E$. For Table B.
jacobi_epsilon(u,k) Jacobi's Epsilon Function $E(u,k)$. For Table E.
jacobi_zeta(u,k) Jacobi's Zeta Function $Z(u,k)$. For Table E.
tabled1_1stkind_deg(phi,k) Legendre's incomplete elliptic integral of the 1st kind $F(\Phi,k)$, for Table D. Implemented via bisection method as suggested. Would be slow.
tabled2_integral_e(u,k) Legendre's incomplete elliptic integral of the 2nd kind $D(\Phi,k)$, for Table D. Implemented via calling tabled1_1stkind_deg(phi,k). Lawden used $D$ instead of the more commonly used $E$ in an attempt to avoid confusion.
tablef1_function(uow1,kappa) Returns $\omega_1^{-1}\sigma(u,\omega_1,i\kappa\omega_1)$ for Table F.
sigma1_function(uow1,kappa) Returns $\sigma_1(u,\omega_1,i\kappa\omega_1)$ for Table F.
sigma2_function(uow1,kappa) Returns $\sigma_2(u,\omega_1,i\kappa\omega_1)$ for Table F.
sigma3_function(uow1,kappa) Returns $\sigma_3(u,\omega_1,i\kappa\omega_1)$ for Table F.
tablef1_function_duow1(uow1,kappa) Returns the derivative of tablef1_function(uow1,kappa), for Table G.
tableg_function(uow1,kappa) Returns $\omega_1\zeta(u,\omega_1,i\kappa\omega_1)$ for Table G.
tableh1_p(uow1,kappa) Returns $\omega_1^2\wp(u,\omega_1,i\kappa\omega_1)$ for Table H. Problem: Two functions!?
tablef1_function_duow2(uow1,kappa) Returns the derivative of tablef1_function_duow1(uow1,kappa), for tableg_function_duow1(uow1,kappa) below.
tableg_function_duow1(uow1,kappa) Returns the derivative of tableg_function(uow1,kappa), for tableh_p(uow1,kappa) below.
tableh_p(uow1,kappa) Returns $\omega_1^2\wp(u,\omega_1,i\kappa\omega_1)$ for Table H. Problem: Two functions!?
tablek1_e1w1square(kappa) Returns $\omega_1^2 e_1$ for upper half of Table K.
tablek1_e2w1square(kappa) Returns $\omega_1^2 e_2$ for upper half of Table K.
tablek1_e3w1square(kappa) Returns $\omega_1^2 e_3$ for upper half of Table K.
tablek1_g2w1fourth(kappa) Returns $\omega_1^4 g_2$ for upper half of Table K.
tablek1_g3w1sixth(kappa) Returns $\omega_1^6 g_3$ for upper half of Table K.
tablei_p(uow1,kappa) Returns $\omega_1^2\wp(u+\omega_3,\omega_1,i\kappa\omega_1)$ for Table I.
psi(z,nu) A sum $\psi(z)$ defined in Lawden Chapter 6 Exercise 22. Important for computing $\wp(u,\omega_1,\frac12\omega_1(1+i\nu))$ without using complex numbers in BC for Table J-M.
psi_dz(z,nu) Returns $\psi'(z)$.
psi_dz2(z,nu) Returns $\psi''(z)$.
psi_dz3(z,nu) Returns $\psi^{(3)}(z)$.
tablej_p(uow1,nu) Returns $\omega_1^2\wp(u,\omega_1,\frac12\omega_1(1+i\nu))$ needed for Table J.
tablej_p_duow1(uow1,nu) Returns the derivative of tablej_p(uow1,nu).
tablek1_bigg(kappa) Returns $G$ for upper half of the Table K.
tablek2_e1w1square(nu) Returns $\omega_1^2 e_1$ for lower half of Table K.
tablek2_e2imagpart(nu) Returns $\Im(\omega_1^2 e_2)$ for lower half of Table K.
void tablek2_print_e2w1square(nu) Pretty-print of the complex conjugate pair on terminal for lower half of Table K.
tablek2_g2w1fourth(nu) Returns $\omega_1^4 g_2$ for lower half of Table K.
tablek2_g3w1sixth(nu) Returns $\omega_1^6 g_3$ for lower half of Table K.
tablek2_bigg(nu) Returns $G$ for lower half of the Table K.
bigg2nu_g3gt0(g) Solves $\nu$ given $G$ for upper-left of Table M. Implemented via bisection method, would be slow.
bigg2nu_g3lt0(g) Solves $\nu$ given $G$ for upper-right of Table M. Implemented via bisection method, would be slow.
bigg2kappa_g3gt0(g) Solves $\kappa$ given $G$ for lower-left of Table M. Implemented via bisection method, would be slow.
bigg2kappa_g3lt0(g) Solves $\kappa$ given $G$ for lower-right of Table M. Implemented via bisection method, would be slow.

About

Recreating code for reproducing Mathematical Tables at the back of Lawden's elliptical function book.


Languages

Language:Makefile 100.0%