solve_vie1
solve_vie1
solve_vie1(*, kernel, g=None, continuous=False, y0=None, dt=1.0, coll_setting=None, quadrature='product', samples_per_interval=None, kernel_interp_degree=None, mesh=None, coll_nodes=None, kernel_singularity=None, reuse_adaptive_blocks=True)
Solve a Volterra integral equation of the first kind.
by collocation: on each mesh interval \(y\) is a polynomial that satisfies the equation at the collocation nodes.
The inputs are either arrays of samples at \(t = 0, dt, 2\,dt, \ldots\)
(the sampled regime) or callables (the functional regime, solved on
the breakpoints mesh); see Notes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kernel
|
array_like or callable
|
\(K\). Sampled: shape |
required |
g
|
array_like or callable
|
\(g\), with \(g(0) = 0\). Sampled: |
None
|
continuous
|
bool
|
Use the continuous collocation method (Brunner's \(S_m^{(0)}\), degree
\(m\) on \(m\) nodes, one order higher) instead of the default
discontinuous one (\(S_{m-1}^{(-1)}\)). Needs |
False
|
y0
|
array_like
|
\(y(0)\), for |
None
|
dt
|
float
|
Sampled inputs: the sample spacing. Default 1.0. |
1.0
|
coll_setting
|
int or (int, sequence of int)
|
Sampled inputs: the collocation nodes |
None
|
quadrature
|
('product', 'collocation')
|
Sampled inputs: how the integrals are evaluated from the samples.
|
"product"
|
samples_per_interval
|
int
|
Sampled inputs: samples per mesh interval. A multiple of |
None
|
kernel_interp_degree
|
int
|
Sampled inputs, product quadrature: the degree of the kernel interpolant. Default: the number of nodes. |
None
|
mesh
|
array_like
|
Callable inputs: the mesh breakpoints, strictly increasing from 0 to \(T\). Required for callable inputs. |
None
|
coll_nodes
|
array_like
|
Callable inputs: node positions in \((0, 1]\), e.g.
|
None
|
kernel_singularity
|
(float, list, dict or callable)
|
Callable inputs: where the kernel is weakly singular, in
\(u = t - s\): a location, a list of locations, |
None
|
reuse_adaptive_blocks
|
bool
|
Callable inputs: on a uniform mesh, reuse adaptive-quadrature blocks across mesh intervals. Default True. |
True
|
Returns:
| Type | Description |
|---|---|
VolterraSolution
|
The solution: |
Raises:
| Type | Description |
|---|---|
TypeError
|
An argument of the wrong type (a float where an integer is needed, a non-bool flag, a non-numeric array), or a required one missing. |
ValueError
|
A wrong value: shapes that don't fit, an option from the other regime, a node set for which the method diverges, NaN or inf in the data, too few samples for one mesh interval. |
NotImplementedError
|
Mixed callable and sampled inputs, or an uncompiled setting under
|
LinAlgError
|
A collocation system is singular (e.g. an identically zero kernel). |
Warns:
| Type | Description |
|---|---|
AccuracyWarning
|
\(g(0) \ne 0\); a node set with \(\rho = +1\) (one order lower); \(K(0)\) too small for collocation quadrature; a singularity declared on a uniform mesh. |
PerformanceWarning
|
The numba fallback is used; or a declared exponent in
|
VolesWarning
|
A |
See Also
- solve_vie2, solve_vide: the other two equations.
- VolterraSolution: the returned object.
- optimal_graded_mesh: a mesh for a weakly singular kernel.
- radau_iia_nodes: node sets for
coll_nodes.
Notes
The regime is chosen by the input types: arrays give the sampled regime
(dt, coll_setting, quadrature, samples_per_interval,
kernel_interp_degree apply), callables the functional regime
(mesh, coll_nodes, kernel_singularity,
reuse_adaptive_blocks apply). An option from the other regime is
an error. Mixing callable and sampled inputs is not supported yet.
The discontinuous method converges iff its amplification factor \(\rho_m = (-1)^m \prod_{i=1}^{m} (1 - c_i)/c_i\) satisfies \(|\rho_m| \le 1\), and the continuous one iff \(\rho_{m-1} = (-1)^m \prod_{i<m} (1 - c_i)/c_i\) does, with \(c_m = 1\) (Brunner 2004, Theorems 2.4.2 and 2.4.5). The order is full for \(-1 \le \rho < 1\) and one lower at \(\rho = +1\). Radau IIA nodes have \(\rho_m = 0\); Gauss-Legendre nodes have \(\rho_m = (-1)^m\).
Examples:
Sampled data: with \(K = 1\) and \(g(t) = \sin t\) the solution is \(y = \cos t\).
>>> import numpy as np
>>> import voles
>>> t = np.linspace(0, 2, 201)
>>> sol = voles.solve_vie1(kernel=np.ones_like(t), g=np.sin(t), dt=t[1])
>>> sol
<VolterraSolution vie1, sampled, 22 intervals on [0, 2], degree 2, ...>
>>> sol.y.shape
(201,)
>>> print(f"{sol(1.0):.6f} {np.cos(1.0):.6f}")
0.540303 0.540302
Callables: Abel's equation, \(K(u) = u^{-1/2}\) and \(g(t) = \pi t / 2\), whose solution \(y = \sqrt{t}\) has an unbounded derivative at 0. Declare the singularity and grade the mesh to match it:
>>> mesh = voles.optimal_graded_mesh(alpha=0.5, t_end=1.0, n_intervals=16, order=3)
>>> sol = voles.solve_vie1(kernel=lambda u: u**-0.5, g=lambda t: np.pi / 2 * t,
... mesh=mesh, kernel_singularity={0.0: 0.5})
>>> print(f"{sol(0.25):.4f}")
0.5000
Source code in src/voles/_api.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 | |