
(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}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (* y z) (* z t))))
(if (or (<= t_1 -5e+118) (not (<= t_1 5e+277)))
(* 2.0 (/ (/ x z) (- y t)))
(/ (* 2.0 x) (* z (- y t))))))
double code(double x, double y, double z, double t) {
double t_1 = (y * z) - (z * t);
double tmp;
if ((t_1 <= -5e+118) || !(t_1 <= 5e+277)) {
tmp = 2.0 * ((x / z) / (y - t));
} else {
tmp = (2.0 * x) / (z * (y - t));
}
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 = (y * z) - (z * t)
if ((t_1 <= (-5d+118)) .or. (.not. (t_1 <= 5d+277))) then
tmp = 2.0d0 * ((x / z) / (y - t))
else
tmp = (2.0d0 * x) / (z * (y - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = (y * z) - (z * t);
double tmp;
if ((t_1 <= -5e+118) || !(t_1 <= 5e+277)) {
tmp = 2.0 * ((x / z) / (y - t));
} else {
tmp = (2.0 * x) / (z * (y - t));
}
return tmp;
}
def code(x, y, z, t): t_1 = (y * z) - (z * t) tmp = 0 if (t_1 <= -5e+118) or not (t_1 <= 5e+277): tmp = 2.0 * ((x / z) / (y - t)) else: tmp = (2.0 * x) / (z * (y - t)) return tmp
function code(x, y, z, t) t_1 = Float64(Float64(y * z) - Float64(z * t)) tmp = 0.0 if ((t_1 <= -5e+118) || !(t_1 <= 5e+277)) tmp = Float64(2.0 * Float64(Float64(x / z) / Float64(y - t))); else tmp = Float64(Float64(2.0 * x) / Float64(z * Float64(y - t))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = (y * z) - (z * t); tmp = 0.0; if ((t_1 <= -5e+118) || ~((t_1 <= 5e+277))) tmp = 2.0 * ((x / z) / (y - t)); else tmp = (2.0 * x) / (z * (y - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y * z), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e+118], N[Not[LessEqual[t$95$1, 5e+277]], $MachinePrecision]], N[(2.0 * N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * x), $MachinePrecision] / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := y \cdot z - z \cdot t\\
\mathbf{if}\;t_1 \leq -5 \cdot 10^{+118} \lor \neg \left(t_1 \leq 5 \cdot 10^{+277}\right):\\
\;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot x}{z \cdot \left(y - t\right)}\\
\end{array}
\end{array}
if (-.f64 (*.f64 y z) (*.f64 t z)) < -4.99999999999999972e118 or 4.99999999999999982e277 < (-.f64 (*.f64 y z) (*.f64 t z)) Initial program 74.2%
associate-*l/75.4%
*-commutative75.4%
distribute-rgt-out--81.5%
associate-/r*99.3%
Simplified99.3%
if -4.99999999999999972e118 < (-.f64 (*.f64 y z) (*.f64 t z)) < 4.99999999999999982e277Initial program 98.5%
distribute-rgt-out--99.1%
Simplified99.1%
Final simplification99.1%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.85e-50) (not (<= t 4.5e+69))) (* x (/ -2.0 (* z t))) (* x (/ (/ 2.0 y) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.85e-50) || !(t <= 4.5e+69)) {
tmp = x * (-2.0 / (z * t));
} else {
tmp = x * ((2.0 / y) / z);
}
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 ((t <= (-1.85d-50)) .or. (.not. (t <= 4.5d+69))) then
tmp = x * ((-2.0d0) / (z * t))
else
tmp = x * ((2.0d0 / y) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.85e-50) || !(t <= 4.5e+69)) {
tmp = x * (-2.0 / (z * t));
} else {
tmp = x * ((2.0 / y) / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.85e-50) or not (t <= 4.5e+69): tmp = x * (-2.0 / (z * t)) else: tmp = x * ((2.0 / y) / z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.85e-50) || !(t <= 4.5e+69)) tmp = Float64(x * Float64(-2.0 / Float64(z * t))); else tmp = Float64(x * Float64(Float64(2.0 / y) / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.85e-50) || ~((t <= 4.5e+69))) tmp = x * (-2.0 / (z * t)); else tmp = x * ((2.0 / y) / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.85e-50], N[Not[LessEqual[t, 4.5e+69]], $MachinePrecision]], N[(x * N[(-2.0 / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(2.0 / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.85 \cdot 10^{-50} \lor \neg \left(t \leq 4.5 \cdot 10^{+69}\right):\\
\;\;\;\;x \cdot \frac{-2}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\
\end{array}
\end{array}
if t < -1.85e-50 or 4.4999999999999999e69 < t Initial program 83.4%
associate-*r/84.3%
distribute-rgt-out--89.0%
associate-/l/88.9%
sub-neg88.9%
+-commutative88.9%
neg-sub088.9%
associate-+l-88.9%
sub0-neg88.9%
neg-mul-188.9%
associate-/r*88.9%
metadata-eval88.9%
Simplified88.9%
Taylor expanded in t around inf 81.8%
if -1.85e-50 < t < 4.4999999999999999e69Initial program 95.8%
associate-*r/94.6%
distribute-rgt-out--95.2%
associate-/l/95.3%
sub-neg95.3%
+-commutative95.3%
neg-sub095.3%
associate-+l-95.3%
sub0-neg95.3%
neg-mul-195.3%
associate-/r*95.3%
metadata-eval95.3%
Simplified95.3%
Taylor expanded in t around 0 73.0%
Final simplification76.6%
(FPCore (x y z t) :precision binary64 (if (<= y -1.45e-74) (* (/ x y) (/ 2.0 z)) (if (<= y 2.8e-13) (* x (/ -2.0 (* z t))) (* x (/ (/ 2.0 y) z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.45e-74) {
tmp = (x / y) * (2.0 / z);
} else if (y <= 2.8e-13) {
tmp = x * (-2.0 / (z * t));
} else {
tmp = x * ((2.0 / y) / z);
}
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.45d-74)) then
tmp = (x / y) * (2.0d0 / z)
else if (y <= 2.8d-13) then
tmp = x * ((-2.0d0) / (z * t))
else
tmp = x * ((2.0d0 / y) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.45e-74) {
tmp = (x / y) * (2.0 / z);
} else if (y <= 2.8e-13) {
tmp = x * (-2.0 / (z * t));
} else {
tmp = x * ((2.0 / y) / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.45e-74: tmp = (x / y) * (2.0 / z) elif y <= 2.8e-13: tmp = x * (-2.0 / (z * t)) else: tmp = x * ((2.0 / y) / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.45e-74) tmp = Float64(Float64(x / y) * Float64(2.0 / z)); elseif (y <= 2.8e-13) tmp = Float64(x * Float64(-2.0 / Float64(z * t))); else tmp = Float64(x * Float64(Float64(2.0 / y) / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.45e-74) tmp = (x / y) * (2.0 / z); elseif (y <= 2.8e-13) tmp = x * (-2.0 / (z * t)); else tmp = x * ((2.0 / y) / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.45e-74], N[(N[(x / y), $MachinePrecision] * N[(2.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.8e-13], N[(x * N[(-2.0 / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(2.0 / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{-74}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{2}{z}\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-13}:\\
\;\;\;\;x \cdot \frac{-2}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\
\end{array}
\end{array}
if y < -1.45e-74Initial program 87.4%
associate-*l/87.4%
*-commutative87.4%
distribute-rgt-out--89.9%
associate-/r*90.3%
Simplified90.3%
*-commutative90.3%
associate-*l/90.3%
associate-*r/90.2%
clear-num90.1%
frac-times89.6%
metadata-eval89.6%
Applied egg-rr89.6%
Taylor expanded in y around inf 70.2%
associate-/l*74.8%
Simplified74.8%
associate-/r/74.0%
frac-times68.7%
*-commutative68.7%
times-frac76.1%
Applied egg-rr76.1%
if -1.45e-74 < y < 2.8000000000000002e-13Initial program 93.2%
associate-*r/93.1%
distribute-rgt-out--94.0%
associate-/l/93.9%
sub-neg93.9%
+-commutative93.9%
neg-sub093.9%
associate-+l-93.9%
sub0-neg93.9%
neg-mul-193.9%
associate-/r*93.9%
metadata-eval93.9%
Simplified93.9%
Taylor expanded in t around inf 76.8%
if 2.8000000000000002e-13 < y Initial program 90.3%
associate-*r/90.1%
distribute-rgt-out--95.1%
associate-/l/95.1%
sub-neg95.1%
+-commutative95.1%
neg-sub095.1%
associate-+l-95.1%
sub0-neg95.1%
neg-mul-195.1%
associate-/r*95.1%
metadata-eval95.1%
Simplified95.1%
Taylor expanded in t around 0 79.5%
Final simplification77.2%
(FPCore (x y z t) :precision binary64 (if (<= y -1.4e-74) (* (/ x y) (/ 2.0 z)) (if (<= y 6.2e-21) (* -2.0 (/ x (* z t))) (* x (/ (/ 2.0 y) z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.4e-74) {
tmp = (x / y) * (2.0 / z);
} else if (y <= 6.2e-21) {
tmp = -2.0 * (x / (z * t));
} else {
tmp = x * ((2.0 / y) / z);
}
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.4d-74)) then
tmp = (x / y) * (2.0d0 / z)
else if (y <= 6.2d-21) then
tmp = (-2.0d0) * (x / (z * t))
else
tmp = x * ((2.0d0 / y) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -1.4e-74) {
tmp = (x / y) * (2.0 / z);
} else if (y <= 6.2e-21) {
tmp = -2.0 * (x / (z * t));
} else {
tmp = x * ((2.0 / y) / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -1.4e-74: tmp = (x / y) * (2.0 / z) elif y <= 6.2e-21: tmp = -2.0 * (x / (z * t)) else: tmp = x * ((2.0 / y) / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -1.4e-74) tmp = Float64(Float64(x / y) * Float64(2.0 / z)); elseif (y <= 6.2e-21) tmp = Float64(-2.0 * Float64(x / Float64(z * t))); else tmp = Float64(x * Float64(Float64(2.0 / y) / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -1.4e-74) tmp = (x / y) * (2.0 / z); elseif (y <= 6.2e-21) tmp = -2.0 * (x / (z * t)); else tmp = x * ((2.0 / y) / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -1.4e-74], N[(N[(x / y), $MachinePrecision] * N[(2.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.2e-21], N[(-2.0 * N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(2.0 / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{-74}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{2}{z}\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{-21}:\\
\;\;\;\;-2 \cdot \frac{x}{z \cdot t}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\
\end{array}
\end{array}
if y < -1.39999999999999994e-74Initial program 87.4%
associate-*l/87.4%
*-commutative87.4%
distribute-rgt-out--89.9%
associate-/r*90.3%
Simplified90.3%
*-commutative90.3%
associate-*l/90.3%
associate-*r/90.2%
clear-num90.1%
frac-times89.6%
metadata-eval89.6%
Applied egg-rr89.6%
Taylor expanded in y around inf 70.2%
associate-/l*74.8%
Simplified74.8%
associate-/r/74.0%
frac-times68.7%
*-commutative68.7%
times-frac76.1%
Applied egg-rr76.1%
if -1.39999999999999994e-74 < y < 6.1999999999999997e-21Initial program 93.2%
associate-*l/94.0%
*-commutative94.0%
distribute-rgt-out--94.9%
associate-/r*93.6%
Simplified93.6%
Taylor expanded in y around 0 76.9%
*-commutative76.9%
Simplified76.9%
if 6.1999999999999997e-21 < y Initial program 90.3%
associate-*r/90.1%
distribute-rgt-out--95.1%
associate-/l/95.1%
sub-neg95.1%
+-commutative95.1%
neg-sub095.1%
associate-+l-95.1%
sub0-neg95.1%
neg-mul-195.1%
associate-/r*95.1%
metadata-eval95.1%
Simplified95.1%
Taylor expanded in t around 0 79.5%
Final simplification77.3%
(FPCore (x y z t) :precision binary64 (if (<= t -9.8e-50) (* -2.0 (/ (/ x z) t)) (if (<= t 4.5e+69) (/ (* 2.0 x) (* y z)) (* x (/ -2.0 (* z t))))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -9.8e-50) {
tmp = -2.0 * ((x / z) / t);
} else if (t <= 4.5e+69) {
tmp = (2.0 * x) / (y * z);
} else {
tmp = x * (-2.0 / (z * t));
}
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 (t <= (-9.8d-50)) then
tmp = (-2.0d0) * ((x / z) / t)
else if (t <= 4.5d+69) then
tmp = (2.0d0 * x) / (y * z)
else
tmp = x * ((-2.0d0) / (z * t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -9.8e-50) {
tmp = -2.0 * ((x / z) / t);
} else if (t <= 4.5e+69) {
tmp = (2.0 * x) / (y * z);
} else {
tmp = x * (-2.0 / (z * t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -9.8e-50: tmp = -2.0 * ((x / z) / t) elif t <= 4.5e+69: tmp = (2.0 * x) / (y * z) else: tmp = x * (-2.0 / (z * t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -9.8e-50) tmp = Float64(-2.0 * Float64(Float64(x / z) / t)); elseif (t <= 4.5e+69) tmp = Float64(Float64(2.0 * x) / Float64(y * z)); else tmp = Float64(x * Float64(-2.0 / Float64(z * t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -9.8e-50) tmp = -2.0 * ((x / z) / t); elseif (t <= 4.5e+69) tmp = (2.0 * x) / (y * z); else tmp = x * (-2.0 / (z * t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -9.8e-50], N[(-2.0 * N[(N[(x / z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 4.5e+69], N[(N[(2.0 * x), $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision], N[(x * N[(-2.0 / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -9.8 \cdot 10^{-50}:\\
\;\;\;\;-2 \cdot \frac{\frac{x}{z}}{t}\\
\mathbf{elif}\;t \leq 4.5 \cdot 10^{+69}:\\
\;\;\;\;\frac{2 \cdot x}{y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-2}{z \cdot t}\\
\end{array}
\end{array}
if t < -9.7999999999999997e-50Initial program 87.5%
associate-*l/89.0%
*-commutative89.0%
distribute-rgt-out--92.2%
associate-/r*93.8%
Simplified93.8%
Taylor expanded in y around 0 81.6%
*-commutative81.6%
*-commutative81.6%
associate-/r*81.6%
Simplified81.6%
if -9.7999999999999997e-50 < t < 4.4999999999999999e69Initial program 95.8%
associate-*l/95.8%
*-commutative95.8%
distribute-rgt-out--96.5%
associate-/r*91.2%
Simplified91.2%
Taylor expanded in y around inf 74.2%
associate-*r/74.2%
*-commutative74.2%
Simplified74.2%
if 4.4999999999999999e69 < t Initial program 77.5%
associate-*r/77.5%
distribute-rgt-out--84.5%
associate-/l/84.6%
sub-neg84.6%
+-commutative84.6%
neg-sub084.6%
associate-+l-84.6%
sub0-neg84.6%
neg-mul-184.6%
associate-/r*84.6%
metadata-eval84.6%
Simplified84.6%
Taylor expanded in t around inf 82.2%
Final simplification77.3%
(FPCore (x y z t) :precision binary64 (if (<= t -1.1e-50) (* -2.0 (/ (/ x z) t)) (if (<= t 4800000000000.0) (/ (* 2.0 x) (* y z)) (/ (/ (* x -2.0) t) z))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.1e-50) {
tmp = -2.0 * ((x / z) / t);
} else if (t <= 4800000000000.0) {
tmp = (2.0 * x) / (y * z);
} else {
tmp = ((x * -2.0) / t) / z;
}
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 (t <= (-1.1d-50)) then
tmp = (-2.0d0) * ((x / z) / t)
else if (t <= 4800000000000.0d0) then
tmp = (2.0d0 * x) / (y * z)
else
tmp = ((x * (-2.0d0)) / t) / z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -1.1e-50) {
tmp = -2.0 * ((x / z) / t);
} else if (t <= 4800000000000.0) {
tmp = (2.0 * x) / (y * z);
} else {
tmp = ((x * -2.0) / t) / z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -1.1e-50: tmp = -2.0 * ((x / z) / t) elif t <= 4800000000000.0: tmp = (2.0 * x) / (y * z) else: tmp = ((x * -2.0) / t) / z return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -1.1e-50) tmp = Float64(-2.0 * Float64(Float64(x / z) / t)); elseif (t <= 4800000000000.0) tmp = Float64(Float64(2.0 * x) / Float64(y * z)); else tmp = Float64(Float64(Float64(x * -2.0) / t) / z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -1.1e-50) tmp = -2.0 * ((x / z) / t); elseif (t <= 4800000000000.0) tmp = (2.0 * x) / (y * z); else tmp = ((x * -2.0) / t) / z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -1.1e-50], N[(-2.0 * N[(N[(x / z), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 4800000000000.0], N[(N[(2.0 * x), $MachinePrecision] / N[(y * z), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * -2.0), $MachinePrecision] / t), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.1 \cdot 10^{-50}:\\
\;\;\;\;-2 \cdot \frac{\frac{x}{z}}{t}\\
\mathbf{elif}\;t \leq 4800000000000:\\
\;\;\;\;\frac{2 \cdot x}{y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x \cdot -2}{t}}{z}\\
\end{array}
\end{array}
if t < -1.0999999999999999e-50Initial program 87.5%
associate-*l/89.0%
*-commutative89.0%
distribute-rgt-out--92.2%
associate-/r*93.8%
Simplified93.8%
Taylor expanded in y around 0 81.6%
*-commutative81.6%
*-commutative81.6%
associate-/r*81.6%
Simplified81.6%
if -1.0999999999999999e-50 < t < 4.8e12Initial program 95.4%
associate-*l/95.4%
*-commutative95.4%
distribute-rgt-out--96.1%
associate-/r*91.0%
Simplified91.0%
Taylor expanded in y around inf 74.9%
associate-*r/74.9%
*-commutative74.9%
Simplified74.9%
if 4.8e12 < t Initial program 83.2%
associate-*r/83.3%
distribute-rgt-out--88.4%
associate-/l/88.5%
sub-neg88.5%
+-commutative88.5%
neg-sub088.5%
associate-+l-88.5%
sub0-neg88.5%
neg-mul-188.5%
associate-/r*88.5%
metadata-eval88.5%
Simplified88.5%
Taylor expanded in t around inf 76.9%
associate-*r/76.9%
associate-/r*81.7%
Applied egg-rr81.7%
Final simplification78.1%
(FPCore (x y z t) :precision binary64 (if (<= z 3.3e+133) (* x (/ (/ -2.0 (- t y)) z)) (* 2.0 (/ (/ x z) (- y t)))))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= 3.3e+133) {
tmp = x * ((-2.0 / (t - y)) / z);
} else {
tmp = 2.0 * ((x / z) / (y - t));
}
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 (z <= 3.3d+133) then
tmp = x * (((-2.0d0) / (t - y)) / z)
else
tmp = 2.0d0 * ((x / z) / (y - t))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= 3.3e+133) {
tmp = x * ((-2.0 / (t - y)) / z);
} else {
tmp = 2.0 * ((x / z) / (y - t));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= 3.3e+133: tmp = x * ((-2.0 / (t - y)) / z) else: tmp = 2.0 * ((x / z) / (y - t)) return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= 3.3e+133) tmp = Float64(x * Float64(Float64(-2.0 / Float64(t - y)) / z)); else tmp = Float64(2.0 * Float64(Float64(x / z) / Float64(y - t))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= 3.3e+133) tmp = x * ((-2.0 / (t - y)) / z); else tmp = 2.0 * ((x / z) / (y - t)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, 3.3e+133], N[(x * N[(N[(-2.0 / N[(t - y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 3.3 \cdot 10^{+133}:\\
\;\;\;\;x \cdot \frac{\frac{-2}{t - y}}{z}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\
\end{array}
\end{array}
if z < 3.3e133Initial program 95.1%
associate-*r/94.7%
distribute-rgt-out--96.1%
associate-/l/96.1%
sub-neg96.1%
+-commutative96.1%
neg-sub096.1%
associate-+l-96.1%
sub0-neg96.1%
neg-mul-196.1%
associate-/r*96.1%
metadata-eval96.1%
Simplified96.1%
if 3.3e133 < z Initial program 68.9%
associate-*l/68.9%
*-commutative68.9%
distribute-rgt-out--75.9%
associate-/r*96.6%
Simplified96.6%
Final simplification96.2%
(FPCore (x y z t) :precision binary64 (* 2.0 (/ (/ x z) (- y t))))
double code(double x, double y, double z, double t) {
return 2.0 * ((x / z) / (y - t));
}
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 = 2.0d0 * ((x / z) / (y - t))
end function
public static double code(double x, double y, double z, double t) {
return 2.0 * ((x / z) / (y - t));
}
def code(x, y, z, t): return 2.0 * ((x / z) / (y - t))
function code(x, y, z, t) return Float64(2.0 * Float64(Float64(x / z) / Float64(y - t))) end
function tmp = code(x, y, z, t) tmp = 2.0 * ((x / z) / (y - t)); end
code[x_, y_, z_, t_] := N[(2.0 * N[(N[(x / z), $MachinePrecision] / N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 \cdot \frac{\frac{x}{z}}{y - t}
\end{array}
Initial program 90.7%
associate-*l/91.1%
*-commutative91.1%
distribute-rgt-out--93.4%
associate-/r*91.5%
Simplified91.5%
Final simplification91.5%
(FPCore (x y z t) :precision binary64 (* x (/ -2.0 (* z t))))
double code(double x, double y, double z, double t) {
return x * (-2.0 / (z * t));
}
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) / (z * t))
end function
public static double code(double x, double y, double z, double t) {
return x * (-2.0 / (z * t));
}
def code(x, y, z, t): return x * (-2.0 / (z * t))
function code(x, y, z, t) return Float64(x * Float64(-2.0 / Float64(z * t))) end
function tmp = code(x, y, z, t) tmp = x * (-2.0 / (z * t)); end
code[x_, y_, z_, t_] := N[(x * N[(-2.0 / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{-2}{z \cdot t}
\end{array}
Initial program 90.7%
associate-*r/90.3%
distribute-rgt-out--92.7%
associate-/l/92.7%
sub-neg92.7%
+-commutative92.7%
neg-sub092.7%
associate-+l-92.7%
sub0-neg92.7%
neg-mul-192.7%
associate-/r*92.7%
metadata-eval92.7%
Simplified92.7%
Taylor expanded in t around inf 55.2%
Final simplification55.2%
(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 2023174
(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))))