On Dec. 8, 2008, Dieter Kaiser wrote:
=================
.....
> Extension and implementation of the Error functions
> New Maxima User functions: erf(z)
...
> Real and complex evaluation in double float and bigfloat precision.
....
===================
What are the limitations on the slatec
routine slatec:derf as far as the magnitude of the
complex argument to erf(z)?
The following evaluation of the FresnelS(x)
real integral in terms of the error function,
which integrate(..) provides, shows limitations
as x gets into the range x >= 5. (we compare
via a numerical evaluation using quad_qags).
-------------------------------------------------------
(%i1) (display2d:false,ratprint:false)$
(%i2) fs(x) :=
block([ttt,xf],
xf:x,
first(quad_qags(sin(ttt^2),ttt,0,xf)))$
(%i3) fs(1);
(%o3) 0.31026830172338
(%i4) assume(x>0)$
(%i5) expand( float( integrate(sin(s^2),s,0,x)));
(%o5) 0.31332853432888*%i*erf(0.70710678118655*%i*x+0.70710678118655*x)
+0.31332853432888*erf(0.70710678118655*%i*x+0.70710678118655*x)
+0.31332853432888*%i*erf(0.70710678118655*%i*x-0.70710678118655*x)
-0.31332853432888*erf(0.70710678118655*%i*x-0.70710678118655*x)
since we are working with display2d:false, we can copy the above
function of x into the following definition of fresnelS(x):
(%i6) fresnelS(x):=
block([val],
val : (
0.31332853432888*%i*erf(0.70710678118655*%i*x+0.70710678118655*x)
+0.31332853432888*erf(0.70710678118655*%i*x+0.70710678118655*x)
+0.31332853432888*%i*erf(0.70710678118655*%i*x-0.70710678118655*x)
-0.31332853432888*erf(0.70710678118655*%i*x-0.70710678118655*x)),
expand(val))$
(%i7) fresnelS(1);
(%o7) 0.31026830172339-5.5511151231257827E-17*%i
note that I am not going to employ any homemade
chopping of small numbers here; they are not my
concern.
first the quad_qags(..) answers:
(%i8) map('fs,[1,2,3,4,5,6,7]);
(%o8) [0.31026830172338,0.80477648934376,0.77356252689377,0.74713384464811,
0.52791728116532,0.63845918931501,0.60588693162783]
now the integrate, float(erf),.. answers :
(%i9) map('fresnelS,[1,2,3,4,5,6,7]);
(%o9) [0.31026830172339-5.5511151231257827E-17*%i,
2.2204460492503131E-16*%i+0.80477648934376,
0.77356252689379-3.6082248300317588E-15*%i,
5.8352933596239609E-11*%i+0.7471338446895,
1.9600563649913028E-7*%i+0.52791753626395,
0.016804536220479*%i+0.62946421241101,
-7101.770897795603*%i-2016.137872763371]
and the differences:
(%i10) %o9 - %o8;
(%o10) [8.0491169285323849E-15-5.5511151231257827E-17*%i,
2.2204460492503131E-16*%i+7.6605388699135801E-15,
2.5424107263916085E-14-3.6082248300317588E-15*%i,
5.8352933596239609E-11*%i+4.1387115956581511E-11,
1.9600563649913028E-7*%i+2.5509862389139215E-7,
0.016804536220479*%i-0.0089949769040033,
-7101.770897795603*%i-2016.743759694998]
--------------------------------------------------
Ted Woollett