diff --git a/README.md b/README.md index 3ce0308..1bbbf3a 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ doc_IVP tech ## Main IVP Solver Function `[t,y] = solve_ivp(f,[t0,tf],y0,h)`\ -`[t,y] = solve_ivp(f,{t0,C},y0,h)`\ +`[t,y] = solve_ivp(f,{t0,E},y0,h)`\ `[t,y] = solve_ivp(__,method)`\ `[t,y] = solve_ivp(__,method,wb)` @@ -37,7 +37,7 @@ doc_IVP tech ## Matrix-Valued IVP Solver Function `[t,M] = solve_ivp_matrix(F,[t0,tf],M0,h)`\ -`[t,M] = solve_ivp_matrix(F,{t0,C},M0,h)`\ +`[t,M] = solve_ivp_matrix(F,{t0,E},M0,h)`\ `[t,M] = solve_ivp_matrix(__,p,method)`\ `[t,M] = solve_ivp_matrix(__,p,method,wb)` diff --git a/Technical Documentation/Solving_Initial_Value_Problems_for_ODEs.pdf b/Technical Documentation/Solving_Initial_Value_Problems_for_ODEs.pdf index 953fe77..61193b3 100644 Binary files a/Technical Documentation/Solving_Initial_Value_Problems_for_ODEs.pdf and b/Technical Documentation/Solving_Initial_Value_Problems_for_ODEs.pdf differ diff --git a/docs/AB2_doc.html b/docs/AB2_doc.html index 8026389..0b48c09 100644 --- a/docs/AB2_doc.html +++ b/docs/AB2_doc.html @@ -6,7 +6,7 @@ AB2

IVP Solver Toolbox Documentation

Copyright © 2021 Tamas Kis

Contents

Technical Documentation

Click here.

Opening this documentation using the MATLAB Command Window.

To open the home page (this page) of the toolbox documentation in MATLAB, type

doc_IVP
 

in the Command Window. To open the documentation of a specific function with name function_name from the Command Window, type

doc_IVP function_name
 

To open the PDF file with the technical documentation (Solving_Initial_Value_Problems_for_ODEs.pdf) from the Command Window, type

doc_IVP tech
-

Installation

The toolbox can be downloaded from File Exchange or GitHub. The downloaded zip folder contains the following:

To install as a toolbox, simply open "IVP Solver Toolbox.mltbx" in the "INSTALL" folder. MATLAB will automatically perform the installation and add all the functions included in the toolbox to the MATLAB search path.

IVP Solvers

Utilities for IVP Solvers

Single-Step Methods

Multistep Predictor Methods

Multistep Predictor-Corrector Methods

Generating IVP Solver Equations

External Libraries

mat2vec_C

mat2vec_C

Transforms the condition function for a matrix-valued IVP into the condition function for its corresponding vector-valued IVP.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

Cv = mat2vec_C(Cm,p)
-

Description

Cv = mat2vec_C(Cm,p) transforms the condition function $C(t,\mathbf{M})$ (where $C:\mathrm{R}\times\mathrm{R}^{p\times r}\to\mathrm{B}$) for a matrix-valued IVP into a condition function $C(t,\mathbf{y})$ (where $C:\mathrm{R}\times\mathrm{R}^{pr}\to\mathrm{B}$) for its corresponding vector-valued IVP.

Input/Output Parameters

+

mat2vec_E

Transforms the event function for a matrix-valued IVP into the event function for its corresponding vector-valued IVP.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

Ev = mat2vec_E(Em,p)
+

Description

Ev = mat2vec_E(Em,p) transforms the event function $E(t,\mathbf{M})$ (where $E:\mathrm{R}\times\mathrm{R}^{p\times r}\to\mathrm{B}$) for a matrix-valued IVP into the event function $E(t,\mathbf{y})$ (where $E:\mathrm{R}\times\mathrm{R}^{pr}\to\mathrm{B}$) for its corresponding vector-valued IVP.

Input/Output Parameters

@@ -79,11 +79,11 @@ - - - + + + @@ -94,29 +94,28 @@ - - - + + +
InputCmcondition function for matrix-valued IVP () -
- inputs to Cm are the current time (t, 1×1 double) and the current state matrix (M, p×r double) -
- output of Cm is the evaluation of the condition function (C, 1×1 logical) at the current time/state
Emevent function for matrix-valued IVP () +
- inputs to Em are the current time (t, 1×1 double) and the current state matrix (M, p×r double) +
- output of Em is the evaluation of the event function (E, 1×1 logical) at the current time/state
1×1
function_handle
OutputCvcondition function for corresponding vector-valued IVP () -
- inputs to Cv are the current time (t, 1×1 double) and the current state vector (y, pr×1 double) -
- output of Cv is the evaluation of the condition function (C, 1×1 logical) at the current time/state
Evevent function for corresponding vector-valued IVP () +
- inputs to Ev are the current time (t, 1×1 double) and the current state vector (y, pr×1 double) +
- output of Ev is the evaluation of the event function (E, 1×1 logical) at the current time/state
1×1
function_handle
-

See also

mat2vec_IC | mat2vec_ode | vec2mat_sol

\ No newline at end of file diff --git a/docs/mat2vec_E_doc_eq00032832468601070543.png b/docs/mat2vec_E_doc_eq00032832468601070543.png new file mode 100644 index 0000000..31fa0e1 Binary files /dev/null and b/docs/mat2vec_E_doc_eq00032832468601070543.png differ diff --git a/docs/mat2vec_E_doc_eq07816092729369968159.png b/docs/mat2vec_E_doc_eq07816092729369968159.png new file mode 100644 index 0000000..e5cf138 Binary files /dev/null and b/docs/mat2vec_E_doc_eq07816092729369968159.png differ diff --git a/docs/mat2vec_E_doc_eq08948580053969620677.png b/docs/mat2vec_E_doc_eq08948580053969620677.png new file mode 100644 index 0000000..d5d9ddf Binary files /dev/null and b/docs/mat2vec_E_doc_eq08948580053969620677.png differ diff --git a/docs/mat2vec_E_doc_eq15271344992949193215.png b/docs/mat2vec_E_doc_eq15271344992949193215.png new file mode 100644 index 0000000..e16083c Binary files /dev/null and b/docs/mat2vec_E_doc_eq15271344992949193215.png differ diff --git a/docs/mat2vec_IC_doc.html b/docs/mat2vec_IC_doc.html index 962f8e3..4f97dd7 100644 --- a/docs/mat2vec_IC_doc.html +++ b/docs/mat2vec_IC_doc.html @@ -6,7 +6,7 @@ mat2vec_IC

mat2vec_IC

Transforms the initial condition for a matrix-valued IVP into the initial condition for the corresponding vector-valued IVP.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

y0 = mat2vec_IC(M0)
-

Description

y0 = mat2vec_IC(M0) transforms the initial condition $\mathbf{M}_{0}\in\mathrm{R}^{p\times r}$ for a matrix-valued IVP into the initial condition $\mathbf{y}_{0}\in\mathrm{R}^{pr}$ for the corresponding vector-valued IVP.

Input/Output Parameters

+

mat2vec_IC

Transforms the initial condition for a matrix-valued IVP into the initial condition for its corresponding vector-valued IVP.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

y0 = mat2vec_IC(M0)
+

Description

y0 = mat2vec_IC(M0) transforms the initial condition $\mathbf{M}_{0}\in\mathrm{R}^{p\times r}$ for a matrix-valued IVP into the initial condition $\mathbf{y}_{0}\in\mathrm{R}^{pr}$ for its corresponding vector-valued IVP.

Input/Output Parameters

@@ -92,11 +92,11 @@
pr×1
double
-

See also

mat2vec_C | mat2vec_ode | vec2mat_sol

\ No newline at end of file diff --git a/docs/mat2vec_IC_doc_eq01866163084224256806.png b/docs/mat2vec_IC_doc_eq01866163084224256806.png index a1339fa..c2672a6 100644 Binary files a/docs/mat2vec_IC_doc_eq01866163084224256806.png and b/docs/mat2vec_IC_doc_eq01866163084224256806.png differ diff --git a/docs/mat2vec_IC_doc_eq15282979089752469712.png b/docs/mat2vec_IC_doc_eq15282979089752469712.png index 4777e87..f6a0ef3 100644 Binary files a/docs/mat2vec_IC_doc_eq15282979089752469712.png and b/docs/mat2vec_IC_doc_eq15282979089752469712.png differ diff --git a/docs/mat2vec_fun_doc_eq01518063970584319034.png b/docs/mat2vec_fun_doc_eq01518063970584319034.png deleted file mode 100644 index 2bb7d42..0000000 Binary files a/docs/mat2vec_fun_doc_eq01518063970584319034.png and /dev/null differ diff --git a/docs/mat2vec_fun_doc_eq01774414981705130240.png b/docs/mat2vec_fun_doc_eq01774414981705130240.png deleted file mode 100644 index c21fd89..0000000 Binary files a/docs/mat2vec_fun_doc_eq01774414981705130240.png and /dev/null differ diff --git a/docs/mat2vec_fun_doc_eq03729901751903020778.png b/docs/mat2vec_fun_doc_eq03729901751903020778.png deleted file mode 100644 index 8cc2de8..0000000 Binary files a/docs/mat2vec_fun_doc_eq03729901751903020778.png and /dev/null differ diff --git a/docs/mat2vec_fun_doc_eq11546780198861005830.png b/docs/mat2vec_fun_doc_eq11546780198861005830.png deleted file mode 100644 index a41bcc2..0000000 Binary files a/docs/mat2vec_fun_doc_eq11546780198861005830.png and /dev/null differ diff --git a/docs/mat2vec_fun_doc_eq14844018579718567230.png b/docs/mat2vec_fun_doc_eq14844018579718567230.png deleted file mode 100644 index 49228b5..0000000 Binary files a/docs/mat2vec_fun_doc_eq14844018579718567230.png and /dev/null differ diff --git a/docs/mat2vec_fun_doc_eq15557481901179112500.png b/docs/mat2vec_fun_doc_eq15557481901179112500.png deleted file mode 100644 index bfbd061..0000000 Binary files a/docs/mat2vec_fun_doc_eq15557481901179112500.png and /dev/null differ diff --git a/docs/mat2vec_fun_doc_eq15903383774327063487.png b/docs/mat2vec_fun_doc_eq15903383774327063487.png deleted file mode 100644 index f0b0ea8..0000000 Binary files a/docs/mat2vec_fun_doc_eq15903383774327063487.png and /dev/null differ diff --git a/docs/mat2vec_fun_doc_eq16176746348441022933.png b/docs/mat2vec_fun_doc_eq16176746348441022933.png deleted file mode 100644 index a2bb481..0000000 Binary files a/docs/mat2vec_fun_doc_eq16176746348441022933.png and /dev/null differ diff --git a/docs/mat2vec_ode_doc.html b/docs/mat2vec_ode_doc.html index 40f2ac9..23baf8e 100644 --- a/docs/mat2vec_ode_doc.html +++ b/docs/mat2vec_ode_doc.html @@ -6,7 +6,7 @@ mat2vec_ode

