# ?

Average Error: 0.3 → 0.3
Time: 8.6s
Precision: binary64
Cost: 6848

# ?

$\left(1 \leq x \land x \leq 1000\right) \land \left(1 \leq a \land a \leq 1000\right)$
$\frac{x}{{x}^{2} + {a}^{2}}$
$\frac{x}{\mathsf{fma}\left(a, a, x \cdot x\right)}$
(FPCore (x a) :precision binary64 (/ x (+ (pow x 2.0) (pow a 2.0))))
(FPCore (x a) :precision binary64 (/ x (fma a a (* x x))))
double code(double x, double a) {
return x / (pow(x, 2.0) + pow(a, 2.0));
}

double code(double x, double a) {
return x / fma(a, a, (x * x));
}

function code(x, a)
return Float64(x / Float64((x ^ 2.0) + (a ^ 2.0)))
end

function code(x, a)
return Float64(x / fma(a, a, Float64(x * x)))
end

code[x_, a_] := N[(x / N[(N[Power[x, 2.0], $MachinePrecision] + N[Power[a, 2.0],$MachinePrecision]), $MachinePrecision]),$MachinePrecision]

code[x_, a_] := N[(x / N[(a * a + N[(x * x), $MachinePrecision]),$MachinePrecision]), \$MachinePrecision]

\frac{x}{{x}^{2} + {a}^{2}}

\frac{x}{\mathsf{fma}\left(a, a, x \cdot x\right)}


# Derivation?

1. Initial program 0.3

$\frac{x}{{x}^{2} + {a}^{2}}$
2. Simplified0.3

$\leadsto \color{blue}{\frac{x}{x \cdot x + a \cdot a}}$
Proof
[Start]0.3 $\frac{x}{{x}^{2} + {a}^{2}}$ $\frac{x}{\color{blue}{x \cdot x} + {a}^{2}}$ $\frac{x}{x \cdot x + \color{blue}{a \cdot a}}$
3. Taylor expanded in x around 0 0.3

$\leadsto \frac{x}{\color{blue}{{x}^{2} + {a}^{2}}}$
4. Simplified0.3

$\leadsto \frac{x}{\color{blue}{\mathsf{fma}\left(a, a, x \cdot x\right)}}$
Proof
[Start]0.3 $\frac{x}{{x}^{2} + {a}^{2}}$ $\frac{x}{\color{blue}{{a}^{2} + {x}^{2}}}$ $\frac{x}{\color{blue}{a \cdot a} + {x}^{2}}$ $\frac{x}{a \cdot a + \color{blue}{x \cdot x}}$ $\frac{x}{\color{blue}{\mathsf{fma}\left(a, a, x \cdot x\right)}}$
5. Final simplification0.3

$\leadsto \frac{x}{\mathsf{fma}\left(a, a, x \cdot x\right)}$

# Alternatives

Alternative 1
Error0.3
Cost576
$\frac{x}{x \cdot x + a \cdot a}$
Alternative 2
Error47.0
Cost452
$\begin{array}{l} \mathbf{if}\;x \leq 21:\\ \;\;\;\;\frac{x}{a \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x}\\ \end{array}$
Alternative 3
Error47.0
Cost452
$\begin{array}{l} \mathbf{if}\;x \leq 21:\\ \;\;\;\;\frac{x}{a \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{x \cdot x}\\ \end{array}$
Alternative 4
Error50.0
Cost192
$\frac{1}{x}$

# Reproduce?

herbie shell --seed 1
(FPCore (x a)
:name "x/(x^2+a^2)"
:precision binary64
:pre (and (and (<= 1.0 x) (<= x 1000.0)) (and (<= 1.0 a) (<= a 1000.0)))
(/ x (+ (pow x 2.0) (pow a 2.0))))