bvp_eval
Builtin index · Signal processing
result = bvp_eval(sol, xq)
Input: sol, xq · Output: result
What it is
Evaluates a bvp solution at the query point(s) xq (a number or a vector) with the cubic Hermite interpolant that the residual estimate is based on, so it is as accurate as the solution itself between nodes. sol: the record returned by bvp; xq: numbers inside [x[0], x[end]].
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = bvp_eval(sol, xq) | sol —sol: the record returned by bvp.xq numberxq: numbers inside [x[0], x[end]]. | result number, vector, or matrix | Returns the value of y: for one unknown a number (xq a number) or a vector (xq a vector); for several unknowns a vector of the unknowns (xq a number) or a matrix with one row per unknown and one column per query point. Errors: sol not a bvp record, and a query point outside the solved interval. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
# y'' + y = 0, y(0) = 0, y(pi/2) = 1 (y = sin x), as the system y' = [y1, -y0]
function osc(x, y)
return [y[1], -y[0]]
end function
function ends(ya, yb)
return [ya[0], yb[0] - 1]
end function
b = bvp(osc, ends, linspace(0, pi/2, 11), zeros(2, 11))
print("{b.status} on {b.nodes} nodes") # converged on 41 nodes
print(bvp_eval(b, pi/4)[0] - sin(pi/4)) # -1.83e-09
c = chebdiff(16)
print(max(abs(c.D * exp(c.x) - exp(c.x)))) # 5.8e-14, spectral accuracy
print(integral2((x, y) := 1, -1, 1, (x) := -sqrt(1 - x^2), (x) := sqrt(1 - x^2))) # 3.141593, the unit disc
r = fminbnd((x) := cos(x), 3, 4)
print("{r.params} {r.converged}") # 3.141593 true
output
converged on 41 nodes -1.834181e-9 5.817569e-14 3.141593 3.141593 true
from signal-processing