diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2026-01-17 18:28:35 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2026-01-17 18:28:35 -0500 |
| commit | 1c5caa656d9eb4bd851df946854fbd2bf5dbf3b1 (patch) | |
| tree | 65790fa223fd8edd974c383021cb295c9b34d80c | |
| parent | e5c597628e5fb03bff3a030d6f8c5d1ce58cad96 (diff) | |
Simplifying rules for exp/logconstructive-reals
| -rw-r--r-- | src/stdlib/reals.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/stdlib/reals.c b/src/stdlib/reals.c index 4c00acbf..4178011f 100644 --- a/src/stdlib/reals.c +++ b/src/stdlib/reals.c @@ -145,6 +145,31 @@ Real_t Real$simplify(Real_t x) { case SYM_POW: if (Real$obviously_equal(right, R(0))) return R(1); if (Real$obviously_equal(right, R(1))) return left; + if (Real$obviously_equal(left, Real$e)) return sym_to_real(.op = SYM_EXP, .left = right, .right = R(0)); + break; + case SYM_EXP: + if (Real$obviously_equal(left, R(0))) return R(1); + if (Real$obviously_equal(left, R(1))) return Real$e; + if (Real$is_symbolic(left)) { + symbolic_t *log = REAL_SYMBOLIC(left); + if (log->op == SYM_LOG) return log->left; + } + break; + case SYM_LOG: + if (Real$obviously_equal(left, R(1))) return R(0); + if (Real$is_symbolic(left)) { + symbolic_t *exp = REAL_SYMBOLIC(left); + if (exp->op == SYM_EXP) return exp->left; + } + break; + case SYM_LOG10: + if (Real$obviously_equal(left, R(1))) return R(0); + if (Real$is_symbolic(left)) { + symbolic_t *pow = REAL_SYMBOLIC(left); + if (pow->op == SYM_POW && Real$obviously_equal(pow->left, R(10))) { + return pow->right; + } + } break; case SYM_SIN: if (Real$obviously_equal(left, R(0))) return R(0); |
