Demo entry 6626771

bvp

   

Submitted by anonymous on Jun 26, 2017 at 16:38
Language: Matlab. Code size: 737 Bytes.

%¯S©º¤èµ{?§@
% 2
%x
%-- + 2x - 3 = 0
%2
%¸Ñ±o??¤£¦P?®Ú
lambda = roots([1 / 2, 2, -3]);

%?©w?­È?¥ó¡A¨ä¤¤£X?¥¿?²Ö?¤À¥¬¨ç?
z = [-1; 1];
Phi = normcdf(z, 0, 1);

%??­È?¥ó¥N¤J­ì¤èµ{³q¸Ñ¡A¦}¸Ñ?¤_¥ô·N±`?ªº¤G¤¸¤@¦¸?©Ê¤èµ{?
c = exp(z * lambda') \ Phi;

%Õu­ì¤èµ{¸ÑªR¸Ñ¡A?¥Xx?(-1,1)?ªººëṶ́ȤÎv(0)
x = linspace(z(1), z(2));
vExt = c' * exp(lambda * x);
v0Ext = c' * exp(lambda * 0)

%?­ì¤èµ{¤Æ?¤@??¦¸?©Ê·L¤À¤èµ{?
uDiff = @(x, u)[u(2); 2 * (3 * u(1) - 2 * u(2))];

%?­È?¥ó
bc = @(uLeft, uRight)[uLeft(1) - Phi(1); uRight(1) - Phi(2)];

%
solinit = bvpinit(linspace(z(1), z(2), 10), [1; 0]);
sol = bvp4c(uDiff, bc, solinit);
vNumrc = deval(sol, x);
v0Numrc = deval(sol, 0)

%§@?
plot(x, vExt, x, vNumrc(1, :), '--')

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).