
(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 15 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}
t_m = (fabs.f64 t) (FPCore (x y z t_m) :precision binary64 (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (pow (exp (- t_m)) (* t_m -0.5))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
return (((x * 0.5) - y) * sqrt((z * 2.0))) * pow(exp(-t_m), (t_m * -0.5));
}
t_m = abs(t)
real(8) function code(x, y, z, t_m)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t_m
code = (((x * 0.5d0) - y) * sqrt((z * 2.0d0))) * (exp(-t_m) ** (t_m * (-0.5d0)))
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
return (((x * 0.5) - y) * Math.sqrt((z * 2.0))) * Math.pow(Math.exp(-t_m), (t_m * -0.5));
}
t_m = math.fabs(t) def code(x, y, z, t_m): return (((x * 0.5) - y) * math.sqrt((z * 2.0))) * math.pow(math.exp(-t_m), (t_m * -0.5))
t_m = abs(t) function code(x, y, z, t_m) return Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z * 2.0))) * (exp(Float64(-t_m)) ^ Float64(t_m * -0.5))) end
t_m = abs(t); function tmp = code(x, y, z, t_m) tmp = (((x * 0.5) - y) * sqrt((z * 2.0))) * (exp(-t_m) ^ (t_m * -0.5)); end
t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z_, t$95$m_] := N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[N[Exp[(-t$95$m)], $MachinePrecision], N[(t$95$m * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|
\\
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot {\left(e^{-t\_m}\right)}^{\left(t\_m \cdot -0.5\right)}
\end{array}
Initial program 99.7%
lift-exp.f64N/A
lift-/.f64N/A
frac-2negN/A
div-invN/A
lift-*.f64N/A
distribute-lft-neg-inN/A
associate-*l*N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64N/A
lower-neg.f64N/A
lower-*.f64N/A
metadata-evalN/A
metadata-eval99.8
Applied rewrites99.8%
t_m = (fabs.f64 t) (FPCore (x y z t_m) :precision binary64 (* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (pow (exp t_m) (* 0.5 t_m))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
return (((x * 0.5) - y) * sqrt((z * 2.0))) * pow(exp(t_m), (0.5 * t_m));
}
t_m = abs(t)
real(8) function code(x, y, z, t_m)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t_m
code = (((x * 0.5d0) - y) * sqrt((z * 2.0d0))) * (exp(t_m) ** (0.5d0 * t_m))
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
return (((x * 0.5) - y) * Math.sqrt((z * 2.0))) * Math.pow(Math.exp(t_m), (0.5 * t_m));
}
t_m = math.fabs(t) def code(x, y, z, t_m): return (((x * 0.5) - y) * math.sqrt((z * 2.0))) * math.pow(math.exp(t_m), (0.5 * t_m))
t_m = abs(t) function code(x, y, z, t_m) return Float64(Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z * 2.0))) * (exp(t_m) ^ Float64(0.5 * t_m))) end
t_m = abs(t); function tmp = code(x, y, z, t_m) tmp = (((x * 0.5) - y) * sqrt((z * 2.0))) * (exp(t_m) ^ (0.5 * t_m)); end
t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z_, t$95$m_] := N[(N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Power[N[Exp[t$95$m], $MachinePrecision], N[(0.5 * t$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|
\\
\left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right) \cdot {\left(e^{t\_m}\right)}^{\left(0.5 \cdot t\_m\right)}
\end{array}
Initial program 99.4%
lift-exp.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
exp-prodN/A
lower-pow.f64N/A
lower-exp.f64N/A
div-invN/A
metadata-evalN/A
lower-*.f6499.4
Applied rewrites99.4%
Final simplification99.4%
(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 2024226
(FPCore (x y z t)
:name "Data.Number.Erf:$cinvnormcdf from erf-2.0.0.0, A"
:precision binary64
:alt
(! :herbie-platform default (* (* (- (* x 1/2) y) (sqrt (* z 2))) (pow (exp 1) (/ (* t t) 2))))
(* (* (- (* x 0.5) y) (sqrt (* z 2.0))) (exp (/ (* t t) 2.0))))