
(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}
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (<= (* x_m 2.0) 2e+69)
(/ (* x_m 2.0) (* z (- y t)))
(* (/ x_m (- y t)) (/ 2.0 z)))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if ((x_m * 2.0) <= 2e+69) {
tmp = (x_m * 2.0) / (z * (y - t));
} else {
tmp = (x_m / (y - t)) * (2.0 / z);
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x_m * 2.0d0) <= 2d+69) then
tmp = (x_m * 2.0d0) / (z * (y - t))
else
tmp = (x_m / (y - t)) * (2.0d0 / z)
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if ((x_m * 2.0) <= 2e+69) {
tmp = (x_m * 2.0) / (z * (y - t));
} else {
tmp = (x_m / (y - t)) * (2.0 / z);
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z, t): tmp = 0 if (x_m * 2.0) <= 2e+69: tmp = (x_m * 2.0) / (z * (y - t)) else: tmp = (x_m / (y - t)) * (2.0 / z) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) tmp = 0.0 if (Float64(x_m * 2.0) <= 2e+69) tmp = Float64(Float64(x_m * 2.0) / Float64(z * Float64(y - t))); else tmp = Float64(Float64(x_m / Float64(y - t)) * Float64(2.0 / z)); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z, t) tmp = 0.0; if ((x_m * 2.0) <= 2e+69) tmp = (x_m * 2.0) / (z * (y - t)); else tmp = (x_m / (y - t)) * (2.0 / z); end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[N[(x$95$m * 2.0), $MachinePrecision], 2e+69], N[(N[(x$95$m * 2.0), $MachinePrecision] / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m / N[(y - t), $MachinePrecision]), $MachinePrecision] * N[(2.0 / z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;x_m \cdot 2 \leq 2 \cdot 10^{+69}:\\
\;\;\;\;\frac{x_m \cdot 2}{z \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x_m}{y - t} \cdot \frac{2}{z}\\
\end{array}
\end{array}
if (*.f64 x 2) < 2.0000000000000001e69Initial program 93.7%
distribute-rgt-out--96.2%
Simplified96.2%
if 2.0000000000000001e69 < (*.f64 x 2) Initial program 81.1%
distribute-rgt-out--83.0%
Simplified83.0%
*-commutative83.0%
times-frac94.4%
Applied egg-rr94.4%
Final simplification95.8%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (<= t -4.2e-32)
(* -2.0 (/ (/ x_m t) z))
(if (<= t 1.3e-53) (* x_m (/ (/ 2.0 y) z)) (* x_m (/ (/ -2.0 t) z))))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (t <= -4.2e-32) {
tmp = -2.0 * ((x_m / t) / z);
} else if (t <= 1.3e-53) {
tmp = x_m * ((2.0 / y) / z);
} else {
tmp = x_m * ((-2.0 / t) / z);
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-4.2d-32)) then
tmp = (-2.0d0) * ((x_m / t) / z)
else if (t <= 1.3d-53) then
tmp = x_m * ((2.0d0 / y) / z)
else
tmp = x_m * (((-2.0d0) / t) / z)
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (t <= -4.2e-32) {
tmp = -2.0 * ((x_m / t) / z);
} else if (t <= 1.3e-53) {
tmp = x_m * ((2.0 / y) / z);
} else {
tmp = x_m * ((-2.0 / t) / z);
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z, t): tmp = 0 if t <= -4.2e-32: tmp = -2.0 * ((x_m / t) / z) elif t <= 1.3e-53: tmp = x_m * ((2.0 / y) / z) else: tmp = x_m * ((-2.0 / t) / z) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) tmp = 0.0 if (t <= -4.2e-32) tmp = Float64(-2.0 * Float64(Float64(x_m / t) / z)); elseif (t <= 1.3e-53) tmp = Float64(x_m * Float64(Float64(2.0 / y) / z)); else tmp = Float64(x_m * Float64(Float64(-2.0 / t) / z)); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z, t) tmp = 0.0; if (t <= -4.2e-32) tmp = -2.0 * ((x_m / t) / z); elseif (t <= 1.3e-53) tmp = x_m * ((2.0 / y) / z); else tmp = x_m * ((-2.0 / t) / z); end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[t, -4.2e-32], N[(-2.0 * N[(N[(x$95$m / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 1.3e-53], N[(x$95$m * N[(N[(2.0 / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(N[(-2.0 / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq -4.2 \cdot 10^{-32}:\\
\;\;\;\;-2 \cdot \frac{\frac{x_m}{t}}{z}\\
\mathbf{elif}\;t \leq 1.3 \cdot 10^{-53}:\\
\;\;\;\;x_m \cdot \frac{\frac{2}{y}}{z}\\
\mathbf{else}:\\
\;\;\;\;x_m \cdot \frac{\frac{-2}{t}}{z}\\
\end{array}
\end{array}
if t < -4.1999999999999998e-32Initial program 87.1%
*-commutative87.1%
associate-*l/87.0%
*-commutative87.0%
distribute-rgt-out--91.8%
associate-/l/92.2%
Simplified92.2%
Taylor expanded in y around 0 75.7%
associate-/r*77.9%
Simplified77.9%
if -4.1999999999999998e-32 < t < 1.29999999999999998e-53Initial program 94.3%
*-commutative94.3%
associate-*l/93.9%
*-commutative93.9%
distribute-rgt-out--95.0%
associate-/l/94.9%
Simplified94.9%
Taylor expanded in y around inf 84.5%
associate-/r*84.4%
Simplified84.4%
if 1.29999999999999998e-53 < t Initial program 91.1%
*-commutative91.1%
associate-*l/91.1%
*-commutative91.1%
distribute-rgt-out--92.4%
associate-/l/94.4%
Simplified94.4%
Taylor expanded in y around 0 77.2%
Final simplification80.1%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (<= t -5.4e-32)
(* -2.0 (/ (/ x_m t) z))
(if (<= t 2.45e-60) (/ (* x_m 2.0) (* z y)) (* x_m (/ (/ -2.0 t) z))))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (t <= -5.4e-32) {
tmp = -2.0 * ((x_m / t) / z);
} else if (t <= 2.45e-60) {
tmp = (x_m * 2.0) / (z * y);
} else {
tmp = x_m * ((-2.0 / t) / z);
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-5.4d-32)) then
tmp = (-2.0d0) * ((x_m / t) / z)
else if (t <= 2.45d-60) then
tmp = (x_m * 2.0d0) / (z * y)
else
tmp = x_m * (((-2.0d0) / t) / z)
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (t <= -5.4e-32) {
tmp = -2.0 * ((x_m / t) / z);
} else if (t <= 2.45e-60) {
tmp = (x_m * 2.0) / (z * y);
} else {
tmp = x_m * ((-2.0 / t) / z);
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z, t): tmp = 0 if t <= -5.4e-32: tmp = -2.0 * ((x_m / t) / z) elif t <= 2.45e-60: tmp = (x_m * 2.0) / (z * y) else: tmp = x_m * ((-2.0 / t) / z) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) tmp = 0.0 if (t <= -5.4e-32) tmp = Float64(-2.0 * Float64(Float64(x_m / t) / z)); elseif (t <= 2.45e-60) tmp = Float64(Float64(x_m * 2.0) / Float64(z * y)); else tmp = Float64(x_m * Float64(Float64(-2.0 / t) / z)); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z, t) tmp = 0.0; if (t <= -5.4e-32) tmp = -2.0 * ((x_m / t) / z); elseif (t <= 2.45e-60) tmp = (x_m * 2.0) / (z * y); else tmp = x_m * ((-2.0 / t) / z); end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[t, -5.4e-32], N[(-2.0 * N[(N[(x$95$m / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 2.45e-60], N[(N[(x$95$m * 2.0), $MachinePrecision] / N[(z * y), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(N[(-2.0 / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq -5.4 \cdot 10^{-32}:\\
\;\;\;\;-2 \cdot \frac{\frac{x_m}{t}}{z}\\
\mathbf{elif}\;t \leq 2.45 \cdot 10^{-60}:\\
\;\;\;\;\frac{x_m \cdot 2}{z \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x_m \cdot \frac{\frac{-2}{t}}{z}\\
\end{array}
\end{array}
if t < -5.39999999999999962e-32Initial program 87.1%
*-commutative87.1%
associate-*l/87.0%
*-commutative87.0%
distribute-rgt-out--91.8%
associate-/l/92.2%
Simplified92.2%
Taylor expanded in y around 0 75.7%
associate-/r*77.9%
Simplified77.9%
if -5.39999999999999962e-32 < t < 2.44999999999999994e-60Initial program 94.3%
distribute-rgt-out--95.4%
Simplified95.4%
Taylor expanded in y around inf 84.6%
*-commutative84.6%
Simplified84.6%
if 2.44999999999999994e-60 < t Initial program 91.1%
*-commutative91.1%
associate-*l/91.1%
*-commutative91.1%
distribute-rgt-out--92.4%
associate-/l/94.4%
Simplified94.4%
Taylor expanded in y around 0 77.2%
Final simplification80.2%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (<= t -2.6e-32)
(/ (* (/ x_m t) -2.0) z)
(if (<= t 2.2e-54) (/ (* x_m 2.0) (* z y)) (* x_m (/ (/ -2.0 t) z))))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (t <= -2.6e-32) {
tmp = ((x_m / t) * -2.0) / z;
} else if (t <= 2.2e-54) {
tmp = (x_m * 2.0) / (z * y);
} else {
tmp = x_m * ((-2.0 / t) / z);
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (t <= (-2.6d-32)) then
tmp = ((x_m / t) * (-2.0d0)) / z
else if (t <= 2.2d-54) then
tmp = (x_m * 2.0d0) / (z * y)
else
tmp = x_m * (((-2.0d0) / t) / z)
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (t <= -2.6e-32) {
tmp = ((x_m / t) * -2.0) / z;
} else if (t <= 2.2e-54) {
tmp = (x_m * 2.0) / (z * y);
} else {
tmp = x_m * ((-2.0 / t) / z);
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z, t): tmp = 0 if t <= -2.6e-32: tmp = ((x_m / t) * -2.0) / z elif t <= 2.2e-54: tmp = (x_m * 2.0) / (z * y) else: tmp = x_m * ((-2.0 / t) / z) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) tmp = 0.0 if (t <= -2.6e-32) tmp = Float64(Float64(Float64(x_m / t) * -2.0) / z); elseif (t <= 2.2e-54) tmp = Float64(Float64(x_m * 2.0) / Float64(z * y)); else tmp = Float64(x_m * Float64(Float64(-2.0 / t) / z)); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z, t) tmp = 0.0; if (t <= -2.6e-32) tmp = ((x_m / t) * -2.0) / z; elseif (t <= 2.2e-54) tmp = (x_m * 2.0) / (z * y); else tmp = x_m * ((-2.0 / t) / z); end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[t, -2.6e-32], N[(N[(N[(x$95$m / t), $MachinePrecision] * -2.0), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[t, 2.2e-54], N[(N[(x$95$m * 2.0), $MachinePrecision] / N[(z * y), $MachinePrecision]), $MachinePrecision], N[(x$95$m * N[(N[(-2.0 / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;t \leq -2.6 \cdot 10^{-32}:\\
\;\;\;\;\frac{\frac{x_m}{t} \cdot -2}{z}\\
\mathbf{elif}\;t \leq 2.2 \cdot 10^{-54}:\\
\;\;\;\;\frac{x_m \cdot 2}{z \cdot y}\\
\mathbf{else}:\\
\;\;\;\;x_m \cdot \frac{\frac{-2}{t}}{z}\\
\end{array}
\end{array}
if t < -2.5999999999999997e-32Initial program 87.1%
*-commutative87.1%
associate-*l/87.0%
*-commutative87.0%
distribute-rgt-out--91.8%
associate-/l/92.2%
Simplified92.2%
Taylor expanded in y around 0 75.7%
*-commutative75.7%
associate-/r*77.9%
associate-*l/78.0%
Applied egg-rr78.0%
if -2.5999999999999997e-32 < t < 2.2e-54Initial program 94.3%
distribute-rgt-out--95.4%
Simplified95.4%
Taylor expanded in y around inf 84.6%
*-commutative84.6%
Simplified84.6%
if 2.2e-54 < t Initial program 91.1%
*-commutative91.1%
associate-*l/91.1%
*-commutative91.1%
distribute-rgt-out--92.4%
associate-/l/94.4%
Simplified94.4%
Taylor expanded in y around 0 77.2%
Final simplification80.2%
x_m = (fabs.f64 x)
x_s = (copysign.f64 1 x)
(FPCore (x_s x_m y z t)
:precision binary64
(*
x_s
(if (<= (* x_m 2.0) 2e+69)
(* x_m (/ (/ 2.0 (- y t)) z))
(* (/ x_m (- y t)) (/ 2.0 z)))))x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if ((x_m * 2.0) <= 2e+69) {
tmp = x_m * ((2.0 / (y - t)) / z);
} else {
tmp = (x_m / (y - t)) * (2.0 / z);
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((x_m * 2.0d0) <= 2d+69) then
tmp = x_m * ((2.0d0 / (y - t)) / z)
else
tmp = (x_m / (y - t)) * (2.0d0 / z)
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if ((x_m * 2.0) <= 2e+69) {
tmp = x_m * ((2.0 / (y - t)) / z);
} else {
tmp = (x_m / (y - t)) * (2.0 / z);
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z, t): tmp = 0 if (x_m * 2.0) <= 2e+69: tmp = x_m * ((2.0 / (y - t)) / z) else: tmp = (x_m / (y - t)) * (2.0 / z) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) tmp = 0.0 if (Float64(x_m * 2.0) <= 2e+69) tmp = Float64(x_m * Float64(Float64(2.0 / Float64(y - t)) / z)); else tmp = Float64(Float64(x_m / Float64(y - t)) * Float64(2.0 / z)); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z, t) tmp = 0.0; if ((x_m * 2.0) <= 2e+69) tmp = x_m * ((2.0 / (y - t)) / z); else tmp = (x_m / (y - t)) * (2.0 / z); end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[N[(x$95$m * 2.0), $MachinePrecision], 2e+69], N[(x$95$m * N[(N[(2.0 / N[(y - t), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x$95$m / N[(y - t), $MachinePrecision]), $MachinePrecision] * N[(2.0 / z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;x_m \cdot 2 \leq 2 \cdot 10^{+69}:\\
\;\;\;\;x_m \cdot \frac{\frac{2}{y - t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x_m}{y - t} \cdot \frac{2}{z}\\
\end{array}
\end{array}
if (*.f64 x 2) < 2.0000000000000001e69Initial program 93.7%
*-commutative93.7%
associate-*l/93.5%
*-commutative93.5%
distribute-rgt-out--96.0%
associate-/l/96.4%
Simplified96.4%
if 2.0000000000000001e69 < (*.f64 x 2) Initial program 81.1%
distribute-rgt-out--83.0%
Simplified83.0%
*-commutative83.0%
times-frac94.4%
Applied egg-rr94.4%
Final simplification95.9%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z t) :precision binary64 (let* ((t_1 (/ 2.0 (- y t)))) (* x_s (if (<= z 6.2e-47) (* x_m (/ t_1 z)) (* t_1 (/ x_m z))))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double t_1 = 2.0 / (y - t);
double tmp;
if (z <= 6.2e-47) {
tmp = x_m * (t_1 / z);
} else {
tmp = t_1 * (x_m / z);
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = 2.0d0 / (y - t)
if (z <= 6.2d-47) then
tmp = x_m * (t_1 / z)
else
tmp = t_1 * (x_m / z)
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
double t_1 = 2.0 / (y - t);
double tmp;
if (z <= 6.2e-47) {
tmp = x_m * (t_1 / z);
} else {
tmp = t_1 * (x_m / z);
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z, t): t_1 = 2.0 / (y - t) tmp = 0 if z <= 6.2e-47: tmp = x_m * (t_1 / z) else: tmp = t_1 * (x_m / z) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) t_1 = Float64(2.0 / Float64(y - t)) tmp = 0.0 if (z <= 6.2e-47) tmp = Float64(x_m * Float64(t_1 / z)); else tmp = Float64(t_1 * Float64(x_m / z)); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z, t) t_1 = 2.0 / (y - t); tmp = 0.0; if (z <= 6.2e-47) tmp = x_m * (t_1 / z); else tmp = t_1 * (x_m / z); end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := Block[{t$95$1 = N[(2.0 / N[(y - t), $MachinePrecision]), $MachinePrecision]}, N[(x$95$s * If[LessEqual[z, 6.2e-47], N[(x$95$m * N[(t$95$1 / z), $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[(x$95$m / z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
\begin{array}{l}
t_1 := \frac{2}{y - t}\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 6.2 \cdot 10^{-47}:\\
\;\;\;\;x_m \cdot \frac{t_1}{z}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \frac{x_m}{z}\\
\end{array}
\end{array}
\end{array}
if z < 6.1999999999999996e-47Initial program 91.1%
*-commutative91.1%
associate-*l/90.9%
*-commutative90.9%
distribute-rgt-out--93.3%
associate-/l/93.6%
Simplified93.6%
if 6.1999999999999996e-47 < z Initial program 90.6%
distribute-rgt-out--93.0%
times-frac97.9%
Simplified97.9%
Final simplification95.0%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z t) :precision binary64 (* x_s (if (<= z 5000000000.0) (* -2.0 (/ x_m (* z t))) (* -2.0 (/ (/ x_m t) z)))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (z <= 5000000000.0) {
tmp = -2.0 * (x_m / (z * t));
} else {
tmp = -2.0 * ((x_m / t) / z);
}
return x_s * tmp;
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= 5000000000.0d0) then
tmp = (-2.0d0) * (x_m / (z * t))
else
tmp = (-2.0d0) * ((x_m / t) / z)
end if
code = x_s * tmp
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
double tmp;
if (z <= 5000000000.0) {
tmp = -2.0 * (x_m / (z * t));
} else {
tmp = -2.0 * ((x_m / t) / z);
}
return x_s * tmp;
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z, t): tmp = 0 if z <= 5000000000.0: tmp = -2.0 * (x_m / (z * t)) else: tmp = -2.0 * ((x_m / t) / z) return x_s * tmp
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) tmp = 0.0 if (z <= 5000000000.0) tmp = Float64(-2.0 * Float64(x_m / Float64(z * t))); else tmp = Float64(-2.0 * Float64(Float64(x_m / t) / z)); end return Float64(x_s * tmp) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp_2 = code(x_s, x_m, y, z, t) tmp = 0.0; if (z <= 5000000000.0) tmp = -2.0 * (x_m / (z * t)); else tmp = -2.0 * ((x_m / t) / z); end tmp_2 = x_s * tmp; end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * If[LessEqual[z, 5000000000.0], N[(-2.0 * N[(x$95$m / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-2.0 * N[(N[(x$95$m / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x_s \cdot \begin{array}{l}
\mathbf{if}\;z \leq 5000000000:\\
\;\;\;\;-2 \cdot \frac{x_m}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{\frac{x_m}{t}}{z}\\
\end{array}
\end{array}
if z < 5e9Initial program 91.8%
*-commutative91.8%
associate-*l/91.5%
*-commutative91.5%
distribute-rgt-out--93.7%
associate-/l/94.1%
Simplified94.1%
Taylor expanded in y around 0 58.0%
if 5e9 < z Initial program 88.7%
*-commutative88.7%
associate-*l/88.6%
*-commutative88.6%
distribute-rgt-out--91.5%
associate-/l/93.2%
Simplified93.2%
Taylor expanded in y around 0 47.1%
associate-/r*51.6%
Simplified51.6%
Final simplification56.3%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z t) :precision binary64 (* x_s (* x_m (/ (/ 2.0 (- y t)) z))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
return x_s * (x_m * ((2.0 / (y - t)) / z));
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x_s * (x_m * ((2.0d0 / (y - t)) / z))
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
return x_s * (x_m * ((2.0 / (y - t)) / z));
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z, t): return x_s * (x_m * ((2.0 / (y - t)) / z))
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) return Float64(x_s * Float64(x_m * Float64(Float64(2.0 / Float64(y - t)) / z))) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m, y, z, t) tmp = x_s * (x_m * ((2.0 / (y - t)) / z)); end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * N[(x$95$m * N[(N[(2.0 / N[(y - t), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x_s \cdot \left(x_m \cdot \frac{\frac{2}{y - t}}{z}\right)
\end{array}
Initial program 91.0%
*-commutative91.0%
associate-*l/90.7%
*-commutative90.7%
distribute-rgt-out--93.1%
associate-/l/93.8%
Simplified93.8%
Final simplification93.8%
x_m = (fabs.f64 x) x_s = (copysign.f64 1 x) (FPCore (x_s x_m y z t) :precision binary64 (* x_s (* -2.0 (/ x_m (* z t)))))
x_m = fabs(x);
x_s = copysign(1.0, x);
double code(double x_s, double x_m, double y, double z, double t) {
return x_s * (-2.0 * (x_m / (z * t)));
}
x_m = abs(x)
x_s = copysign(1.0d0, x)
real(8) function code(x_s, x_m, y, z, t)
real(8), intent (in) :: x_s
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x_s * ((-2.0d0) * (x_m / (z * t)))
end function
x_m = Math.abs(x);
x_s = Math.copySign(1.0, x);
public static double code(double x_s, double x_m, double y, double z, double t) {
return x_s * (-2.0 * (x_m / (z * t)));
}
x_m = math.fabs(x) x_s = math.copysign(1.0, x) def code(x_s, x_m, y, z, t): return x_s * (-2.0 * (x_m / (z * t)))
x_m = abs(x) x_s = copysign(1.0, x) function code(x_s, x_m, y, z, t) return Float64(x_s * Float64(-2.0 * Float64(x_m / Float64(z * t)))) end
x_m = abs(x); x_s = sign(x) * abs(1.0); function tmp = code(x_s, x_m, y, z, t) tmp = x_s * (-2.0 * (x_m / (z * t))); end
x_m = N[Abs[x], $MachinePrecision]
x_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[x]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[x$95$s_, x$95$m_, y_, z_, t_] := N[(x$95$s * N[(-2.0 * N[(x$95$m / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
x_s = \mathsf{copysign}\left(1, x\right)
\\
x_s \cdot \left(-2 \cdot \frac{x_m}{z \cdot t}\right)
\end{array}
Initial program 91.0%
*-commutative91.0%
associate-*l/90.7%
*-commutative90.7%
distribute-rgt-out--93.1%
associate-/l/93.8%
Simplified93.8%
Taylor expanded in y around 0 55.1%
Final simplification55.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 2024019
(FPCore (x y z t)
:name "Linear.Projection:infinitePerspective from linear-1.19.1.3, A"
:precision binary64
:herbie-target
(if (< (/ (* x 2.0) (- (* y z) (* t z))) -2.559141628295061e-13) (* (/ x (* (- y t) z)) 2.0) (if (< (/ (* x 2.0) (- (* y z) (* t z))) 1.045027827330126e-269) (/ (* (/ x z) 2.0) (- y t)) (* (/ x (* (- y t) z)) 2.0)))
(/ (* x 2.0) (- (* y z) (* t z))))