solve_vie2
solve_vie2
solve_vie2(*, kernel, g=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 second 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\). Sampled: |
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, an invalid node set, 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. |
Warns:
| Type | Description |
|---|---|
AccuracyWarning
|
A singularity declared on a uniform mesh. |
PerformanceWarning
|
The numba fallback is used; or a declared exponent in
|
VolesWarning
|
A |
See Also
- solve_vie1, solve_vide: the other two equations.
- VolterraSolution: the returned object.
- optimal_graded_mesh: a mesh for a weakly singular kernel.
- gauss_legendre_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.
Examples:
Sampled data: \(y(t) = 1 + \int_0^t y(s)\,ds\) has the solution \(e^t\).
>>> import numpy as np
>>> import voles
>>> t = np.linspace(0, 1, 101)
>>> sol = voles.solve_vie2(kernel=np.ones_like(t), g=np.ones_like(t), dt=t[1])
>>> sol
<VolterraSolution vie2, sampled, 50 intervals on [0, 1], degree 2, ...>
>>> print(f"{sol(1.0):.8f} {np.e:.8f}")
2.71828183 2.71828183
Callables, on a mesh of your choice: \(K(u) = e^{-u}\) and \(g = 1\) give \(y = 1 + t\), which the quadratic collocation polynomials represent exactly.
>>> sol = voles.solve_vie2(kernel=lambda u: np.exp(-u), g=lambda t: np.ones_like(t),
... mesh=np.linspace(0, 1, 11))
>>> sol.t.shape, sol.node_values.shape
((11,), (10, 3))
>>> print(f"{sol(0.55):.6f}")
1.550000
Source code in src/voles/_api.py
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 | |