
(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 11 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 (if (<= (/ (* x 2.0) (- (* y z) (* z t))) -5e-277) (/ (* x 2.0) (* z (- y t))) (* (/ x (- y t)) (/ 2.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (((x * 2.0) / ((y * z) - (z * t))) <= -5e-277) {
tmp = (x * 2.0) / (z * (y - t));
} else {
tmp = (x / (y - t)) * (2.0 / 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 (((x * 2.0d0) / ((y * z) - (z * t))) <= (-5d-277)) then
tmp = (x * 2.0d0) / (z * (y - t))
else
tmp = (x / (y - t)) * (2.0d0 / z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (((x * 2.0) / ((y * z) - (z * t))) <= -5e-277) {
tmp = (x * 2.0) / (z * (y - t));
} else {
tmp = (x / (y - t)) * (2.0 / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if ((x * 2.0) / ((y * z) - (z * t))) <= -5e-277: tmp = (x * 2.0) / (z * (y - t)) else: tmp = (x / (y - t)) * (2.0 / z) return tmp
function code(x, y, z, t) tmp = 0.0 if (Float64(Float64(x * 2.0) / Float64(Float64(y * z) - Float64(z * t))) <= -5e-277) tmp = Float64(Float64(x * 2.0) / Float64(z * Float64(y - t))); else tmp = Float64(Float64(x / Float64(y - t)) * Float64(2.0 / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (((x * 2.0) / ((y * z) - (z * t))) <= -5e-277) tmp = (x * 2.0) / (z * (y - t)); else tmp = (x / (y - t)) * (2.0 / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[N[(N[(x * 2.0), $MachinePrecision] / N[(N[(y * z), $MachinePrecision] - N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -5e-277], N[(N[(x * 2.0), $MachinePrecision] / N[(z * N[(y - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision] * N[(2.0 / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x \cdot 2}{y \cdot z - z \cdot t} \leq -5 \cdot 10^{-277}:\\
\;\;\;\;\frac{x \cdot 2}{z \cdot \left(y - t\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y - t} \cdot \frac{2}{z}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) < -5e-277Initial program 99.5%
distribute-rgt-out--99.5%
Simplified99.5%
if -5e-277 < (/.f64 (*.f64 x 2) (-.f64 (*.f64 y z) (*.f64 t z))) Initial program 86.8%
distribute-rgt-out--90.9%
Simplified90.9%
*-commutative90.9%
times-frac98.8%
Applied egg-rr98.8%
Final simplification99.0%
(FPCore (x y z t) :precision binary64 (if (or (<= y -4.5e-84) (not (<= y 2.7e-8))) (* x (/ (/ 2.0 y) z)) (* x (/ (/ -2.0 t) z))))
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= -4.5e-84) || !(y <= 2.7e-8)) {
tmp = x * ((2.0 / 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 ((y <= (-4.5d-84)) .or. (.not. (y <= 2.7d-8))) then
tmp = x * ((2.0d0 / 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 ((y <= -4.5e-84) || !(y <= 2.7e-8)) {
tmp = x * ((2.0 / y) / z);
} else {
tmp = x * ((-2.0 / t) / z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (y <= -4.5e-84) or not (y <= 2.7e-8): tmp = x * ((2.0 / y) / z) else: tmp = x * ((-2.0 / t) / z) return tmp
function code(x, y, z, t) tmp = 0.0 if ((y <= -4.5e-84) || !(y <= 2.7e-8)) tmp = Float64(x * Float64(Float64(2.0 / y) / z)); else tmp = Float64(x * Float64(Float64(-2.0 / t) / z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= -4.5e-84) || ~((y <= 2.7e-8))) tmp = x * ((2.0 / y) / z); else tmp = x * ((-2.0 / t) / z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[y, -4.5e-84], N[Not[LessEqual[y, 2.7e-8]], $MachinePrecision]], N[(x * N[(N[(2.0 / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(-2.0 / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{-84} \lor \neg \left(y \leq 2.7 \cdot 10^{-8}\right):\\
\;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{\frac{-2}{t}}{z}\\
\end{array}
\end{array}
if y < -4.50000000000000016e-84 or 2.70000000000000002e-8 < y Initial program 89.7%
associate-*r/89.6%
distribute-rgt-out--94.7%
associate-/l/95.6%
sub-neg95.6%
+-commutative95.6%
neg-sub095.6%
associate-+l-95.6%
sub0-neg95.6%
neg-mul-195.6%
associate-/r*95.6%
metadata-eval95.6%
Simplified95.6%
Taylor expanded in t around 0 82.7%
if -4.50000000000000016e-84 < y < 2.70000000000000002e-8Initial program 92.5%
associate-*r/92.5%
distribute-rgt-out--92.6%
associate-/l/92.8%
sub-neg92.8%
+-commutative92.8%
neg-sub092.8%
associate-+l-92.8%
sub0-neg92.8%
neg-mul-192.8%
associate-/r*92.8%
metadata-eval92.8%
Simplified92.8%
Taylor expanded in t around inf 82.3%
Final simplification82.5%
(FPCore (x y z t) :precision binary64 (if (<= y -4.5e-84) (* x (/ (/ 2.0 y) z)) (if (<= y 9e-5) (* x (/ (/ -2.0 t) z)) (* (/ 2.0 z) (/ x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.5e-84) {
tmp = x * ((2.0 / y) / z);
} else if (y <= 9e-5) {
tmp = x * ((-2.0 / t) / z);
} else {
tmp = (2.0 / z) * (x / 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) :: tmp
if (y <= (-4.5d-84)) then
tmp = x * ((2.0d0 / y) / z)
else if (y <= 9d-5) then
tmp = x * (((-2.0d0) / t) / z)
else
tmp = (2.0d0 / z) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.5e-84) {
tmp = x * ((2.0 / y) / z);
} else if (y <= 9e-5) {
tmp = x * ((-2.0 / t) / z);
} else {
tmp = (2.0 / z) * (x / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -4.5e-84: tmp = x * ((2.0 / y) / z) elif y <= 9e-5: tmp = x * ((-2.0 / t) / z) else: tmp = (2.0 / z) * (x / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -4.5e-84) tmp = Float64(x * Float64(Float64(2.0 / y) / z)); elseif (y <= 9e-5) tmp = Float64(x * Float64(Float64(-2.0 / t) / z)); else tmp = Float64(Float64(2.0 / z) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -4.5e-84) tmp = x * ((2.0 / y) / z); elseif (y <= 9e-5) tmp = x * ((-2.0 / t) / z); else tmp = (2.0 / z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.5e-84], N[(x * N[(N[(2.0 / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9e-5], N[(x * N[(N[(-2.0 / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{-84}:\\
\;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\
\mathbf{elif}\;y \leq 9 \cdot 10^{-5}:\\
\;\;\;\;x \cdot \frac{\frac{-2}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < -4.50000000000000016e-84Initial program 89.5%
associate-*r/89.5%
distribute-rgt-out--96.0%
associate-/l/97.1%
sub-neg97.1%
+-commutative97.1%
neg-sub097.1%
associate-+l-97.1%
sub0-neg97.1%
neg-mul-197.1%
associate-/r*97.1%
metadata-eval97.1%
Simplified97.1%
Taylor expanded in t around 0 85.1%
if -4.50000000000000016e-84 < y < 9.00000000000000057e-5Initial program 92.5%
associate-*r/92.5%
distribute-rgt-out--92.6%
associate-/l/92.8%
sub-neg92.8%
+-commutative92.8%
neg-sub092.8%
associate-+l-92.8%
sub0-neg92.8%
neg-mul-192.8%
associate-/r*92.8%
metadata-eval92.8%
Simplified92.8%
Taylor expanded in t around inf 82.3%
if 9.00000000000000057e-5 < y Initial program 89.9%
distribute-rgt-out--93.2%
Simplified93.2%
*-commutative93.2%
times-frac96.7%
Applied egg-rr96.7%
Taylor expanded in y around inf 81.0%
Final simplification82.8%
(FPCore (x y z t) :precision binary64 (if (<= y -4.5e-84) (* x (/ (/ 2.0 y) z)) (if (<= y 4e-7) (* -2.0 (/ (/ x t) z)) (* (/ 2.0 z) (/ x y)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.5e-84) {
tmp = x * ((2.0 / y) / z);
} else if (y <= 4e-7) {
tmp = -2.0 * ((x / t) / z);
} else {
tmp = (2.0 / z) * (x / 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) :: tmp
if (y <= (-4.5d-84)) then
tmp = x * ((2.0d0 / y) / z)
else if (y <= 4d-7) then
tmp = (-2.0d0) * ((x / t) / z)
else
tmp = (2.0d0 / z) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.5e-84) {
tmp = x * ((2.0 / y) / z);
} else if (y <= 4e-7) {
tmp = -2.0 * ((x / t) / z);
} else {
tmp = (2.0 / z) * (x / y);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -4.5e-84: tmp = x * ((2.0 / y) / z) elif y <= 4e-7: tmp = -2.0 * ((x / t) / z) else: tmp = (2.0 / z) * (x / y) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -4.5e-84) tmp = Float64(x * Float64(Float64(2.0 / y) / z)); elseif (y <= 4e-7) tmp = Float64(-2.0 * Float64(Float64(x / t) / z)); else tmp = Float64(Float64(2.0 / z) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -4.5e-84) tmp = x * ((2.0 / y) / z); elseif (y <= 4e-7) tmp = -2.0 * ((x / t) / z); else tmp = (2.0 / z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.5e-84], N[(x * N[(N[(2.0 / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4e-7], N[(-2.0 * N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 / z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{-84}:\\
\;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-7}:\\
\;\;\;\;-2 \cdot \frac{\frac{x}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{z} \cdot \frac{x}{y}\\
\end{array}
\end{array}
if y < -4.50000000000000016e-84Initial program 89.5%
associate-*r/89.5%
distribute-rgt-out--96.0%
associate-/l/97.1%
sub-neg97.1%
+-commutative97.1%
neg-sub097.1%
associate-+l-97.1%
sub0-neg97.1%
neg-mul-197.1%
associate-/r*97.1%
metadata-eval97.1%
Simplified97.1%
Taylor expanded in t around 0 85.1%
if -4.50000000000000016e-84 < y < 3.9999999999999998e-7Initial program 92.5%
associate-*l/92.5%
*-commutative92.5%
distribute-rgt-out--92.6%
associate-/r*95.1%
Simplified95.1%
Taylor expanded in y around 0 82.1%
*-commutative82.1%
associate-/r*86.9%
Simplified86.9%
if 3.9999999999999998e-7 < y Initial program 89.9%
distribute-rgt-out--93.2%
Simplified93.2%
*-commutative93.2%
times-frac96.7%
Applied egg-rr96.7%
Taylor expanded in y around inf 81.0%
Final simplification84.9%
(FPCore (x y z t) :precision binary64 (if (<= y -4.2e-84) (* x (/ (/ 2.0 y) z)) (if (<= y 1.3e-9) (* -2.0 (/ (/ x t) z)) (/ (/ x y) (* z 0.5)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.2e-84) {
tmp = x * ((2.0 / y) / z);
} else if (y <= 1.3e-9) {
tmp = -2.0 * ((x / t) / z);
} else {
tmp = (x / y) / (z * 0.5);
}
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 <= (-4.2d-84)) then
tmp = x * ((2.0d0 / y) / z)
else if (y <= 1.3d-9) then
tmp = (-2.0d0) * ((x / t) / z)
else
tmp = (x / y) / (z * 0.5d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.2e-84) {
tmp = x * ((2.0 / y) / z);
} else if (y <= 1.3e-9) {
tmp = -2.0 * ((x / t) / z);
} else {
tmp = (x / y) / (z * 0.5);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -4.2e-84: tmp = x * ((2.0 / y) / z) elif y <= 1.3e-9: tmp = -2.0 * ((x / t) / z) else: tmp = (x / y) / (z * 0.5) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -4.2e-84) tmp = Float64(x * Float64(Float64(2.0 / y) / z)); elseif (y <= 1.3e-9) tmp = Float64(-2.0 * Float64(Float64(x / t) / z)); else tmp = Float64(Float64(x / y) / Float64(z * 0.5)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -4.2e-84) tmp = x * ((2.0 / y) / z); elseif (y <= 1.3e-9) tmp = -2.0 * ((x / t) / z); else tmp = (x / y) / (z * 0.5); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.2e-84], N[(x * N[(N[(2.0 / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.3e-9], N[(-2.0 * N[(N[(x / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(z * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.2 \cdot 10^{-84}:\\
\;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{-9}:\\
\;\;\;\;-2 \cdot \frac{\frac{x}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{z \cdot 0.5}\\
\end{array}
\end{array}
if y < -4.19999999999999996e-84Initial program 89.5%
associate-*r/89.5%
distribute-rgt-out--96.0%
associate-/l/97.1%
sub-neg97.1%
+-commutative97.1%
neg-sub097.1%
associate-+l-97.1%
sub0-neg97.1%
neg-mul-197.1%
associate-/r*97.1%
metadata-eval97.1%
Simplified97.1%
Taylor expanded in t around 0 85.1%
if -4.19999999999999996e-84 < y < 1.3000000000000001e-9Initial program 92.5%
associate-*l/92.5%
*-commutative92.5%
distribute-rgt-out--92.6%
associate-/r*95.1%
Simplified95.1%
Taylor expanded in y around 0 82.1%
*-commutative82.1%
associate-/r*86.9%
Simplified86.9%
if 1.3000000000000001e-9 < y Initial program 89.9%
associate-*r/89.8%
distribute-rgt-out--93.1%
associate-/l/93.7%
sub-neg93.7%
+-commutative93.7%
neg-sub093.7%
associate-+l-93.7%
sub0-neg93.7%
neg-mul-193.7%
associate-/r*93.7%
metadata-eval93.7%
Simplified93.7%
Taylor expanded in t around 0 79.6%
associate-/r*79.0%
associate-*r/79.1%
times-frac81.0%
clear-num81.0%
un-div-inv81.1%
div-inv81.1%
metadata-eval81.1%
Applied egg-rr81.1%
Final simplification85.0%
(FPCore (x y z t) :precision binary64 (if (<= y -4.5e-84) (* x (/ (/ 2.0 y) z)) (if (<= y 4.5e-11) (/ (/ (* x -2.0) t) z) (/ (/ x y) (* z 0.5)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.5e-84) {
tmp = x * ((2.0 / y) / z);
} else if (y <= 4.5e-11) {
tmp = ((x * -2.0) / t) / z;
} else {
tmp = (x / y) / (z * 0.5);
}
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 <= (-4.5d-84)) then
tmp = x * ((2.0d0 / y) / z)
else if (y <= 4.5d-11) then
tmp = ((x * (-2.0d0)) / t) / z
else
tmp = (x / y) / (z * 0.5d0)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= -4.5e-84) {
tmp = x * ((2.0 / y) / z);
} else if (y <= 4.5e-11) {
tmp = ((x * -2.0) / t) / z;
} else {
tmp = (x / y) / (z * 0.5);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= -4.5e-84: tmp = x * ((2.0 / y) / z) elif y <= 4.5e-11: tmp = ((x * -2.0) / t) / z else: tmp = (x / y) / (z * 0.5) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= -4.5e-84) tmp = Float64(x * Float64(Float64(2.0 / y) / z)); elseif (y <= 4.5e-11) tmp = Float64(Float64(Float64(x * -2.0) / t) / z); else tmp = Float64(Float64(x / y) / Float64(z * 0.5)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= -4.5e-84) tmp = x * ((2.0 / y) / z); elseif (y <= 4.5e-11) tmp = ((x * -2.0) / t) / z; else tmp = (x / y) / (z * 0.5); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, -4.5e-84], N[(x * N[(N[(2.0 / y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.5e-11], N[(N[(N[(x * -2.0), $MachinePrecision] / t), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / y), $MachinePrecision] / N[(z * 0.5), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{-84}:\\
\;\;\;\;x \cdot \frac{\frac{2}{y}}{z}\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{-11}:\\
\;\;\;\;\frac{\frac{x \cdot -2}{t}}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{x}{y}}{z \cdot 0.5}\\
\end{array}
\end{array}
if y < -4.50000000000000016e-84Initial program 89.5%
associate-*r/89.5%
distribute-rgt-out--96.0%
associate-/l/97.1%
sub-neg97.1%
+-commutative97.1%
neg-sub097.1%
associate-+l-97.1%
sub0-neg97.1%
neg-mul-197.1%
associate-/r*97.1%
metadata-eval97.1%
Simplified97.1%
Taylor expanded in t around 0 85.1%
if -4.50000000000000016e-84 < y < 4.5e-11Initial program 92.5%
associate-*l/92.5%
*-commutative92.5%
distribute-rgt-out--92.6%
associate-/r*95.1%
Simplified95.1%
Taylor expanded in y around 0 82.1%
associate-*r/82.1%
metadata-eval82.1%
distribute-lft-neg-in82.1%
*-commutative82.1%
associate-/r*86.9%
distribute-rgt-neg-in86.9%
metadata-eval86.9%
Applied egg-rr86.9%
if 4.5e-11 < y Initial program 89.9%
associate-*r/89.8%
distribute-rgt-out--93.1%
associate-/l/93.7%
sub-neg93.7%
+-commutative93.7%
neg-sub093.7%
associate-+l-93.7%
sub0-neg93.7%
neg-mul-193.7%
associate-/r*93.7%
metadata-eval93.7%
Simplified93.7%
Taylor expanded in t around 0 79.6%
associate-/r*79.0%
associate-*r/79.1%
times-frac81.0%
clear-num81.0%
un-div-inv81.1%
div-inv81.1%
metadata-eval81.1%
Applied egg-rr81.1%
Final simplification85.0%
(FPCore (x y z t) :precision binary64 (if (<= z 1.4e-211) (* 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 <= 1.4e-211) {
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 <= 1.4d-211) 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 <= 1.4e-211) {
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 <= 1.4e-211: 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 <= 1.4e-211) 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 <= 1.4e-211) 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, 1.4e-211], 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 1.4 \cdot 10^{-211}:\\
\;\;\;\;x \cdot \frac{\frac{-2}{t - y}}{z}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \frac{\frac{x}{z}}{y - t}\\
\end{array}
\end{array}
if z < 1.3999999999999999e-211Initial program 93.2%
associate-*r/93.2%
distribute-rgt-out--94.0%
associate-/l/95.0%
sub-neg95.0%
+-commutative95.0%
neg-sub095.0%
associate-+l-95.0%
sub0-neg95.0%
neg-mul-195.0%
associate-/r*95.0%
metadata-eval95.0%
Simplified95.0%
if 1.3999999999999999e-211 < z Initial program 88.0%
associate-*l/88.0%
*-commutative88.0%
distribute-rgt-out--93.5%
associate-/r*98.9%
Simplified98.9%
Final simplification96.7%
(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 91.0%
associate-*l/91.0%
*-commutative91.0%
distribute-rgt-out--93.8%
associate-/r*94.7%
Simplified94.7%
Final simplification94.7%
(FPCore (x y z t) :precision binary64 (* (/ x (- y t)) (/ 2.0 z)))
double code(double x, double y, double z, double t) {
return (x / (y - t)) * (2.0 / 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 / (y - t)) * (2.0d0 / z)
end function
public static double code(double x, double y, double z, double t) {
return (x / (y - t)) * (2.0 / z);
}
def code(x, y, z, t): return (x / (y - t)) * (2.0 / z)
function code(x, y, z, t) return Float64(Float64(x / Float64(y - t)) * Float64(2.0 / z)) end
function tmp = code(x, y, z, t) tmp = (x / (y - t)) * (2.0 / z); end
code[x_, y_, z_, t_] := N[(N[(x / N[(y - t), $MachinePrecision]), $MachinePrecision] * N[(2.0 / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{y - t} \cdot \frac{2}{z}
\end{array}
Initial program 91.0%
distribute-rgt-out--93.8%
Simplified93.8%
*-commutative93.8%
times-frac97.3%
Applied egg-rr97.3%
Final simplification97.3%
(FPCore (x y z t) :precision binary64 (* -2.0 (/ x (* z t))))
double code(double x, double y, double z, double t) {
return -2.0 * (x / (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 = (-2.0d0) * (x / (z * t))
end function
public static double code(double x, double y, double z, double t) {
return -2.0 * (x / (z * t));
}
def code(x, y, z, t): return -2.0 * (x / (z * t))
function code(x, y, z, t) return Float64(-2.0 * Float64(x / Float64(z * t))) end
function tmp = code(x, y, z, t) tmp = -2.0 * (x / (z * t)); end
code[x_, y_, z_, t_] := N[(-2.0 * N[(x / N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-2 \cdot \frac{x}{z \cdot t}
\end{array}
Initial program 91.0%
associate-*l/91.0%
*-commutative91.0%
distribute-rgt-out--93.8%
associate-/r*94.7%
Simplified94.7%
Taylor expanded in y around 0 55.6%
Final simplification55.6%
(FPCore (x y z t) :precision binary64 (* x (/ (/ -2.0 t) z)))
double code(double x, double y, double z, double t) {
return x * ((-2.0 / 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) / t) / z)
end function
public static double code(double x, double y, double z, double t) {
return x * ((-2.0 / t) / z);
}
def code(x, y, z, t): return x * ((-2.0 / t) / z)
function code(x, y, z, t) return Float64(x * Float64(Float64(-2.0 / t) / z)) end
function tmp = code(x, y, z, t) tmp = x * ((-2.0 / t) / z); end
code[x_, y_, z_, t_] := N[(x * N[(N[(-2.0 / t), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\frac{-2}{t}}{z}
\end{array}
Initial program 91.0%
associate-*r/90.9%
distribute-rgt-out--93.7%
associate-/l/94.3%
sub-neg94.3%
+-commutative94.3%
neg-sub094.3%
associate-+l-94.3%
sub0-neg94.3%
neg-mul-194.3%
associate-/r*94.3%
metadata-eval94.3%
Simplified94.3%
Taylor expanded in t around inf 55.7%
Final simplification55.7%
(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 2023242
(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))))