Code covered by the BSD License  

Highlights from
Chebfun V4

image thumbnail

Chebfun V4

by

 

30 Apr 2009 (Updated )

Numerical computation with functions instead of numbers.

Editor's Notes:

This file was selected as MATLAB Central Pick of the Week

besseljroots
function pass = besseljroots
% Checks if the roots of the BesselJ function on [0,100] are recovered
% correctly.

% TAD

g = chebfun(@(x) besselj(0,x),[0 100]);
r = roots(g);
exact = [ 2.40482555769577276862163; 5.52007811028631064959660
8.65372791291101221695437; 11.7915344390142816137431
14.9309177084877859477626; 18.0710639679109225431479
21.2116366298792589590784; 24.3524715307493027370579
27.4934791320402547958773; 30.6346064684319751175496
33.7758202135735686842385; 36.9170983536640439797695
40.0584257646282392947993; 43.1997917131767303575241
46.3411883716618140186858; 49.4826098973978171736028
52.6240518411149960292513; 55.7655107550199793116835
58.9069839260809421328344; 62.0484691902271698828525
65.1899648002068604406360; 68.3314693298567982709923
71.4729816035937328250631; 74.6145006437018378838205
77.7560256303880550377394; 80.8975558711376278637723
84.0390907769381901578795; 87.1806298436411536512617
90.3221726372104800557177; 93.4637187819447741711905
96.6052679509962687781216; 99.7468198586805964702799
];

pass = norm(r-exact,Inf) < 4e-13*chebfunpref('eps')/eps;

Contact us