mat2vec_ode

Transforms a matrix-valued ODE into a vector-valued ODE.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

f = mat2vec_ode(F,p)
-

Description

f = mat2vec_ode(F,p) transforms the matrix-valued ODE $d\mathbf{M}/dt=\mathbf{F}(t,\mathbf{M})$ (where $\mathbf{F}:\mathrm{R}\times\mathrm{R}^{p\times r}\to\mathrm{R}^{p\times r}$) into the vector-valued ODE $d\mathbf{y}/dt=\mathbf{f}(t,\mathbf{y})$ (where $\mathbf{f}:\mathrm{R}\times\mathrm{R}^{pr}\to\mathrm{R}^{pr}$). p specifies the number of rows of M.

Input/Output Parameters

+

mat2vec_ODE

Transforms a matrix-valued ODE into a vector-valued ODE.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

f = mat2vec_ODE(F,p)
+

Description

f = mat2vec_ODE(F,p) transforms the matrix-valued ODE $d\mathbf{M}/dt=\mathbf{F}(t,\mathbf{M})$ (where $\mathbf{F}:\mathrm{R}\times\mathrm{R}^{p\times r}\to\mathrm{R}^{p\times r}$) into the vector-valued ODE $d\mathbf{y}/dt=\mathbf{f}(t,\mathbf{y})$ (where $\mathbf{f}:\mathrm{R}\times\mathrm{R}^{pr}\to\mathrm{R}^{pr}$). p specifies the number of rows of M.

Input/Output Parameters

@@ -102,16 +102,16 @@
1×1
function_handle
-

See also

mat2vec_C | mat2vec_IC | vec2mat_sol

solve_ivp

solve_ivp

Solve initial value problems using fixed-step IVP solvers.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

[t,y] = solve_ivp(f,[t0,tf],y0,h)
-[t,y] = solve_ivp(f,{t0,C},y0,h)
+  

solve_ivp

Fixed-step IVP solvers for solving vector-valued initial value problems.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

[t,y] = solve_ivp(f,[t0,tf],y0,h)
+[t,y] = solve_ivp(f,{t0,E},y0,h)
 [t,y] = solve_ivp(__,method)
 [t,y] = solve_ivp(__,method,wb)
-

Description

[t,y] = solve_ivp(f,[t0,tf],y0,h) solves the IVP defined by f(t,y) from t0 until tf using the classic Runge-Kutta fourth-order method with an initial condition y0 and step size h.

[t,y] = solve_ivp(f,{t0,C},y0,h) does the same as the syntax above, but instead of terminating at a final time tf, the solver terminates once the condition function C(t,y) is no longer satisfied.

[t,y] = solve_ivp(...,method) can be used with either of the syntaxes above to specify the integration method (i.e. the function will use the specified integration method, instead of the classic Runge-Kutta fourth-order method used by the previous two syntaxes). Options for the integration method are listed in the "Input/Output Parameters" section.

[t,y] = solve_ivp(...,method,wb) can be used with any of the syntaxes above to define a waitbar. If wb is input as true, then a waitbar is displayed with the default message 'Solving IVP...'. To specify a custom waitbar message, input wb as a char array storing the desired message.

Input/Output Parameters

+

Description

[t,y] = solve_ivp(f,[t0,tf],y0,h) solves the IVP defined by f(t,y) from t0 until tf using the classic Runge-Kutta fourth-order method with an initial condition y0 and step size h.

[t,y] = solve_ivp(f,{t0,E},y0,h) does the same as the syntax above, but instead of terminating at a final time tf, the solver terminates once the event function E(t,y) is no longer satisfied.

[t,y] = solve_ivp(...,method) can be used with either of the syntaxes above to specify the integration method (i.e. the function will use the specified integration method, instead of the classic Runge-Kutta fourth-order method used by the previous two syntaxes). Options for the integration method are listed in the "Input/Output Parameters" section.

[t,y] = solve_ivp(...,method,wb) can be used with any of the syntaxes above to define a waitbar. If wb is input as true, then a waitbar is displayed with the default message 'Solving IVP...'. To specify a custom waitbar message, input wb as a char array storing the desired message.

Input/Output Parameters

@@ -103,8 +103,8 @@ - - + @@ -200,8 +200,8 @@ zlabel('$z$','Interpreter','latex','FontSize',18);

Example #2: Event detection.

Consider the initial value problem

$$\frac{dy}{dt}=y,\quad y(2)=3$$

Find the solution $y(t)$ until $y=10$.

First, let's define our ODE ($\frac{dy}{dt}=f(t,y)$) and initial condition in MATLAB.

f = @(t,y) y;
 y2 = 3;
-

Next, let's define the condition function, $C(t,y)$. Since we want to continue solving until $y=10$, we want the solver to run while $y\leq10$; this forms our condition. Therefore,

C = @(t,y) y <= 10;
-

Solving for $y$ using the Euler method with a step size of $h=0.01$,

[t,y] = solve_ivp(f,{2,C},y2,0.01,'Euler');
+

Next, let's define the event function, $E(t,y)$. Since we want to continue solving until $y=10$, we want the solver to run while $y\leq10$; this forms our condition. Therefore,

E = @(t,y) y <= 10;
+

Solving for $y$ using the Euler method with a step size of $h=0.01$,

[t,y] = solve_ivp(f,{2,E},y2,0.01,'Euler');
 

Plotting the solution,

figure;
 plot(t,y,'LineWidth',1.5);
 grid on;
@@ -214,34 +214,34 @@
 
 y10 =
 
-    0.0023
+   0.002269996488128
 
 

Confirming our result by solving the same ODE but from $t=10$ to $t=20$ and using our result for $y(10)$ as the initial condition,

[t,y] = solve_ivp(f,[10,20],y10,0.001,'ABM8');
 y20 = y(end)
 
 y20 =
 
-   50.0000
+  49.999999999999226
 
-

Example #4: Backward integration (event-detection case).

Once again, consider

$$\frac{dy}{dt}=y,\quad y(20)=50$$

Find $y(10)$ using an IVP solver with a condition function (i.e. event-detection).

First, let's define our ODE ($\frac{dy}{dt}=f(t,y)$) and initial condition in MATLAB.

f = @(t,y) y;
+

Example #4: Backward integration (event-detection case).

Once again, consider

$$\frac{dy}{dt}=y,\quad y(20)=50$$

Find $y(10)$ using an IVP solver with a event function (i.e. event-detection).

First, let's define our ODE ($\frac{dy}{dt}=f(t,y)$) and initial condition in MATLAB.

f = @(t,y) y;
 y20 = 50;
-

The event that terminates the solver is when $t=10$. Therefore, we define the condition function as

C = @(t,y) t > 10;
-

