# How to numerically solve such differential system (ODE, Nonstationary, Nonhomogeneous) (what steps to take)?

So I have next system with boundary conditions:

Maples sol:=dsolve([sysG, bc]) and dsolve([sysG, bc], [v[1](s), v[2](s), v[3](s), v[4](s), v[5](s), v[6](s)]) (where sysG and bc are presented as simple arrays) waits for a wthile and exits returning NULL to sol. This means Maple can not solve this out from the box? Any way I wonder how to solve this ODE numerically for s:= 0..1/4*Pi. What steps shall I take?

Does the fact of $v_4$ and $v_6$ make it not an ODE? Isnt it possible to get $v_4$ and $v_6$ out from given $v$'s? make them depand on other $v$'s?

-
Are those boundary conditions correct? You are missing bc's for $v_4$ and $v_6$. – Pragabhava Nov 21 '12 at 2:21
boundary conditions are correct. – myWallJSON Nov 21 '12 at 22:03

The last three equations are uncoupled form the first three. In matricial form $$\textbf{v}'(s) = \pmatrix{ 0 & \tfrac{5003}{5000} & \tfrac{1}{2000} \\ \tfrac{15009}{2500} & 0 & \tfrac{2503}{500} \\ -\tfrac{5003}{1000} & - \tfrac{5003}{1000} & -\tfrac{1}{400} } \textbf{v}(s) + \pmatrix{ -\tfrac{3}{1000} \\ -\tfrac{35081}{2500} \\ \tfrac{20027}{1000} } = \textbf{A} \, \textbf{v}(s) + \textbf{b}$$

