"""Symbolic checks of formulas in F. M. Arscott, Proc. Roy. Soc. Edinburgh A 67(4) (1967) 265-276 (equation numbers are Arscott 1967's) against our v4 notation (mu,nu,lambda; b,c; alpha2,alpha3; k). Method: every trig/hyperbolic identity is rewritten in exponentials, theta -> -i log(E_theta), and the resulting rational function is cancelled EXACTLY (so PASS = exact symbolic identity). Run: python3 -u check_arscott1967.py """ import sympy as sp from sympy import sinh, cosh, sin, cos, exp, Rational as R al, be, ga, uu = sp.symbols('alpha beta gamma u') C, k, b, c = sp.symbols('C k b c', positive=True) lam_A, mu_A = sp.symbols('lambda_A mu_A') xi, eta, p = sp.symbols('xi eta p') a2, a3 = sp.symbols('alpha2 alpha3') Ea, Eb, Eg, Eu = sp.symbols('E_a E_b E_g E_u', positive=True) def to_rational(expr): e = sp.sympify(expr).rewrite(exp) for th, E in [(al, Ea), (be, Eb), (ga, Eg), (uu, Eu)]: e = e.subs(th, -sp.I*sp.log(E)) return sp.expand(sp.powsimp(sp.expand(e), force=True)) def is_zero(expr): return sp.cancel(sp.together(to_rational(expr))) == 0 def chk(expr, name, expect=True): ok = is_zero(expr) tag = "PASS" if ok else "FAIL" note = "" if ok == expect else " <-- UNEXPECTED" print(f"{tag} {name}{note}", flush=True) return ok # ------------------------------------------------------------ (1.1) coordinates X = R(1,2)*C*(cosh(2*al)+cos(2*be)-cosh(2*ga)) Y = 2*C*cosh(al)*cos(be)*sinh(ga) Z = 2*C*sinh(al)*sin(be)*cosh(ga) q = [al, be, ga] J = sp.Matrix([[sp.diff(f, v) for v in q] for f in (X, Y, Z)]) G = J.T*J Pa = cosh(2*ga)+cosh(2*al); Pb = cos(2*be)+cosh(2*ga); Pg = cosh(2*al)-cos(2*be) print("== (1.1): orthogonality and scale factors ==") for (i, j) in [(0,1),(0,2),(1,2)]: chk(G[i,j], f"(1.1) orthogonal: g_{i}{j} = 0") chk(G[0,0]-C**2*Pa*Pg, "h_alpha^2 = c^2 (cosh2g+cosh2a)(cosh2a-cos2b)") chk(G[1,1]-C**2*Pb*Pg, "h_beta^2 = c^2 (cos2b+cosh2g)(cosh2a-cos2b)") chk(G[2,2]-C**2*Pa*Pb, "h_gamma^2 = c^2 (cosh2g+cosh2a)(cos2b+cosh2g)") # Laplacian: sqrt(g) = h_a h_b h_g = C^3 Pa Pb Pg (all P>0), so lap V = (1/(C^2 P)) sum_i d_i(P_i' d_i V), P_i' = P/(P_j P_k) print(" => c^2 P_a P_b P_g * lap V = (cos2b+cosh2g)V_aa + (cosh2g+cosh2a)V_bb + (cosh2a-cos2b)V_gg [= (1.4) with k=0]") chk((C**3*Pa*Pb*Pg)**2 - G[0,0]*G[1,1]*G[2,2], "sqrt(g) = c^3 Pa Pb Pg (g = h_a^2 h_b^2 h_g^2)") print(" P_i' are independent of their own coordinate, so no first-derivative terms: this reproduces the left side of (1.4); the k^2 term of (1.4) is c^2 k^2 Pa Pb Pg V, matching the factor c^2 P.") # ------------------------------------------------------------ (1.6a-c): separation inside (1.4) print("\n== (1.4) -> (1.6a-c) ==") EA_p = lam_A + mu_A*cosh(2*al) - R(1,2)*k**2*C**2*cosh(4*al) # (1.6a): A'' = EA A EB_p = -(lam_A + mu_A*cos(2*be)) + R(1,2)*k**2*C**2*cos(4*be) # (1.6b): B'' = EB B EG_printed = lam_A + mu_A*cosh(2*ga) - R(1,2)*k**2*C**2*cosh(4*ga) # (1.6c) AS PRINTED (-lam - mu cosh2g + ...): C'' = +(lam + mu cosh2g - ...) C EG_flipped = lam_A - mu_A*cosh(2*ga) - R(1,2)*k**2*C**2*cosh(4*ga) # mu-term sign reversed Pfull = Pa*Pb*Pg def residual(EG): return Pb*EA_p + Pa*EB_p + Pg*EG + C**2*k**2*Pfull chk(residual(EG_printed), "(1.4) with (1.6a),(1.6b) and (1.6c) AS PRINTED", expect=False) chk(residual(EG_flipped), "(1.4) with (1.6a),(1.6b) and (1.6c) having +mu cosh 2g in the bracket (C''+(-lam+mu cosh2g+1/2 k^2c^2 cosh4g)C=0)") # ------------------------------------------------------------ (1.7) print("\n== (1.7): common form ==") target = lam_A + mu_A*cos(2*uu) - R(1,2)*k**2*C**2*cos(4*uu) chk(-EB_p.subs(be, uu) - target, "(1.7) from (1.6b), beta = u") chk(EA_p.subs(al, -sp.I*uu) - target, "(1.7) from (1.6a), i*alpha = u") chk(EG_flipped.subs(ga, (uu - sp.pi/2)/sp.I) - target, "(1.7) from corrected (1.6c), pi/2 + i*gamma = u") chk(EG_printed.subs(ga, (uu - sp.pi/2)/sp.I) - target, "(1.7) from (1.6c) as printed, pi/2 + i*gamma = u", expect=False) # ------------------------------------------------------------ dictionary to ours print("\n== dictionary to our (mu,nu,lambda; b,c; alpha2,alpha3; k) ==") Cb = b - c mu_s = b + Cb*sinh(al)**2; lam_s = c + Cb*cos(be)**2; nu_s = c - Cb*sinh(ga)**2 sub = {C: Cb} xo, yo, zo = Z.subs(sub), Y.subs(sub), X.subs(sub) + (b+c)/2 # denominators (b-c) -> multiply through chk((xo**2)*(b-c) - 4*(mu_s-b)*(b-nu_s)*(b-lam_s), "our x^2 = 4(mu-b)(b-nu)(b-lam)/(b-c) <- Arscott z (with c_A = b-c)") chk((yo**2)*(b-c) - 4*(mu_s-c)*(c-nu_s)*(lam_s-c), "our y^2 = 4(mu-c)(c-nu)(lam-c)/(b-c) <- Arscott y") chk(zo - (mu_s+nu_s+lam_s-b-c), "our z = mu+nu+lam-b-c <- Arscott x + (b+c)/2") # principal parts via chain rule (functions of the angle) Fv = sp.Function('Fv') def principal(s_expr, var): Fs = Fv(var) d1 = sp.diff(Fs, var)/sp.diff(s_expr, var) d2 = sp.diff(d1, var)/sp.diff(s_expr, var) return ((s_expr-b)*(s_expr-c)*d2 + R(1,2)*(2*s_expr-b-c)*d1), Fs signs = {} for nm, s_expr, var in [('mu(alpha)', mu_s, al), ('lambda(beta)', lam_s, be), ('nu(gamma)', nu_s, ga)]: expr, Fs = principal(s_expr, var) if is_zero(expr - R(1,4)*sp.diff(Fs, var, 2)): signs[nm] = +1 elif is_zero(expr + R(1,4)*sp.diff(Fs, var, 2)): signs[nm] = -1 else: signs[nm] = 0 print(f"PASS (s-b)(s-c)F_ss + (1/2)(2s-b-c)F_s = {'+' if signs[nm]>0 else '-'}(1/4) d2F/d{var}^2 for s = {nm}" if signs[nm] else f"FAIL principal part for {nm}", flush=True) lam_dict = 4*a2 - 2*a3*(b+c) - k**2*((b+c)**2 + R(1,2)*(b-c)**2) mu_dict = -2*(b-c)*(a3 + k**2*(b+c)) U = lambda s: k**2*s**2 + a3*s - a2 # the potential term of our unified ODE # alpha: F_aa + 4 U(mu) F = 0 (sign +1) chk(4*U(mu_s) - (-lam_A - mu_A*cosh(2*al) + R(1,2)*k**2*Cb**2*cosh(4*al)).subs({lam_A: lam_dict, mu_A: mu_dict}), "ours (s=mu) == Arscott (1.6a), with c_A = b-c and the dictionary below") # gamma: sign from principal part sg = signs['nu(gamma)'] chk(sg*4*U(nu_s) - (-lam_A - mu_A*cosh(2*ga) + R(1,2)*k**2*Cb**2*cosh(4*ga)).subs({lam_A: lam_dict, mu_A: mu_dict}), "ours (s=nu) == Arscott (1.6c) AS PRINTED", expect=False) chk(sg*4*U(nu_s) - (-lam_A + mu_A*cosh(2*ga) + R(1,2)*k**2*Cb**2*cosh(4*ga)).subs({lam_A: lam_dict, mu_A: mu_dict}), "ours (s=nu) == (1.6c) with +mu cosh2g (corrected sign)") # beta sb = signs['lambda(beta)'] chk(sb*4*U(lam_s) - (lam_A + mu_A*cos(2*be) - R(1,2)*k**2*Cb**2*cos(4*be)).subs({lam_A: lam_dict, mu_A: mu_dict}), "ours (s=lambda) == Arscott (1.6b)") print(" dictionary: c_A = b - c ; lambda_A =", sp.expand(lam_dict), "; mu_A =", sp.expand(mu_dict)) a_m = 4*a2 - 2*a3*(b+c); q_m = a3*(b-c) chk(lam_dict.subs(k, 0) - a_m, "k=0: lambda_A = a (a = 4 alpha2 - 2 alpha3 (b+c), our Mathieu eq.)") chk(mu_dict.subs(k, 0) + 2*q_m, "k=0: mu_A = -2q (q = alpha3 (b-c))") # inverse dictionary al2_sol = sp.solve([sp.Eq(lam_A, lam_dict), sp.Eq(mu_A, mu_dict)], [a2, a3], dict=True)[0] print(" inverse: alpha3 =", sp.simplify(al2_sol[a3]), " ; alpha2 =", sp.simplify(al2_sol[a2])) print(" xi^2 = -4 k^2 c_A^2 = -4 k^2 (b-c)^2 (from (2.1): 2ikc = xi); real xi <=> k^2 < 0", flush=True) # ------------------------------------------------------------ Ince form (2.1)-(2.5) print("\n== Ince form (2.1)-(2.5) ==") lam_21 = eta - xi**2/8; mu_21 = -(p+1)*xi Q17 = lam_21 + mu_21*cos(2*uu) - R(1,2)*(-xi**2/4)*cos(4*uu) # k^2 c^2 = -xi^2/4 Q22 = eta - xi**2/8 - (p+1)*xi*cos(2*uu) + xi**2/8*cos(4*uu) chk(Q17 - Q22, "(2.2) follows from (1.7) with (2.1)") def subs3(Q, s1, s2, s3): if s1: Q = Q.subs(xi, -xi) if s2: Q = Q.subs(p, -p-2) if s3: Q = Q.subs(uu, sp.pi/2 + uu) return Q for combo in [(1,1,0),(1,0,1),(0,1,1)]: chk(subs3(Q22, *combo) - Q22, f"(2.3): substitutions {combo} (xi->-xi, p->-p-2, u->pi/2+u) leave (2.2) unchanged") chk(subs3(Q22, 1,1,1) - Q22, "(2.3): all three together leave (2.2) unchanged", expect=False) v = sp.Function('v') wexpr = v(uu)*sp.exp(-xi/4*cos(2*uu)) ode22 = sp.diff(wexpr, uu, 2) + Q22*wexpr ode25 = sp.diff(v(uu), uu, 2) + xi*sin(2*uu)*sp.diff(v(uu), uu) + (eta - p*xi*cos(2*uu))*v(uu) chk(sp.expand(ode22*sp.exp(xi/4*cos(2*uu))) - ode25, "(2.4): w = v exp(-xi cos2u/4) turns (2.2) into Ince's equation (2.5)") # Recurrence (2.7a) by exact projection for rr in [2, 3, 4]: Am, A0, Ap = sp.symbols('A_m A_0 A_p') expr = 0 for A_, n in [(Am, 2*rr-2), (A0, 2*rr), (Ap, 2*rr+2)]: vv = A_*cos(n*uu) expr += sp.diff(vv, uu, 2) + xi*sin(2*uu)*sp.diff(vv, uu) + (eta - p*xi*cos(2*uu))*vv co = sp.simplify(sp.integrate(sp.expand(expr*cos(2*rr*uu)), (uu, 0, sp.pi))/(sp.pi/2)) printed = (R(1,2)*p - rr + 1)*xi*Am + (4*rr**2 - eta)*A0 + (R(1,2)*p + rr + 1)*xi*Ap ok = sp.expand(co + printed) == 0 print(("PASS" if ok else "FAIL") + f" (2.7a), r={rr}: coefficient of cos(2ru) in (2.5) equals -[(p/2-r+1)xi A_(2r-2) + (4r^2-eta)A_2r + (p/2+r+1)xi A_(2r+2)]", flush=True) # (5.1) Gp, Gpp, Gv = sp.symbols('Gp Gpp Gv') v1 = -sin(uu)*Gp; v2 = sin(uu)**2*Gpp - cos(uu)*Gp lhs = v2 + xi*sin(2*uu)*v1 + (eta - p*xi*cos(2*uu))*Gv tt = cos(uu) lhs51 = (1-tt**2)*Gpp - tt*(2*xi + 1 - 2*xi*tt**2)*Gp + (eta + p*xi - 2*p*xi*tt**2)*Gv chk(lhs - lhs51, "(5.1): Ince's equation with t = cos u") # (5.4): exponents at t = infinity t, s_ = sp.symbols('t s_') def exps(Yf): ode = (1-t**2)*sp.diff(Yf, t, 2) - t*(2*xi + 1 - 2*xi*t**2)*sp.diff(Yf, t) + (eta + p*xi - 2*p*xi*t**2)*Yf return sp.expand(sp.simplify(ode/Yf)) e1 = exps(t**s_); e2 = exps(sp.exp(xi*t**2)*t**s_) print(" (5.4a) Y1 ~ t^s : leading coefficient (t^2) =", sp.factor(e1.coeff(t, 2)), "-> identically 0 (leading order balances; exponent fixed at next order)") print(" (5.4b) Y2 ~ e^{xi t^2} t^s : coefficient of t^2 =", sp.factor(e2.coeff(t, 2)), " -> s =", sp.solve(e2.coeff(t, 2), s_), " (Arscott: -p-2)") # next order for Y1: t^p (1 + c/t^2): test exponent s=p solves the recurrence (5.5) first line c0, c2 = sp.symbols('c0 c2') Y1 = t**s_*(c0 + c2/t**2) ode = (1-t**2)*sp.diff(Y1, t, 2) - t*(2*xi + 1 - 2*xi*t**2)*sp.diff(Y1, t) + (eta + p*xi - 2*p*xi*t**2)*Y1 ode = sp.expand(sp.simplify(ode/t**s_)) cc = ode.coeff(t, 2) print(" (5.4a) leading t^2 term of ODE for Y1=t^s(c0+c2/t^2):", sp.factor(cc), "| t^0 term:", sp.factor(ode.coeff(t, 0))) print("\nDONE", flush=True)