Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_specfun_dawson (s15af)

## Purpose

nag_specfun_dawson (s15af) returns a value for Dawson's Integral, $F\left(x\right)$, via the function name.

## Syntax

[result, ifail] = s15af(x)
[result, ifail] = nag_specfun_dawson(x)

## Description

nag_specfun_dawson (s15af) evaluates an approximation for Dawson's Integral
 $Fx=e-x2∫0xet2dt.$
The function is based on two Chebyshev expansions:
For $0<\left|x\right|\le 4$,
 $Fx=x∑r=0′arTrt, where t=2 x4 2-1.$
For $\left|x\right|>4$,
 $Fx=1x∑r=0′brTrt, where t=2 4x 2-1.$
For $\left|x\right|$ near zero, $F\left(x\right)\simeq x$, and for $\left|x\right|$ large, $F\left(x\right)\simeq \frac{1}{2x}$. These approximations are used for those values of $x$ for which the result is correct to machine precision.

## References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{x}$ – double scalar
The argument $x$ of the function.

None.

### Output Parameters

1:     $\mathrm{result}$ – double scalar
The result of the function.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

There are no failure exits from this routine.

## Accuracy

Let $\delta$ and $\epsilon$ be the relative errors in the argument and result respectively.
If $\delta$ is considerably greater than the machine precision (i.e., if $\delta$ is due to data errors etc.), then $\epsilon$ and $\delta$ are approximately related by:
 $ε≃ x 1-2xFx Fx δ.$
The following graph shows the behaviour of the error amplification factor $\left|\frac{x\left(1-2xF\left(x\right)\right)}{F\left(x\right)}\right|$: Figure 1
However if $\delta$ is of the same order as machine precision, then rounding errors could make $\epsilon$ somewhat larger than the above relation indicates. In fact $\epsilon$ will be largely independent of $x$ or $\delta$, but will be of the order of a few times the machine precision.

None.

## Example

This example reads values of the argument $x$ from a file, evaluates the function at each value of $x$ and prints the results.
```function s15af_example

fprintf('s15af example results\n\n');

x = [-2   -0.5   1   1.5   2  5  10];
n = size(x,2);
result = x;

for j=1:n
[result(j), ifail] = s15af(x(j));
end

disp('      x           F(x)');
fprintf('%12.3e%12.3e\n',[x; result]);

```
```s15af example results

x           F(x)
-2.000e+00  -3.013e-01
-5.000e-01  -4.244e-01
1.000e+00   5.381e-01
1.500e+00   4.282e-01
2.000e+00   3.013e-01
5.000e+00   1.021e-01
1.000e+01   5.025e-02
```