# ?

Average Error: 0.5 → 0.4
Time: 14.7s
Precision: binary64
Cost: 20672

# ?

$\left(\left(\left(10^{-9} \leq d \land d \leq 1\right) \land \left(10^{-9} \leq t \land t \leq 100000\right)\right) \land \left(10^{-9} \leq k \land k \leq 1\right)\right) \land \left(-100000 \leq x \land x \leq 100000\right)$
$\frac{\frac{1}{1 + d \cdot t}}{2 \cdot \sqrt{\left(3.141592 \cdot k\right) \cdot t}} \cdot e^{\frac{\left(-x\right) \cdot x}{\left(4 \cdot k\right) \cdot t}}$
$\frac{0.5 \cdot {\left(\left(t \cdot 3.141592\right) \cdot k\right)}^{-0.5}}{\mathsf{fma}\left(d, t, 1\right)} \cdot e^{\frac{x \cdot \left(-x\right)}{t \cdot \left(k \cdot 4\right)}}$
(FPCore (d t k x)
:precision binary64
(*
(/ (/ 1.0 (+ 1.0 (* d t))) (* 2.0 (sqrt (* (* 3.141592 k) t))))
(exp (/ (* (- x) x) (* (* 4.0 k) t)))))
(FPCore (d t k x)
:precision binary64
(*
(/ (* 0.5 (pow (* (* t 3.141592) k) -0.5)) (fma d t 1.0))
(exp (/ (* x (- x)) (* t (* k 4.0))))))
double code(double d, double t, double k, double x) {
return ((1.0 / (1.0 + (d * t))) / (2.0 * sqrt(((3.141592 * k) * t)))) * exp(((-x * x) / ((4.0 * k) * t)));
}

double code(double d, double t, double k, double x) {
return ((0.5 * pow(((t * 3.141592) * k), -0.5)) / fma(d, t, 1.0)) * exp(((x * -x) / (t * (k * 4.0))));
}

function code(d, t, k, x)
return Float64(Float64(Float64(1.0 / Float64(1.0 + Float64(d * t))) / Float64(2.0 * sqrt(Float64(Float64(3.141592 * k) * t)))) * exp(Float64(Float64(Float64(-x) * x) / Float64(Float64(4.0 * k) * t))))
end

function code(d, t, k, x)
return Float64(Float64(Float64(0.5 * (Float64(Float64(t * 3.141592) * k) ^ -0.5)) / fma(d, t, 1.0)) * exp(Float64(Float64(x * Float64(-x)) / Float64(t * Float64(k * 4.0)))))
end

code[d_, t_, k_, x_] := N[(N[(N[(1.0 / N[(1.0 + N[(d * t), $MachinePrecision]),$MachinePrecision]), $MachinePrecision] / N[(2.0 * N[Sqrt[N[(N[(3.141592 * k),$MachinePrecision] * t), $MachinePrecision]],$MachinePrecision]), $MachinePrecision]),$MachinePrecision] * N[Exp[N[(N[((-x) * x), $MachinePrecision] / N[(N[(4.0 * k),$MachinePrecision] * t), $MachinePrecision]),$MachinePrecision]], $MachinePrecision]),$MachinePrecision]

code[d_, t_, k_, x_] := N[(N[(N[(0.5 * N[Power[N[(N[(t * 3.141592), $MachinePrecision] * k),$MachinePrecision], -0.5], $MachinePrecision]),$MachinePrecision] / N[(d * t + 1.0), $MachinePrecision]),$MachinePrecision] * N[Exp[N[(N[(x * (-x)), $MachinePrecision] / N[(t * N[(k * 4.0),$MachinePrecision]), $MachinePrecision]),$MachinePrecision]], $MachinePrecision]),$MachinePrecision]

\frac{\frac{1}{1 + d \cdot t}}{2 \cdot \sqrt{\left(3.141592 \cdot k\right) \cdot t}} \cdot e^{\frac{\left(-x\right) \cdot x}{\left(4 \cdot k\right) \cdot t}}

\frac{0.5 \cdot {\left(\left(t \cdot 3.141592\right) \cdot k\right)}^{-0.5}}{\mathsf{fma}\left(d, t, 1\right)} \cdot e^{\frac{x \cdot \left(-x\right)}{t \cdot \left(k \cdot 4\right)}}


# Derivation?

1. Initial program 0.5

$\frac{\frac{1}{1 + d \cdot t}}{2 \cdot \sqrt{\left(3.141592 \cdot k\right) \cdot t}} \cdot e^{\frac{\left(-x\right) \cdot x}{\left(4 \cdot k\right) \cdot t}}$
2. Applied egg-rr0.5

$\leadsto \color{blue}{\left(\frac{\frac{0.5}{\sqrt{k \cdot \left(3.141592 \cdot t\right)}}}{\mathsf{fma}\left(d, t, 1\right)} \cdot 1\right)} \cdot e^{\frac{\left(-x\right) \cdot x}{\left(4 \cdot k\right) \cdot t}}$
3. Applied egg-rr0.4