To find the homogeneous solution, first we calculate the eigenvalues for the matrix $\textbf{A}$ $$\det(\textbf{A} - \lambda \textbf{I}) = -\lambda^3 - \frac{1}{400}\lambda^2 - \frac{952015867}{50000000}\lambda - \frac{62650112527}{2500000000}\lambda = 0$$ The three eigenvalues are \begin{align} \lambda_1 &= \sigma_1 + i\sigma_2 \approx 0.61 + 4.49 i \\ \lambda_2 &= \sigma_1 - i\sigma_2 \approx 0.61 - 4.49 i \\ \lambda_3 &= -\sigma_3 \approx -1.22 \\ \end{align} and the eigenvectors $$\textbf{u}_1 \approx \pmatrix{0.14 + 0.03 i \\ -0.05 + 0.64 i \\ -0.75}, \quad \textbf{u}_2 \approx \pmatrix{0.14 - 0.03 i \\ -0.05 - 0.64 i \\ -0.75}, \quad \textbf{u}_3 \approx \pmatrix{-0.55 \\ 0.67 \\ 0.50},$$ and the solution is $$\textbf{v}(s) = c_1\textbf{u}_1 e^{(\sigma_1 + i \sigma_2) s} + c_2\textbf{u}_2 e^{(\sigma_1 - i \sigma_2)s} + c_3\textbf{u}_3 e^{-\sigma_3 s}$$ The particular solution is somewhat trivial, but as I stated in my comment, there are missing conditions. Assuming $v_4(\tfrac{\pi}{4}) = 0$ and $v_6(\tfrac{\pi}{4}) = 0$ $$\textbf{v}(s) = c_1\textbf{u}_1 e^{(\sigma_1 + i \sigma_2) s} + c_2\textbf{u}_2 e^{(\sigma_1 - i \sigma_2)s} + c_3\textbf{u}_3 e^{-\sigma_3 s} + \textbf{d}$$ where $\textbf{d}$ is a vector to be determined. Using the boundary conditions \begin{align} \textbf{e}_1\cdot \left(c_1\textbf{u}_1 e^{-\sigma_1 \frac{\pi}{4}} + c_2\textbf{u}_2 e^{(\sigma_2 - i \sigma_3)\frac{\pi}{4}} + c_3\textbf{u}_3 e^{(\sigma_2 + i \sigma_3) \frac{\pi}{4}} + \textbf{d}\right) &= 0\\ \textbf{e}_2\cdot \Big(c_1\textbf{u}_1 + c_2\textbf{u}_2 + c_3\textbf{u}_3 + \textbf{d}\Big) &= 0\\ \textbf{e}_3\cdot \left(c_1\textbf{u}_1 e^{-\sigma_1 \frac{\pi}{4}} + c_2\textbf{u}_2 e^{(\sigma_2 - i \sigma_3)\frac{\pi}{4}} + c_3\textbf{u}_3 e^{(\sigma_2 + i \sigma_3) \frac{\pi}{4}} + \textbf{d}\right) &= 0 \end{align} where $\textbf{e}_1 = (1,0,0)^T$, $\textbf{e}_2 = (0,1,0)^T$ and $\textbf{e}_3 = (0,0,1)^T$. From the differential equation $$\textbf{A}\,\textbf{d} + \textbf{b} = 0,$$ hence $\textbf{d} = -\textbf{A}^{-1} \textbf{b}$ or $$\textbf{d} = \pmatrix{ 4 \\ \tfrac{100045}{25045018} \\ -\tfrac{4991}{2503} }$$ Solving for $c_1$, $c_2$ and $c_3$ we have $$c_1 \approx -4.42 - 14.82 i, \quad c_2 \approx -4.42 + 14.82 i, \quad c_3 \approx -29.05$$ and then \begin{align} v_4(s) &\approx e^{\sigma_1 s}\big\{(-0.355) \cos (\sigma_2 s) + (4.396) \sin(\sigma_2 s)\big\} + (15.989) e^{-\sigma_3 s} + 4 \\ v_5(s) &\approx e^{\sigma_1 s}\big\{(19.505) \cos (\sigma_2 s) + (4.281) \sin(\sigma_2 s)\big\} - (19.501) e^{-\sigma_3 s} + 0.004\\ v_6(s) &\approx e^{\sigma_1 s}\big\{(6.639) \cos (\sigma_2 s) + (-22.244) \sin(\sigma_2 s)\big\} - (14.420) e^{-\sigma_3 s} - 1.994 \end{align} The function $v_3(s)$ can be easily calculated now, by simply integrating the equation \begin{multline} v_3(s) \approx e^{\sigma_1 s} \big\{(-0.971) \cos(\sigma_2 s) + (0.053) \sin(\sigma_2 s)\big\} \\ - (13.1001) e^{-\sigma_3 s} + (3.999)s + 14.071 \end{multline} and finally we can integrate for $v_1(x)$ and $v_2(x)$ \begin{multline} v_1(s) \approx 7.128 + \sin(s) \big\{(0.408) + (7.105) e^{-\sigma_3 s} - (0.565) s \qquad \qquad \\ - (0.052) e^{\sigma_1 s} \cos(\sigma_2 s) - (0.216) e^{\sigma_1 s} \sin(\sigma_2 s)\big\} \qquad\\ + \cos(s) \big\{(-11.390) + (4.303) e^{-\sigma_3 s} - (3.961) s \\ \qquad - (0.041) e^{\sigma_1 s} \cos(\sigma_2 s) + (0.047) e^{\sigma_1 s} \sin(\sigma_2 s)\big\} \qquad \end{multline} \begin{multline} v_2(s) \approx -7.462 + \cos(s) \big\{(0.408) + (7.105) e^{-\sigma_3 s} - (0.565) s \qquad \qquad \\ - (0.052) e^{\sigma_1 s} \cos(\sigma_2 s) - (0.216) e^{\sigma_1 s} \sin(\sigma_2 s)\big\} \qquad\\ + \sin(s) \big\{(11.390) - (4.303) e^{-\sigma_3 s} + (3.961) s \\ \qquad + (0.041) e^{\sigma_1 s} \cos(\sigma_2 s) - (0.047) e^{\sigma_1 s} \sin(\sigma_2 s)\big\} \qquad \end{multline}

Note that all calculations can be performed exaclty.

## EDIT

Assuming no conditions on $v_4$ and $v_6$, we have the solution $$\textbf{v}(s) = c_1 \textbf{u}_1 e^{(\sigma_1 + i \sigma_2)s} + c_2 \textbf{u}_2 e^{(\sigma_1 + i \sigma_2)s} + c_3 \textbf{u}_3 e^{-\sigma_3s}$$ and only the boundary condition for $v_5$, i.e. $$\textbf{e}_2\cdot(c_1 \textbf{u}_1 + c_2 \textbf{u}_2 + c_3 \textbf{u}_3 + \textbf{d}) = 0$$ For equation $v_3$ we have $$\int_0^s v_3'(x) dx = v_3(s) = \int_0^s\left\{-\frac{3}{1250} + \frac{5003}{5000} v_4(x) + \frac{1}{2500}v_6(x)\right\}dx$$ The boundary condition $v_3(\frac{\pi}{4}) = 0$ means $$\int_0^\frac{\pi}{4}\left\{-\frac{3}{1250} + \frac{5003}{5000} v_4(x) + \frac{1}{2500}v_6(x)\right\}dx = 0$$

