summaryrefslogtreecommitdiff
path: root/series.mac
diff options
context:
space:
mode:
authorThomas Guillermo Albers Raviola <thomas@thomaslabs.org>2026-08-03 15:37:05 +0200
committerThomas Guillermo Albers Raviola <thomas@thomaslabs.org>2026-08-03 15:37:05 +0200
commit50e987414ad6b4978e37ef9915fe259f5aeef2e5 (patch)
treeb6c1c81e6d27d8753fc5cfd4d45cfe2aa27b1b93 /series.mac
parent5349d508b7daacb6622a3ce3ec9caf6c1fc2e1fc (diff)
Refactor wrap_exp
Diffstat (limited to 'series.mac')
-rw-r--r--series.mac28
1 files changed, 13 insertions, 15 deletions
diff --git a/series.mac b/series.mac
index 6ee8655..f757e4c 100644
--- a/series.mac
+++ b/series.mac
@@ -173,30 +173,28 @@ mul_series(factors, max_order) := block(
else (
exp(x*Φc[0])*horner_exp_series(x*(rhs(main_ansatz[5])-Φc[0]), r, n, -n, 2)));
-matchdeclare(m_any1, lambda ([e], freeof(β, γ, e)));
-matchdeclare(m_any2, lambda ([e], freeof(β, γ, e)));
-matchdeclare(m_any3, lambda ([e], freeof(β, γ, e)));
-matchdeclare(m_beta, lambda ([e], not freeof(β, e) and freeof(γ, e)));
-matchdeclare(m_gamma, lambda ([e], not freeof(γ, e) and freeof(β, e)));
+matchdeclare(m_any1, lambda ([e], freeof(β, γ, Φ, e)));
+matchdeclare(m_any2, lambda ([e], freeof(β, γ, Φ, e)));
+matchdeclare(m_any3, lambda ([e], freeof(β, γ, Φ, e)));
+matchdeclare(m_exp_expr, lambda ([e], e = β_expr or e = γ_expr or e = Φ_expr));
-/* Replace β and γ expressions into a symbolic representation */
-defrule(r_wrap_exp_β, exp(m_any1*m_beta), β_expr(m_any1));
-defrule(r_wrap_exp_γ, exp(m_any1*m_gamma), γ_expr(m_any1));
-defrule(r_wrap_exp_βγ, exp(m_any1*m_beta + m_any2*m_gamma),
- β_expr(m_any1)*γ_expr(m_any2));
-defrule(r_wrap_exp_βγ2, exp(m_any1*m_beta + m_any2*m_gamma + m_any3),
- exp(m_any3)*β_expr(m_any1)*γ_expr(m_any2));
+/* Replace β, γ and Φ expressions into a symbolic representation */
+defrule(r_wrap_exp,
+ exp(m_any1*β + m_any2*γ + m_any3*Φ),
+ β_expr(m_any1)*γ_expr(m_any2)*Φ_expr(m_any3));
+
+defrule(r_simp_exp_expr, m_exp_expr(0), 1);
/* Apply wrap rules to expression */
-wrap_exp(expr) := (
- apply1(expr, r_wrap_exp_β, r_wrap_exp_γ, r_wrap_exp_βγ, r_wrap_exp_βγ2));
+wrap_exp(expr) := apply1(expr, r_wrap_exp, r_simp_exp_expr);
/* Replace symbolic representations of β and γ expressions into their their
expansions */
defrule(r_exp_β_val, β_expr(m_any1), β_expr_val(m_any1, expansion_order));
defrule(r_exp_γ_val, γ_expr(m_any1), γ_expr_val(m_any1, expansion_order));
+defrule(r_exp_Φ_val, Φ_expr(m_any1), Φ_expr_val(m_any1, expansion_order));
-unwrap_exp(expr) := apply1(expr, r_exp_β_val, r_exp_γ_val);
+unwrap_exp(expr) := apply1(expr, r_exp_β_val, r_exp_γ_val, r_exp_Φ_val);
/**/