
(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 6 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 (* (* (sqrt (* z 2.0)) (sqrt (pow (exp t_m) t_m))) (- (* x 0.5) y)))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
return (sqrt((z * 2.0)) * sqrt(pow(exp(t_m), t_m))) * ((x * 0.5) - y);
}
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 = (sqrt((z * 2.0d0)) * sqrt((exp(t_m) ** t_m))) * ((x * 0.5d0) - y)
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
return (Math.sqrt((z * 2.0)) * Math.sqrt(Math.pow(Math.exp(t_m), t_m))) * ((x * 0.5) - y);
}
t_m = math.fabs(t) def code(x, y, z, t_m): return (math.sqrt((z * 2.0)) * math.sqrt(math.pow(math.exp(t_m), t_m))) * ((x * 0.5) - y)
t_m = abs(t) function code(x, y, z, t_m) return Float64(Float64(sqrt(Float64(z * 2.0)) * sqrt((exp(t_m) ^ t_m))) * Float64(Float64(x * 0.5) - y)) end
t_m = abs(t); function tmp = code(x, y, z, t_m) tmp = (sqrt((z * 2.0)) * sqrt((exp(t_m) ^ t_m))) * ((x * 0.5) - y); end
t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z_, t$95$m_] := N[(N[(N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Power[N[Exp[t$95$m], $MachinePrecision], t$95$m], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|
\\
\left(\sqrt{z \cdot 2} \cdot \sqrt{{\left(e^{t\_m}\right)}^{t\_m}}\right) \cdot \left(x \cdot 0.5 - y\right)
\end{array}
Initial program 99.4%
associate-*l*99.7%
exp-sqrt99.7%
exp-prod99.8%
Simplified99.8%
Final simplification99.8%
t_m = (fabs.f64 t) (FPCore (x y z t_m) :precision binary64 (* (- (* x 0.5) y) (sqrt (* (* z 2.0) (exp (pow t_m 2.0))))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
return ((x * 0.5) - y) * sqrt(((z * 2.0) * exp(pow(t_m, 2.0))));
}
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 ** 2.0d0))))
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.exp(Math.pow(t_m, 2.0))));
}
t_m = math.fabs(t) def code(x, y, z, t_m): return ((x * 0.5) - y) * math.sqrt(((z * 2.0) * math.exp(math.pow(t_m, 2.0))))
t_m = abs(t) function code(x, y, z, t_m) return Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(Float64(z * 2.0) * exp((t_m ^ 2.0))))) 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 ^ 2.0)))); end
t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z_, t$95$m_] := N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(N[(z * 2.0), $MachinePrecision] * N[Exp[N[Power[t$95$m, 2.0], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|
\\
\left(x \cdot 0.5 - y\right) \cdot \sqrt{\left(z \cdot 2\right) \cdot e^{{t\_m}^{2}}}
\end{array}
Initial program 99.4%
associate-*r*99.7%
*-commutative99.7%
sub-neg99.7%
distribute-lft-in75.5%
exp-sqrt75.5%
pow-exp75.5%
sqrt-unprod75.5%
associate-*l*75.5%
pow-exp75.5%
pow275.5%
Applied egg-rr75.5%
distribute-lft-out99.7%
*-commutative99.7%
sub-neg99.7%
*-commutative99.7%
*-commutative99.7%
*-commutative99.7%
associate-*l*99.7%
Simplified99.7%
Final simplification99.7%
t_m = (fabs.f64 t) (FPCore (x y z t_m) :precision binary64 (* (* (sqrt (* z 2.0)) (- (* x 0.5) y)) (exp (/ (* t_m t_m) 2.0))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
return (sqrt((z * 2.0)) * ((x * 0.5) - y)) * exp(((t_m * t_m) / 2.0));
}
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 = (sqrt((z * 2.0d0)) * ((x * 0.5d0) - y)) * exp(((t_m * t_m) / 2.0d0))
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
return (Math.sqrt((z * 2.0)) * ((x * 0.5) - y)) * Math.exp(((t_m * t_m) / 2.0));
}
t_m = math.fabs(t) def code(x, y, z, t_m): return (math.sqrt((z * 2.0)) * ((x * 0.5) - y)) * math.exp(((t_m * t_m) / 2.0))
t_m = abs(t) function code(x, y, z, t_m) return Float64(Float64(sqrt(Float64(z * 2.0)) * Float64(Float64(x * 0.5) - y)) * exp(Float64(Float64(t_m * t_m) / 2.0))) end
t_m = abs(t); function tmp = code(x, y, z, t_m) tmp = (sqrt((z * 2.0)) * ((x * 0.5) - y)) * exp(((t_m * t_m) / 2.0)); end
t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z_, t$95$m_] := N[(N[(N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision] * N[Exp[N[(N[(t$95$m * t$95$m), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|
\\
\left(\sqrt{z \cdot 2} \cdot \left(x \cdot 0.5 - y\right)\right) \cdot e^{\frac{t\_m \cdot t\_m}{2}}
\end{array}
Initial program 99.4%
Final simplification99.4%
t_m = (fabs.f64 t) (FPCore (x y z t_m) :precision binary64 (* (sqrt z) (* (- (* x 0.5) y) (sqrt 2.0))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
return sqrt(z) * (((x * 0.5) - y) * sqrt(2.0));
}
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 = sqrt(z) * (((x * 0.5d0) - y) * sqrt(2.0d0))
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
return Math.sqrt(z) * (((x * 0.5) - y) * Math.sqrt(2.0));
}
t_m = math.fabs(t) def code(x, y, z, t_m): return math.sqrt(z) * (((x * 0.5) - y) * math.sqrt(2.0))
t_m = abs(t) function code(x, y, z, t_m) return Float64(sqrt(z) * Float64(Float64(Float64(x * 0.5) - y) * sqrt(2.0))) end
t_m = abs(t); function tmp = code(x, y, z, t_m) tmp = sqrt(z) * (((x * 0.5) - y) * sqrt(2.0)); end
t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z_, t$95$m_] := N[(N[Sqrt[z], $MachinePrecision] * N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|
\\
\sqrt{z} \cdot \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{2}\right)
\end{array}
Initial program 99.4%
Taylor expanded in t around 0 58.2%
Final simplification58.2%
t_m = (fabs.f64 t) (FPCore (x y z t_m) :precision binary64 (* (sqrt 2.0) (* (- (* x 0.5) y) (sqrt z))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
return sqrt(2.0) * (((x * 0.5) - y) * sqrt(z));
}
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 = sqrt(2.0d0) * (((x * 0.5d0) - y) * sqrt(z))
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
return Math.sqrt(2.0) * (((x * 0.5) - y) * Math.sqrt(z));
}
t_m = math.fabs(t) def code(x, y, z, t_m): return math.sqrt(2.0) * (((x * 0.5) - y) * math.sqrt(z))
t_m = abs(t) function code(x, y, z, t_m) return Float64(sqrt(2.0) * Float64(Float64(Float64(x * 0.5) - y) * sqrt(z))) end
t_m = abs(t); function tmp = code(x, y, z, t_m) tmp = sqrt(2.0) * (((x * 0.5) - y) * sqrt(z)); end
t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z_, t$95$m_] := N[(N[Sqrt[2.0], $MachinePrecision] * N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[z], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|
\\
\sqrt{2} \cdot \left(\left(x \cdot 0.5 - y\right) \cdot \sqrt{z}\right)
\end{array}
Initial program 99.4%
Taylor expanded in t around 0 58.2%
associate-*r*58.1%
*-commutative58.1%
associate-*l*58.1%
Simplified58.1%
Final simplification58.1%
t_m = (fabs.f64 t) (FPCore (x y z t_m) :precision binary64 (* (sqrt z) (* 0.5 (* x (sqrt 2.0)))))
t_m = fabs(t);
double code(double x, double y, double z, double t_m) {
return sqrt(z) * (0.5 * (x * sqrt(2.0)));
}
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 = sqrt(z) * (0.5d0 * (x * sqrt(2.0d0)))
end function
t_m = Math.abs(t);
public static double code(double x, double y, double z, double t_m) {
return Math.sqrt(z) * (0.5 * (x * Math.sqrt(2.0)));
}
t_m = math.fabs(t) def code(x, y, z, t_m): return math.sqrt(z) * (0.5 * (x * math.sqrt(2.0)))
t_m = abs(t) function code(x, y, z, t_m) return Float64(sqrt(z) * Float64(0.5 * Float64(x * sqrt(2.0)))) end
t_m = abs(t); function tmp = code(x, y, z, t_m) tmp = sqrt(z) * (0.5 * (x * sqrt(2.0))); end
t_m = N[Abs[t], $MachinePrecision] code[x_, y_, z_, t$95$m_] := N[(N[Sqrt[z], $MachinePrecision] * N[(0.5 * N[(x * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
t_m = \left|t\right|
\\
\sqrt{z} \cdot \left(0.5 \cdot \left(x \cdot \sqrt{2}\right)\right)
\end{array}
Initial program 99.4%
add-sqr-sqrt47.8%
pow247.8%
Applied egg-rr47.8%
Taylor expanded in x around inf 61.0%
*-commutative61.0%
associate-*l*61.0%
*-commutative61.0%
associate-*r*61.0%
*-commutative61.0%
*-commutative61.0%
associate-*r*61.0%
Simplified61.0%
Taylor expanded in t around 0 30.9%
associate-*r*30.9%
*-commutative30.9%
Simplified30.9%
Final simplification30.9%
(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 2024111
(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))))