For $v_2(s)$, \begin{multline} \int_s^\frac{\pi}{4} v_2'(x) dx = -v_2(s) = \int_s^\frac{\pi}{4}\left\{-\sin(3+x) + \sin(x) - \frac{5003}{5000}\cos(3+x) v_3(x) \right. \\ \left. - \frac{1}{10000}\sin(3+x)v_6(x) + \frac{15009}{5000}\cos(3+x)\right\}dx \end{multline}

Finally, for $v_1(s)$ we have \begin{multline} \int_0^s v_1'(x) dx = v_1(s) = \int_0^s \left\{\cos(3+x) - \cos(x) - \frac{5003}{5000}\sin(3+x) v_3(x) \right. \\ \left. + \frac{1}{10000}\cos(3+x)v_6(x) + \frac{15009}{5000}\sin(3+x)\right\}dx \end{multline} and the condition $v_1(\frac{\pi}{4}) = 0$ means \begin{multline} \int_0^\frac{\pi}{4} \left\{\cos(3+x) - \cos(x) - \frac{5003}{5000}\sin(3+x) v_3(x) \right. \\ \left. + \frac{1}{10000}\cos(3+x)v_6(x) + \frac{15009}{5000}\sin(3+x)\right\}dx = 0 \end{multline}

Recapitulating, the equations $$\textbf{e}_2\cdot(c_1 \textbf{u}_1 + c_2 \textbf{u}_2 + c_3 \textbf{u}_3 + \textbf{d}) = 0,$$ $$\int_0^\frac{\pi}{4}\left\{-\frac{3}{1250} + \frac{5003}{5000} v_4(x) + \frac{1}{2500}v_6(x)\right\}dx = 0$$ and \begin{multline} \int_0^\frac{\pi}{4} \left\{\cos(3+x) - \cos(x) - \frac{5003}{5000}\sin(3+x) v_3(x) \right. \\ \left. + \frac{1}{10000}\cos(3+x)v_6(x) + \frac{15009}{5000}\sin(3+x)\right\}dx = 0 \end{multline} determine $c_1$, $c_2$ and $c_3$.

Integrate the equations for $v_1(s)$, $v_2(s)$ and substitute the values of $c_1$, $c_2$ and $c_3$ in all $v_1, \ldots, v_6$ and you've solved the whole system.

Can you work out the details?

-
Does the fact of $v_4$ and $v_6$ make it not an ODE? Isnt it possible to get $v_4$ and $v_6$ out from given vs? make them depand on other vs? – myWallJSON Nov 21 '12 at 22:06
@myWallJSON I've completed the answer. – Pragabhava Nov 22 '12 at 0:42
1) What is $d$? 2) There is no bc on $v_2(0)= 0$ so how can we get a solution for $v_2(s)=eq$ and not $eq + const$ so there are more unknowns thn equations amnd we will not be capable to solve the system? 3) why we take only last 3 equations? – myWallJSON Nov 22 '12 at 19:50
@myWallJSON 1) The value of $\textbf{d}$ is explicitly calculated in the answer. Read carefully. 2) The boundary condition on $v_2$ is included when integrating, $$\int_s^\color{red}{\frac{\pi}{4}} v_2'(x) dx = \color{red}{v_2(\tfrac{\pi}{4})} - v_2(s) = -v_2(s).$$ 3) You have three unkowns, $c_1$, $c_2$ and $c_3$ due the fact that there are no conditions on $v_4$ and $v_6$. In order to determine them, you have to evaluate $v_1$ and $v_3$ in $s = \frac{\pi}{4}$ (the last two equations) and use that $v_5(0) = 0$ (the first equation). Study the answer carefully, all the details are there. – Pragabhava Nov 22 '12 at 23:42
{"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 1, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 3, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "http://math.stackexchange.com/questions/240025/how-to-numerically-solve-such-differential-system-ode-nonstationary-nonhomoge?answertab=oldest", "fetch_time": 1448478899000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2015-48/segments/1448398445291.19/warc/CC-MAIN-20151124205405-00338-ip-10-71-132-137.ec2.internal.warc.gz", "warc_record_offset": 142729046, "warc_record_length": 19397, "token_count": 3708, "char_count": 8432, "score": 3.765625, "int_score": 4, "crawl": "CC-MAIN-2015-48", "snapshot_type": "longest", "language": "en", "language_score": 0.6401767730712891, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00044-of-00064.parquet"}