
(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 8 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 (* (- (* 0.5 x) y) (sqrt (* z (* 2.0 (exp (pow t 2.0)))))))
double code(double x, double y, double z, double t) {
return ((0.5 * x) - y) * sqrt((z * (2.0 * exp(pow(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 = ((0.5d0 * x) - y) * sqrt((z * (2.0d0 * exp((t ** 2.0d0)))))
end function
public static double code(double x, double y, double z, double t) {
return ((0.5 * x) - y) * Math.sqrt((z * (2.0 * Math.exp(Math.pow(t, 2.0)))));
}
def code(x, y, z, t): return ((0.5 * x) - y) * math.sqrt((z * (2.0 * math.exp(math.pow(t, 2.0)))))
function code(x, y, z, t) return Float64(Float64(Float64(0.5 * x) - y) * sqrt(Float64(z * Float64(2.0 * exp((t ^ 2.0)))))) end
function tmp = code(x, y, z, t) tmp = ((0.5 * x) - y) * sqrt((z * (2.0 * exp((t ^ 2.0))))); end
code[x_, y_, z_, t_] := N[(N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * N[(2.0 * N[Exp[N[Power[t, 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot x - y\right) \cdot \sqrt{z \cdot \left(2 \cdot e^{{t}^{2}}\right)}
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (* z 2.0))))
(if (<= t 1.52e-6)
(* (- (* 0.5 x) y) t_1)
(if (<= t 2e+159)
(* (exp (/ (* t t) 2.0)) (* 0.5 (* x t_1)))
(* t_1 (- (* 0.5 (- x (* y (pow t 2.0)))) y))))))
double code(double x, double y, double z, double t) {
double t_1 = sqrt((z * 2.0));
double tmp;
if (t <= 1.52e-6) {
tmp = ((0.5 * x) - y) * t_1;
} else if (t <= 2e+159) {
tmp = exp(((t * t) / 2.0)) * (0.5 * (x * t_1));
} else {
tmp = t_1 * ((0.5 * (x - (y * pow(t, 2.0)))) - y);
}
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 = sqrt((z * 2.0d0))
if (t <= 1.52d-6) then
tmp = ((0.5d0 * x) - y) * t_1
else if (t <= 2d+159) then
tmp = exp(((t * t) / 2.0d0)) * (0.5d0 * (x * t_1))
else
tmp = t_1 * ((0.5d0 * (x - (y * (t ** 2.0d0)))) - y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.sqrt((z * 2.0));
double tmp;
if (t <= 1.52e-6) {
tmp = ((0.5 * x) - y) * t_1;
} else if (t <= 2e+159) {
tmp = Math.exp(((t * t) / 2.0)) * (0.5 * (x * t_1));
} else {
tmp = t_1 * ((0.5 * (x - (y * Math.pow(t, 2.0)))) - y);
}
return tmp;
}
def code(x, y, z, t): t_1 = math.sqrt((z * 2.0)) tmp = 0 if t <= 1.52e-6: tmp = ((0.5 * x) - y) * t_1 elif t <= 2e+159: tmp = math.exp(((t * t) / 2.0)) * (0.5 * (x * t_1)) else: tmp = t_1 * ((0.5 * (x - (y * math.pow(t, 2.0)))) - y) return tmp
function code(x, y, z, t) t_1 = sqrt(Float64(z * 2.0)) tmp = 0.0 if (t <= 1.52e-6) tmp = Float64(Float64(Float64(0.5 * x) - y) * t_1); elseif (t <= 2e+159) tmp = Float64(exp(Float64(Float64(t * t) / 2.0)) * Float64(0.5 * Float64(x * t_1))); else tmp = Float64(t_1 * Float64(Float64(0.5 * Float64(x - Float64(y * (t ^ 2.0)))) - y)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = sqrt((z * 2.0)); tmp = 0.0; if (t <= 1.52e-6) tmp = ((0.5 * x) - y) * t_1; elseif (t <= 2e+159) tmp = exp(((t * t) / 2.0)) * (0.5 * (x * t_1)); else tmp = t_1 * ((0.5 * (x - (y * (t ^ 2.0)))) - y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, 1.52e-6], N[(N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision] * t$95$1), $MachinePrecision], If[LessEqual[t, 2e+159], N[(N[Exp[N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(0.5 * N[(x * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(N[(0.5 * N[(x - N[(y * N[Power[t, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sqrt{z \cdot 2}\\
\mathbf{if}\;t \leq 1.52 \cdot 10^{-6}:\\
\;\;\;\;\left(0.5 \cdot x - y\right) \cdot t_1\\
\mathbf{elif}\;t \leq 2 \cdot 10^{+159}:\\
\;\;\;\;e^{\frac{t \cdot t}{2}} \cdot \left(0.5 \cdot \left(x \cdot t_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left(0.5 \cdot \left(x - y \cdot {t}^{2}\right) - y\right)\\
\end{array}
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (* z 2.0))))
(if (<= t 1.52e-6)
(* (- (* 0.5 x) y) t_1)
(* (exp (/ (* t t) 2.0)) (* 0.5 (* x t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = sqrt((z * 2.0));
double tmp;
if (t <= 1.52e-6) {
tmp = ((0.5 * x) - y) * t_1;
} else {
tmp = exp(((t * t) / 2.0)) * (0.5 * (x * t_1));
}
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 = sqrt((z * 2.0d0))
if (t <= 1.52d-6) then
tmp = ((0.5d0 * x) - y) * t_1
else
tmp = exp(((t * t) / 2.0d0)) * (0.5d0 * (x * t_1))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.sqrt((z * 2.0));
double tmp;
if (t <= 1.52e-6) {
tmp = ((0.5 * x) - y) * t_1;
} else {
tmp = Math.exp(((t * t) / 2.0)) * (0.5 * (x * t_1));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.sqrt((z * 2.0)) tmp = 0 if t <= 1.52e-6: tmp = ((0.5 * x) - y) * t_1 else: tmp = math.exp(((t * t) / 2.0)) * (0.5 * (x * t_1)) return tmp
function code(x, y, z, t) t_1 = sqrt(Float64(z * 2.0)) tmp = 0.0 if (t <= 1.52e-6) tmp = Float64(Float64(Float64(0.5 * x) - y) * t_1); else tmp = Float64(exp(Float64(Float64(t * t) / 2.0)) * Float64(0.5 * Float64(x * t_1))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = sqrt((z * 2.0)); tmp = 0.0; if (t <= 1.52e-6) tmp = ((0.5 * x) - y) * t_1; else tmp = exp(((t * t) / 2.0)) * (0.5 * (x * t_1)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, 1.52e-6], N[(N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[Exp[N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(0.5 * N[(x * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sqrt{z \cdot 2}\\
\mathbf{if}\;t \leq 1.52 \cdot 10^{-6}:\\
\;\;\;\;\left(0.5 \cdot x - y\right) \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{t \cdot t}{2}} \cdot \left(0.5 \cdot \left(x \cdot t_1\right)\right)\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (* (exp (/ (* t t) 2.0)) (* (- (* 0.5 x) y) (sqrt (* z 2.0)))))
double code(double x, double y, double z, double t) {
return exp(((t * t) / 2.0)) * (((0.5 * x) - y) * sqrt((z * 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 = exp(((t * t) / 2.0d0)) * (((0.5d0 * x) - y) * sqrt((z * 2.0d0)))
end function
public static double code(double x, double y, double z, double t) {
return Math.exp(((t * t) / 2.0)) * (((0.5 * x) - y) * Math.sqrt((z * 2.0)));
}
def code(x, y, z, t): return math.exp(((t * t) / 2.0)) * (((0.5 * x) - y) * math.sqrt((z * 2.0)))
function code(x, y, z, t) return Float64(exp(Float64(Float64(t * t) / 2.0)) * Float64(Float64(Float64(0.5 * x) - y) * sqrt(Float64(z * 2.0)))) end
function tmp = code(x, y, z, t) tmp = exp(((t * t) / 2.0)) * (((0.5 * x) - y) * sqrt((z * 2.0))); end
code[x_, y_, z_, t_] := N[(N[Exp[N[(N[(t * t), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{\frac{t \cdot t}{2}} \cdot \left(\left(0.5 \cdot x - y\right) \cdot \sqrt{z \cdot 2}\right)
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (* z 2.0))))
(if (or (<= y -7.8e-85) (not (<= y 5.4e-19)))
(* y (- t_1))
(* (* 0.5 x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = sqrt((z * 2.0));
double tmp;
if ((y <= -7.8e-85) || !(y <= 5.4e-19)) {
tmp = y * -t_1;
} else {
tmp = (0.5 * x) * t_1;
}
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 = sqrt((z * 2.0d0))
if ((y <= (-7.8d-85)) .or. (.not. (y <= 5.4d-19))) then
tmp = y * -t_1
else
tmp = (0.5d0 * x) * t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.sqrt((z * 2.0));
double tmp;
if ((y <= -7.8e-85) || !(y <= 5.4e-19)) {
tmp = y * -t_1;
} else {
tmp = (0.5 * x) * t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = math.sqrt((z * 2.0)) tmp = 0 if (y <= -7.8e-85) or not (y <= 5.4e-19): tmp = y * -t_1 else: tmp = (0.5 * x) * t_1 return tmp
function code(x, y, z, t) t_1 = sqrt(Float64(z * 2.0)) tmp = 0.0 if ((y <= -7.8e-85) || !(y <= 5.4e-19)) tmp = Float64(y * Float64(-t_1)); else tmp = Float64(Float64(0.5 * x) * t_1); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = sqrt((z * 2.0)); tmp = 0.0; if ((y <= -7.8e-85) || ~((y <= 5.4e-19))) tmp = y * -t_1; else tmp = (0.5 * x) * t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[y, -7.8e-85], N[Not[LessEqual[y, 5.4e-19]], $MachinePrecision]], N[(y * (-t$95$1)), $MachinePrecision], N[(N[(0.5 * x), $MachinePrecision] * t$95$1), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sqrt{z \cdot 2}\\
\mathbf{if}\;y \leq -7.8 \cdot 10^{-85} \lor \neg \left(y \leq 5.4 \cdot 10^{-19}\right):\\
\;\;\;\;y \cdot \left(-t_1\right)\\
\mathbf{else}:\\
\;\;\;\;\left(0.5 \cdot x\right) \cdot t_1\\
\end{array}
\end{array}
(FPCore (x y z t) :precision binary64 (* (- (* 0.5 x) y) (sqrt (* z 2.0))))
double code(double x, double y, double z, double t) {
return ((0.5 * x) - y) * sqrt((z * 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 = ((0.5d0 * x) - y) * sqrt((z * 2.0d0))
end function
public static double code(double x, double y, double z, double t) {
return ((0.5 * x) - y) * Math.sqrt((z * 2.0));
}
def code(x, y, z, t): return ((0.5 * x) - y) * math.sqrt((z * 2.0))
function code(x, y, z, t) return Float64(Float64(Float64(0.5 * x) - y) * sqrt(Float64(z * 2.0))) end
function tmp = code(x, y, z, t) tmp = ((0.5 * x) - y) * sqrt((z * 2.0)); end
code[x_, y_, z_, t_] := N[(N[(N[(0.5 * x), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(0.5 \cdot x - y\right) \cdot \sqrt{z \cdot 2}
\end{array}
(FPCore (x y z t) :precision binary64 (* y (- (sqrt (* z 2.0)))))
double code(double x, double y, double z, double t) {
return y * -sqrt((z * 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 = y * -sqrt((z * 2.0d0))
end function
public static double code(double x, double y, double z, double t) {
return y * -Math.sqrt((z * 2.0));
}
def code(x, y, z, t): return y * -math.sqrt((z * 2.0))
function code(x, y, z, t) return Float64(y * Float64(-sqrt(Float64(z * 2.0)))) end
function tmp = code(x, y, z, t) tmp = y * -sqrt((z * 2.0)); end
code[x_, y_, z_, t_] := N[(y * (-N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \left(-\sqrt{z \cdot 2}\right)
\end{array}
(FPCore (x y z t) :precision binary64 (* y (sqrt (* z 2.0))))
double code(double x, double y, double z, double t) {
return y * sqrt((z * 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 = y * sqrt((z * 2.0d0))
end function
public static double code(double x, double y, double z, double t) {
return y * Math.sqrt((z * 2.0));
}
def code(x, y, z, t): return y * math.sqrt((z * 2.0))
function code(x, y, z, t) return Float64(y * sqrt(Float64(z * 2.0))) end
function tmp = code(x, y, z, t) tmp = y * sqrt((z * 2.0)); end
code[x_, y_, z_, t_] := N[(y * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot \sqrt{z \cdot 2}
\end{array}
(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 2023350
(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))))