bestbarcoder.com

asp.net aspx barcode % y must be row vector in .NET Creator gs1 datamatrix barcode in .NET % y must be row vector

% y must be row vector use none none generating toencode none with nonebarcode printing asp.net % Storage for Richardson extrapolation. Microsoft Visual Studio % Start with two integ ration steps. nSteps = 2; r(1,1:n) = mid(dEqs,x,y,xStop,nSteps); rOld = r(1,1:n); for k = 2:kMax % Increase the number of steps by 2 & refine results by % Richardson extrapolation. nSteps = 2*k; r(k,1:n) = mid(dEqs,x,y,xStop,nSteps); r = richardson(r,k,n); % Check for convergence.

dr = r(1,1:n) - rOld;. Initial Value Problems e = sqrt(dot(dr,dr)/n) ; if e < tol; y = r(1,1:n); return; end rOld = r(1,1:n); end error( Midpoint method did not converge ). function r = richardso none none n(r,k,n) % Richardson extrapolation. for j = k-1:-1:1 c =(k/(k-1)) (2*(k-j)); r(j,1:n) =(c*r(j+1,1:n) - r(j,1:n))/(c - 1.0); end return.

function y = mid(dEqs, x,y,xStop,nSteps) % Midpoint formulas. h = (xStop - x)/nSteps; y0 = y; y1 = y0 + h*feval(dEqs,x,y0); for i = 1:nSteps-1 x = x + h; y2 = y0 + 2.0*h*feval(dEqs,x,y1); y0 = y1; y1 = y2; end y = 0.

5*(y1 + y0 + h*feval(dEqs,x,y2));. Bulirsch Stoer Algorithm When used on its own, the module midpoint has a major shortcoming: the solution at points between the initial and nal values of x cannot be re ned by Richardson extrapolation, so that y is usable only at the last point. This de ciency is recti ed in the Bulirsch Stoer method. The fundamental idea behind the method is simple: apply the midpoint method in a piecewise fashion.

That is, advance the solution in stages of length H, using the midpoint method with Richardson extrapolation to perform the integration in each stage. The value of H can be quite large, since the precision of the result is determined mainly by the step length h in the midpoint method, not by H. However, if H is too large, the midpoint method may not converge.

If this happens, try smaller value of H or larger error tolerance. The original Bulirsch and Stoer technique20 is a very complex procedure that incorporates many re nements (including automatic adjustment of H) missing in our. Stoer, J., and Bulirsc none none h, R., Introduction to Numerical Analysis, Springer, New York, 1980.

. 7.6 Bulirsch Stoer Method algorithm. However, th none none e function bulStoer given below retains the essential idea of Bulirsch and Stoer. What are the relative merits of adaptive Runge Kutta and Bulirsch Stoer methods The Runge Kutta method is more robust, having higher tolerance for nonsmooth functions and stiff problems.

In applications where extremely high precision is not required, it is also more ef cient. Bulirsch Stoer algorithm (in its original form) is used mainly in problems where high accuracy is of paramount importance. Our simpli ed version is no more accurate than the adaptive Runge Kutta method, but it is useful if the output is to appear at equally spaced values of x.

. bulStoer This function contains our greatly simpli ed algorithm for the Bulirsch Stoer method. function [xSol,ySol] = none none bulStoer(dEqs,x,y,xStop,H,tol) % Simplified Bulirsch-Stoer method for integration of y = F(x,y). % USAGE: [xSol,ySol] = bulStoer(dEqs,x,y,xStop,H,tol) % INPUT: % dEqs % % x, y = handle of function that returns the first-order differential equations F(x,y) = [dy1/dx,dy2/dx,..

.]. = initial values; y must be a row vector.

. % xStop = terminal val ue of x. % H % tol = increment of x at which solution is stored. = per-step error tolerance (default = 1.

0e-6).. % OUTPUT: % xSol, ySol = solution at increments H. if size(y,1) > 1 ; y = y ; end if nargin < 6; tol = 1.0e-6; end n = length(y);. % y must be row vector xSol = zeros(2,1); ySo l = zeros(2,n); xSol(1) = x; ySol(1,:) = y; k = 1; while x < xStop k = k + 1; H = min(H,xStop - x); y = midpoint(dEqs,x,y,x + H,tol); x = x + H; xSol(k) = x; ySol(k,:) = y; end. Initial Value Problems EXAMPLE 7.10 Compute t he solution of the initial value problem y = sin y y(0) = 1. at x = 0.5 with the mi none for none dpoint formulas using n = 2 and n = 4, followed by Richardson extrapolation (this problem was solved with the second-order Runge Kutta method in Example 7.3).

Solution With n = 2, the step length is h = 0.25. The midpoint formulas, Eqs.

(7.26) and (7.27) yield y1 = y0 + hf0 = 1 + 0.

25 sin 1.0 = 1.210 368 y2 = y0 + 2hf1 = 1 + 2(0.

25) sin 1.210 368 = 1.467 87 3 yh (0.

5) = 1 (y1 + y0 + hf2 ) 2 1 = (1.210 368 + 1.467 87 3 + 0.

25 sin 1.467 87 3) 2 = 1.463 459.

Using n = 4, we have h = 0.125 and the midpoint formulas become y1 = y0 + hf0 = 1 + 0.125 sin 1.

0 = 1.105 184 y2 = y0 + 2hf1 = 1 + 2(0.125) sin 1.

105 184 = 1.223 387 y3 = y1 + 2hf2 = 1.105 184 + 2(0.

125) sin 1.223 387 = 1.340 248 y4 = y2 + 2hf3 = 1.

223 387 + 2(0.125) sin 1.340 248 = 1.

466 772 yh/2 (0.5) = 1 (y4 + y3 + hf4 ) 2 1 = (1.466 772 + 1.

340 248 + 0.125 sin 1.466 772) 2 = 1.

465 672. Richardson extrapolati none none on results in 4(1.465 672) 1.463 459 = 1.

466 410 3. y(0.5) =. which compares favorab none none ly with the true solution y(0.5) = 1.466 404.

.
Copyright © bestbarcoder.com . All rights reserved.