?

Average Accuracy: 99.5% → 99.5%
Time: 21.5s
Precision: binary64
Cost: 26752

?

\[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
\[\begin{array}{l} t_1 := \sqrt{z + z}\\ \mathsf{fma}\left(x \cdot 0.5, t_1, t_1 \cdot \left(-y\right)\right) \cdot e^{\frac{t \cdot t}{2}} \end{array} \]
(FPCore (x y z t)
 :precision binary64
 (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (exp (/ (* t t) 2.0))))
(FPCore (x y z t)
 :precision binary64
 (let* ((t_1 (sqrt (+ z z))))
   (* (fma (* x 0.5) t_1 (* t_1 (- y))) (exp (/ (* t t) 2.0)))))
double code(double x, double y, double z, double t) {
	return (((x * 0.5) - y) * sqrt((z * 2.0))) * exp(((t * t) / 2.0));
}
double code(double x, double y, double z, double t) {
	double t_1 = sqrt((z + z));
	return fma((x * 0.5), t_1, (t_1 * -y)) * exp(((t * t) / 2.0));
}
function code(x, y, z, t)
	return Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z * 2.0))) * exp(Float64(Float64(t * t) / 2.0)))
end
function code(x, y, z, t)
	t_1 = sqrt(Float64(z + z))
	return Float64(fma(Float64(x * 0.5), t_1, Float64(t_1 * Float64(-y))) * exp(Float64(Float64(t * t) / 2.0)))
