
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
double code(double x, double y, double z, double t) {
return (x * 2.0) / ((y * z) - (t * 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 * 2.0d0) / ((y * z) - (t * z))
end function
public static double code(double x, double y, double z, double t) {
return (x * 2.0) / ((y * z) - (t * z));
}
def code(x, y, z, t): return (x * 2.0) / ((y * z) - (t * z))
function code(x, y, z, t) return Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(t * z))) end
function tmp = code(x, y, z, t) tmp = (x * 2.0) / ((y * z) - (t * z)); end
code[x_, y_, z_, t_] := N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (/ (* x 2.0) (- (* y z) (* t z))))
double code(double x, double y, double z, double t) {
return (x * 2.0) / ((y * z) - (t * 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 * 2.0d0) / ((y * z) - (t * z))
end function
public static double code(double x, double y, double z, double t) {
return (x * 2.0) / ((y * z) - (t * z));
}
def code(x, y, z, t): return (x * 2.0) / ((y * z) - (t * z))
function code(x, y, z, t) return Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(t * z))) end
function tmp = code(x, y, z, t) tmp = (x * 2.0) / ((y * z) - (t * z)); end
code[x_, y_, z_, t_] := N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot 2}{y \cdot z - t \cdot z}
\end{array}
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m t)
:precision binary64
(*
z_s
(if (<= z_m 5e+36)
(/ (* x 2.0) (* z_m (- y t)))
(* (/ x (- y t)) (/ 2.0 z_m)))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 5e+36) {
tmp = (x * 2.0) / (z_m * (y - t));
} else {
tmp = (x / (y - t)) * (2.0 / z_m);
}
return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m, t)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: tmp
if (z_m <= 5d+36) then
tmp = (x * 2.0d0) / (z_m * (y - t))
else
tmp = (x / (y - t)) * (2.0d0 / z_m)
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 5e+36) {
tmp = (x * 2.0) / (z_m * (y - t));
} else {
tmp = (x / (y - t)) * (2.0 / z_m);
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): tmp = 0 if z_m <= 5e+36: tmp = (x * 2.0) / (z_m * (y - t)) else: tmp = (x / (y - t)) * (2.0 / z_m) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) tmp = 0.0 if (z_m <= 5e+36) tmp = Float64(Float64(x * 2.0) / Float64(z_m * Float64(y - t))); else tmp = Float64(Float64(x / Float64(y - t)) * Float64(2.0 / z_m)); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m, t) tmp = 0.0; if (z_m <= 5e+36) tmp = (x * 2.0) / (z_m * (y - t)); else tmp = (x / (y - t)) * (2.0 / z_m); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * If[LessEqual[z$95$m, 5e+36], N[(N[(x * 2.0), $MachinePrecision] / N[(z$95$m * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision] * N[(2.0 / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 5 \cdot 10^{+36}:\\
\;\;\;\;\frac{x \cdot 2}{z\_m \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y - t} \cdot \frac{2}{z\_m}\\
\end{array}
\end{array}
if z < 4.99999999999999977e36Initial program 92.3%
distribute-rgt-out--94.9%
Simplified94.9%
if 4.99999999999999977e36 < z Initial program 87.0%
distribute-rgt-out--88.7%
Simplified88.7%
*-commutative88.7%
times-frac98.1%
Applied egg-rr98.1%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m t)
:precision binary64
(*
z_s
(if (<= y -580000000000.0)
(* (/ 2.0 z_m) (/ x y))
(if (<= y 74000000.0)
(/ (* x 2.0) (* z_m (- t)))
(* x (/ 2.0 (* z_m y)))))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (y <= -580000000000.0) {
tmp = (2.0 / z_m) * (x / y);
} else if (y <= 74000000.0) {
tmp = (x * 2.0) / (z_m * -t);
} else {
tmp = x * (2.0 / (z_m * y));
}
return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m, t)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: tmp
if (y <= (-580000000000.0d0)) then
tmp = (2.0d0 / z_m) * (x / y)
else if (y <= 74000000.0d0) then
tmp = (x * 2.0d0) / (z_m * -t)
else
tmp = x * (2.0d0 / (z_m * y))
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (y <= -580000000000.0) {
tmp = (2.0 / z_m) * (x / y);
} else if (y <= 74000000.0) {
tmp = (x * 2.0) / (z_m * -t);
} else {
tmp = x * (2.0 / (z_m * y));
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): tmp = 0 if y <= -580000000000.0: tmp = (2.0 / z_m) * (x / y) elif y <= 74000000.0: tmp = (x * 2.0) / (z_m * -t) else: tmp = x * (2.0 / (z_m * y)) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) tmp = 0.0 if (y <= -580000000000.0) tmp = Float64(Float64(2.0 / z_m) * Float64(x / y)); elseif (y <= 74000000.0) tmp = Float64(Float64(x * 2.0) / Float64(z_m * Float64(-t))); else tmp = Float64(x * Float64(2.0 / Float64(z_m * y))); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m, t) tmp = 0.0; if (y <= -580000000000.0) tmp = (2.0 / z_m) * (x / y); elseif (y <= 74000000.0) tmp = (x * 2.0) / (z_m * -t); else tmp = x * (2.0 / (z_m * y)); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * If[LessEqual[y, -580000000000.0], N[(N[(2.0 / z$95$m), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 74000000.0], N[(N[(x * 2.0), $MachinePrecision] / N[(z$95$m * (-t)), $MachinePrecision]), $MachinePrecision], N[(x * N[(2.0 / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -580000000000:\\
\;\;\;\;\frac{2}{z\_m} \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq 74000000:\\
\;\;\;\;\frac{x \cdot 2}{z\_m \cdot \left(-t\right)}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{2}{z\_m \cdot y}\\
\end{array}
\end{array}
if y < -5.8e11Initial program 89.4%
distribute-rgt-out--92.2%
Simplified92.2%
Taylor expanded in y around inf 74.1%
*-commutative74.1%
Simplified74.1%
*-commutative74.1%
times-frac77.0%
Applied egg-rr77.0%
if -5.8e11 < y < 7.4e7Initial program 92.5%
distribute-rgt-out--94.0%
Simplified94.0%
Taylor expanded in y around 0 79.0%
associate-*r*79.0%
neg-mul-179.0%
*-commutative79.0%
Simplified79.0%
if 7.4e7 < y Initial program 89.7%
distribute-rgt-out--93.9%
Simplified93.9%
distribute-rgt-out--89.7%
associate-/l*89.7%
*-commutative89.7%
distribute-rgt-out--93.9%
Applied egg-rr93.9%
div-inv93.9%
Applied egg-rr93.9%
associate-*r/93.9%
metadata-eval93.9%
associate-/r*93.7%
Simplified93.7%
Taylor expanded in y around inf 77.2%
associate-/r*77.1%
Simplified77.1%
Taylor expanded in y around 0 77.2%
Final simplification78.1%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m t)
:precision binary64
(*
z_s
(if (or (<= y -4.2e+15) (not (<= y 16000.0)))
(* x (/ 2.0 (* z_m y)))
(* -2.0 (/ x (* z_m t))))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if ((y <= -4.2e+15) || !(y <= 16000.0)) {
tmp = x * (2.0 / (z_m * y));
} else {
tmp = -2.0 * (x / (z_m * t));
}
return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m, t)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: tmp
if ((y <= (-4.2d+15)) .or. (.not. (y <= 16000.0d0))) then
tmp = x * (2.0d0 / (z_m * y))
else
tmp = (-2.0d0) * (x / (z_m * t))
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if ((y <= -4.2e+15) || !(y <= 16000.0)) {
tmp = x * (2.0 / (z_m * y));
} else {
tmp = -2.0 * (x / (z_m * t));
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): tmp = 0 if (y <= -4.2e+15) or not (y <= 16000.0): tmp = x * (2.0 / (z_m * y)) else: tmp = -2.0 * (x / (z_m * t)) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) tmp = 0.0 if ((y <= -4.2e+15) || !(y <= 16000.0)) tmp = Float64(x * Float64(2.0 / Float64(z_m * y))); else tmp = Float64(-2.0 * Float64(x / Float64(z_m * t))); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m, t) tmp = 0.0; if ((y <= -4.2e+15) || ~((y <= 16000.0))) tmp = x * (2.0 / (z_m * y)); else tmp = -2.0 * (x / (z_m * t)); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * If[Or[LessEqual[y, -4.2e+15], N[Not[LessEqual[y, 16000.0]], $MachinePrecision]], N[(x * N[(2.0 / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(x / N[(z$95$m * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{+15} \lor \neg \left(y \leq 16000\right):\\
\;\;\;\;x \cdot \frac{2}{z\_m \cdot y}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{x}{z\_m \cdot t}\\
\end{array}
\end{array}
if y < -4.2e15 or 16000 < y Initial program 89.5%
distribute-rgt-out--92.8%
Simplified92.8%
distribute-rgt-out--89.5%
associate-/l*89.5%
*-commutative89.5%
distribute-rgt-out--92.8%
Applied egg-rr92.8%
div-inv92.8%
Applied egg-rr92.8%
associate-*r/92.8%
metadata-eval92.8%
associate-/r*92.8%
Simplified92.8%
Taylor expanded in y around inf 75.4%
associate-/r*75.3%
Simplified75.3%
Taylor expanded in y around 0 75.4%
if -4.2e15 < y < 16000Initial program 92.5%
distribute-rgt-out--94.0%
Simplified94.0%
Taylor expanded in y around 0 79.0%
*-commutative79.0%
Simplified79.0%
Final simplification77.2%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m t)
:precision binary64
(*
z_s
(if (<= y -4500000000000.0)
(* (/ 2.0 z_m) (/ x y))
(if (<= y 29500000.0) (* -2.0 (/ x (* z_m t))) (* x (/ 2.0 (* z_m y)))))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (y <= -4500000000000.0) {
tmp = (2.0 / z_m) * (x / y);
} else if (y <= 29500000.0) {
tmp = -2.0 * (x / (z_m * t));
} else {
tmp = x * (2.0 / (z_m * y));
}
return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m, t)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: tmp
if (y <= (-4500000000000.0d0)) then
tmp = (2.0d0 / z_m) * (x / y)
else if (y <= 29500000.0d0) then
tmp = (-2.0d0) * (x / (z_m * t))
else
tmp = x * (2.0d0 / (z_m * y))
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (y <= -4500000000000.0) {
tmp = (2.0 / z_m) * (x / y);
} else if (y <= 29500000.0) {
tmp = -2.0 * (x / (z_m * t));
} else {
tmp = x * (2.0 / (z_m * y));
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): tmp = 0 if y <= -4500000000000.0: tmp = (2.0 / z_m) * (x / y) elif y <= 29500000.0: tmp = -2.0 * (x / (z_m * t)) else: tmp = x * (2.0 / (z_m * y)) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) tmp = 0.0 if (y <= -4500000000000.0) tmp = Float64(Float64(2.0 / z_m) * Float64(x / y)); elseif (y <= 29500000.0) tmp = Float64(-2.0 * Float64(x / Float64(z_m * t))); else tmp = Float64(x * Float64(2.0 / Float64(z_m * y))); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m, t) tmp = 0.0; if (y <= -4500000000000.0) tmp = (2.0 / z_m) * (x / y); elseif (y <= 29500000.0) tmp = -2.0 * (x / (z_m * t)); else tmp = x * (2.0 / (z_m * y)); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * If[LessEqual[y, -4500000000000.0], N[(N[(2.0 / z$95$m), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 29500000.0], N[(-2.0 * N[(x / N[(z$95$m * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(2.0 / N[(z$95$m * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;y \leq -4500000000000:\\
\;\;\;\;\frac{2}{z\_m} \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq 29500000:\\
\;\;\;\;-2 \cdot \frac{x}{z\_m \cdot t}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{2}{z\_m \cdot y}\\
\end{array}
\end{array}
if y < -4.5e12Initial program 89.4%
distribute-rgt-out--92.2%
Simplified92.2%
Taylor expanded in y around inf 74.1%
*-commutative74.1%
Simplified74.1%
*-commutative74.1%
times-frac77.0%
Applied egg-rr77.0%
if -4.5e12 < y < 2.95e7Initial program 92.5%
distribute-rgt-out--94.0%
Simplified94.0%
Taylor expanded in y around 0 79.0%
*-commutative79.0%
Simplified79.0%
if 2.95e7 < y Initial program 89.7%
distribute-rgt-out--93.9%
Simplified93.9%
distribute-rgt-out--89.7%
associate-/l*89.7%
*-commutative89.7%
distribute-rgt-out--93.9%
Applied egg-rr93.9%
div-inv93.9%
Applied egg-rr93.9%
associate-*r/93.9%
metadata-eval93.9%
associate-/r*93.7%
Simplified93.7%
Taylor expanded in y around inf 77.2%
associate-/r*77.1%
Simplified77.1%
Taylor expanded in y around 0 77.2%
Final simplification78.1%
z\_m = (fabs.f64 z)
z\_s = (copysign.f64 #s(literal 1 binary64) z)
(FPCore (z_s x y z_m t)
:precision binary64
(*
z_s
(if (<= z_m 1450.0)
(* x (/ 2.0 (* z_m (- y t))))
(* (/ x (- y t)) (/ 2.0 z_m)))))z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 1450.0) {
tmp = x * (2.0 / (z_m * (y - t)));
} else {
tmp = (x / (y - t)) * (2.0 / z_m);
}
return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m, t)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: tmp
if (z_m <= 1450.0d0) then
tmp = x * (2.0d0 / (z_m * (y - t)))
else
tmp = (x / (y - t)) * (2.0d0 / z_m)
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 1450.0) {
tmp = x * (2.0 / (z_m * (y - t)));
} else {
tmp = (x / (y - t)) * (2.0 / z_m);
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): tmp = 0 if z_m <= 1450.0: tmp = x * (2.0 / (z_m * (y - t))) else: tmp = (x / (y - t)) * (2.0 / z_m) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) tmp = 0.0 if (z_m <= 1450.0) tmp = Float64(x * Float64(2.0 / Float64(z_m * Float64(y - t)))); else tmp = Float64(Float64(x / Float64(y - t)) * Float64(2.0 / z_m)); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m, t) tmp = 0.0; if (z_m <= 1450.0) tmp = x * (2.0 / (z_m * (y - t))); else tmp = (x / (y - t)) * (2.0 / z_m); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * If[LessEqual[z$95$m, 1450.0], N[(x * N[(2.0 / N[(z$95$m * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision] * N[(2.0 / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 1450:\\
\;\;\;\;x \cdot \frac{2}{z\_m \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y - t} \cdot \frac{2}{z\_m}\\
\end{array}
\end{array}
if z < 1450Initial program 92.0%
distribute-rgt-out--94.7%
Simplified94.7%
distribute-rgt-out--92.0%
associate-/l*92.0%
*-commutative92.0%
distribute-rgt-out--94.6%
Applied egg-rr94.6%
if 1450 < z Initial program 88.5%
distribute-rgt-out--90.0%
Simplified90.0%
*-commutative90.0%
times-frac98.3%
Applied egg-rr98.3%
Final simplification95.6%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m t) :precision binary64 (* z_s (if (<= z_m 2.5e+35) (* -2.0 (/ x (* z_m t))) (* (/ -2.0 t) (/ x z_m)))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 2.5e+35) {
tmp = -2.0 * (x / (z_m * t));
} else {
tmp = (-2.0 / t) * (x / z_m);
}
return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m, t)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: tmp
if (z_m <= 2.5d+35) then
tmp = (-2.0d0) * (x / (z_m * t))
else
tmp = ((-2.0d0) / t) * (x / z_m)
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 2.5e+35) {
tmp = -2.0 * (x / (z_m * t));
} else {
tmp = (-2.0 / t) * (x / z_m);
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): tmp = 0 if z_m <= 2.5e+35: tmp = -2.0 * (x / (z_m * t)) else: tmp = (-2.0 / t) * (x / z_m) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) tmp = 0.0 if (z_m <= 2.5e+35) tmp = Float64(-2.0 * Float64(x / Float64(z_m * t))); else tmp = Float64(Float64(-2.0 / t) * Float64(x / z_m)); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m, t) tmp = 0.0; if (z_m <= 2.5e+35) tmp = -2.0 * (x / (z_m * t)); else tmp = (-2.0 / t) * (x / z_m); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * If[LessEqual[z$95$m, 2.5e+35], N[(-2.0 * N[(x / N[(z$95$m * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 / t), $MachinePrecision] * N[(x / z$95$m), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 2.5 \cdot 10^{+35}:\\
\;\;\;\;-2 \cdot \frac{x}{z\_m \cdot t}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{t} \cdot \frac{x}{z\_m}\\
\end{array}
\end{array}
if z < 2.50000000000000011e35Initial program 92.3%
distribute-rgt-out--94.9%
Simplified94.9%
Taylor expanded in y around 0 55.5%
*-commutative55.5%
Simplified55.5%
if 2.50000000000000011e35 < z Initial program 87.0%
distribute-rgt-out--88.7%
Simplified88.7%
Taylor expanded in y around 0 53.6%
*-commutative53.6%
Simplified53.6%
clear-num55.5%
un-div-inv55.5%
associate-/l*61.7%
Applied egg-rr61.7%
associate-*r/55.5%
associate-/r/53.5%
associate-*l/53.6%
*-commutative53.6%
times-frac64.2%
Applied egg-rr64.2%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m t) :precision binary64 (* z_s (if (<= z_m 2.7e-46) (* -2.0 (/ x (* z_m t))) (* -2.0 (/ (/ x z_m) t)))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 2.7e-46) {
tmp = -2.0 * (x / (z_m * t));
} else {
tmp = -2.0 * ((x / z_m) / t);
}
return z_s * tmp;
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m, t)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
real(8) :: tmp
if (z_m <= 2.7d-46) then
tmp = (-2.0d0) * (x / (z_m * t))
else
tmp = (-2.0d0) * ((x / z_m) / t)
end if
code = z_s * tmp
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
double tmp;
if (z_m <= 2.7e-46) {
tmp = -2.0 * (x / (z_m * t));
} else {
tmp = -2.0 * ((x / z_m) / t);
}
return z_s * tmp;
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): tmp = 0 if z_m <= 2.7e-46: tmp = -2.0 * (x / (z_m * t)) else: tmp = -2.0 * ((x / z_m) / t) return z_s * tmp
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) tmp = 0.0 if (z_m <= 2.7e-46) tmp = Float64(-2.0 * Float64(x / Float64(z_m * t))); else tmp = Float64(-2.0 * Float64(Float64(x / z_m) / t)); end return Float64(z_s * tmp) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp_2 = code(z_s, x, y, z_m, t) tmp = 0.0; if (z_m <= 2.7e-46) tmp = -2.0 * (x / (z_m * t)); else tmp = -2.0 * ((x / z_m) / t); end tmp_2 = z_s * tmp; end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * If[LessEqual[z$95$m, 2.7e-46], N[(-2.0 * N[(x / N[(z$95$m * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[(x / z$95$m), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \begin{array}{l}
\mathbf{if}\;z\_m \leq 2.7 \cdot 10^{-46}:\\
\;\;\;\;-2 \cdot \frac{x}{z\_m \cdot t}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\frac{x}{z\_m}}{t}\\
\end{array}
\end{array}
if z < 2.7e-46Initial program 91.5%
distribute-rgt-out--94.4%
Simplified94.4%
Taylor expanded in y around 0 55.9%
*-commutative55.9%
Simplified55.9%
if 2.7e-46 < z Initial program 89.9%
distribute-rgt-out--91.2%
Simplified91.2%
Taylor expanded in y around 0 53.1%
*-commutative53.1%
associate-/r*61.2%
Simplified61.2%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m t) :precision binary64 (* z_s (* x (/ 2.0 (* z_m (- y t))))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
return z_s * (x * (2.0 / (z_m * (y - t))));
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m, t)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
code = z_s * (x * (2.0d0 / (z_m * (y - t))))
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
return z_s * (x * (2.0 / (z_m * (y - t))));
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): return z_s * (x * (2.0 / (z_m * (y - t))))
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) return Float64(z_s * Float64(x * Float64(2.0 / Float64(z_m * Float64(y - t))))) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp = code(z_s, x, y, z_m, t) tmp = z_s * (x * (2.0 / (z_m * (y - t)))); end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * N[(x * N[(2.0 / N[(z$95$m * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \left(x \cdot \frac{2}{z\_m \cdot \left(y - t\right)}\right)
\end{array}
Initial program 91.0%
distribute-rgt-out--93.4%
Simplified93.4%
distribute-rgt-out--91.0%
associate-/l*91.0%
*-commutative91.0%
distribute-rgt-out--93.4%
Applied egg-rr93.4%
Final simplification93.4%
z\_m = (fabs.f64 z) z\_s = (copysign.f64 #s(literal 1 binary64) z) (FPCore (z_s x y z_m t) :precision binary64 (* z_s (* -2.0 (/ x (* z_m t)))))
z\_m = fabs(z);
z\_s = copysign(1.0, z);
double code(double z_s, double x, double y, double z_m, double t) {
return z_s * (-2.0 * (x / (z_m * t)));
}
z\_m = abs(z)
z\_s = copysign(1.0d0, z)
real(8) function code(z_s, x, y, z_m, t)
real(8), intent (in) :: z_s
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z_m
real(8), intent (in) :: t
code = z_s * ((-2.0d0) * (x / (z_m * t)))
end function
z\_m = Math.abs(z);
z\_s = Math.copySign(1.0, z);
public static double code(double z_s, double x, double y, double z_m, double t) {
return z_s * (-2.0 * (x / (z_m * t)));
}
z\_m = math.fabs(z) z\_s = math.copysign(1.0, z) def code(z_s, x, y, z_m, t): return z_s * (-2.0 * (x / (z_m * t)))
z\_m = abs(z) z\_s = copysign(1.0, z) function code(z_s, x, y, z_m, t) return Float64(z_s * Float64(-2.0 * Float64(x / Float64(z_m * t)))) end
z\_m = abs(z); z\_s = sign(z) * abs(1.0); function tmp = code(z_s, x, y, z_m, t) tmp = z_s * (-2.0 * (x / (z_m * t))); end
z\_m = N[Abs[z], $MachinePrecision]
z\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[z]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[z$95$s_, x_, y_, z$95$m_, t_] := N[(z$95$s * N[(-2.0 * N[(x / N[(z$95$m * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
z\_m = \left|z\right|
\\
z\_s = \mathsf{copysign}\left(1, z\right)
\\
z\_s \cdot \left(-2 \cdot \frac{x}{z\_m \cdot t}\right)
\end{array}
Initial program 91.0%
distribute-rgt-out--93.4%
Simplified93.4%
Taylor expanded in y around 0 55.1%
*-commutative55.1%
Simplified55.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (/ x (* (- y t) z)) 2.0))
(t_2 (/ (* x 2.0) (- (* y z) (* t z)))))
(if (< t_2 -2.559141628295061e-13)
t_1
(if (< t_2 1.045027827330126e-269) (/ (* (/ x z) 2.0) (- y t)) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (x / ((y - t) * z)) * 2.0;
double t_2 = (x * 2.0) / ((y * z) - (t * z));
double tmp;
if (t_2 < -2.559141628295061e-13) {
tmp = t_1;
} else if (t_2 < 1.045027827330126e-269) {
tmp = ((x / z) * 2.0) / (y - t);
} else {
tmp = 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) :: t_2
real(8) :: tmp
t_1 = (x / ((y - t) * z)) * 2.0d0
t_2 = (x * 2.0d0) / ((y * z) - (t * z))
if (t_2 < (-2.559141628295061d-13)) then
tmp = t_1
else if (t_2 < 1.045027827330126d-269) then
tmp = ((x / z) * 2.0d0) / (y - t)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (x / ((y - t) * z)) * 2.0;
double t_2 = (x * 2.0) / ((y * z) - (t * z));
double tmp;
if (t_2 < -2.559141628295061e-13) {
tmp = t_1;
} else if (t_2 < 1.045027827330126e-269) {
tmp = ((x / z) * 2.0) / (y - t);
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = (x / ((y - t) * z)) * 2.0 t_2 = (x * 2.0) / ((y * z) - (t * z)) tmp = 0 if t_2 < -2.559141628295061e-13: tmp = t_1 elif t_2 < 1.045027827330126e-269: tmp = ((x / z) * 2.0) / (y - t) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(x / Float64(Float64(y - t) * z)) * 2.0) t_2 = Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(t * z))) tmp = 0.0 if (t_2 < -2.559141628295061e-13) tmp = t_1; elseif (t_2 < 1.045027827330126e-269) tmp = Float64(Float64(Float64(x / z) * 2.0) / Float64(y - t)); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (x / ((y - t) * z)) * 2.0; t_2 = (x * 2.0) / ((y * z) - (t * z)); tmp = 0.0; if (t_2 < -2.559141628295061e-13) tmp = t_1; elseif (t_2 < 1.045027827330126e-269) tmp = ((x / z) * 2.0) / (y - t); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x / N[(N[(y - t), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision] * 2.0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$2, -2.559141628295061e-13], t$95$1, If[Less[t$95$2, 1.045027827330126e-269], N[(N[(N[(x / z), $MachinePrecision] * 2.0), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \frac{x}{\left(y - t\right) \cdot z} \cdot 2\\
t_2 := \frac{x \cdot 2}{y \cdot z - t \cdot z}\\
\mathbf{if}\;t\_2 < -2.559141628295061 \cdot 10^{-13}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 < 1.045027827330126 \cdot 10^{-269}:\\
\;\;\;\;\frac{\frac{x}{z} \cdot 2}{y - t}\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
herbie shell --seed 2024152
(FPCore (x y z t)
:name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"
:precision binary64
:alt
(! :herbie-platform default (if (< (/ (* x 2) (- (* y z) (* t z))) -2559141628295061/10000000000000000000000000000) (* (/ x (* (- y t) z)) 2) (if (< (/ (* x 2) (- (* y z) (* t z))) 522513913665063/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (* (/ x z) 2) (- y t)) (* (/ x (* (- y t) z)) 2))))
(/ (* x 2.0) (- (* y z) (* t z))))