In the time-detection case (Example #3) we input [t0,tf] = [20,10], so the solver knew to integrate backwards in time since t0 > tf. Consequently, internally, the solver made the step size negative. However, for the event-detection case, just given t and C(t,y), the solver won't know to use a negative step size to integrate backwards in time. Therefore, we must manually specify a negative step size. Solving for $y(10)$,

[t,y] = solve_ivp(f,{20,C},y20,-0.001,'ABM8');
+

The event that terminates the solver is when $t=10$. Therefore, we define the event function as

E = @(t,y) t > 10;
+

In the time-detection case (Example #3) we input [t0,tf] = [20,10], so the solver knew to integrate backwards in time since t0 > tf. Consequently, internally, the solver made the step size negative. However, for the event-detection case, just given t and E(t,y), the solver won't know to use a negative step size to integrate backwards in time. Therefore, we must manually specify a negative step size. Solving for $y(10)$,

[t,y] = solve_ivp(f,{20,E},y20,-0.001,'ABM8');
 y10 = y(end)
 
 y10 =
 
-    0.0023
+   0.002272267619989
 
 

Note that this is the same result we obtained earlier in Example #3.

See also

solve_ivp_matrix

solve_ivp_matrix

solve_ivp_matrix

Solve matrix-valued initial value problems using fixed-step IVP solvers.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

[t,M] = solve_ivp_matrix(F,[t0,tf],M0,h)
-[t,M] = solve_ivp_matrix(F,{t0,C},M0,h)
+  

solve_ivp_matrix

Fixed-step IVP solvers for solving matrix-valued initial value problems.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

[t,M] = solve_ivp_matrix(F,[t0,tf],M0,h)
+[t,M] = solve_ivp_matrix(F,{t0,E},M0,h)
 [t,M] = solve_ivp_matrix(__,method)
 [t,M] = solve_ivp_matrix(__,method,wb)
-

Description

[t,M] = solve_ivp_matrix(F,[t0,tf],M0,h) solves the IVP defined by F(t,M) from t0 until tf using the classic Runge-Kutta fourth-order method with an initial condition M0 and step size h. This syntax assumes that the state matrix is a square matrix.

[t,M] = solve_ivp_matrix(F,{t0,C},M0,h) does the same as the syntax above, but instead of terminating at a final time tf, the solver terminates once the condition function C(t,y) is no longer satisfied. This syntax assumes that the state matrix ($\mathbf{M}$) is a square matrix.

[t,M] = solve_ivp_matrix(...,method) can be used with any of the syntaxes above to specify the integration method (i.e. the function will use the specified integration method, instead of the classic Runge-Kutta fourth-order method used by the previous two syntaxes). Options for the integration method are listed in the "Input/Output Parameters" section.

[t,M] = solve_ivp_matrix(...,method,wb) can be used with any of the syntaxes above to define a waitbar. If wb is input as true, then a waitbar is displayed with the default message 'Solving IVP...'. To specify a custom waitbar message, input wb as a char array storing the desired message.

Input/Output Parameters

+

Description

[t,M] = solve_ivp_matrix(F,[t0,tf],M0,h) solves the IVP defined by F(t,M) from t0 until tf using the classic Runge-Kutta fourth-order method with an initial condition M0 and step size h. This syntax assumes that the state matrix is a square matrix.

[t,M] = solve_ivp_matrix(F,{t0,E},M0,h) does the same as the syntax above, but instead of terminating at a final time tf, the solver terminates once the event function E(t,y) is no longer satisfied. This syntax assumes that the state matrix ($\mathbf{M}$) is a square matrix.

[t,M] = solve_ivp_matrix(...,method) can be used with any of the syntaxes above to specify the integration method (i.e. the function will use the specified integration method, instead of the classic Runge-Kutta fourth-order method used by the previous two syntaxes). Options for the integration method are listed in the "Input/Output Parameters" section.

[t,M] = solve_ivp_matrix(...,method,wb) can be used with any of the syntaxes above to define a waitbar. If wb is input as true, then a waitbar is displayed with the default message 'Solving IVP...'. To specify a custom waitbar message, input wb as a char array storing the desired message.

Input/Output Parameters

Ccondition function () + event function ()
- inputs are the current time (t, 1×1 double) and the current state vector (y, p×1 double)
- output is a 1×1 logical (true if solver should continue running, false if solver should terminate)
1×1
function_handle
@@ -103,8 +103,8 @@ - - + @@ -206,18 +206,18 @@
 P0 =
 
-    2.1471    1.1582
-    1.1582    1.2547
+   2.147130739665738   1.158223807741478
+   1.158223807741478   1.254683874725441
 
 

References

The example above is adapted from the following sources:

See also

solve_ivp

tableau2eqns

vec2mat_sol

Transforms the solution matrix for a vector-valued IVP into the solution array for the corresponding matrix-valued IVP.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

M = vec2mat_sol(y,p)
+  

vec2mat_sol

Transforms the solution matrix for a vector-valued IVP into the solution array for its corresponding matrix-valued IVP.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

M = vec2mat_sol(y,p)
 

Description

M = vec2mat_sol(y,p) transforms the solution matrix, $[\mathbf{y}]\in\mathrm{R}^{(N+1)\times pr}$ (y in MATLAB), for the vector-valued IVP into the solution array, $[\mathbf{M}]\in\mathrm{R}^{p\times r\times (N+1)}$ (M in MATLAB) for the corresponding matrix-valued IVP. p specifies the number of rows of M.

Input/Output Parameters

Ccondition function () + event function ()
- inputs are the current time (t, 1×1 double) and the current state matrix (M, p×r double)
- output is a 1×1 logical (true if solver should continue running, false if solver should terminate)
1×1
function_handle
@@ -98,11 +98,11 @@
p×r×(N+1)
double
-

Note

  • $\mathbf{M}\in\mathbf{R}^{p\times r}$
  • $\mathbf{y}\in\mathbf{R}^{pr}$
  • $\mathbf{t}\in\mathbf{R}^{N+1}$
  • The nth page of $[\mathbf{M}]$ stores the state matrix (i.e. the solution) corresponding to the nth time in $\mathbf{t}$.

See also

mat2vec_C | mat2vec_IC | mat2vec_ode

\ No newline at end of file diff --git a/docs/vec2mat_sol_doc_eq00614485794024923100.png b/docs/vec2mat_sol_doc_eq00614485794024923100.png index 41cb521..2c9b5b7 100644 Binary files a/docs/vec2mat_sol_doc_eq00614485794024923100.png and b/docs/vec2mat_sol_doc_eq00614485794024923100.png differ diff --git a/docs/vec2mat_sol_doc_eq01442555386716173869.png b/docs/vec2mat_sol_doc_eq01442555386716173869.png index 97e15a1..62b5e2b 100644 Binary files a/docs/vec2mat_sol_doc_eq01442555386716173869.png and b/docs/vec2mat_sol_doc_eq01442555386716173869.png differ diff --git a/docs/vec2mat_sol_doc_eq01518063970584319034.png b/docs/vec2mat_sol_doc_eq01518063970584319034.png deleted file mode 100644 index 04ffef0..0000000 Binary files a/docs/vec2mat_sol_doc_eq01518063970584319034.png and /dev/null differ diff --git a/docs/vec2mat_sol_doc_eq03729901751903020778.png b/docs/vec2mat_sol_doc_eq03729901751903020778.png deleted file mode 100644 index c18dc59..0000000 Binary files a/docs/vec2mat_sol_doc_eq03729901751903020778.png and /dev/null differ diff --git a/docs/vec2mat_sol_doc_eq04096253379015678133.png b/docs/vec2mat_sol_doc_eq04096253379015678133.png index d00193a..29fb9fd 100644 Binary files a/docs/vec2mat_sol_doc_eq04096253379015678133.png and b/docs/vec2mat_sol_doc_eq04096253379015678133.png differ diff --git a/docs/vec2mat_sol_doc_eq05510629066224650637.png b/docs/vec2mat_sol_doc_eq05510629066224650637.png deleted file mode 100644 index 723fad6..0000000 Binary files a/docs/vec2mat_sol_doc_eq05510629066224650637.png and /dev/null differ diff --git a/docs/vec2mat_sol_doc_eq07742130518583913975.png b/docs/vec2mat_sol_doc_eq07742130518583913975.png index d4fcf53..8d380b3 100644 Binary files a/docs/vec2mat_sol_doc_eq07742130518583913975.png and b/docs/vec2mat_sol_doc_eq07742130518583913975.png differ diff --git a/docs/vec2mat_sol_doc_eq08448184081582174560.png b/docs/vec2mat_sol_doc_eq08448184081582174560.png index 44b6506..7ebab34 100644 Binary files a/docs/vec2mat_sol_doc_eq08448184081582174560.png and b/docs/vec2mat_sol_doc_eq08448184081582174560.png differ diff --git a/docs/vec2mat_sol_doc_eq08980551379751452677.png b/docs/vec2mat_sol_doc_eq08980551379751452677.png index f49117a..7938078 100644 Binary files a/docs/vec2mat_sol_doc_eq08980551379751452677.png and b/docs/vec2mat_sol_doc_eq08980551379751452677.png differ diff --git a/docs/vec2mat_sol_doc_eq12196841189823136547.png b/docs/vec2mat_sol_doc_eq12196841189823136547.png deleted file mode 100644 index 4fd9af9..0000000 Binary files a/docs/vec2mat_sol_doc_eq12196841189823136547.png and /dev/null differ diff --git a/docs/vec2mat_sol_doc_eq14577781216167612366.png b/docs/vec2mat_sol_doc_eq14577781216167612366.png index 53e61fa..99b882f 100644 Binary files a/docs/vec2mat_sol_doc_eq14577781216167612366.png and b/docs/vec2mat_sol_doc_eq14577781216167612366.png differ diff --git a/toolbox/Integrator.m b/toolbox/Integrator.m deleted file mode 100644 index e670578..0000000 --- a/toolbox/Integrator.m +++ /dev/null @@ -1,178 +0,0 @@ -%========================================================================== -% -% Integrator Class defining an integrator. -% -% Copyright © 2022 Tamas Kis -% Last Update: 2022-09-17 -% Website: https://tamaskis.github.io -% Contact: tamas.a.kis@outlook.com -% -% TOOLBOX DOCUMENTATION: -% https://tamaskis.github.io/IVP_Solver_Toolbox-MATLAB/ -% -% TECHNICAL DOCUMENTATION: -% https://tamaskis.github.io/files/Solving_Initial_Value_Problems_for_ODEs.pdf -% -%========================================================================== - -classdef Integrator < handle - - % ----------- - % Properties. - % ----------- - - properties - dt % (1×1 double) macro step size - dtau % (1×1 double) micro step size - macro_step % (1×1 function_handle) obtains state vector or state matrix at next sample time using a single macro step - method % (char) integration method (defaults to 'RK4') - end - - % --------------- - % Public methods. - % --------------- - - methods (Access = public) - - function obj = Integrator(dt,method,dtau) - % obj = Integrator(dt,method,dtau) - % - % Constructor. - %-------------------------------------------------------------- - % - % ------ - % INPUT: - % ------ - % dt - (1×1 double) major time step, Δt - % method - (OPTIONAL) (char) integration method --> - % 'Euler', 'RK2', 'RK2 Heun', 'RK2 Ralston', 'RK3', - % 'RK3 Heun', 'RK3 Ralston', 'SSPRK3', 'RK4', - % 'RK4 Ralston', 'RK4 3/8', 'AB2', 'AB3', 'AB4', - % 'AB5', 'AB6', 'AB7', 'AB8', 'ABM2', 'ABM3', - % 'ABM4', 'ABM5', 'ABM6', 'ABM7', 'ABM8' (defaults - % to 'RK4') - % dtau - (OPTIONAL) (1×1 double) minor time step, Δτ - % (defaults to Δt/10) - % - % - % ------- - % OUTPUT: - % ------- - % obj - (1×1 Integrator) integrator object - % - %-------------------------------------------------------------- - - % defaults "method" to 'RK4' if not input - if (nargin < 2) || isempty(method) - obj.method = 'RK4'; - else - obj.method = method; - end - - % sets time step - obj.dt = dt; - - % sets micro time step (defaults to Δt/10) - if (nargin < 3) || isempty(dtau) - obj.dtau = dt/10; - else - obj.dtau = dtau; - end - - % sets up macro step function (NOTE: if the integration method - % is a multistep method, the macro step function will default - % to using RK4) - if strcmpi(obj.method,'Euler') - obj.macro_step = @(f,t,y) RK1_euler(f,t,xk,obj.dt); - elseif strcmpi(obj.method,'RK2') - obj.macro_step = @(f,t,y) RK2(f,t,xk,obj.dt); - elseif strcmpi(obj.method,'RK2 Heun') - obj.macro_step = @(f,t,y) RK2_heun(f,t,xk,obj.dt); - elseif strcmpi(obj.method,'RK2 Ralston') - obj.macro_step = @(f,t,y) RK2_ralston(f,t,xk,obj.dt); - elseif strcmpi(obj.method,'RK3') - obj.macro_step = @(f,t,y) RK3(f,t,xk,obj.dt); - elseif strcmpi(obj.method,'RK3 Heun') - obj.macro_step = @(f,t,y) RK3_heun(f,t,xk,obj.dt); - elseif strcmpi(obj.method,'RK3 Ralston') - obj.macro_step = @(f,t,y) RK3_ralston(f,t,xk,obj.dt); - elseif strcmpi(obj.method,'SSPRK3') - obj.macro_step = @(f,t,y) SSPRK3(f,t,xk,obj.dt); - elseif strcmpi(obj.method,'RK4') - obj.macro_step = @(f,t,t) RK4(f,t,xk,obj.dt); - elseif strcmpi(obj.method,'RK4 Ralston') - obj.macro_step = @(f,t,y) RK4_ralston(f,t,xk,obj.dt); - elseif strcmpi(obj.method,'RK4 3/8') - obj.macro_step = @(f,t,y) RK4_38(f,t,xk,obj.dt); - else - obj.macro_step = @(f,t,y) RK4(f,t,xk,obj.dt); - end - - end - - function y_next = micro_step_vector(obj,f,t,y) - % y_next = Integrator.micro_step_vector(f,t,y) - % - % Obtains state vector at next sample time using multiple micro - % steps. - %-------------------------------------------------------------- - % - % ------ - % INPUT: - % ------ - % f - (1×1 function_handle) dy/dt = f(t,y) --> - % multivariate, vector-valued function - % (f : ℝ×ℝᵖ → ℝᵖ) defining ODE - % t - (1×1 double) current time - % y - (p×1 double) state vector at current sample time - % - % ------- - % OUTPUT: - % ------- - % y_next - (p×1 double) state vector at next sample time - % - %-------------------------------------------------------------- - - % solves IVP from t to t + Δt with a step size of Δτ - [~,y_array] = solve_ivp(f,[t,t+obj.dt],y,obj.dtau,obj.method); - - % only keeps solution at t + Δt - y_next = y_array(end,:).'; - - end - - function M_next = micro_step_matrix(obj,F,t,M) - % M_next = Integrator.micro_step_matrix(f,t,y) - % - % Obtains state matrix at next sample time using multiple micro - % steps. - %-------------------------------------------------------------- - % - % ------ - % INPUT: - % ------ - % F - (1×1 function_handle) dM/dt = F(t,M) --> - % multivariate, matrix-valued function - % (F : ℝ×ℝᵖˣʳ → ℝᵖˣʳ) defining matrix-valued ODE - % t - (1×1 double) current time - % M - (p×r double) state matrix at current sample time - % - % ------- - % OUTPUT: - % ------- - % M_next - (p×r double) state matrix at next sample time - % - %-------------------------------------------------------------- - - % solves IVP from t to t + Δt with a step size of Δτ - [~,M_array] = solve_ivp_matrix(F,[t,t+obj.dt],M,obj.dtau,... - obj.method); - - % only keeps solution at t + Δt - M_next = M_array(:,:,end); - - end - - end - -end \ No newline at end of file diff --git a/toolbox/adamsbashforth/AB2.m b/toolbox/adamsbashforth/AB2.m index 2271e52..b01ee80 100644 --- a/toolbox/adamsbashforth/AB2.m +++ b/toolbox/adamsbashforth/AB2.m @@ -8,7 +8,7 @@ % See also AB3, AB4, AB5, AB6, AB7, AB8. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -23,8 +23,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % F - (p×3 double) F matrix for current sample time % --> columns 1-2: function evaluations at previous 2 sample diff --git a/toolbox/adamsbashforth/AB3.m b/toolbox/adamsbashforth/AB3.m index 572210b..ff216b4 100644 --- a/toolbox/adamsbashforth/AB3.m +++ b/toolbox/adamsbashforth/AB3.m @@ -8,7 +8,7 @@ % See also AB2, AB4, AB5, AB6, AB7, AB8. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -23,8 +23,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % F - (p×4 double) F matrix for current sample time % --> columns 1-3: function evaluations at previous 3 sample diff --git a/toolbox/adamsbashforth/AB4.m b/toolbox/adamsbashforth/AB4.m index 1ff1788..1969189 100644 --- a/toolbox/adamsbashforth/AB4.m +++ b/toolbox/adamsbashforth/AB4.m @@ -8,7 +8,7 @@ % See also AB2, AB3, AB5, AB6, AB7, AB8. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -23,8 +23,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % F - (p×5 double) F matrix for current sample time % --> columns 1-4: function evaluations at previous 4 sample diff --git a/toolbox/adamsbashforth/AB5.m b/toolbox/adamsbashforth/AB5.m index 0d61fb2..b28bd04 100644 --- a/toolbox/adamsbashforth/AB5.m +++ b/toolbox/adamsbashforth/AB5.m @@ -8,7 +8,7 @@ % See also AB2, AB3, AB4, AB6, AB7, AB8. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -23,8 +23,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % F - (p×6 double) F matrix for current sample time % --> columns 1-5: function evaluations at previous 5 sample diff --git a/toolbox/adamsbashforth/AB6.m b/toolbox/adamsbashforth/AB6.m index 10acc2e..7478e27 100644 --- a/toolbox/adamsbashforth/AB6.m +++ b/toolbox/adamsbashforth/AB6.m @@ -8,7 +8,7 @@ % See also AB2, AB3, AB4, AB5, AB7, AB8. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -23,8 +23,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % F - (p×7 double) F matrix for current sample time % --> columns 1-6: function evaluations at previous 6 sample diff --git a/toolbox/adamsbashforth/AB7.m b/toolbox/adamsbashforth/AB7.m index f0c51a8..1196533 100644 --- a/toolbox/adamsbashforth/AB7.m +++ b/toolbox/adamsbashforth/AB7.m @@ -8,7 +8,7 @@ % See also AB2, AB3, AB4, AB5, AB6, AB8. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -23,8 +23,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % F - (p×8 double) F matrix for current sample time % --> columns 1-7: function evaluations at previous 7 sample diff --git a/toolbox/adamsbashforth/AB8.m b/toolbox/adamsbashforth/AB8.m index cd31f9a..f45ee70 100644 --- a/toolbox/adamsbashforth/AB8.m +++ b/toolbox/adamsbashforth/AB8.m @@ -8,7 +8,7 @@ % See also AB2, AB3, AB4, AB5, AB6, AB7. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -23,8 +23,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % F - (p×9 double) F matrix for current sample time % --> columns 1-8: function evaluations at previous 8 sample diff --git a/toolbox/adamsbashforthmoulton/ABM2.m b/toolbox/adamsbashforthmoulton/ABM2.m index 7de6bd8..a883db2 100644 --- a/toolbox/adamsbashforthmoulton/ABM2.m +++ b/toolbox/adamsbashforthmoulton/ABM2.m @@ -8,7 +8,7 @@ % See also ABM3, ABM4, ABM5, ABM6, ABM7, ABM8. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -23,8 +23,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % F - (p×3 double) F matrix for current sample time % --> columns 1-2: function evaluations at previous 2 sample diff --git a/toolbox/adamsbashforthmoulton/ABM3.m b/toolbox/adamsbashforthmoulton/ABM3.m index 308ead7..db3780b 100644 --- a/toolbox/adamsbashforthmoulton/ABM3.m +++ b/toolbox/adamsbashforthmoulton/ABM3.m @@ -8,7 +8,7 @@ % See also ABM2, ABM4, ABM5, ABM6, ABM7, ABM8. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -23,8 +23,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % F - (p×4 double) F matrix for current sample time % --> columns 1-3: function evaluations at previous 3 sample diff --git a/toolbox/adamsbashforthmoulton/ABM4.m b/toolbox/adamsbashforthmoulton/ABM4.m index 1040b3e..0d56ccd 100644 --- a/toolbox/adamsbashforthmoulton/ABM4.m +++ b/toolbox/adamsbashforthmoulton/ABM4.m @@ -8,7 +8,7 @@ % See also ABM2, ABM3, ABM5, ABM6, ABM7, ABM8. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -23,8 +23,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % F - (p×5 double) F matrix for current sample time % --> columns 1-4: function evaluations at previous 4 sample diff --git a/toolbox/adamsbashforthmoulton/ABM5.m b/toolbox/adamsbashforthmoulton/ABM5.m index 2110ca9..1abf2d4 100644 --- a/toolbox/adamsbashforthmoulton/ABM5.m +++ b/toolbox/adamsbashforthmoulton/ABM5.m @@ -8,7 +8,7 @@ % See also ABM2, ABM3, ABM4, ABM6, ABM7, ABM8. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -23,8 +23,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % F - (p×6 double) F matrix for current sample time % --> columns 1-5: function evaluations at previous 5 sample diff --git a/toolbox/adamsbashforthmoulton/ABM6.m b/toolbox/adamsbashforthmoulton/ABM6.m index b65a407..8bd9d45 100644 --- a/toolbox/adamsbashforthmoulton/ABM6.m +++ b/toolbox/adamsbashforthmoulton/ABM6.m @@ -8,7 +8,7 @@ % See also ABM2, ABM3, ABM4, ABM5, ABM7, ABM8. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -23,8 +23,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % F - (p×7 double) F matrix for current sample time % --> columns 1-6: function evaluations at previous 6 sample diff --git a/toolbox/adamsbashforthmoulton/ABM7.m b/toolbox/adamsbashforthmoulton/ABM7.m index 41aa4d3..a252d4c 100644 --- a/toolbox/adamsbashforthmoulton/ABM7.m +++ b/toolbox/adamsbashforthmoulton/ABM7.m @@ -8,7 +8,7 @@ % See also ABM2, ABM3, ABM4, ABM5, ABM6, ABM8. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -23,8 +23,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % F - (p×8 double) F matrix for current sample time % --> columns 1-7: function evaluations at previous 7 sample diff --git a/toolbox/adamsbashforthmoulton/ABM8.m b/toolbox/adamsbashforthmoulton/ABM8.m index c28c76e..03e2318 100644 --- a/toolbox/adamsbashforthmoulton/ABM8.m +++ b/toolbox/adamsbashforthmoulton/ABM8.m @@ -8,7 +8,7 @@ % See also ABM2, ABM3, ABM4, ABM5, ABM6, ABM7. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -23,8 +23,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % F - (p×9 double) F matrix for current sample time % --> columns 1-8: function evaluations at previous 8 sample diff --git a/toolbox/doc/Solving_Initial_Value_Problems_for_ODEs.pdf b/toolbox/doc/Solving_Initial_Value_Problems_for_ODEs.pdf index 953fe77..61193b3 100644 Binary files a/toolbox/doc/Solving_Initial_Value_Problems_for_ODEs.pdf and b/toolbox/doc/Solving_Initial_Value_Problems_for_ODEs.pdf differ diff --git a/toolbox/doc/html_IVP/AB2_doc.html b/toolbox/doc/html_IVP/AB2_doc.html index 8026389..0b48c09 100644 --- a/toolbox/doc/html_IVP/AB2_doc.html +++ b/toolbox/doc/html_IVP/AB2_doc.html @@ -6,7 +6,7 @@ AB2

IVP Solver Toolbox Documentation

Copyright © 2021 Tamas Kis

Contents

Technical Documentation

Click here.

Opening this documentation using the MATLAB Command Window.

To open the home page (this page) of the toolbox documentation in MATLAB, type

doc_IVP
 

in the Command Window. To open the documentation of a specific function with name function_name from the Command Window, type

doc_IVP function_name
 

To open the PDF file with the technical documentation (Solving_Initial_Value_Problems_for_ODEs.pdf) from the Command Window, type

doc_IVP tech
-

Installation

The toolbox can be downloaded from File Exchange or GitHub. The downloaded zip folder contains the following:

  • docs → Contains the HTML documentation needed by GitHub to deploy the online version of the toolbox documentation.
  • examples → Contains examples for using various functions of the IVP Solver Toolbox, as well as examples for some more elementary concepts discussed in the technical documentation.
  • INSTALL → Contains the toolbox installer (IVP Solver Toolbox.mltbx).
  • licenses → Contains the software licenses.
  • README.md → Markdown documentation for GitHub repository.
  • Technical Documentation → Contains the technical documentation (Solving_Initial_Value_Problems_for_ODEs.pdf).
  • toolbox → Contains all the functions specific to this toolbox.
  • toolbox/doc → Contains a copy of all the files and functions needed to open both the toolbox documentation and the technical documentation directly from the MATLAB command window using the doc_IVP function.
  • toolbox/lib → External libraries/functions required by this toolbox.

To install as a toolbox, simply open "IVP Solver Toolbox.mltbx" in the "INSTALL" folder. MATLAB will automatically perform the installation and add all the functions included in the toolbox to the MATLAB search path.

IVP Solvers

  • solve_ivp Solve initial value problems using fixed-step IVP solvers.
  • solve_ivp_matrix Solve matrix-valued initial value problems using fixed-step IVP solvers.

Utilities for IVP Solvers

  • expand_ivp_arrays Expands the arrays storing the IVP solution.
  • mat2vec_fun Transforms a matrix-valued ODE into a vector-valued ODE.
  • mat2vec_IC Transforms the initial condition for a matrix-valued IVP into the initial condition for the corresponding vector-valued IVP.
  • mat2vec_C Transforms the condition function for a matrix-valued IVP into the condition function for the corresponding vector-valued IVP.
  • vec2mat_sol Transforms the solution matrix for a vector-valued IVP into the solution array for the corresponding matrix-valued IVP.

Single-Step Methods

  • RK1_euler Propagates the state vector forward one time step using the Euler method (1st-order).
  • RK2 Propagates the state vector forward one time step using the midpoint method (2nd-order).
  • RK2_heun Propagates the state vector forward one time step using Heun's second-order method (2nd-order).
  • RK2_ralston Propagates the state vector forward one time step using Ralston's second-order method (2nd-order).
  • RK3 Propagates the state vector forward one time step using (Kutta's) Runge-Kutta third-order method (3rd-order).
  • RK3_heun Propagates the state vector forward one time step using Heun's third-order method (3rd-order).
  • RK3_ralston Propagates the state vector forward one time step using Ralston's third-order method (3rd-order).
  • SSPRK3 Propagates the state vector forward one time step using the strong stability preserving Runge-Kutta third-order method (3rd-order).
  • RK4 Propagates the state vector forward one time step using the (classic) Runge-Kutta fourth-order method (4th-order).
  • RK4_ralston Propagates the state vector forward one time step using Ralston's fourth-order method (4th-order).
  • RK4_38 Propagates the state vector forward one time step using the 3/8-rule Runge-Kutta fourth-order method (4th-order).

Multistep Predictor Methods

  • AB2 Propagates the state vector forward one time step using the Adams-Bashforth 2nd-order method.
  • AB3 Propagates the state vector forward one time step using the Adams-Bashforth 3rd-order method.
  • AB4 Propagates the state vector forward one time step using the Adams-Bashforth 4th-order method.
  • AB5 Propagates the state vector forward one time step using the Adams-Bashforth 5th-order method.
  • AB6 Propagates the state vector forward one time step using the Adams-Bashforth 6th-order method.
  • AB7 Propagates the state vector forward one time step using the Adams-Bashforth 7th-order method.
  • AB8 Propagates the state vector forward one time step using the Adams-Bashforth 8th-order method.

Multistep Predictor-Corrector Methods

  • ABM2 Propagates the state vector forward one time step using the Adams-Bashforth-Moulton 2nd-order method.
  • ABM3 Propagates the state vector forward one time step using the Adams-Bashforth-Moulton 3rd-order method.
  • ABM4 Propagates the state vector forward one time step using the Adams-Bashforth-Moulton 4th-order method.
  • ABM5 Propagates the state vector forward one time step using the Adams-Bashforth-Moulton 5th-order method.
  • ABM6 Propagates the state vector forward one time step using the Adams-Bashforth-Moulton 6th-order method.
  • ABM7 Propagates the state vector forward one time step using the Adams-Bashforth-Moulton 7th-order method.
  • ABM8 Propagates the state vector forward one time step using the Adams-Bashforth-Moulton 8th-order method.

Generating IVP Solver Equations

External Libraries

mat2vec_ode

mat2vec_ode

Transforms a matrix-valued ODE into a vector-valued ODE.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

f = mat2vec_ode(F,p)
-

Description

f = mat2vec_ode(F,p) transforms the matrix-valued ODE $d\mathbf{M}/dt=\mathbf{F}(t,\mathbf{M})$ (where $\mathbf{F}:\mathrm{R}\times\mathrm{R}^{p\times r}\to\mathrm{R}^{p\times r}$) into the vector-valued ODE $d\mathbf{y}/dt=\mathbf{f}(t,\mathbf{y})$ (where $\mathbf{f}:\mathrm{R}\times\mathrm{R}^{pr}\to\mathrm{R}^{pr}$). p specifies the number of rows of M.

Input/Output Parameters

+

mat2vec_E

Transforms the event function for a matrix-valued IVP into the event function for its corresponding vector-valued IVP.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

Ev = mat2vec_E(Em,p)
+

Description

Ev = mat2vec_E(Em,p) transforms the event function $E(t,\mathbf{M})$ (where $E:\mathrm{R}\times\mathrm{R}^{p\times r}\to\mathrm{B}$) for a matrix-valued IVP into the event function $E(t,\mathbf{y})$ (where $E:\mathrm{R}\times\mathrm{R}^{pr}\to\mathrm{B}$) for its corresponding vector-valued IVP.

Input/Output Parameters

@@ -79,11 +79,11 @@ - - - + + + @@ -94,29 +94,29 @@ - - - + + +
InputFmultivariate, matrix-valued function () defining the ordinary differential equation -
- inputs to F are the current time (t, 1×1 double) and the current state matrix (M, p×r double) -
- output of F is the state matrix derivative (dMdt, p×r double) at the current time/state
Emevent function for matrix-valued IVP () +
- inputs to Em are the current time (t, 1×1 double) and the current state matrix (M, p×r double) +
- output of Em is the evaluation of the event function (E, 1×1 logical) at the current time/state
1×1
function_handle
Outputfmultivariate, vector-valued function () defining the ordinary differential equation -
- inputs to f are the current time (t, 1×1 double) and the current state vector (y, pr×1 double) -
- output of f is the state vector derivative (dydt, pr×1 double) at the current time/state
Evevent function for corresponding vector-valued IVP () +
- inputs to Ev are the current time (t, 1×1 double) and the current state vector (y, pr×1 double) +
- output of Ev is the evaluation of the event function (E, 1×1 logical) at the current time/state
1×1
function_handle
-

See also

mat2vec_IC | mat2vec_C | vec2mat_sol

\ No newline at end of file diff --git a/toolbox/doc/html_IVP/mat2vec_E_doc_eq00032832468601070543.png b/toolbox/doc/html_IVP/mat2vec_E_doc_eq00032832468601070543.png new file mode 100644 index 0000000..31fa0e1 Binary files /dev/null and b/toolbox/doc/html_IVP/mat2vec_E_doc_eq00032832468601070543.png differ diff --git a/toolbox/doc/html_IVP/mat2vec_E_doc_eq07816092729369968159.png b/toolbox/doc/html_IVP/mat2vec_E_doc_eq07816092729369968159.png new file mode 100644 index 0000000..e5cf138 Binary files /dev/null and b/toolbox/doc/html_IVP/mat2vec_E_doc_eq07816092729369968159.png differ diff --git a/toolbox/doc/html_IVP/mat2vec_E_doc_eq08948580053969620677.png b/toolbox/doc/html_IVP/mat2vec_E_doc_eq08948580053969620677.png new file mode 100644 index 0000000..d5d9ddf Binary files /dev/null and b/toolbox/doc/html_IVP/mat2vec_E_doc_eq08948580053969620677.png differ diff --git a/toolbox/doc/html_IVP/mat2vec_E_doc_eq15271344992949193215.png b/toolbox/doc/html_IVP/mat2vec_E_doc_eq15271344992949193215.png new file mode 100644 index 0000000..e16083c Binary files /dev/null and b/toolbox/doc/html_IVP/mat2vec_E_doc_eq15271344992949193215.png differ diff --git a/toolbox/doc/html_IVP/mat2vec_IC_doc.html b/toolbox/doc/html_IVP/mat2vec_IC_doc.html index 962f8e3..4f97dd7 100644 --- a/toolbox/doc/html_IVP/mat2vec_IC_doc.html +++ b/toolbox/doc/html_IVP/mat2vec_IC_doc.html @@ -6,7 +6,7 @@ mat2vec_IC

mat2vec_IC

Transforms the initial condition for a matrix-valued IVP into the initial condition for the corresponding vector-valued IVP.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

y0 = mat2vec_IC(M0)
-

Description

y0 = mat2vec_IC(M0) transforms the initial condition $\mathbf{M}_{0}\in\mathrm{R}^{p\times r}$ for a matrix-valued IVP into the initial condition $\mathbf{y}_{0}\in\mathrm{R}^{pr}$ for the corresponding vector-valued IVP.

Input/Output Parameters

+

mat2vec_IC

Transforms the initial condition for a matrix-valued IVP into the initial condition for its corresponding vector-valued IVP.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

y0 = mat2vec_IC(M0)
+

Description

y0 = mat2vec_IC(M0) transforms the initial condition $\mathbf{M}_{0}\in\mathrm{R}^{p\times r}$ for a matrix-valued IVP into the initial condition $\mathbf{y}_{0}\in\mathrm{R}^{pr}$ for its corresponding vector-valued IVP.

Input/Output Parameters

@@ -92,11 +92,11 @@
pr×1
double
-

See also

mat2vec_C | mat2vec_ode | vec2mat_sol

\ No newline at end of file diff --git a/toolbox/doc/html_IVP/mat2vec_IC_doc_eq01866163084224256806.png b/toolbox/doc/html_IVP/mat2vec_IC_doc_eq01866163084224256806.png index a1339fa..c2672a6 100644 Binary files a/toolbox/doc/html_IVP/mat2vec_IC_doc_eq01866163084224256806.png and b/toolbox/doc/html_IVP/mat2vec_IC_doc_eq01866163084224256806.png differ diff --git a/toolbox/doc/html_IVP/mat2vec_IC_doc_eq15282979089752469712.png b/toolbox/doc/html_IVP/mat2vec_IC_doc_eq15282979089752469712.png index 4777e87..f6a0ef3 100644 Binary files a/toolbox/doc/html_IVP/mat2vec_IC_doc_eq15282979089752469712.png and b/toolbox/doc/html_IVP/mat2vec_IC_doc_eq15282979089752469712.png differ diff --git a/toolbox/doc/html_IVP/mat2vec_ode_doc.html b/toolbox/doc/html_IVP/mat2vec_ode_doc.html index 40f2ac9..23baf8e 100644 --- a/toolbox/doc/html_IVP/mat2vec_ode_doc.html +++ b/toolbox/doc/html_IVP/mat2vec_ode_doc.html @@ -6,7 +6,7 @@ mat2vec_ode

mat2vec_ode

Transforms a matrix-valued ODE into a vector-valued ODE.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

f = mat2vec_ode(F,p)
-

Description

f = mat2vec_ode(F,p) transforms the matrix-valued ODE $d\mathbf{M}/dt=\mathbf{F}(t,\mathbf{M})$ (where $\mathbf{F}:\mathrm{R}\times\mathrm{R}^{p\times r}\to\mathrm{R}^{p\times r}$) into the vector-valued ODE $d\mathbf{y}/dt=\mathbf{f}(t,\mathbf{y})$ (where $\mathbf{f}:\mathrm{R}\times\mathrm{R}^{pr}\to\mathrm{R}^{pr}$). p specifies the number of rows of M.

Input/Output Parameters

+

mat2vec_ODE

Transforms a matrix-valued ODE into a vector-valued ODE.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

f = mat2vec_ODE(F,p)
+

Description

f = mat2vec_ODE(F,p) transforms the matrix-valued ODE $d\mathbf{M}/dt=\mathbf{F}(t,\mathbf{M})$ (where $\mathbf{F}:\mathrm{R}\times\mathrm{R}^{p\times r}\to\mathrm{R}^{p\times r}$) into the vector-valued ODE $d\mathbf{y}/dt=\mathbf{f}(t,\mathbf{y})$ (where $\mathbf{f}:\mathrm{R}\times\mathrm{R}^{pr}\to\mathrm{R}^{pr}$). p specifies the number of rows of M.

Input/Output Parameters

@@ -102,16 +102,16 @@
1×1
function_handle
-

See also

mat2vec_C | mat2vec_IC | vec2mat_sol

solve_ivp

solve_ivp

Solve initial value problems using fixed-step IVP solvers.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

[t,y] = solve_ivp(f,[t0,tf],y0,h)
-[t,y] = solve_ivp(f,{t0,C},y0,h)
+  

solve_ivp

Fixed-step IVP solvers for solving vector-valued initial value problems.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

[t,y] = solve_ivp(f,[t0,tf],y0,h)
+[t,y] = solve_ivp(f,{t0,E},y0,h)
 [t,y] = solve_ivp(__,method)
 [t,y] = solve_ivp(__,method,wb)
-

Description

[t,y] = solve_ivp(f,[t0,tf],y0,h) solves the IVP defined by f(t,y) from t0 until tf using the classic Runge-Kutta fourth-order method with an initial condition y0 and step size h.

[t,y] = solve_ivp(f,{t0,C},y0,h) does the same as the syntax above, but instead of terminating at a final time tf, the solver terminates once the condition function C(t,y) is no longer satisfied.

[t,y] = solve_ivp(...,method) can be used with either of the syntaxes above to specify the integration method (i.e. the function will use the specified integration method, instead of the classic Runge-Kutta fourth-order method used by the previous two syntaxes). Options for the integration method are listed in the "Input/Output Parameters" section.

[t,y] = solve_ivp(...,method,wb) can be used with any of the syntaxes above to define a waitbar. If wb is input as true, then a waitbar is displayed with the default message 'Solving IVP...'. To specify a custom waitbar message, input wb as a char array storing the desired message.

Input/Output Parameters

+

Description

[t,y] = solve_ivp(f,[t0,tf],y0,h) solves the IVP defined by f(t,y) from t0 until tf using the classic Runge-Kutta fourth-order method with an initial condition y0 and step size h.

[t,y] = solve_ivp(f,{t0,E},y0,h) does the same as the syntax above, but instead of terminating at a final time tf, the solver terminates once the event function E(t,y) is no longer satisfied.

[t,y] = solve_ivp(...,method) can be used with either of the syntaxes above to specify the integration method (i.e. the function will use the specified integration method, instead of the classic Runge-Kutta fourth-order method used by the previous two syntaxes). Options for the integration method are listed in the "Input/Output Parameters" section.

[t,y] = solve_ivp(...,method,wb) can be used with any of the syntaxes above to define a waitbar. If wb is input as true, then a waitbar is displayed with the default message 'Solving IVP...'. To specify a custom waitbar message, input wb as a char array storing the desired message.

Input/Output Parameters

@@ -103,8 +103,8 @@ - - + @@ -200,8 +200,8 @@ zlabel('$z$','Interpreter','latex','FontSize',18);

Example #2: Event detection.

Consider the initial value problem

$$\frac{dy}{dt}=y,\quad y(2)=3$$

Find the solution $y(t)$ until $y=10$.

First, let's define our ODE ($\frac{dy}{dt}=f(t,y)$) and initial condition in MATLAB.

f = @(t,y) y;
 y2 = 3;
-

Next, let's define the condition function, $C(t,y)$. Since we want to continue solving until $y=10$, we want the solver to run while $y\leq10$; this forms our condition. Therefore,

C = @(t,y) y <= 10;
-

Solving for $y$ using the Euler method with a step size of $h=0.01$,

[t,y] = solve_ivp(f,{2,C},y2,0.01,'Euler');
+

Next, let's define the event function, $E(t,y)$. Since we want to continue solving until $y=10$, we want the solver to run while $y\leq10$; this forms our condition. Therefore,

E = @(t,y) y <= 10;
+

Solving for $y$ using the Euler method with a step size of $h=0.01$,

[t,y] = solve_ivp(f,{2,E},y2,0.01,'Euler');
 

Plotting the solution,

figure;
 plot(t,y,'LineWidth',1.5);
 grid on;
@@ -214,34 +214,34 @@
 
 y10 =
 
-    0.0023
+   0.002269996488128
 
 

Confirming our result by solving the same ODE but from $t=10$ to $t=20$ and using our result for $y(10)$ as the initial condition,

[t,y] = solve_ivp(f,[10,20],y10,0.001,'ABM8');
 y20 = y(end)
 
 y20 =
 
-   50.0000
+  49.999999999999226
 
-

Example #4: Backward integration (event-detection case).

Once again, consider

$$\frac{dy}{dt}=y,\quad y(20)=50$$

Find $y(10)$ using an IVP solver with a condition function (i.e. event-detection).

First, let's define our ODE ($\frac{dy}{dt}=f(t,y)$) and initial condition in MATLAB.

f = @(t,y) y;
+

Example #4: Backward integration (event-detection case).

Once again, consider

$$\frac{dy}{dt}=y,\quad y(20)=50$$

Find $y(10)$ using an IVP solver with a event function (i.e. event-detection).

First, let's define our ODE ($\frac{dy}{dt}=f(t,y)$) and initial condition in MATLAB.

f = @(t,y) y;
 y20 = 50;
-

The event that terminates the solver is when $t=10$. Therefore, we define the condition function as

C = @(t,y) t > 10;
-

In the time-detection case (Example #3) we input [t0,tf] = [20,10], so the solver knew to integrate backwards in time since t0 > tf. Consequently, internally, the solver made the step size negative. However, for the event-detection case, just given t and C(t,y), the solver won't know to use a negative step size to integrate backwards in time. Therefore, we must manually specify a negative step size. Solving for $y(10)$,

[t,y] = solve_ivp(f,{20,C},y20,-0.001,'ABM8');
+

The event that terminates the solver is when $t=10$. Therefore, we define the event function as

E = @(t,y) t > 10;
+

In the time-detection case (Example #3) we input [t0,tf] = [20,10], so the solver knew to integrate backwards in time since t0 > tf. Consequently, internally, the solver made the step size negative. However, for the event-detection case, just given t and E(t,y), the solver won't know to use a negative step size to integrate backwards in time. Therefore, we must manually specify a negative step size. Solving for $y(10)$,

[t,y] = solve_ivp(f,{20,E},y20,-0.001,'ABM8');
 y10 = y(end)
 
 y10 =
 
-    0.0023
+   0.002272267619989
 
 

Note that this is the same result we obtained earlier in Example #3.

See also

solve_ivp_matrix

solve_ivp_matrix

solve_ivp_matrix

Solve matrix-valued initial value problems using fixed-step IVP solvers.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

[t,M] = solve_ivp_matrix(F,[t0,tf],M0,h)
-[t,M] = solve_ivp_matrix(F,{t0,C},M0,h)
+  

solve_ivp_matrix

Fixed-step IVP solvers for solving matrix-valued initial value problems.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

[t,M] = solve_ivp_matrix(F,[t0,tf],M0,h)
+[t,M] = solve_ivp_matrix(F,{t0,E},M0,h)
 [t,M] = solve_ivp_matrix(__,method)
 [t,M] = solve_ivp_matrix(__,method,wb)
-

Description

[t,M] = solve_ivp_matrix(F,[t0,tf],M0,h) solves the IVP defined by F(t,M) from t0 until tf using the classic Runge-Kutta fourth-order method with an initial condition M0 and step size h. This syntax assumes that the state matrix is a square matrix.

[t,M] = solve_ivp_matrix(F,{t0,C},M0,h) does the same as the syntax above, but instead of terminating at a final time tf, the solver terminates once the condition function C(t,y) is no longer satisfied. This syntax assumes that the state matrix ($\mathbf{M}$) is a square matrix.

[t,M] = solve_ivp_matrix(...,method) can be used with any of the syntaxes above to specify the integration method (i.e. the function will use the specified integration method, instead of the classic Runge-Kutta fourth-order method used by the previous two syntaxes). Options for the integration method are listed in the "Input/Output Parameters" section.

[t,M] = solve_ivp_matrix(...,method,wb) can be used with any of the syntaxes above to define a waitbar. If wb is input as true, then a waitbar is displayed with the default message 'Solving IVP...'. To specify a custom waitbar message, input wb as a char array storing the desired message.

Input/Output Parameters

+

Description

[t,M] = solve_ivp_matrix(F,[t0,tf],M0,h) solves the IVP defined by F(t,M) from t0 until tf using the classic Runge-Kutta fourth-order method with an initial condition M0 and step size h. This syntax assumes that the state matrix is a square matrix.

[t,M] = solve_ivp_matrix(F,{t0,E},M0,h) does the same as the syntax above, but instead of terminating at a final time tf, the solver terminates once the event function E(t,y) is no longer satisfied. This syntax assumes that the state matrix ($\mathbf{M}$) is a square matrix.

[t,M] = solve_ivp_matrix(...,method) can be used with any of the syntaxes above to specify the integration method (i.e. the function will use the specified integration method, instead of the classic Runge-Kutta fourth-order method used by the previous two syntaxes). Options for the integration method are listed in the "Input/Output Parameters" section.

[t,M] = solve_ivp_matrix(...,method,wb) can be used with any of the syntaxes above to define a waitbar. If wb is input as true, then a waitbar is displayed with the default message 'Solving IVP...'. To specify a custom waitbar message, input wb as a char array storing the desired message.

Input/Output Parameters

Ccondition function () + event function ()
- inputs are the current time (t, 1×1 double) and the current state vector (y, p×1 double)
- output is a 1×1 logical (true if solver should continue running, false if solver should terminate)
1×1
function_handle
@@ -103,8 +103,8 @@ - - + @@ -206,18 +206,18 @@
 P0 =
 
-    2.1471    1.1582
-    1.1582    1.2547
+   2.147130739665738   1.158223807741478
+   1.158223807741478   1.254683874725441
 
 

References

The example above is adapted from the following sources:

See also

solve_ivp

tableau2eqns

vec2mat_sol

Transforms the solution matrix for a vector-valued IVP into the solution array for the corresponding matrix-valued IVP.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

M = vec2mat_sol(y,p)
+  

vec2mat_sol

Transforms the solution matrix for a vector-valued IVP into the solution array for its corresponding matrix-valued IVP.

Back to IVP Solver Toolbox Contents.

Contents

Syntax

M = vec2mat_sol(y,p)
 

Description

M = vec2mat_sol(y,p) transforms the solution matrix, $[\mathbf{y}]\in\mathrm{R}^{(N+1)\times pr}$ (y in MATLAB), for the vector-valued IVP into the solution array, $[\mathbf{M}]\in\mathrm{R}^{p\times r\times (N+1)}$ (M in MATLAB) for the corresponding matrix-valued IVP. p specifies the number of rows of M.

Input/Output Parameters

Ccondition function () + event function ()
- inputs are the current time (t, 1×1 double) and the current state matrix (M, p×r double)
- output is a 1×1 logical (true if solver should continue running, false if solver should terminate)
1×1
function_handle
@@ -98,11 +98,11 @@
p×r×(N+1)
double
-

Note

  • $\mathbf{M}\in\mathbf{R}^{p\times r}$
  • $\mathbf{y}\in\mathbf{R}^{pr}$
  • $\mathbf{t}\in\mathbf{R}^{N+1}$
  • The nth page of $[\mathbf{M}]$ stores the state matrix (i.e. the solution) corresponding to the nth time in $\mathbf{t}$.

See also

mat2vec_C | mat2vec_IC | mat2vec_ode

\ No newline at end of file diff --git a/toolbox/doc/html_IVP/vec2mat_sol_doc_eq00614485794024923100.png b/toolbox/doc/html_IVP/vec2mat_sol_doc_eq00614485794024923100.png index 41cb521..2c9b5b7 100644 Binary files a/toolbox/doc/html_IVP/vec2mat_sol_doc_eq00614485794024923100.png and b/toolbox/doc/html_IVP/vec2mat_sol_doc_eq00614485794024923100.png differ diff --git a/toolbox/doc/html_IVP/vec2mat_sol_doc_eq01442555386716173869.png b/toolbox/doc/html_IVP/vec2mat_sol_doc_eq01442555386716173869.png index 97e15a1..62b5e2b 100644 Binary files a/toolbox/doc/html_IVP/vec2mat_sol_doc_eq01442555386716173869.png and b/toolbox/doc/html_IVP/vec2mat_sol_doc_eq01442555386716173869.png differ diff --git a/toolbox/doc/html_IVP/vec2mat_sol_doc_eq04096253379015678133.png b/toolbox/doc/html_IVP/vec2mat_sol_doc_eq04096253379015678133.png index d00193a..29fb9fd 100644 Binary files a/toolbox/doc/html_IVP/vec2mat_sol_doc_eq04096253379015678133.png and b/toolbox/doc/html_IVP/vec2mat_sol_doc_eq04096253379015678133.png differ diff --git a/toolbox/doc/html_IVP/vec2mat_sol_doc_eq07742130518583913975.png b/toolbox/doc/html_IVP/vec2mat_sol_doc_eq07742130518583913975.png index d4fcf53..8d380b3 100644 Binary files a/toolbox/doc/html_IVP/vec2mat_sol_doc_eq07742130518583913975.png and b/toolbox/doc/html_IVP/vec2mat_sol_doc_eq07742130518583913975.png differ diff --git a/toolbox/doc/html_IVP/vec2mat_sol_doc_eq08448184081582174560.png b/toolbox/doc/html_IVP/vec2mat_sol_doc_eq08448184081582174560.png index 44b6506..7ebab34 100644 Binary files a/toolbox/doc/html_IVP/vec2mat_sol_doc_eq08448184081582174560.png and b/toolbox/doc/html_IVP/vec2mat_sol_doc_eq08448184081582174560.png differ diff --git a/toolbox/doc/html_IVP/vec2mat_sol_doc_eq08980551379751452677.png b/toolbox/doc/html_IVP/vec2mat_sol_doc_eq08980551379751452677.png index f49117a..7938078 100644 Binary files a/toolbox/doc/html_IVP/vec2mat_sol_doc_eq08980551379751452677.png and b/toolbox/doc/html_IVP/vec2mat_sol_doc_eq08980551379751452677.png differ diff --git a/toolbox/doc/html_IVP/vec2mat_sol_doc_eq14577781216167612366.png b/toolbox/doc/html_IVP/vec2mat_sol_doc_eq14577781216167612366.png index 53e61fa..99b882f 100644 Binary files a/toolbox/doc/html_IVP/vec2mat_sol_doc_eq14577781216167612366.png and b/toolbox/doc/html_IVP/vec2mat_sol_doc_eq14577781216167612366.png differ diff --git a/toolbox/ivpsolvers/solve_ivp.m b/toolbox/ivpsolvers/solve_ivp.m index 61e2f6c..d514840 100644 --- a/toolbox/ivpsolvers/solve_ivp.m +++ b/toolbox/ivpsolvers/solve_ivp.m @@ -11,7 +11,7 @@ % See also solve_ivp_matrix. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-09-17 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -26,8 +26,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % I - defines interval over which to solve the IVP, 2 options: % --> [t0,tf] - (1×2 double) initial and final times % --> {t0,E} - (1×2 cell) initial time, t₀, and function diff --git a/toolbox/ivpsolvers/solve_ivp_matrix.m b/toolbox/ivpsolvers/solve_ivp_matrix.m index d71834b..bc39ca4 100644 --- a/toolbox/ivpsolvers/solve_ivp_matrix.m +++ b/toolbox/ivpsolvers/solve_ivp_matrix.m @@ -11,7 +11,7 @@ % See also solve_ivp. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-09-17 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -26,9 +26,9 @@ % ------ % INPUT: % ------ -% F - (1×1 function_handle) dM/dt = F(t,M) --> multivariate, -% matrix-valued function (F : ℝ×ℝᵖˣʳ → ℝᵖˣʳ) defining -% matrix-valued ODE +% F - (1×1 function_handle) multivariate, matrix-valued function +% defining matrix-valued ODE, dM/dt = F(t,M) +% (F : ℝ×ℝᵖˣʳ → ℝᵖˣʳ) % I - defines interval over which to solve the IVP, 2 options: % --> [t0,tf] - (1×2 double) initial and final times % --> {t0,E} - (1×2 cell) initial time, t₀, and function @@ -71,7 +71,7 @@ p = size(M0,1); % converts matrix-valued ODE to vector-valued ODE - f = mat2vec_ode(F,p); + f = mat2vec_ODE(F,p); % converts initial condition for matrix-valued IVP into initial % condition for the corresponding vector-valued IVP diff --git a/toolbox/rungekutta/RK1_euler.m b/toolbox/rungekutta/RK1_euler.m index e1b4873..4226899 100644 --- a/toolbox/rungekutta/RK1_euler.m +++ b/toolbox/rungekutta/RK1_euler.m @@ -9,7 +9,7 @@ % RK4, RK4_ralston, RK4_38. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -24,8 +24,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % y - (p×1 double) state (i.e. solution) at current sample time, t % h - (1×1 double) step size diff --git a/toolbox/rungekutta/RK2.m b/toolbox/rungekutta/RK2.m index 46aa933..0740182 100644 --- a/toolbox/rungekutta/RK2.m +++ b/toolbox/rungekutta/RK2.m @@ -9,7 +9,7 @@ % SSPRK3, RK4, RK4_ralston, RK4_38. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -24,8 +24,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % y - (p×1 double) state (i.e. solution) at current sample time, t % h - (1×1 double) step size diff --git a/toolbox/rungekutta/RK2_heun.m b/toolbox/rungekutta/RK2_heun.m index b10ece6..1072ad4 100644 --- a/toolbox/rungekutta/RK2_heun.m +++ b/toolbox/rungekutta/RK2_heun.m @@ -9,7 +9,7 @@ % RK4, RK4_ralston, RK4_38. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -24,8 +24,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % y - (p×1 double) state (i.e. solution) at current sample time, t % h - (1×1 double) step size diff --git a/toolbox/rungekutta/RK2_ralston.m b/toolbox/rungekutta/RK2_ralston.m index 8329137..1749b76 100644 --- a/toolbox/rungekutta/RK2_ralston.m +++ b/toolbox/rungekutta/RK2_ralston.m @@ -9,7 +9,7 @@ % RK4, RK4_ralston, RK4_38. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -24,8 +24,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % y - (p×1 double) state (i.e. solution) at current sample time, t % h - (1×1 double) step size diff --git a/toolbox/rungekutta/RK3.m b/toolbox/rungekutta/RK3.m index 73c9ebc..8605b23 100644 --- a/toolbox/rungekutta/RK3.m +++ b/toolbox/rungekutta/RK3.m @@ -9,7 +9,7 @@ % SSPRK3, RK4, RK4_ralston, RK4_38. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -24,8 +24,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % y - (p×1 double) state (i.e. solution) at current sample time, t % h - (1×1 double) step size diff --git a/toolbox/rungekutta/RK3_heun.m b/toolbox/rungekutta/RK3_heun.m index 2aace52..e4a14cb 100644 --- a/toolbox/rungekutta/RK3_heun.m +++ b/toolbox/rungekutta/RK3_heun.m @@ -9,7 +9,7 @@ % RK4, RK4_ralston, RK4_38. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -24,8 +24,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % y - (p×1 double) state (i.e. solution) at current sample time, t % h - (1×1 double) step size diff --git a/toolbox/rungekutta/RK3_ralston.m b/toolbox/rungekutta/RK3_ralston.m index 9756b77..c370ea6 100644 --- a/toolbox/rungekutta/RK3_ralston.m +++ b/toolbox/rungekutta/RK3_ralston.m @@ -9,7 +9,7 @@ % RK4, RK4_ralston, RK4_38. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -24,8 +24,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % y - (p×1 double) state (i.e. solution) at current sample time, t % h - (1×1 double) step size diff --git a/toolbox/rungekutta/RK4.m b/toolbox/rungekutta/RK4.m index f195c2e..03b7680 100644 --- a/toolbox/rungekutta/RK4.m +++ b/toolbox/rungekutta/RK4.m @@ -9,7 +9,7 @@ % RK3_ralston, SSPRK3, RK4_ralston, RK4_38. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -24,8 +24,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % y - (p×1 double) state (i.e. solution) at current sample time, t % h - (1×1 double) step size diff --git a/toolbox/rungekutta/RK4_38.m b/toolbox/rungekutta/RK4_38.m index 4454362..a1938f2 100644 --- a/toolbox/rungekutta/RK4_38.m +++ b/toolbox/rungekutta/RK4_38.m @@ -9,7 +9,7 @@ % RK3_ralston, SSPRK3, RK4, RK4_ralston. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -24,8 +24,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % y - (p×1 double) state (i.e. solution) at current sample time, t % h - (1×1 double) step size diff --git a/toolbox/rungekutta/RK4_ralston.m b/toolbox/rungekutta/RK4_ralston.m index 2f9ded0..a41ef8e 100644 --- a/toolbox/rungekutta/RK4_ralston.m +++ b/toolbox/rungekutta/RK4_ralston.m @@ -9,7 +9,7 @@ % RK3_ralston, SSPRK3, RK4, RK4_38. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -24,8 +24,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % y - (p×1 double) state (i.e. solution) at current sample time, t % h - (1×1 double) step size diff --git a/toolbox/rungekutta/SSPRK3.m b/toolbox/rungekutta/SSPRK3.m index a2bfdb3..3e8c9f5 100644 --- a/toolbox/rungekutta/SSPRK3.m +++ b/toolbox/rungekutta/SSPRK3.m @@ -9,7 +9,7 @@ % RK3_ralston, RK4, RK4_ralston, RK4_38. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-08-28 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -24,8 +24,8 @@ % ------ % INPUT: % ------ -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖ → ℝᵖ) defining ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining vector-valued ODE, dy/dt = f(t,y) (f : ℝ×ℝᵖ → ℝᵖ) % t - (1×1 double) current sample time % y - (p×1 double) state (i.e. solution) at current sample time, t % h - (1×1 double) step size diff --git a/toolbox/utils/mat2vec_E.m b/toolbox/utils/mat2vec_E.m index 100270b..f2a5d1a 100644 --- a/toolbox/utils/mat2vec_E.m +++ b/toolbox/utils/mat2vec_E.m @@ -8,7 +8,7 @@ % See also mat2vec_IC, mat2vec_ODE, vec2mat_sol. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-09-17 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -46,14 +46,18 @@ % vector. %---------------------------------------------------------------------- % + % ------ % INPUT: + % ------ % Em - (1×1 function_handle) event function for matrix- % valued IVP, Eₘ(t,M) (Eₘ : ℝ×ℝᵖˣʳ → B) % t - (1×1 double) current time % y - (pr×1 double) state vector at current time % p - (1×1 double) number of rows of state matrix % + % ------- % OUTPUT: + % ------- % E - (1×1 logical) evaluation of event function %---------------------------------------------------------------------- function E = vector_event_function(Em,t,y,p) @@ -61,11 +65,6 @@ % state dimension pr = length(y); - % determine "p" if not specified (assuming M is square) - if isempty(p) - p = sqrt(pr); - end - % determines r r = pr/p; diff --git a/toolbox/utils/mat2vec_ode.m b/toolbox/utils/mat2vec_ode.m index 87418e7..67ad013 100644 --- a/toolbox/utils/mat2vec_ode.m +++ b/toolbox/utils/mat2vec_ode.m @@ -7,7 +7,7 @@ % See also mat2vec_E, mat2vec_IC, vec2mat_sol. % % Copyright © 2021 Tamas Kis -% Last Update: 2022-09-17 +% Last Update: 2022-09-18 % Website: https://tamaskis.github.io % Contact: tamas.a.kis@outlook.com % @@ -22,17 +22,17 @@ % ------ % INPUT: % ------ -% F - (1×1 function_handle) dM/dt = F(t,M) --> multivariate, -% matrix-valued function (F : ℝ×ℝᵖˣʳ → ℝᵖˣʳ) defining -% matrix-valued ODE +% F - (1×1 function_handle) multivariate, matrix-valued function +% defining the matrix-valued ODE, dM/dt = F(t,M) +% (F : ℝ×ℝᵖˣʳ → ℝᵖˣʳ) % p - (1×1 double) number of rows of state matrix % % ------- % OUTPUT: % ------- -% f - (1×1 function_handle) dy/dt = f(t,y) --> multivariate, -% vector-valued function (f : ℝ×ℝᵖʳ → ℝᵖʳ) defining -% corresponding vector-valued ODE +% f - (1×1 function_handle) multivariate, vector-valued function +% defining corresponding vector-valued ODE, dy/dt = f(t,y) +% (f : ℝ×ℝᵖʳ → ℝᵖʳ) % %========================================================================== function f = mat2vec_ODE(F,p) @@ -45,14 +45,19 @@ % matrix-valued ODE. %---------------------------------------------------------------------- % + % ------ % INPUT: - % F - (1×1 function_handle) dM/dt = F(t,M) --> multivariate, - % matrix-valued function (F : ℝ×ℝᵖˣʳ → ℝᵖˣʳ) defining ODE + % ------ + % F - (1×1 function_handle) multivariate, matrix-valued + % function defining matrix-valued ODE, dM/dt = F(t,M) + % (F : ℝ×ℝᵖˣʳ → ℝᵖˣʳ) % t - (1×1 double) current time % y - (pr×1 double) state vector at current time % p - (1×1 double) number of rows of state matrix % + % ------- % OUTPUT: + % ------- % dydt - (pr×1 double) state vector derivative % %----------------------------------------------------------------------