
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (+ (- y z) 1.0)) z))
double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x * ((y - z) + 1.0d0)) / z
end function
public static double code(double x, double y, double z) {
return (x * ((y - z) + 1.0)) / z;
}
def code(x, y, z): return (x * ((y - z) + 1.0)) / z
function code(x, y, z) return Float64(Float64(x * Float64(Float64(y - z) + 1.0)) / z) end
function tmp = code(x, y, z) tmp = (x * ((y - z) + 1.0)) / z; end
code[x_, y_, z_] := N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(\left(y - z\right) + 1\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (if (or (<= z -5e+26) (not (<= z 2.1e+54))) (/ x (/ z (+ (- y z) 1.0))) (* (/ x z) (- (+ y 1.0) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5e+26) || !(z <= 2.1e+54)) {
tmp = x / (z / ((y - z) + 1.0));
} else {
tmp = (x / z) * ((y + 1.0) - z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-5d+26)) .or. (.not. (z <= 2.1d+54))) then
tmp = x / (z / ((y - z) + 1.0d0))
else
tmp = (x / z) * ((y + 1.0d0) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5e+26) || !(z <= 2.1e+54)) {
tmp = x / (z / ((y - z) + 1.0));
} else {
tmp = (x / z) * ((y + 1.0) - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5e+26) or not (z <= 2.1e+54): tmp = x / (z / ((y - z) + 1.0)) else: tmp = (x / z) * ((y + 1.0) - z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5e+26) || !(z <= 2.1e+54)) tmp = Float64(x / Float64(z / Float64(Float64(y - z) + 1.0))); else tmp = Float64(Float64(x / z) * Float64(Float64(y + 1.0) - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5e+26) || ~((z <= 2.1e+54))) tmp = x / (z / ((y - z) + 1.0)); else tmp = (x / z) * ((y + 1.0) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5e+26], N[Not[LessEqual[z, 2.1e+54]], $MachinePrecision]], N[(x / N[(z / N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(N[(y + 1.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{+26} \lor \neg \left(z \leq 2.1 \cdot 10^{+54}\right):\\
\;\;\;\;\frac{x}{\frac{z}{\left(y - z\right) + 1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(\left(y + 1\right) - z\right)\\
\end{array}
\end{array}
if z < -5.0000000000000001e26 or 2.09999999999999986e54 < z Initial program 65.3%
associate-/l*100.0%
Simplified100.0%
if -5.0000000000000001e26 < z < 2.09999999999999986e54Initial program 98.8%
associate-/l*92.7%
Simplified92.7%
Taylor expanded in x around 0 98.8%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= y 4e+79) (- (/ (fma x y x) z) x) (/ x (/ z (+ (- y z) 1.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 4e+79) {
tmp = (fma(x, y, x) / z) - x;
} else {
tmp = x / (z / ((y - z) + 1.0));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= 4e+79) tmp = Float64(Float64(fma(x, y, x) / z) - x); else tmp = Float64(x / Float64(z / Float64(Float64(y - z) + 1.0))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, 4e+79], N[(N[(N[(x * y + x), $MachinePrecision] / z), $MachinePrecision] - x), $MachinePrecision], N[(x / N[(z / N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4 \cdot 10^{+79}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, x\right)}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{\left(y - z\right) + 1}}\\
\end{array}
\end{array}
if y < 3.99999999999999987e79Initial program 85.8%
Simplified98.6%
if 3.99999999999999987e79 < y Initial program 80.9%
associate-/l*97.9%
Simplified97.9%
Final simplification98.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -260000000000.0)
(- x)
(if (<= z -8.5e-42)
t_0
(if (<= z -7.8e-153)
(/ x z)
(if (<= z -9.5e-212)
t_0
(if (<= z 2.1e-212)
(/ x z)
(if (<= z 2050000000000.0) t_0 (- x)))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -260000000000.0) {
tmp = -x;
} else if (z <= -8.5e-42) {
tmp = t_0;
} else if (z <= -7.8e-153) {
tmp = x / z;
} else if (z <= -9.5e-212) {
tmp = t_0;
} else if (z <= 2.1e-212) {
tmp = x / z;
} else if (z <= 2050000000000.0) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = y * (x / z)
if (z <= (-260000000000.0d0)) then
tmp = -x
else if (z <= (-8.5d-42)) then
tmp = t_0
else if (z <= (-7.8d-153)) then
tmp = x / z
else if (z <= (-9.5d-212)) then
tmp = t_0
else if (z <= 2.1d-212) then
tmp = x / z
else if (z <= 2050000000000.0d0) then
tmp = t_0
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -260000000000.0) {
tmp = -x;
} else if (z <= -8.5e-42) {
tmp = t_0;
} else if (z <= -7.8e-153) {
tmp = x / z;
} else if (z <= -9.5e-212) {
tmp = t_0;
} else if (z <= 2.1e-212) {
tmp = x / z;
} else if (z <= 2050000000000.0) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -260000000000.0: tmp = -x elif z <= -8.5e-42: tmp = t_0 elif z <= -7.8e-153: tmp = x / z elif z <= -9.5e-212: tmp = t_0 elif z <= 2.1e-212: tmp = x / z elif z <= 2050000000000.0: tmp = t_0 else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (z <= -260000000000.0) tmp = Float64(-x); elseif (z <= -8.5e-42) tmp = t_0; elseif (z <= -7.8e-153) tmp = Float64(x / z); elseif (z <= -9.5e-212) tmp = t_0; elseif (z <= 2.1e-212) tmp = Float64(x / z); elseif (z <= 2050000000000.0) tmp = t_0; else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (x / z); tmp = 0.0; if (z <= -260000000000.0) tmp = -x; elseif (z <= -8.5e-42) tmp = t_0; elseif (z <= -7.8e-153) tmp = x / z; elseif (z <= -9.5e-212) tmp = t_0; elseif (z <= 2.1e-212) tmp = x / z; elseif (z <= 2050000000000.0) tmp = t_0; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -260000000000.0], (-x), If[LessEqual[z, -8.5e-42], t$95$0, If[LessEqual[z, -7.8e-153], N[(x / z), $MachinePrecision], If[LessEqual[z, -9.5e-212], t$95$0, If[LessEqual[z, 2.1e-212], N[(x / z), $MachinePrecision], If[LessEqual[z, 2050000000000.0], t$95$0, (-x)]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -260000000000:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -8.5 \cdot 10^{-42}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -7.8 \cdot 10^{-153}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq -9.5 \cdot 10^{-212}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{-212}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 2050000000000:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -2.6e11 or 2.05e12 < z Initial program 66.9%
Simplified90.9%
Taylor expanded in z around inf 83.5%
neg-mul-183.5%
Simplified83.5%
if -2.6e11 < z < -8.4999999999999996e-42 or -7.8000000000000004e-153 < z < -9.50000000000000029e-212 or 2.1e-212 < z < 2.05e12Initial program 99.8%
associate-/l*91.6%
Simplified91.6%
Taylor expanded in y around inf 57.8%
associate-/r/68.8%
Applied egg-rr68.8%
if -8.4999999999999996e-42 < z < -7.8000000000000004e-153 or -9.50000000000000029e-212 < z < 2.1e-212Initial program 100.0%
Taylor expanded in z around 0 100.0%
Taylor expanded in y around 0 74.5%
Final simplification77.1%
(FPCore (x y z)
:precision binary64
(if (<= y -2.4e+150)
(* y (/ x z))
(if (or (<= y 76000.0) (and (not (<= y 7.5e+25)) (<= y 3.1e+167)))
(- (/ x z) x)
(* x (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.4e+150) {
tmp = y * (x / z);
} else if ((y <= 76000.0) || (!(y <= 7.5e+25) && (y <= 3.1e+167))) {
tmp = (x / z) - x;
} else {
tmp = x * (y / z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-2.4d+150)) then
tmp = y * (x / z)
else if ((y <= 76000.0d0) .or. (.not. (y <= 7.5d+25)) .and. (y <= 3.1d+167)) then
tmp = (x / z) - x
else
tmp = x * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.4e+150) {
tmp = y * (x / z);
} else if ((y <= 76000.0) || (!(y <= 7.5e+25) && (y <= 3.1e+167))) {
tmp = (x / z) - x;
} else {
tmp = x * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.4e+150: tmp = y * (x / z) elif (y <= 76000.0) or (not (y <= 7.5e+25) and (y <= 3.1e+167)): tmp = (x / z) - x else: tmp = x * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.4e+150) tmp = Float64(y * Float64(x / z)); elseif ((y <= 76000.0) || (!(y <= 7.5e+25) && (y <= 3.1e+167))) tmp = Float64(Float64(x / z) - x); else tmp = Float64(x * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.4e+150) tmp = y * (x / z); elseif ((y <= 76000.0) || (~((y <= 7.5e+25)) && (y <= 3.1e+167))) tmp = (x / z) - x; else tmp = x * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.4e+150], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 76000.0], And[N[Not[LessEqual[y, 7.5e+25]], $MachinePrecision], LessEqual[y, 3.1e+167]]], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{+150}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 76000 \lor \neg \left(y \leq 7.5 \cdot 10^{+25}\right) \land y \leq 3.1 \cdot 10^{+167}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -2.40000000000000003e150Initial program 94.1%
associate-/l*83.4%
Simplified83.4%
Taylor expanded in y around inf 80.8%
associate-/r/92.6%
Applied egg-rr92.6%
if -2.40000000000000003e150 < y < 76000 or 7.49999999999999993e25 < y < 3.1e167Initial program 82.4%
Simplified97.4%
Taylor expanded in y around 0 89.7%
if 76000 < y < 7.49999999999999993e25 or 3.1e167 < y Initial program 89.3%
associate-/l*97.2%
Simplified97.2%
Taylor expanded in y around inf 88.1%
clear-num88.1%
associate-/r/88.0%
clear-num88.1%
Applied egg-rr88.1%
Final simplification89.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ x z) x)))
(if (<= y -2.4e+150)
(* y (/ x z))
(if (<= y 76000.0)
t_0
(if (<= y 7.5e+25)
(* x (/ y z))
(if (<= y 3.1e+167) t_0 (/ x (/ z y))))))))
double code(double x, double y, double z) {
double t_0 = (x / z) - x;
double tmp;
if (y <= -2.4e+150) {
tmp = y * (x / z);
} else if (y <= 76000.0) {
tmp = t_0;
} else if (y <= 7.5e+25) {
tmp = x * (y / z);
} else if (y <= 3.1e+167) {
tmp = t_0;
} else {
tmp = x / (z / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x / z) - x
if (y <= (-2.4d+150)) then
tmp = y * (x / z)
else if (y <= 76000.0d0) then
tmp = t_0
else if (y <= 7.5d+25) then
tmp = x * (y / z)
else if (y <= 3.1d+167) then
tmp = t_0
else
tmp = x / (z / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x / z) - x;
double tmp;
if (y <= -2.4e+150) {
tmp = y * (x / z);
} else if (y <= 76000.0) {
tmp = t_0;
} else if (y <= 7.5e+25) {
tmp = x * (y / z);
} else if (y <= 3.1e+167) {
tmp = t_0;
} else {
tmp = x / (z / y);
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) - x tmp = 0 if y <= -2.4e+150: tmp = y * (x / z) elif y <= 76000.0: tmp = t_0 elif y <= 7.5e+25: tmp = x * (y / z) elif y <= 3.1e+167: tmp = t_0 else: tmp = x / (z / y) return tmp
function code(x, y, z) t_0 = Float64(Float64(x / z) - x) tmp = 0.0 if (y <= -2.4e+150) tmp = Float64(y * Float64(x / z)); elseif (y <= 76000.0) tmp = t_0; elseif (y <= 7.5e+25) tmp = Float64(x * Float64(y / z)); elseif (y <= 3.1e+167) tmp = t_0; else tmp = Float64(x / Float64(z / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / z) - x; tmp = 0.0; if (y <= -2.4e+150) tmp = y * (x / z); elseif (y <= 76000.0) tmp = t_0; elseif (y <= 7.5e+25) tmp = x * (y / z); elseif (y <= 3.1e+167) tmp = t_0; else tmp = x / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[y, -2.4e+150], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 76000.0], t$95$0, If[LessEqual[y, 7.5e+25], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.1e+167], t$95$0, N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z} - x\\
\mathbf{if}\;y \leq -2.4 \cdot 10^{+150}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 76000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+25}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{+167}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < -2.40000000000000003e150Initial program 94.1%
associate-/l*83.4%
Simplified83.4%
Taylor expanded in y around inf 80.8%
associate-/r/92.6%
Applied egg-rr92.6%
if -2.40000000000000003e150 < y < 76000 or 7.49999999999999993e25 < y < 3.1e167Initial program 82.4%
Simplified97.4%
Taylor expanded in y around 0 89.7%
if 76000 < y < 7.49999999999999993e25Initial program 99.8%
associate-/l*99.1%
Simplified99.1%
Taylor expanded in y around inf 81.5%
clear-num81.5%
associate-/r/81.3%
clear-num81.8%
Applied egg-rr81.8%
if 3.1e167 < y Initial program 86.7%
associate-/l*96.7%
Simplified96.7%
Taylor expanded in y around inf 89.8%
Final simplification89.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ x z) x)))
(if (<= y -2.45e+150)
(* y (/ x z))
(if (<= y 76000.0)
t_0
(if (<= y 6.2e+25)
(/ y (/ z x))
(if (<= y 3.2e+167) t_0 (/ x (/ z y))))))))
double code(double x, double y, double z) {
double t_0 = (x / z) - x;
double tmp;
if (y <= -2.45e+150) {
tmp = y * (x / z);
} else if (y <= 76000.0) {
tmp = t_0;
} else if (y <= 6.2e+25) {
tmp = y / (z / x);
} else if (y <= 3.2e+167) {
tmp = t_0;
} else {
tmp = x / (z / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x / z) - x
if (y <= (-2.45d+150)) then
tmp = y * (x / z)
else if (y <= 76000.0d0) then
tmp = t_0
else if (y <= 6.2d+25) then
tmp = y / (z / x)
else if (y <= 3.2d+167) then
tmp = t_0
else
tmp = x / (z / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x / z) - x;
double tmp;
if (y <= -2.45e+150) {
tmp = y * (x / z);
} else if (y <= 76000.0) {
tmp = t_0;
} else if (y <= 6.2e+25) {
tmp = y / (z / x);
} else if (y <= 3.2e+167) {
tmp = t_0;
} else {
tmp = x / (z / y);
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) - x tmp = 0 if y <= -2.45e+150: tmp = y * (x / z) elif y <= 76000.0: tmp = t_0 elif y <= 6.2e+25: tmp = y / (z / x) elif y <= 3.2e+167: tmp = t_0 else: tmp = x / (z / y) return tmp
function code(x, y, z) t_0 = Float64(Float64(x / z) - x) tmp = 0.0 if (y <= -2.45e+150) tmp = Float64(y * Float64(x / z)); elseif (y <= 76000.0) tmp = t_0; elseif (y <= 6.2e+25) tmp = Float64(y / Float64(z / x)); elseif (y <= 3.2e+167) tmp = t_0; else tmp = Float64(x / Float64(z / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / z) - x; tmp = 0.0; if (y <= -2.45e+150) tmp = y * (x / z); elseif (y <= 76000.0) tmp = t_0; elseif (y <= 6.2e+25) tmp = y / (z / x); elseif (y <= 3.2e+167) tmp = t_0; else tmp = x / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[y, -2.45e+150], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 76000.0], t$95$0, If[LessEqual[y, 6.2e+25], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.2e+167], t$95$0, N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z} - x\\
\mathbf{if}\;y \leq -2.45 \cdot 10^{+150}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 76000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+25}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+167}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < -2.45000000000000003e150Initial program 94.1%
associate-/l*83.4%
Simplified83.4%
Taylor expanded in y around inf 80.8%
associate-/r/92.6%
Applied egg-rr92.6%
if -2.45000000000000003e150 < y < 76000 or 6.1999999999999996e25 < y < 3.19999999999999981e167Initial program 82.4%
Simplified97.4%
Taylor expanded in y around 0 89.7%
if 76000 < y < 6.1999999999999996e25Initial program 99.8%
associate-/l*99.1%
Simplified99.1%
Taylor expanded in y around inf 81.5%
associate-/r/81.8%
Applied egg-rr81.8%
associate-*l/81.8%
*-commutative81.8%
associate-/l*81.8%
Applied egg-rr81.8%
if 3.19999999999999981e167 < y Initial program 86.7%
associate-/l*96.7%
Simplified96.7%
Taylor expanded in y around inf 89.8%
Final simplification89.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (/ x z) x)))
(if (<= y -2.4e+150)
(/ (* y x) z)
(if (<= y 76000.0)
t_0
(if (<= y 1.08e+26)
(/ y (/ z x))
(if (<= y 3.1e+167) t_0 (/ x (/ z y))))))))
double code(double x, double y, double z) {
double t_0 = (x / z) - x;
double tmp;
if (y <= -2.4e+150) {
tmp = (y * x) / z;
} else if (y <= 76000.0) {
tmp = t_0;
} else if (y <= 1.08e+26) {
tmp = y / (z / x);
} else if (y <= 3.1e+167) {
tmp = t_0;
} else {
tmp = x / (z / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x / z) - x
if (y <= (-2.4d+150)) then
tmp = (y * x) / z
else if (y <= 76000.0d0) then
tmp = t_0
else if (y <= 1.08d+26) then
tmp = y / (z / x)
else if (y <= 3.1d+167) then
tmp = t_0
else
tmp = x / (z / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x / z) - x;
double tmp;
if (y <= -2.4e+150) {
tmp = (y * x) / z;
} else if (y <= 76000.0) {
tmp = t_0;
} else if (y <= 1.08e+26) {
tmp = y / (z / x);
} else if (y <= 3.1e+167) {
tmp = t_0;
} else {
tmp = x / (z / y);
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) - x tmp = 0 if y <= -2.4e+150: tmp = (y * x) / z elif y <= 76000.0: tmp = t_0 elif y <= 1.08e+26: tmp = y / (z / x) elif y <= 3.1e+167: tmp = t_0 else: tmp = x / (z / y) return tmp
function code(x, y, z) t_0 = Float64(Float64(x / z) - x) tmp = 0.0 if (y <= -2.4e+150) tmp = Float64(Float64(y * x) / z); elseif (y <= 76000.0) tmp = t_0; elseif (y <= 1.08e+26) tmp = Float64(y / Float64(z / x)); elseif (y <= 3.1e+167) tmp = t_0; else tmp = Float64(x / Float64(z / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / z) - x; tmp = 0.0; if (y <= -2.4e+150) tmp = (y * x) / z; elseif (y <= 76000.0) tmp = t_0; elseif (y <= 1.08e+26) tmp = y / (z / x); elseif (y <= 3.1e+167) tmp = t_0; else tmp = x / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]}, If[LessEqual[y, -2.4e+150], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 76000.0], t$95$0, If[LessEqual[y, 1.08e+26], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.1e+167], t$95$0, N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z} - x\\
\mathbf{if}\;y \leq -2.4 \cdot 10^{+150}:\\
\;\;\;\;\frac{y \cdot x}{z}\\
\mathbf{elif}\;y \leq 76000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.08 \cdot 10^{+26}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\mathbf{elif}\;y \leq 3.1 \cdot 10^{+167}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < -2.40000000000000003e150Initial program 94.1%
Taylor expanded in y around inf 94.1%
if -2.40000000000000003e150 < y < 76000 or 1.08e26 < y < 3.1e167Initial program 82.4%
Simplified97.4%
Taylor expanded in y around 0 89.7%
if 76000 < y < 1.08e26Initial program 99.8%
associate-/l*99.1%
Simplified99.1%
Taylor expanded in y around inf 81.5%
associate-/r/81.8%
Applied egg-rr81.8%
associate-*l/81.8%
*-commutative81.8%
associate-/l*81.8%
Applied egg-rr81.8%
if 3.1e167 < y Initial program 86.7%
associate-/l*96.7%
Simplified96.7%
Taylor expanded in y around inf 89.8%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -4.5e+77) (not (<= z 2e+20))) (- (/ y (/ z x)) x) (* (/ x z) (- (+ y 1.0) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4.5e+77) || !(z <= 2e+20)) {
tmp = (y / (z / x)) - x;
} else {
tmp = (x / z) * ((y + 1.0) - z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-4.5d+77)) .or. (.not. (z <= 2d+20))) then
tmp = (y / (z / x)) - x
else
tmp = (x / z) * ((y + 1.0d0) - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -4.5e+77) || !(z <= 2e+20)) {
tmp = (y / (z / x)) - x;
} else {
tmp = (x / z) * ((y + 1.0) - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4.5e+77) or not (z <= 2e+20): tmp = (y / (z / x)) - x else: tmp = (x / z) * ((y + 1.0) - z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4.5e+77) || !(z <= 2e+20)) tmp = Float64(Float64(y / Float64(z / x)) - x); else tmp = Float64(Float64(x / z) * Float64(Float64(y + 1.0) - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -4.5e+77) || ~((z <= 2e+20))) tmp = (y / (z / x)) - x; else tmp = (x / z) * ((y + 1.0) - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4.5e+77], N[Not[LessEqual[z, 2e+20]], $MachinePrecision]], N[(N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(N[(y + 1.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+77} \lor \neg \left(z \leq 2 \cdot 10^{+20}\right):\\
\;\;\;\;\frac{y}{\frac{z}{x}} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(\left(y + 1\right) - z\right)\\
\end{array}
\end{array}
if z < -4.50000000000000024e77 or 2e20 < z Initial program 63.3%
Simplified90.4%
Taylor expanded in y around inf 90.4%
associate-/l*96.2%
Simplified96.2%
if -4.50000000000000024e77 < z < 2e20Initial program 98.8%
associate-/l*93.0%
Simplified93.0%
Taylor expanded in x around 0 98.8%
associate-*l/99.3%
Simplified99.3%
Final simplification98.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -19.5) (not (<= y 0.00048))) (- (/ y (/ z x)) x) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -19.5) || !(y <= 0.00048)) {
tmp = (y / (z / x)) - x;
} else {
tmp = (x / z) - x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-19.5d0)) .or. (.not. (y <= 0.00048d0))) then
tmp = (y / (z / x)) - x
else
tmp = (x / z) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -19.5) || !(y <= 0.00048)) {
tmp = (y / (z / x)) - x;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -19.5) or not (y <= 0.00048): tmp = (y / (z / x)) - x else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -19.5) || !(y <= 0.00048)) tmp = Float64(Float64(y / Float64(z / x)) - x); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -19.5) || ~((y <= 0.00048))) tmp = (y / (z / x)) - x; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -19.5], N[Not[LessEqual[y, 0.00048]], $MachinePrecision]], N[(N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -19.5 \lor \neg \left(y \leq 0.00048\right):\\
\;\;\;\;\frac{y}{\frac{z}{x}} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -19.5 or 4.80000000000000012e-4 < y Initial program 85.1%
Simplified91.3%
Taylor expanded in y around inf 89.0%
associate-/l*93.7%
Simplified93.7%
if -19.5 < y < 4.80000000000000012e-4Initial program 84.7%
Simplified100.0%
Taylor expanded in y around 0 99.9%
Final simplification96.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (- (/ y (/ z x)) x) (/ (* x (+ y 1.0)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = (y / (z / x)) - x;
} else {
tmp = (x * (y + 1.0)) / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1.0d0)) .or. (.not. (z <= 1.0d0))) then
tmp = (y / (z / x)) - x
else
tmp = (x * (y + 1.0d0)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = (y / (z / x)) - x;
} else {
tmp = (x * (y + 1.0)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = (y / (z / x)) - x else: tmp = (x * (y + 1.0)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(Float64(y / Float64(z / x)) - x); else tmp = Float64(Float64(x * Float64(y + 1.0)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = (y / (z / x)) - x; else tmp = (x * (y + 1.0)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], N[(N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;\frac{y}{\frac{z}{x}} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 67.7%
Simplified91.2%
Taylor expanded in y around inf 90.9%
associate-/l*95.6%
Simplified95.6%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 99.8%
Final simplification97.8%
(FPCore (x y z) :precision binary64 (if (<= z -1.0) (- x) (if (<= z 1.0) (/ x z) (- x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 1.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= (-1.0d0)) then
tmp = -x
else if (z <= 1.0d0) then
tmp = x / z
else
tmp = -x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.0) {
tmp = -x;
} else if (z <= 1.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.0: tmp = -x elif z <= 1.0: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.0) tmp = Float64(-x); elseif (z <= 1.0) tmp = Float64(x / z); else tmp = Float64(-x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.0) tmp = -x; elseif (z <= 1.0) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.0], (-x), If[LessEqual[z, 1.0], N[(x / z), $MachinePrecision], (-x)]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 67.7%
Simplified91.2%
Taylor expanded in z around inf 81.5%
neg-mul-181.5%
Simplified81.5%
if -1 < z < 1Initial program 99.9%
Taylor expanded in z around 0 99.8%
Taylor expanded in y around 0 58.2%
Final simplification69.0%
(FPCore (x y z) :precision binary64 (- x))
double code(double x, double y, double z) {
return -x;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -x
end function
public static double code(double x, double y, double z) {
return -x;
}
def code(x, y, z): return -x
function code(x, y, z) return Float64(-x) end
function tmp = code(x, y, z) tmp = -x; end
code[x_, y_, z_] := (-x)
\begin{array}{l}
\\
-x
\end{array}
Initial program 84.9%
Simplified95.8%
Taylor expanded in z around inf 39.6%
neg-mul-139.6%
Simplified39.6%
Final simplification39.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- (* (+ 1.0 y) (/ x z)) x)))
(if (< x -2.71483106713436e-162)
t_0
(if (< x 3.874108816439546e-197)
(* (* x (+ (- y z) 1.0)) (/ 1.0 z))
t_0))))
double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = ((1.0d0 + y) * (x / z)) - x
if (x < (-2.71483106713436d-162)) then
tmp = t_0
else if (x < 3.874108816439546d-197) then
tmp = (x * ((y - z) + 1.0d0)) * (1.0d0 / z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = ((1.0 + y) * (x / z)) - x;
double tmp;
if (x < -2.71483106713436e-162) {
tmp = t_0;
} else if (x < 3.874108816439546e-197) {
tmp = (x * ((y - z) + 1.0)) * (1.0 / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = ((1.0 + y) * (x / z)) - x tmp = 0 if x < -2.71483106713436e-162: tmp = t_0 elif x < 3.874108816439546e-197: tmp = (x * ((y - z) + 1.0)) * (1.0 / z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(Float64(1.0 + y) * Float64(x / z)) - x) tmp = 0.0 if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = Float64(Float64(x * Float64(Float64(y - z) + 1.0)) * Float64(1.0 / z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = ((1.0 + y) * (x / z)) - x; tmp = 0.0; if (x < -2.71483106713436e-162) tmp = t_0; elseif (x < 3.874108816439546e-197) tmp = (x * ((y - z) + 1.0)) * (1.0 / z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(N[(1.0 + y), $MachinePrecision] * N[(x / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]}, If[Less[x, -2.71483106713436e-162], t$95$0, If[Less[x, 3.874108816439546e-197], N[(N[(x * N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 + y\right) \cdot \frac{x}{z} - x\\
\mathbf{if}\;x < -2.71483106713436 \cdot 10^{-162}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x < 3.874108816439546 \cdot 10^{-197}:\\
\;\;\;\;\left(x \cdot \left(\left(y - z\right) + 1\right)\right) \cdot \frac{1}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
herbie shell --seed 2023208
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:herbie-target
(if (< x -2.71483106713436e-162) (- (* (+ 1.0 y) (/ x z)) x) (if (< x 3.874108816439546e-197) (* (* x (+ (- y z) 1.0)) (/ 1.0 z)) (- (* (+ 1.0 y) (/ x z)) x)))
(/ (* x (+ (- y z) 1.0)) z))