
(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 9 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 (* (exp (/ (* t t) 2.0)) (* (- (* x 0.5) y) (sqrt (* z 2.0)))))
double code(double x, double y, double z, double t) {
return exp(((t * t) / 2.0)) * (((x * 0.5) - 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)) * (((x * 0.5d0) - 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)) * (((x * 0.5) - y) * Math.sqrt((z * 2.0)));
}
def code(x, y, z, t): return math.exp(((t * t) / 2.0)) * (((x * 0.5) - y) * math.sqrt((z * 2.0)))
function code(x, y, z, t) return Float64(exp(Float64(Float64(t * t) / 2.0)) * Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z * 2.0)))) end
function tmp = code(x, y, z, t) tmp = exp(((t * t) / 2.0)) * (((x * 0.5) - 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[(x * 0.5), $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(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\right)
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (* z 2.0))))
(if (<= t 6200.0)
(* (- (* x 0.5) 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 <= 6200.0) {
tmp = ((x * 0.5) - 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 <= 6200.0d0) then
tmp = ((x * 0.5d0) - 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 <= 6200.0) {
tmp = ((x * 0.5) - 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 <= 6200.0: tmp = ((x * 0.5) - 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 <= 6200.0) tmp = Float64(Float64(Float64(x * 0.5) - 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 <= 6200.0) tmp = ((x * 0.5) - 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, 6200.0], N[(N[(N[(x * 0.5), $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 6200:\\
\;\;\;\;\left(x \cdot 0.5 - 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}
if t < 6200Initial program 99.7%
Taylor expanded in t around 0 69.2%
associate-*r*69.1%
sqrt-prod69.3%
*-commutative69.3%
add-sqr-sqrt40.9%
sqrt-unprod46.5%
sqr-neg46.5%
sqrt-unprod11.3%
add-sqr-sqrt34.3%
distribute-rgt-out--33.7%
*-commutative33.7%
cancel-sign-sub-inv33.7%
*-commutative33.7%
associate-*r*33.7%
add-sqr-sqrt10.8%
sqrt-unprod46.5%
sqr-neg46.5%
sqrt-unprod40.9%
add-sqr-sqrt69.3%
Applied egg-rr69.3%
distribute-lft-neg-out69.3%
unsub-neg69.3%
associate-*r*69.3%
*-commutative69.3%
add-sqr-sqrt69.3%
sqr-neg69.3%
sqrt-unprod0.0%
add-sqr-sqrt33.7%
*-commutative33.7%
add-sqr-sqrt0.0%
sqrt-unprod69.3%
sqr-neg69.3%
add-sqr-sqrt69.3%
Applied egg-rr69.3%
distribute-rgt-out--69.3%
*-commutative69.3%
Simplified69.3%
if 6200 < t Initial program 100.0%
Taylor expanded in x around inf 75.4%
associate-*l*75.4%
Simplified75.4%
*-commutative75.4%
sqrt-prod75.4%
Applied egg-rr75.4%
Final simplification70.8%
(FPCore (x y z t) :precision binary64 (if (or (<= y -1.06e+244) (not (<= y -6.2e+112))) (* (- (* x 0.5) y) (sqrt (* z 2.0))) (sqrt (* (* z 2.0) (pow y 2.0)))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.06e+244) || !(y <= -6.2e+112)) {
tmp = ((x * 0.5) - y) * sqrt((z * 2.0));
} else {
tmp = sqrt(((z * 2.0) * pow(y, 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) :: tmp
if ((y <= (-1.06d+244)) .or. (.not. (y <= (-6.2d+112)))) then
tmp = ((x * 0.5d0) - y) * sqrt((z * 2.0d0))
else
tmp = sqrt(((z * 2.0d0) * (y ** 2.0d0)))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -1.06e+244) || !(y <= -6.2e+112)) {
tmp = ((x * 0.5) - y) * Math.sqrt((z * 2.0));
} else {
tmp = Math.sqrt(((z * 2.0) * Math.pow(y, 2.0)));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -1.06e+244) or not (y <= -6.2e+112): tmp = ((x * 0.5) - y) * math.sqrt((z * 2.0)) else: tmp = math.sqrt(((z * 2.0) * math.pow(y, 2.0))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -1.06e+244) || !(y <= -6.2e+112)) tmp = Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z * 2.0))); else tmp = sqrt(Float64(Float64(z * 2.0) * (y ^ 2.0))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -1.06e+244) || ~((y <= -6.2e+112))) tmp = ((x * 0.5) - y) * sqrt((z * 2.0)); else tmp = sqrt(((z * 2.0) * (y ^ 2.0))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -1.06e+244], N[Not[LessEqual[y, -6.2e+112]], $MachinePrecision]], N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(N[(z * 2.0), $MachinePrecision] * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.06 \cdot 10^{+244} \lor \neg \left(y \leq -6.2 \cdot 10^{+112}\right):\\
\;\;\;\;\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(z \cdot 2\right) \cdot {y}^{2}}\\
\end{array}
\end{array}
if y < -1.0599999999999999e244 or -6.19999999999999965e112 < y Initial program 99.8%
Taylor expanded in t around 0 60.0%
associate-*r*59.6%
sqrt-prod59.8%
*-commutative59.8%
add-sqr-sqrt38.2%
sqrt-unprod46.4%
sqr-neg46.4%
sqrt-unprod10.6%
add-sqr-sqrt31.7%
distribute-rgt-out--31.7%
*-commutative31.7%
cancel-sign-sub-inv31.7%
*-commutative31.7%
associate-*r*31.6%
add-sqr-sqrt10.6%
sqrt-unprod46.4%
sqr-neg46.4%
sqrt-unprod38.2%
add-sqr-sqrt59.8%
Applied egg-rr59.8%
distribute-lft-neg-out59.8%
unsub-neg59.8%
associate-*r*59.8%
*-commutative59.8%
add-sqr-sqrt59.8%
sqr-neg59.8%
sqrt-unprod0.0%
add-sqr-sqrt31.7%
*-commutative31.7%
add-sqr-sqrt0.0%
sqrt-unprod59.8%
sqr-neg59.8%
add-sqr-sqrt59.8%
Applied egg-rr59.8%
distribute-rgt-out--59.8%
*-commutative59.8%
Simplified59.8%
if -1.0599999999999999e244 < y < -6.19999999999999965e112Initial program 100.0%
Taylor expanded in t around 0 45.3%
Taylor expanded in x around 0 45.3%
mul-1-neg45.3%
*-commutative45.3%
distribute-rgt-neg-in45.3%
Simplified45.3%
associate-*r*45.3%
sqrt-prod45.4%
distribute-rgt-neg-in45.4%
distribute-lft-neg-out45.4%
add-sqr-sqrt45.3%
sqrt-unprod59.8%
swap-sqr78.2%
sqr-neg78.2%
add-sqr-sqrt78.2%
pow278.2%
Applied egg-rr78.2%
*-commutative78.2%
*-commutative78.2%
Simplified78.2%
Final simplification61.7%
(FPCore (x y z t)
:precision binary64
(if (<= y -3.7e+242)
(* (sqrt z) (* y (- (sqrt 2.0))))
(if (<= y -5.1e+110)
(sqrt (* (* z 2.0) (pow y 2.0)))
(* (- (* x 0.5) y) (sqrt (* z 2.0))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.7e+242) {
tmp = sqrt(z) * (y * -sqrt(2.0));
} else if (y <= -5.1e+110) {
tmp = sqrt(((z * 2.0) * pow(y, 2.0)));
} else {
tmp = ((x * 0.5) - y) * sqrt((z * 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) :: tmp
if (y <= (-3.7d+242)) then
tmp = sqrt(z) * (y * -sqrt(2.0d0))
else if (y <= (-5.1d+110)) then
tmp = sqrt(((z * 2.0d0) * (y ** 2.0d0)))
else
tmp = ((x * 0.5d0) - y) * sqrt((z * 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -3.7e+242) {
tmp = Math.sqrt(z) * (y * -Math.sqrt(2.0));
} else if (y <= -5.1e+110) {
tmp = Math.sqrt(((z * 2.0) * Math.pow(y, 2.0)));
} else {
tmp = ((x * 0.5) - y) * Math.sqrt((z * 2.0));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -3.7e+242: tmp = math.sqrt(z) * (y * -math.sqrt(2.0)) elif y <= -5.1e+110: tmp = math.sqrt(((z * 2.0) * math.pow(y, 2.0))) else: tmp = ((x * 0.5) - y) * math.sqrt((z * 2.0)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -3.7e+242) tmp = Float64(sqrt(z) * Float64(y * Float64(-sqrt(2.0)))); elseif (y <= -5.1e+110) tmp = sqrt(Float64(Float64(z * 2.0) * (y ^ 2.0))); else tmp = Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z * 2.0))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -3.7e+242) tmp = sqrt(z) * (y * -sqrt(2.0)); elseif (y <= -5.1e+110) tmp = sqrt(((z * 2.0) * (y ^ 2.0))); else tmp = ((x * 0.5) - y) * sqrt((z * 2.0)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -3.7e+242], N[(N[Sqrt[z], $MachinePrecision] * N[(y * (-N[Sqrt[2.0], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -5.1e+110], N[Sqrt[N[(N[(z * 2.0), $MachinePrecision] * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.7 \cdot 10^{+242}:\\
\;\;\;\;\sqrt{z} \cdot \left(y \cdot \left(-\sqrt{2}\right)\right)\\
\mathbf{elif}\;y \leq -5.1 \cdot 10^{+110}:\\
\;\;\;\;\sqrt{\left(z \cdot 2\right) \cdot {y}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}\\
\end{array}
\end{array}
if y < -3.7e242Initial program 99.9%
Taylor expanded in t around 0 82.1%
Taylor expanded in x around 0 79.7%
mul-1-neg79.7%
*-commutative79.7%
distribute-rgt-neg-in79.7%
Simplified79.7%
if -3.7e242 < y < -5.1000000000000002e110Initial program 100.0%
Taylor expanded in t around 0 45.3%
Taylor expanded in x around 0 45.3%
mul-1-neg45.3%
*-commutative45.3%
distribute-rgt-neg-in45.3%
Simplified45.3%
associate-*r*45.3%
sqrt-prod45.4%
distribute-rgt-neg-in45.4%
distribute-lft-neg-out45.4%
add-sqr-sqrt45.3%
sqrt-unprod59.8%
swap-sqr78.2%
sqr-neg78.2%
add-sqr-sqrt78.2%
pow278.2%
Applied egg-rr78.2%
*-commutative78.2%
*-commutative78.2%
Simplified78.2%
if -5.1000000000000002e110 < y Initial program 99.8%
Taylor expanded in t around 0 58.4%
associate-*r*58.4%
sqrt-prod58.5%
*-commutative58.5%
add-sqr-sqrt41.1%
sqrt-unprod49.9%
sqr-neg49.9%
sqrt-unprod11.3%
add-sqr-sqrt34.0%
distribute-rgt-out--34.0%
*-commutative34.0%
cancel-sign-sub-inv34.0%
*-commutative34.0%
associate-*r*34.0%
add-sqr-sqrt11.3%
sqrt-unprod49.9%
sqr-neg49.9%
sqrt-unprod41.1%
add-sqr-sqrt58.5%
Applied egg-rr58.5%
distribute-lft-neg-out58.5%
unsub-neg58.5%
associate-*r*58.5%
*-commutative58.5%
add-sqr-sqrt58.5%
sqr-neg58.5%
sqrt-unprod0.0%
add-sqr-sqrt34.0%
*-commutative34.0%
add-sqr-sqrt0.0%
sqrt-unprod58.5%
sqr-neg58.5%
add-sqr-sqrt58.5%
Applied egg-rr58.5%
distribute-rgt-out--58.5%
*-commutative58.5%
Simplified58.5%
Final simplification61.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* x 0.5) y)))
(if (<= y -1.06e+244)
(* (sqrt z) (* t_1 (sqrt 2.0)))
(if (<= y -4.5e+111)
(sqrt (* (* z 2.0) (pow y 2.0)))
(* t_1 (sqrt (* z 2.0)))))))
double code(double x, double y, double z, double t) {
double t_1 = (x * 0.5) - y;
double tmp;
if (y <= -1.06e+244) {
tmp = sqrt(z) * (t_1 * sqrt(2.0));
} else if (y <= -4.5e+111) {
tmp = sqrt(((z * 2.0) * pow(y, 2.0)));
} else {
tmp = t_1 * sqrt((z * 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 (y <= (-1.06d+244)) then
tmp = sqrt(z) * (t_1 * sqrt(2.0d0))
else if (y <= (-4.5d+111)) then
tmp = sqrt(((z * 2.0d0) * (y ** 2.0d0)))
else
tmp = t_1 * sqrt((z * 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 (y <= -1.06e+244) {
tmp = Math.sqrt(z) * (t_1 * Math.sqrt(2.0));
} else if (y <= -4.5e+111) {
tmp = Math.sqrt(((z * 2.0) * Math.pow(y, 2.0)));
} else {
tmp = t_1 * Math.sqrt((z * 2.0));
}
return tmp;
}
def code(x, y, z, t): t_1 = (x * 0.5) - y tmp = 0 if y <= -1.06e+244: tmp = math.sqrt(z) * (t_1 * math.sqrt(2.0)) elif y <= -4.5e+111: tmp = math.sqrt(((z * 2.0) * math.pow(y, 2.0))) else: tmp = t_1 * math.sqrt((z * 2.0)) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x * 0.5) - y) tmp = 0.0 if (y <= -1.06e+244) tmp = Float64(sqrt(z) * Float64(t_1 * sqrt(2.0))); elseif (y <= -4.5e+111) tmp = sqrt(Float64(Float64(z * 2.0) * (y ^ 2.0))); else tmp = Float64(t_1 * sqrt(Float64(z * 2.0))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x * 0.5) - y; tmp = 0.0; if (y <= -1.06e+244) tmp = sqrt(z) * (t_1 * sqrt(2.0)); elseif (y <= -4.5e+111) tmp = sqrt(((z * 2.0) * (y ^ 2.0))); else tmp = t_1 * sqrt((z * 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[y, -1.06e+244], N[(N[Sqrt[z], $MachinePrecision] * N[(t$95$1 * N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -4.5e+111], N[Sqrt[N[(N[(z * 2.0), $MachinePrecision] * N[Power[y, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(t$95$1 * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot 0.5 - y\\
\mathbf{if}\;y \leq -1.06 \cdot 10^{+244}:\\
\;\;\;\;\sqrt{z} \cdot \left(t\_1 \cdot \sqrt{2}\right)\\
\mathbf{elif}\;y \leq -4.5 \cdot 10^{+111}:\\
\;\;\;\;\sqrt{\left(z \cdot 2\right) \cdot {y}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \sqrt{z \cdot 2}\\
\end{array}
\end{array}
if y < -1.0599999999999999e244Initial program 99.9%
Taylor expanded in t around 0 82.1%
if -1.0599999999999999e244 < y < -4.50000000000000001e111Initial program 100.0%
Taylor expanded in t around 0 45.3%
Taylor expanded in x around 0 45.3%
mul-1-neg45.3%
*-commutative45.3%
distribute-rgt-neg-in45.3%
Simplified45.3%
associate-*r*45.3%
sqrt-prod45.4%
distribute-rgt-neg-in45.4%
distribute-lft-neg-out45.4%
add-sqr-sqrt45.3%
sqrt-unprod59.8%
swap-sqr78.2%
sqr-neg78.2%
add-sqr-sqrt78.2%
pow278.2%
Applied egg-rr78.2%
*-commutative78.2%
*-commutative78.2%
Simplified78.2%
if -4.50000000000000001e111 < y Initial program 99.8%
Taylor expanded in t around 0 58.4%
associate-*r*58.4%
sqrt-prod58.5%
*-commutative58.5%
add-sqr-sqrt41.1%
sqrt-unprod49.9%
sqr-neg49.9%
sqrt-unprod11.3%
add-sqr-sqrt34.0%
distribute-rgt-out--34.0%
*-commutative34.0%
cancel-sign-sub-inv34.0%
*-commutative34.0%
associate-*r*34.0%
add-sqr-sqrt11.3%
sqrt-unprod49.9%
sqr-neg49.9%
sqrt-unprod41.1%
add-sqr-sqrt58.5%
Applied egg-rr58.5%
distribute-lft-neg-out58.5%
unsub-neg58.5%
associate-*r*58.5%
*-commutative58.5%
add-sqr-sqrt58.5%
sqr-neg58.5%
sqrt-unprod0.0%
add-sqr-sqrt34.0%
*-commutative34.0%
add-sqr-sqrt0.0%
sqrt-unprod58.5%
sqr-neg58.5%
add-sqr-sqrt58.5%
Applied egg-rr58.5%
distribute-rgt-out--58.5%
*-commutative58.5%
Simplified58.5%
Final simplification62.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (sqrt (* z 2.0))))
(if (or (<= y -2e-43) (not (<= y 1.9e+28)))
(* t_1 (- y))
(* t_1 (+ (* x 0.5) y)))))
double code(double x, double y, double z, double t) {
double t_1 = sqrt((z * 2.0));
double tmp;
if ((y <= -2e-43) || !(y <= 1.9e+28)) {
tmp = t_1 * -y;
} else {
tmp = t_1 * ((x * 0.5) + 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 ((y <= (-2d-43)) .or. (.not. (y <= 1.9d+28))) then
tmp = t_1 * -y
else
tmp = t_1 * ((x * 0.5d0) + 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 ((y <= -2e-43) || !(y <= 1.9e+28)) {
tmp = t_1 * -y;
} else {
tmp = t_1 * ((x * 0.5) + y);
}
return tmp;
}
def code(x, y, z, t): t_1 = math.sqrt((z * 2.0)) tmp = 0 if (y <= -2e-43) or not (y <= 1.9e+28): tmp = t_1 * -y else: tmp = t_1 * ((x * 0.5) + y) return tmp
function code(x, y, z, t) t_1 = sqrt(Float64(z * 2.0)) tmp = 0.0 if ((y <= -2e-43) || !(y <= 1.9e+28)) tmp = Float64(t_1 * Float64(-y)); else tmp = Float64(t_1 * Float64(Float64(x * 0.5) + y)); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = sqrt((z * 2.0)); tmp = 0.0; if ((y <= -2e-43) || ~((y <= 1.9e+28))) tmp = t_1 * -y; else tmp = t_1 * ((x * 0.5) + y); 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, -2e-43], N[Not[LessEqual[y, 1.9e+28]], $MachinePrecision]], N[(t$95$1 * (-y)), $MachinePrecision], N[(t$95$1 * N[(N[(x * 0.5), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \sqrt{z \cdot 2}\\
\mathbf{if}\;y \leq -2 \cdot 10^{-43} \lor \neg \left(y \leq 1.9 \cdot 10^{+28}\right):\\
\;\;\;\;t\_1 \cdot \left(-y\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(x \cdot 0.5 + y\right)\\
\end{array}
\end{array}
if y < -2.00000000000000015e-43 or 1.8999999999999999e28 < y Initial program 99.8%
Taylor expanded in t around 0 62.9%
Taylor expanded in x around 0 51.7%
mul-1-neg51.7%
*-commutative51.7%
distribute-rgt-neg-in51.7%
Simplified51.7%
associate-*r*51.1%
sqrt-prod51.2%
distribute-rgt-neg-in51.2%
neg-sub051.2%
add-sqr-sqrt51.2%
sqr-neg51.2%
sqrt-unprod0.0%
add-sqr-sqrt0.8%
*-commutative0.8%
add-sqr-sqrt0.0%
sqrt-unprod51.2%
sqr-neg51.2%
add-sqr-sqrt51.2%
Applied egg-rr51.2%
neg-sub051.2%
distribute-rgt-neg-in51.2%
*-commutative51.2%
Simplified51.2%
if -2.00000000000000015e-43 < y < 1.8999999999999999e28Initial program 99.8%
Taylor expanded in t around 0 54.2%
associate-*r*54.1%
sqrt-prod54.3%
*-commutative54.3%
add-sqr-sqrt36.5%
sqrt-unprod49.4%
sqr-neg49.4%
sqrt-unprod14.8%
add-sqr-sqrt45.9%
distribute-rgt-out--45.9%
*-commutative45.9%
cancel-sign-sub-inv45.9%
*-commutative45.9%
associate-*r*45.8%
add-sqr-sqrt14.7%
sqrt-unprod49.4%
sqr-neg49.4%
sqrt-unprod36.5%
add-sqr-sqrt54.3%
Applied egg-rr54.3%
+-commutative54.3%
*-commutative54.3%
fma-define54.3%
add-sqr-sqrt0.0%
sqrt-unprod45.8%
sqr-neg45.8%
add-sqr-sqrt45.8%
associate-*r*45.9%
*-commutative45.9%
Applied egg-rr45.9%
fma-undefine45.9%
distribute-rgt-out45.9%
*-commutative45.9%
Simplified45.9%
Final simplification48.5%
(FPCore (x y z t) :precision binary64 (* (- (* x 0.5) y) (sqrt (* z 2.0))))
double code(double x, double y, double z, double t) {
return ((x * 0.5) - 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 = ((x * 0.5d0) - y) * sqrt((z * 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));
}
def code(x, y, z, t): return ((x * 0.5) - y) * math.sqrt((z * 2.0))
function code(x, y, z, t) return Float64(Float64(Float64(x * 0.5) - y) * sqrt(Float64(z * 2.0))) end
function tmp = code(x, y, z, t) tmp = ((x * 0.5) - y) * sqrt((z * 2.0)); end
code[x_, y_, z_, t_] := N[(N[(N[(x * 0.5), $MachinePrecision] - y), $MachinePrecision] * N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot 0.5 - y\right) \cdot \sqrt{z \cdot 2}
\end{array}
Initial program 99.8%
Taylor expanded in t around 0 58.6%
associate-*r*58.2%
sqrt-prod58.3%
*-commutative58.3%
add-sqr-sqrt34.3%
sqrt-unprod41.7%
sqr-neg41.7%
sqrt-unprod9.9%
add-sqr-sqrt28.9%
distribute-rgt-out--28.5%
*-commutative28.5%
cancel-sign-sub-inv28.5%
*-commutative28.5%
associate-*r*28.5%
add-sqr-sqrt9.5%
sqrt-unprod41.7%
sqr-neg41.7%
sqrt-unprod34.3%
add-sqr-sqrt58.3%
Applied egg-rr58.3%
distribute-lft-neg-out58.3%
unsub-neg58.3%
associate-*r*58.3%
*-commutative58.3%
add-sqr-sqrt58.3%
sqr-neg58.3%
sqrt-unprod0.0%
add-sqr-sqrt28.5%
*-commutative28.5%
add-sqr-sqrt0.0%
sqrt-unprod58.3%
sqr-neg58.3%
add-sqr-sqrt58.3%
Applied egg-rr58.3%
distribute-rgt-out--58.3%
*-commutative58.3%
Simplified58.3%
Final simplification58.3%
(FPCore (x y z t) :precision binary64 (* (sqrt (* z 2.0)) (- y)))
double code(double x, double y, double z, double t) {
return sqrt((z * 2.0)) * -y;
}
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((z * 2.0d0)) * -y
end function
public static double code(double x, double y, double z, double t) {
return Math.sqrt((z * 2.0)) * -y;
}
def code(x, y, z, t): return math.sqrt((z * 2.0)) * -y
function code(x, y, z, t) return Float64(sqrt(Float64(z * 2.0)) * Float64(-y)) end
function tmp = code(x, y, z, t) tmp = sqrt((z * 2.0)) * -y; end
code[x_, y_, z_, t_] := N[(N[Sqrt[N[(z * 2.0), $MachinePrecision]], $MachinePrecision] * (-y)), $MachinePrecision]
\begin{array}{l}
\\
\sqrt{z \cdot 2} \cdot \left(-y\right)
\end{array}
Initial program 99.8%
Taylor expanded in t around 0 58.6%
Taylor expanded in x around 0 31.9%
mul-1-neg31.9%
*-commutative31.9%
distribute-rgt-neg-in31.9%
Simplified31.9%
associate-*r*31.5%
sqrt-prod31.6%
distribute-rgt-neg-in31.6%
neg-sub031.6%
add-sqr-sqrt31.6%
sqr-neg31.6%
sqrt-unprod0.0%
add-sqr-sqrt2.5%
*-commutative2.5%
add-sqr-sqrt0.0%
sqrt-unprod31.6%
sqr-neg31.6%
add-sqr-sqrt31.6%
Applied egg-rr31.6%
neg-sub031.6%
distribute-rgt-neg-in31.6%
*-commutative31.6%
Simplified31.6%
Final simplification31.6%
(FPCore (x y z t) :precision binary64 0.0)
double code(double x, double y, double z, double t) {
return 0.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.0d0
end function
public static double code(double x, double y, double z, double t) {
return 0.0;
}
def code(x, y, z, t): return 0.0
function code(x, y, z, t) return 0.0 end
function tmp = code(x, y, z, t) tmp = 0.0; end
code[x_, y_, z_, t_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 99.8%
Taylor expanded in t around 0 58.6%
associate-*r*58.2%
sqrt-prod58.3%
*-commutative58.3%
add-sqr-sqrt34.3%
sqrt-unprod41.7%
sqr-neg41.7%
sqrt-unprod9.9%
add-sqr-sqrt28.9%
distribute-rgt-out--28.5%
*-commutative28.5%
cancel-sign-sub-inv28.5%
*-commutative28.5%
associate-*r*28.5%
add-sqr-sqrt9.5%
sqrt-unprod41.7%
sqr-neg41.7%
sqrt-unprod34.3%
add-sqr-sqrt58.3%
Applied egg-rr58.3%
distribute-lft-neg-out58.3%
unsub-neg58.3%
associate-*r*58.3%
*-commutative58.3%
add-sqr-sqrt58.3%
sqr-neg58.3%
sqrt-unprod0.0%
add-sqr-sqrt28.5%
*-commutative28.5%
add-sqr-sqrt0.0%
sqrt-unprod58.3%
sqr-neg58.3%
add-sqr-sqrt58.3%
Applied egg-rr58.3%
Taylor expanded in z around 0 3.1%
Final simplification3.1%
(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 2024039
(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))))