it.grypho.scala.leonardo.ode
Members list
Type members
Classlikes
Symbolic node for the solution value of a first-order initial-value problem.
Symbolic node for the solution value of a first-order initial-value problem.
Represents y(target) where y satisfies y' = rhs(t, y), y(t0) = y0.
Both depVar (the dependent variable y) and indepVar (the independent variable t) are binders: they are excluded from children so that substitute and dependsOn never recurse into them, matching the convention of scalar._Derivative and scalar._Limit. The expression positions rhs, t0, y0, and target are ordinary children and may hold free variables (e.g. a symbolic target keeps the result closed-form).
Evaluation strategy (two tiers, in order):
- Closed-form via
solveODESymbolic: handlesy' = a*y + bfor constant (t-free)a,b; returns a symbolic expression that stays closed-form whent0/y0/targetare free. - Numeric RK4 via
solveODE: foldst0/y0/targetto concrete_Numbers and runs the integrator; returnsRight(_Number(result)). When neither applies,evalreturnsLeft(this)— the fixpoint convention shared with the transform nodes and thescalar._Functionalhierarchy.
Round-trip: toString emits ode(rhs, depVar, indepVar, t0, y0, target), which re-parses to an equivalent node.
Value parameters
- depVar
-
the dependent variable (the unknown function, e.g.
y) - indepVar
-
the independent variable (what
yis differentiated against, e.g.t) - rhs
-
the right-hand side
f(t, y)of the ODE - t0
-
the initial time point
- target
-
the point at which the solution is evaluated
- y0
-
the initial value
y(t0)
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass _Functionaltrait _Expressionclass Objecttrait Matchableclass AnyShow all
Value members
Concrete methods
Integrates y' = rhs(t, y), y(t0) = y0 to y(target) via RK4.
Integrates y' = rhs(t, y), y(t0) = y0 to y(target) via RK4.
Value parameters
- depVar
-
the dependent variable name (bound to the current
yat each stage) - env
-
the evaluation environment (provides precision and other bindings)
- indepVar
-
the independent variable name (bound to the current
tat each stage) - rhs
-
the right-hand side
f(t, y)as a symbolic expression - t0
-
the initial time
- target
-
the time at which the solution is requested
- y0
-
the initial value
y(t0)
Attributes
- Returns
-
Some(y(target))on success;Noneif any stage is non-numeric or non-finite
Closed-form tier for linear first-order IVPs y' = a(t)*y + b(t).
Closed-form tier for linear first-order IVPs y' = a(t)*y + b(t).
The right-hand side must be linear in the dependent variable (collect(rhs, depVar) yields at most a degree-1 coefficient vector [b, a]); non-linear shapes such as sin(y) or y^2 return None (the caller falls back to RK4).
Two sub-tiers:
-
Constant coefficients (
a,bfree of the independent variablet) — the exacttau = target - t0forms, avoiding any substitution:y' = a*y(b = 0):y = y0 * exp(a*tau)y' = b(a = 0):y = y0 + b*tauy' = a*y + b(general):y = (y0 + b/a) * exp(a*tau) - b/a
-
Variable coefficients (
aorbdepends ont) — the integrating-factor method. WithA = integral(a dt)andmu = exp(-A)the equation(mu*y)' = mu*bintegrates tomu*y = Q + C,Q = integral(mu*b dt); the initial condition fixesC = mu(t0)*y0 - Q(t0), giving
y(target) = (Q(target) - Q(t0) + y0*mu(t0)) / mu(target)
This closes whenever both integral(a dt) and integral(mu*b dt) reduce to a closed form (it reuses the full indefinite-integration engine, so e.g. mu*b = t*e^t is handled by integration by parts); if either stays symbolic, this tier returns None and the caller falls back to RK4.
In both tiers the result stays symbolic when target, y0, t0, or a coefficient is free, and folds to a _Number once everything is concrete.
Value parameters
- depVar
-
the dependent variable (
y) - env
-
the evaluation environment
- indepVar
-
the independent variable (
t) - rhs
-
the right-hand side of the ODE
y' = rhs - t0
-
the initial time (may be symbolic)
- target
-
the evaluation point (may be symbolic)
- y0
-
the initial value (may be symbolic)
Attributes
- Returns
-
Some(closed-form expression for y(target)), orNoneif not recognised