end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(z + z), $MachinePrecision]], $MachinePrecision]}, N[(N[(N[(x * 0.5), $MachinePrecision] * t$95$1 + N[(t$95$1 * (-y)), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}}
\begin{array}{l}
t_1 := \sqrt{z + z}\\
\mathsf{fma}\left(x \cdot 0.5, t_1, t_1 \cdot \left(-y\right)\right) \cdot e^{\frac{t \cdot t}{2}}
\end{array}

Error?

Target

Original99.5%
Target99.5%
Herbie99.5%
\[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot {\left(e^{1}\right)}^{\left(\frac{t \cdot t}{2}\right)} \]

Derivation?

  1. Initial program 99.5%

    \[\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]
  2. Applied egg-rr99.5%

    \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot 0.5, \sqrt{z + z}, \left(-y\right) \cdot \sqrt{z + z}\right)} \cdot e^{\frac{t \cdot t}{2}} \]
    Proof

    [Start]99.5

    \[ \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]

    *-commutative [=>]99.5

    \[ \color{blue}{\left(\sqrt{z \cdot 2} \cdot \left(x \cdot 0.5 - y\right)\right)} \cdot e^{\frac{t \cdot t}{2}} \]

    sub-neg [=>]99.5

    \[ \left(\sqrt{z \cdot 2} \cdot \color{blue}{\left(x \cdot 0.5 + \left(-y\right)\right)}\right) \cdot e^{\frac{t \cdot t}{2}} \]

    distribute-rgt-in [=>]99.5

    \[ \color{blue}{\left(\left(x \cdot 0.5\right) \cdot \sqrt{z \cdot 2} + \left(-y\right) \cdot \sqrt{z \cdot 2}\right)} \cdot e^{\frac{t \cdot t}{2}} \]

    fma-def [=>]99.5

    \[ \color{blue}{\mathsf{fma}\left(x \cdot 0.5, \sqrt{z \cdot 2}, \left(-y\right) \cdot \sqrt{z \cdot 2}\right)} \cdot e^{\frac{t \cdot t}{2}} \]

    add-log-exp [=>]30.3

    \[ \mathsf{fma}\left(x \cdot 0.5, \sqrt{\color{blue}{\log \left(e^{z \cdot 2}\right)}}, \left(-y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]

    exp-lft-sqr [=>]30.2

    \[ \mathsf{fma}\left(x \cdot 0.5, \sqrt{\log \color{blue}{\left(e^{z} \cdot e^{z}\right)}}, \left(-y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]

    log-prod [=>]30.3

    \[ \mathsf{fma}\left(x \cdot 0.5, \sqrt{\color{blue}{\log \left(e^{z}\right) + \log \left(e^{z}\right)}}, \left(-y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]

    add-log-exp [<=]34.9

    \[ \mathsf{fma}\left(x \cdot 0.5, \sqrt{\color{blue}{z} + \log \left(e^{z}\right)}, \left(-y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]

    add-log-exp [<=]99.5

    \[ \mathsf{fma}\left(x \cdot 0.5, \sqrt{z + \color{blue}{z}}, \left(-y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}} \]

    add-log-exp [=>]31.5

    \[ \mathsf{fma}\left(x \cdot 0.5, \sqrt{z + z}, \left(-y\right) \cdot \sqrt{\color{blue}{\log \left(e^{z \cdot 2}\right)}}\right) \cdot e^{\frac{t \cdot t}{2}} \]

    exp-lft-sqr [=>]31.4

    \[ \mathsf{fma}\left(x \cdot 0.5, \sqrt{z + z}, \left(-y\right) \cdot \sqrt{\log \color{blue}{\left(e^{z} \cdot e^{z}\right)}}\right) \cdot e^{\frac{t \cdot t}{2}} \]

    log-prod [=>]31.5

    \[ \mathsf{fma}\left(x \cdot 0.5, \sqrt{z + z}, \left(-y\right) \cdot \sqrt{\color{blue}{\log \left(e^{z}\right) + \log \left(e^{z}\right)}}\right) \cdot e^{\frac{t \cdot t}{2}} \]

    add-log-exp [<=]35.8

    \[ \mathsf{fma}\left(x \cdot 0.5, \sqrt{z + z}, \left(-y\right) \cdot \sqrt{\color{blue}{z} + \log \left(e^{z}\right)}\right) \cdot e^{\frac{t \cdot t}{2}} \]

    add-log-exp [<=]99.5

    \[ \mathsf{fma}\left(x \cdot 0.5, \sqrt{z + z}, \left(-y\right) \cdot \sqrt{z + \color{blue}{z}}\right) \cdot e^{\frac{t \cdot t}{2}} \]
  3. Final simplification99.5%

    \[\leadsto \mathsf{fma}\left(x \cdot 0.5, \sqrt{z + z}, \sqrt{z + z} \cdot \left(-y\right)\right) \cdot e^{\frac{t \cdot t}{2}} \]

Alternatives

Alternative 1
Accuracy72.4%
Cost14153
\[\begin{array}{l} t_1 := \sqrt{z \cdot 2}\\ t_2 := e^{\frac{t \cdot t}{2}}\\ \mathbf{if}\;x \cdot 0.5 \leq -4 \cdot 10^{-93} \lor \neg \left(x \cdot 0.5 \leq 2 \cdot 10^{+87}\right):\\ \;\;\;\;t_2 \cdot \left(\left(x \cdot 0.5\right) \cdot t_1\right)\\ \mathbf{else}:\\ \;\;\;\;t_2 \cdot \left(y \cdot \left(-t_1\right)\right)\\ \end{array} \]
Alternative 2
Accuracy53.2%
Cost13897
\[\begin{array}{l} t_1 := e^{\frac{t \cdot t}{2}}\\ \mathbf{if}\;y \leq -2.9 \cdot 10^{-203} \lor \neg \left(y \leq 7 \cdot 10^{-229}\right):\\ \;\;\;\;t_1 \cdot \left(y \cdot \left(-\sqrt{z \cdot 2}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1 \cdot \sqrt{\left(x \cdot x\right) \cdot \left(0.5 \cdot z\right)}\\ \end{array} \]
Alternative 3
Accuracy99.5%
Cost13760
\[e^{\frac{t \cdot t}{2}} \cdot \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \]
Alternative 4
Accuracy50.7%
Cost13568
\[e^{\frac{t \cdot t}{2}} \cdot \left(y \cdot \left(-\sqrt{z \cdot 2}\right)\right) \]
Alternative 5
Accuracy7.6%
Cost7232
\[e^{\frac{t \cdot t}{2}} \cdot \left(z \cdot \left(x + y \cdot -2\right)\right) \]
Alternative 6
Accuracy7.6%
Cost7232
\[e^{\frac{t \cdot t}{2}} \cdot \left(z \cdot \left(x - y \cdot 4\right)\right) \]
Alternative 7
Accuracy6.2%
Cost192
\[x \cdot z \]

Error

Reproduce?

herbie shell --seed 2023147 
(FPCore (x y z t)
  :name "Data.Number.Erf:$cinvnormcdf from erf-2.0.0.0, A"
  :precision binary64

  :herbie-target
  (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (pow (exp 1.0) (/ (* t t) 2.0)))

  (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (exp (/ (* t t) 2.0))))