real machine value of an expression, or null if not a real number
(e: Expression)
| 113 | // The general form Subst[u, expr, v] := u /. expr -> v replaces the |
| 114 | // subexpression `expr` (a non-variable, e.g. the expanded log argument |
| 115 | // c·dⁿ·(e+f·x)^{m·n}) with `v` — used by the 6 "power-in-log" / |
| 116 | // radical back-substitution rules (1.1.3.1 #44/#45, 1.1.3.2 #103/#104, |
| 117 | // 3.2.2 #15, 3.3 #60). Dispatching on args[1] here is essential: |
| 118 | // substituting ctx.x for those compound middles rewrites `x` itself and |
| 119 | // corrupts the antiderivative (spurious powers in the log argument). |
| 120 | const target = build(args[1], ctx); |
| 121 | if (target.symbol === ctx.x) return u.subs({ [ctx.x]: v }).evaluate(); |
| 122 | return replaceSubexpr(u, target, v).evaluate(); |
| 123 | } |
| 124 | case 'Rational': |
| 125 | // NOTE: ce.number() does not accept a MathJSON array (spins) — box |
| 126 | return ce.expr(json as any); |
no test coverage detected