solve_vide
solve_vide
solve_vide(*, kernel, a=None, g=None, y0, 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 integro-differential equation.
by collocation: on each mesh interval \(y\) is a polynomial whose derivative satisfies the equation at the collocation nodes, continuous across the breakpoints.
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 |
a
|
(array_like, callable or constant)
|
\(a\). Sampled: |
None
|
g
|
array_like or callable
|
\(g\). Sampled: |
None
|
y0
|
array_like
|
\(y(0)\): scalar, |
required |
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 |
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_vie2: 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' = \int_0^t y(s)\,ds\) with \(y(0) = 1\) is \(y'' = y\), \(y'(0) = 0\), so \(y = \cosh t\).
>>> import numpy as np
>>> import voles
>>> t = np.linspace(0, 1, 101)
>>> sol = voles.solve_vide(kernel=np.ones_like(t), y0=1.0, dt=t[1])
>>> print(f"{sol(1.0):.8f} {np.cosh(1.0):.8f}")
1.54308063 1.54308063
Callables: \(y' = -\int_0^t y(s)\,ds\) with \(y(0) = 1\) gives
\(y = \cos t\). The solution is continuous, and its derivative comes from
VolterraSolution.to_ppoly:
>>> sol = voles.solve_vide(kernel=lambda u: -np.ones_like(u), y0=1.0,
... mesh=np.linspace(0, np.pi, 21))
>>> sol.continuous
True
>>> print(f"{sol(np.pi / 3):.4f} {sol.to_ppoly().derivative()(np.pi / 3):.4f}")
0.5000 -0.8660
Source code in src/voles/_api.py
825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 | |