
(FPCore (x y z t) :precision binary64 (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (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));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x * 0.5d0) - y) * sqrt((z * 2.0d0))) * exp(((t * t) / 2.0d0))
end function
public static double code(double x, double y, double z, double t) {
return (((x * 0.5) - y) * Math.sqrt((z * 2.0))) * Math.exp(((t * t) / 2.0));
}
def code(x, y, z, t): return (((x * 0.5) - y) * math.sqrt((z * 2.0))) * math.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 tmp = code(x, y, z, t) tmp = (((x * 0.5) - y) * sqrt((z * 2.0))) * exp(((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]
\begin{array}{l}
\\
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (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));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x * 0.5d0) - y) * sqrt((z * 2.0d0))) * exp(((t * t) / 2.0d0))
end function
public static double code(double x, double y, double z, double t) {
return (((x * 0.5) - y) * Math.sqrt((z * 2.0))) * Math.exp(((t * t) / 2.0));
}
def code(x, y, z, t): return (((x * 0.5) - y) * math.sqrt((z * 2.0))) * math.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 tmp = code(x, y, z, t) tmp = (((x * 0.5) - y) * sqrt((z * 2.0))) * exp(((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]
\begin{array}{l}
\\
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot e^{\frac{t \cdot t}{2}}
\end{array}
(FPCore (x y z t) :precision binary64 (* (- (* x 0.5) y) (sqrt (* (exp (pow t 2.0)) (* 2.0 z)))))
double code(double x, double y, double z, double t) {
return ((x * 0.5) - y) * sqrt((exp(pow(t, 2.0)) * (2.0 * z)));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * 0.5d0) - y) * sqrt((exp((t ** 2.0d0)) * (2.0d0 * z)))
end function
public static double code(double x, double y, double z, double t) {
return ((x * 0.5) - y) * Math.sqrt((Math.exp(Math.pow(t, 2.0)) * (2.0 * z)));
}
def code(x, y, z, t): return ((x * 0.5) - y) * math.sqrt((math.exp(math.pow(t, 2.0)) * (2.0 * z)))
function code(x, y, z, t) return Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(exp((t ^ 2.0)) * Float64(2.0 * z)))) end
function tmp = code(x, y, z, t) tmp = ((x * 0.5) - y) * sqrt((exp((t ^ 2.0)) * (2.0 * z))); end
code[x_, y_, z_, t_] := N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(N[Exp[N[Power[t, 2.0], $MachinePrecision]], $MachinePrecision] * N[(2.0 * z), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 0.5 - y\right) \cdot \sqrt{e^{{t}^{2}} \cdot \left(2 \cdot z\right)}
\end{array}
Initial program 99.4%
associate-*l*99.8%
exp-sqrt99.8%
exp-prod99.8%
Simplified99.8%
pow199.8%
sqrt-unprod99.8%
associate-*l*99.8%
pow-exp99.8%
pow299.8%
Applied egg-rr99.8%
unpow199.8%
*-commutative99.8%
*-commutative99.8%
associate-*l*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z t) :precision binary64 (if (<= (* t t) 4.6e-13) (* (- (* x 0.5) y) (pow (* 2.0 z) 0.5)) (* (exp (/ (* t t) 2.0)) (* 0.5 (* x (sqrt (* 2.0 z)))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t * t) <= 4.6e-13) {
tmp = ((x * 0.5) - y) * pow((2.0 * z), 0.5);
} else {
tmp = exp(((t * t) / 2.0)) * (0.5 * (x * sqrt((2.0 * z))));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((t * t) <= 4.6d-13) then
tmp = ((x * 0.5d0) - y) * ((2.0d0 * z) ** 0.5d0)
else
tmp = exp(((t * t) / 2.0d0)) * (0.5d0 * (x * sqrt((2.0d0 * z))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t * t) <= 4.6e-13) {
tmp = ((x * 0.5) - y) * Math.pow((2.0 * z), 0.5);
} else {
tmp = Math.exp(((t * t) / 2.0)) * (0.5 * (x * Math.sqrt((2.0 * z))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t * t) <= 4.6e-13: tmp = ((x * 0.5) - y) * math.pow((2.0 * z), 0.5) else: tmp = math.exp(((t * t) / 2.0)) * (0.5 * (x * math.sqrt((2.0 * z)))) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(t * t) <= 4.6e-13) tmp = Float64(Float64(Float64(x * 0.5) - y) * (Float64(2.0 * z) ^ 0.5)); else tmp = Float64(exp(Float64(Float64(t * t) / 2.0)) * Float64(0.5 * Float64(x * sqrt(Float64(2.0 * z))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t * t) <= 4.6e-13) tmp = ((x * 0.5) - y) * ((2.0 * z) ^ 0.5); else tmp = exp(((t * t) / 2.0)) * (0.5 * (x * sqrt((2.0 * z)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(t * t), $MachinePrecision], 4.6e-13], N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Power[N[(2.0 * z), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(0.5 * N[(x * N[Sqrt[N[(2.0 * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \cdot t \leq 4.6 \cdot 10^{-13}:\\
\;\;\;\;\left(x \cdot 0.5 - y\right) \cdot {\left(2 \cdot z\right)}^{0.5}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{t \cdot t}{2}} \cdot \left(0.5 \cdot \left(x \cdot \sqrt{2 \cdot z}\right)\right)\\
\end{array}
\end{array}
if (*.f64 t t) < 4.59999999999999958e-13Initial program 99.6%
associate-*l*99.6%
exp-sqrt99.6%
exp-prod99.6%
Simplified99.6%
Taylor expanded in t around 0 99.4%
sqrt-prod99.6%
pow1/299.6%
*-commutative99.6%
Applied egg-rr99.6%
if 4.59999999999999958e-13 < (*.f64 t t) Initial program 99.2%
Taylor expanded in x around inf 67.7%
pow167.7%
associate-*l*67.7%
*-commutative67.7%
sqrt-prod67.7%
*-commutative67.7%
Applied egg-rr67.7%
unpow167.7%
Simplified67.7%
Final simplification84.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x 0.5) y)))
(if (<= t 6.8e+131)
(* t_1 (pow (* 2.0 z) 0.5))
(sqrt (* (* 2.0 z) (pow t_1 2.0))))))
double code(double x, double y, double z, double t) {
double t_1 = (x * 0.5) - y;
double tmp;
if (t <= 6.8e+131) {
tmp = t_1 * pow((2.0 * z), 0.5);
} else {
tmp = sqrt(((2.0 * z) * pow(t_1, 2.0)));
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = (x * 0.5d0) - y
if (t <= 6.8d+131) then
tmp = t_1 * ((2.0d0 * z) ** 0.5d0)
else
tmp = sqrt(((2.0d0 * z) * (t_1 ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (x * 0.5) - y;
double tmp;
if (t <= 6.8e+131) {
tmp = t_1 * Math.pow((2.0 * z), 0.5);
} else {
tmp = Math.sqrt(((2.0 * z) * Math.pow(t_1, 2.0)));
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * 0.5) - y tmp = 0 if t <= 6.8e+131: tmp = t_1 * math.pow((2.0 * z), 0.5) else: tmp = math.sqrt(((2.0 * z) * math.pow(t_1, 2.0))) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * 0.5) - y) tmp = 0.0 if (t <= 6.8e+131) tmp = Float64(t_1 * (Float64(2.0 * z) ^ 0.5)); else tmp = sqrt(Float64(Float64(2.0 * z) * (t_1 ^ 2.0))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * 0.5) - y; tmp = 0.0; if (t <= 6.8e+131) tmp = t_1 * ((2.0 * z) ^ 0.5); else tmp = sqrt(((2.0 * z) * (t_1 ^ 2.0))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision]}, If[LessEqual[t, 6.8e+131], N[(t$95$1 * N[Power[N[(2.0 * z), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[(2.0 * z), $MachinePrecision] * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot 0.5 - y\\
\mathbf{if}\;t \leq 6.8 \cdot 10^{+131}:\\
\;\;\;\;t\_1 \cdot {\left(2 \cdot z\right)}^{0.5}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(2 \cdot z\right) \cdot {t\_1}^{2}}\\
\end{array}
\end{array}
if t < 6.79999999999999972e131Initial program 99.8%
associate-*l*99.8%
exp-sqrt99.8%
exp-prod99.8%
Simplified99.8%
Taylor expanded in t around 0 64.3%
sqrt-prod64.4%
pow1/264.4%
*-commutative64.4%
Applied egg-rr64.4%
if 6.79999999999999972e131 < t Initial program 96.8%
associate-*l*100.0%
exp-sqrt100.0%
exp-prod100.0%
Simplified100.0%
Taylor expanded in t around 0 10.6%
pow110.6%
sqrt-prod10.6%
add-sqr-sqrt5.5%
unpow25.5%
metadata-eval5.5%
pow-sqr5.5%
pow-prod-down20.5%
Applied egg-rr30.0%
unpow1/230.0%
*-commutative30.0%
fma-neg30.0%
*-commutative30.0%
Simplified30.0%
Final simplification60.2%
(FPCore (x y z t) :precision binary64 (* (* (- (* x 0.5) y) (sqrt (* 2.0 z))) (exp (/ (* t t) 2.0))))
double code(double x, double y, double z, double t) {
return (((x * 0.5) - y) * sqrt((2.0 * z))) * exp(((t * t) / 2.0));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x * 0.5d0) - y) * sqrt((2.0d0 * z))) * exp(((t * t) / 2.0d0))
end function
public static double code(double x, double y, double z, double t) {
return (((x * 0.5) - y) * Math.sqrt((2.0 * z))) * Math.exp(((t * t) / 2.0));
}
def code(x, y, z, t): return (((x * 0.5) - y) * math.sqrt((2.0 * z))) * math.exp(((t * t) / 2.0))
function code(x, y, z, t) return Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(2.0 * z))) * exp(Float64(Float64(t * t) / 2.0))) end
function tmp = code(x, y, z, t) tmp = (((x * 0.5) - y) * sqrt((2.0 * z))) * exp(((t * t) / 2.0)); end
code[x_, y_, z_, t_] := N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(2.0 * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{2 \cdot z}\right) \cdot e^{\frac{t \cdot t}{2}}
\end{array}
Initial program 99.4%
Final simplification99.4%
(FPCore (x y z t) :precision binary64 (* (- (* x 0.5) y) (pow (* 2.0 z) 0.5)))
double code(double x, double y, double z, double t) {
return ((x * 0.5) - y) * pow((2.0 * z), 0.5);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * 0.5d0) - y) * ((2.0d0 * z) ** 0.5d0)
end function
public static double code(double x, double y, double z, double t) {
return ((x * 0.5) - y) * Math.pow((2.0 * z), 0.5);
}
def code(x, y, z, t): return ((x * 0.5) - y) * math.pow((2.0 * z), 0.5)
function code(x, y, z, t) return Float64(Float64(Float64(x * 0.5) - y) * (Float64(2.0 * z) ^ 0.5)) end
function tmp = code(x, y, z, t) tmp = ((x * 0.5) - y) * ((2.0 * z) ^ 0.5); end
code[x_, y_, z_, t_] := N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Power[N[(2.0 * z), $MachinePrecision], 0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 0.5 - y\right) \cdot {\left(2 \cdot z\right)}^{0.5}
\end{array}
Initial program 99.4%
associate-*l*99.8%
exp-sqrt99.8%
exp-prod99.8%
Simplified99.8%
Taylor expanded in t around 0 57.8%
sqrt-prod57.9%
pow1/257.9%
*-commutative57.9%
Applied egg-rr57.9%
Final simplification57.9%
(FPCore (x y z t) :precision binary64 (* (- (* x 0.5) y) (sqrt (* 2.0 z))))
double code(double x, double y, double z, double t) {
return ((x * 0.5) - y) * sqrt((2.0 * z));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = ((x * 0.5d0) - y) * sqrt((2.0d0 * z))
end function
public static double code(double x, double y, double z, double t) {
return ((x * 0.5) - y) * Math.sqrt((2.0 * z));
}
def code(x, y, z, t): return ((x * 0.5) - y) * math.sqrt((2.0 * z))
function code(x, y, z, t) return Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(2.0 * z))) end
function tmp = code(x, y, z, t) tmp = ((x * 0.5) - y) * sqrt((2.0 * z)); end
code[x_, y_, z_, t_] := N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(2.0 * z), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 0.5 - y\right) \cdot \sqrt{2 \cdot z}
\end{array}
Initial program 99.4%
associate-*l*99.8%
exp-sqrt99.8%
exp-prod99.8%
Simplified99.8%
Taylor expanded in t around 0 57.8%
sqrt-prod57.9%
pow1/257.9%
*-commutative57.9%
Applied egg-rr57.9%
unpow1/257.9%
Simplified57.9%
Final simplification57.9%
(FPCore (x y z t) :precision binary64 (* (sqrt (* 2.0 z)) (* x 0.5)))
double code(double x, double y, double z, double t) {
return sqrt((2.0 * z)) * (x * 0.5);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = sqrt((2.0d0 * z)) * (x * 0.5d0)
end function
public static double code(double x, double y, double z, double t) {
return Math.sqrt((2.0 * z)) * (x * 0.5);
}
def code(x, y, z, t): return math.sqrt((2.0 * z)) * (x * 0.5)
function code(x, y, z, t) return Float64(sqrt(Float64(2.0 * z)) * Float64(x * 0.5)) end
function tmp = code(x, y, z, t) tmp = sqrt((2.0 * z)) * (x * 0.5); end
code[x_, y_, z_, t_] := N[(N[Sqrt[N[(2.0 * z), $MachinePrecision]], $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{2 \cdot z} \cdot \left(x \cdot 0.5\right)
\end{array}
Initial program 99.4%
associate-*l*99.8%
exp-sqrt99.8%
exp-prod99.8%
Simplified99.8%
Taylor expanded in t around 0 57.8%
Taylor expanded in x around inf 29.1%
pow129.1%
associate-*l*29.1%
sqrt-prod29.2%
pow1/229.2%
exp-to-pow27.7%
associate-*r*27.7%
*-commutative27.7%
exp-to-pow29.2%
pow1/229.2%
*-commutative29.2%
Applied egg-rr29.2%
unpow129.2%
*-commutative29.2%
*-commutative29.2%
Simplified29.2%
Final simplification29.2%
(FPCore (x y z t) :precision binary64 (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (pow (exp 1.0) (/ (* t t) 2.0))))
double code(double x, double y, double z, double t) {
return (((x * 0.5) - y) * sqrt((z * 2.0))) * pow(exp(1.0), ((t * t) / 2.0));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (((x * 0.5d0) - y) * sqrt((z * 2.0d0))) * (exp(1.0d0) ** ((t * t) / 2.0d0))
end function
public static double code(double x, double y, double z, double t) {
return (((x * 0.5) - y) * Math.sqrt((z * 2.0))) * Math.pow(Math.exp(1.0), ((t * t) / 2.0));
}
def code(x, y, z, t): return (((x * 0.5) - y) * math.sqrt((z * 2.0))) * math.pow(math.exp(1.0), ((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(1.0) ^ Float64(Float64(t * t) / 2.0))) end
function tmp = code(x, y, z, t) tmp = (((x * 0.5) - y) * sqrt((z * 2.0))) * (exp(1.0) ^ ((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[Power[N[Exp[1.0], $MachinePrecision], N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\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)}
\end{array}
herbie shell --seed 2024078
(FPCore (x y z t)
:name "Data.Number.Erf:$cinvnormcdf from erf-2.0.0.0, A"
:precision binary64
:alt
(* (* (- (* 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))))