$\leadsto \left(\frac{\color{blue}{0.5 \cdot {\left(3.141592 \cdot \left(t \cdot k\right)\right)}^{-0.5}}}{\mathsf{fma}\left(d, t, 1\right)} \cdot 1\right) \cdot e^{\frac{\left(-x\right) \cdot x}{\left(4 \cdot k\right) \cdot t}}$
4. Simplified0.4

$\leadsto \left(\frac{\color{blue}{0.5 \cdot {\left(\left(t \cdot 3.141592\right) \cdot k\right)}^{-0.5}}}{\mathsf{fma}\left(d, t, 1\right)} \cdot 1\right) \cdot e^{\frac{\left(-x\right) \cdot x}{\left(4 \cdot k\right) \cdot t}}$
Proof
[Start]0.4 $\left(\frac{0.5 \cdot {\left(3.141592 \cdot \left(t \cdot k\right)\right)}^{-0.5}}{\mathsf{fma}\left(d, t, 1\right)} \cdot 1\right) \cdot e^{\frac{\left(-x\right) \cdot x}{\left(4 \cdot k\right) \cdot t}}$ $\left(\frac{0.5 \cdot {\color{blue}{\left(\left(3.141592 \cdot t\right) \cdot k\right)}}^{-0.5}}{\mathsf{fma}\left(d, t, 1\right)} \cdot 1\right) \cdot e^{\frac{\left(-x\right) \cdot x}{\left(4 \cdot k\right) \cdot t}}$ $\left(\frac{0.5 \cdot {\left(\color{blue}{\left(t \cdot 3.141592\right)} \cdot k\right)}^{-0.5}}{\mathsf{fma}\left(d, t, 1\right)} \cdot 1\right) \cdot e^{\frac{\left(-x\right) \cdot x}{\left(4 \cdot k\right) \cdot t}}$
5. Final simplification0.4

$\leadsto \frac{0.5 \cdot {\left(\left(t \cdot 3.141592\right) \cdot k\right)}^{-0.5}}{\mathsf{fma}\left(d, t, 1\right)} \cdot e^{\frac{x \cdot \left(-x\right)}{t \cdot \left(k \cdot 4\right)}}$

# Alternatives

Alternative 1
Error0.4
Cost20672
$e^{\frac{x \cdot \left(-x\right)}{t \cdot \left(k \cdot 4\right)}} \cdot \sqrt{\frac{0.07957748810157397}{k \cdot \left(t \cdot {\left(1 + t \cdot d\right)}^{2}\right)}}$
Alternative 2
Error0.4
Cost20480
$e^{\frac{x \cdot \left(-x\right)}{t \cdot \left(k \cdot 4\right)}} \cdot \frac{\sqrt{\frac{0.07957748810157397}{t \cdot k}}}{\mathsf{fma}\left(d, t, 1\right)}$
Alternative 3
Error0.5
Cost14400
$e^{\frac{-0.25 \cdot \left(x \cdot x\right)}{t \cdot k}} \cdot \frac{1}{\left(1 + t \cdot d\right) \cdot \left(2 \cdot \sqrt{3.141592 \cdot \left(t \cdot k\right)}\right)}$
Alternative 4
Error0.5
Cost14400
$\frac{1}{\left(2 \cdot \sqrt{t \cdot \left(3.141592 \cdot k\right)}\right) \cdot \left(1 + t \cdot d\right)} \cdot e^{\frac{-0.25 \cdot \left(x \cdot x\right)}{t \cdot k}}$
Alternative 5
Error18.4
Cost14336
$e^{\frac{x \cdot \left(-x\right)}{t \cdot \left(k \cdot 4\right)}} \cdot \sqrt{-0.15915497620314795 \cdot \frac{d}{k} + 0.07957748810157397 \cdot \frac{1}{t \cdot k}}$
Alternative 6
Error18.4
Cost14336
$e^{\frac{x \cdot \left(-x\right)}{t \cdot \left(k \cdot 4\right)}} \cdot \sqrt{\frac{1 + \left(t \cdot d\right) \cdot -2}{\left(t \cdot k\right) \cdot 12.566368}}$
Alternative 7
Error17.8
Cost14336
$e^{\frac{x \cdot \left(-x\right)}{t \cdot \left(k \cdot 4\right)}} \cdot \frac{1 - t \cdot d}{2 \cdot \sqrt{t \cdot \left(3.141592 \cdot k\right)}}$
Alternative 8
Error29.8
Cost13824
$e^{\frac{x \cdot \left(-x\right)}{t \cdot \left(k \cdot 4\right)}} \cdot \sqrt{\frac{0.07957748810157397}{t \cdot k}}$

# Reproduce?

herbie shell --seed 1
(FPCore (d t k x)
:name "1 / (1+d*t) / (2*sqrt(3.141592*k*t)) * exp(-x*x/(4*k*t))"
:precision binary64
:pre (and (and (and (and (<= 1e-9 d) (<= d 1.0)) (and (<= 1e-9 t) (<= t 100000.0))) (and (<= 1e-9 k) (<= k 1.0))) (and (<= -100000.0 x) (<= x 100000.0)))
(* (/ (/ 1.0 (+ 1.0 (* d t))) (* 2.0 (sqrt (* (* 3.141592 k) t)))) (exp (/ (* (- x) x) (* (* 4.0 k) t)))))