
(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 10 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 (let* ((t_0 (+ (- y z) 1.0))) (if (or (<= z -2e+36) (not (<= z 1e-18))) (* x (/ t_0 z)) (* t_0 (/ x z)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if ((z <= -2e+36) || !(z <= 1e-18)) {
tmp = x * (t_0 / z);
} else {
tmp = t_0 * (x / 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) :: t_0
real(8) :: tmp
t_0 = (y - z) + 1.0d0
if ((z <= (-2d+36)) .or. (.not. (z <= 1d-18))) then
tmp = x * (t_0 / z)
else
tmp = t_0 * (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if ((z <= -2e+36) || !(z <= 1e-18)) {
tmp = x * (t_0 / z);
} else {
tmp = t_0 * (x / z);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if (z <= -2e+36) or not (z <= 1e-18): tmp = x * (t_0 / z) else: tmp = t_0 * (x / z) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if ((z <= -2e+36) || !(z <= 1e-18)) tmp = Float64(x * Float64(t_0 / z)); else tmp = Float64(t_0 * Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if ((z <= -2e+36) || ~((z <= 1e-18))) tmp = x * (t_0 / z); else tmp = t_0 * (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[Or[LessEqual[z, -2e+36], N[Not[LessEqual[z, 1e-18]], $MachinePrecision]], N[(x * N[(t$95$0 / z), $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(x / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;z \leq -2 \cdot 10^{+36} \lor \neg \left(z \leq 10^{-18}\right):\\
\;\;\;\;x \cdot \frac{t\_0}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \frac{x}{z}\\
\end{array}
\end{array}
if z < -2.00000000000000008e36 or 1.0000000000000001e-18 < z Initial program 75.6%
associate-/l*99.9%
Simplified99.9%
if -2.00000000000000008e36 < z < 1.0000000000000001e-18Initial program 99.9%
associate-/l*92.8%
Simplified92.8%
Taylor expanded in x around 0 99.9%
associate--l+99.9%
+-commutative99.9%
associate-*l/99.9%
+-commutative99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.15e-16) (not (<= z 9.5e-19))) (* x (/ (+ (- y z) 1.0) z)) (/ (* x (+ y 1.0)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.15e-16) || !(z <= 9.5e-19)) {
tmp = x * (((y - z) + 1.0) / z);
} 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.15d-16)) .or. (.not. (z <= 9.5d-19))) then
tmp = x * (((y - z) + 1.0d0) / z)
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.15e-16) || !(z <= 9.5e-19)) {
tmp = x * (((y - z) + 1.0) / z);
} else {
tmp = (x * (y + 1.0)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.15e-16) or not (z <= 9.5e-19): tmp = x * (((y - z) + 1.0) / z) else: tmp = (x * (y + 1.0)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.15e-16) || !(z <= 9.5e-19)) tmp = Float64(x * Float64(Float64(Float64(y - z) + 1.0) / z)); 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.15e-16) || ~((z <= 9.5e-19))) tmp = x * (((y - z) + 1.0) / z); else tmp = (x * (y + 1.0)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.15e-16], N[Not[LessEqual[z, 9.5e-19]], $MachinePrecision]], N[(x * N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.15 \cdot 10^{-16} \lor \neg \left(z \leq 9.5 \cdot 10^{-19}\right):\\
\;\;\;\;x \cdot \frac{\left(y - z\right) + 1}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\end{array}
\end{array}
if z < -1.15e-16 or 9.4999999999999995e-19 < z Initial program 77.9%
associate-/l*99.9%
Simplified99.9%
if -1.15e-16 < z < 9.4999999999999995e-19Initial program 99.9%
associate-/l*91.9%
Simplified91.9%
Taylor expanded in z around 0 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= z -1.35e+50) (- x) (if (<= z 1.06e-240) (* y (/ x z)) (if (<= z 1.0) (/ x z) (- x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.35e+50) {
tmp = -x;
} else if (z <= 1.06e-240) {
tmp = y * (x / z);
} 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.35d+50)) then
tmp = -x
else if (z <= 1.06d-240) then
tmp = y * (x / z)
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.35e+50) {
tmp = -x;
} else if (z <= 1.06e-240) {
tmp = y * (x / z);
} else if (z <= 1.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.35e+50: tmp = -x elif z <= 1.06e-240: tmp = y * (x / z) elif z <= 1.0: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.35e+50) tmp = Float64(-x); elseif (z <= 1.06e-240) tmp = Float64(y * Float64(x / z)); 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.35e+50) tmp = -x; elseif (z <= 1.06e-240) tmp = y * (x / z); elseif (z <= 1.0) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.35e+50], (-x), If[LessEqual[z, 1.06e-240], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], N[(x / z), $MachinePrecision], (-x)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+50}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1.06 \cdot 10^{-240}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.35e50 or 1 < z Initial program 74.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 82.7%
neg-mul-182.7%
Simplified82.7%
if -1.35e50 < z < 1.06e-240Initial program 99.9%
associate-/l*93.5%
Simplified93.5%
Taylor expanded in y around inf 58.1%
*-commutative58.1%
associate-/l*64.3%
Applied egg-rr64.3%
if 1.06e-240 < z < 1Initial program 99.9%
associate-/l*92.0%
Simplified92.0%
Taylor expanded in y around 0 70.0%
associate-/l*69.8%
Simplified69.8%
Taylor expanded in z around 0 69.5%
(FPCore (x y z) :precision binary64 (if (<= z -1.48e+50) (- x) (if (<= z -2.2e-125) (* x (/ y z)) (if (<= z 1.0) (/ x z) (- x)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.48e+50) {
tmp = -x;
} else if (z <= -2.2e-125) {
tmp = x * (y / z);
} 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.48d+50)) then
tmp = -x
else if (z <= (-2.2d-125)) then
tmp = x * (y / z)
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.48e+50) {
tmp = -x;
} else if (z <= -2.2e-125) {
tmp = x * (y / z);
} else if (z <= 1.0) {
tmp = x / z;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.48e+50: tmp = -x elif z <= -2.2e-125: tmp = x * (y / z) elif z <= 1.0: tmp = x / z else: tmp = -x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.48e+50) tmp = Float64(-x); elseif (z <= -2.2e-125) tmp = Float64(x * Float64(y / z)); 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.48e+50) tmp = -x; elseif (z <= -2.2e-125) tmp = x * (y / z); elseif (z <= 1.0) tmp = x / z; else tmp = -x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.48e+50], (-x), If[LessEqual[z, -2.2e-125], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.0], N[(x / z), $MachinePrecision], (-x)]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.48 \cdot 10^{+50}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -2.2 \cdot 10^{-125}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq 1:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -1.48000000000000007e50 or 1 < z Initial program 74.9%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 82.7%
neg-mul-182.7%
Simplified82.7%
if -1.48000000000000007e50 < z < -2.19999999999999995e-125Initial program 99.8%
associate-/l*97.7%
Simplified97.7%
Taylor expanded in y around inf 58.7%
associate-/l*56.7%
Simplified56.7%
if -2.19999999999999995e-125 < z < 1Initial program 99.9%
associate-/l*90.3%
Simplified90.3%
Taylor expanded in y around 0 64.4%
associate-/l*64.3%
Simplified64.3%
Taylor expanded in z around 0 64.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.85e+50) (not (<= z 1.55e+40))) (- x) (/ (* x (+ y 1.0)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.85e+50) || !(z <= 1.55e+40)) {
tmp = -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.85d+50)) .or. (.not. (z <= 1.55d+40))) then
tmp = -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.85e+50) || !(z <= 1.55e+40)) {
tmp = -x;
} else {
tmp = (x * (y + 1.0)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.85e+50) or not (z <= 1.55e+40): tmp = -x else: tmp = (x * (y + 1.0)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.85e+50) || !(z <= 1.55e+40)) tmp = Float64(-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.85e+50) || ~((z <= 1.55e+40))) tmp = -x; else tmp = (x * (y + 1.0)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.85e+50], N[Not[LessEqual[z, 1.55e+40]], $MachinePrecision]], (-x), N[(N[(x * N[(y + 1.0), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.85 \cdot 10^{+50} \lor \neg \left(z \leq 1.55 \cdot 10^{+40}\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(y + 1\right)}{z}\\
\end{array}
\end{array}
if z < -1.85e50 or 1.5499999999999999e40 < z Initial program 74.2%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 84.4%
neg-mul-184.4%
Simplified84.4%
if -1.85e50 < z < 1.5499999999999999e40Initial program 99.9%
associate-/l*93.3%
Simplified93.3%
Taylor expanded in z around 0 94.5%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -8.4e+39) (not (<= y 3.9e+34))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8.4e+39) || !(y <= 3.9e+34)) {
tmp = y * (x / z);
} 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 <= (-8.4d+39)) .or. (.not. (y <= 3.9d+34))) then
tmp = y * (x / z)
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 <= -8.4e+39) || !(y <= 3.9e+34)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8.4e+39) or not (y <= 3.9e+34): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8.4e+39) || !(y <= 3.9e+34)) tmp = Float64(y * Float64(x / z)); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -8.4e+39) || ~((y <= 3.9e+34))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.4e+39], N[Not[LessEqual[y, 3.9e+34]], $MachinePrecision]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.4 \cdot 10^{+39} \lor \neg \left(y \leq 3.9 \cdot 10^{+34}\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -8.3999999999999994e39 or 3.90000000000000019e34 < y Initial program 89.8%
associate-/l*92.4%
Simplified92.4%
Taylor expanded in y around inf 73.5%
*-commutative73.5%
associate-/l*75.9%
Applied egg-rr75.9%
if -8.3999999999999994e39 < y < 3.90000000000000019e34Initial program 85.4%
associate-*r/99.3%
*-commutative99.3%
add-cube-cbrt98.7%
associate-*l*98.7%
pow298.7%
Applied egg-rr98.7%
Taylor expanded in y around 0 81.3%
associate-/l*95.8%
div-sub95.8%
sub-neg95.8%
*-inverses95.8%
metadata-eval95.8%
distribute-rgt-in95.8%
associate-*l/95.9%
*-lft-identity95.9%
mul-1-neg95.9%
unsub-neg95.9%
Simplified95.9%
Final simplification88.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (- y z) 1.0))) (if (<= x 1.22e-20) (/ (* x t_0) z) (* x (/ t_0 z)))))
double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (x <= 1.22e-20) {
tmp = (x * t_0) / z;
} else {
tmp = x * (t_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) :: t_0
real(8) :: tmp
t_0 = (y - z) + 1.0d0
if (x <= 1.22d-20) then
tmp = (x * t_0) / z
else
tmp = x * (t_0 / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y - z) + 1.0;
double tmp;
if (x <= 1.22e-20) {
tmp = (x * t_0) / z;
} else {
tmp = x * (t_0 / z);
}
return tmp;
}
def code(x, y, z): t_0 = (y - z) + 1.0 tmp = 0 if x <= 1.22e-20: tmp = (x * t_0) / z else: tmp = x * (t_0 / z) return tmp
function code(x, y, z) t_0 = Float64(Float64(y - z) + 1.0) tmp = 0.0 if (x <= 1.22e-20) tmp = Float64(Float64(x * t_0) / z); else tmp = Float64(x * Float64(t_0 / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y - z) + 1.0; tmp = 0.0; if (x <= 1.22e-20) tmp = (x * t_0) / z; else tmp = x * (t_0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision]}, If[LessEqual[x, 1.22e-20], N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], N[(x * N[(t$95$0 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(y - z\right) + 1\\
\mathbf{if}\;x \leq 1.22 \cdot 10^{-20}:\\
\;\;\;\;\frac{x \cdot t\_0}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{t\_0}{z}\\
\end{array}
\end{array}
if x < 1.22000000000000003e-20Initial program 90.2%
if 1.22000000000000003e-20 < x Initial program 74.8%
associate-/l*99.8%
Simplified99.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.0) (not (<= z 1.0))) (- x) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.0) || !(z <= 1.0)) {
tmp = -x;
} else {
tmp = x / 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 = -x
else
tmp = x / 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 = -x;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.0) or not (z <= 1.0): tmp = -x else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.0) || !(z <= 1.0)) tmp = Float64(-x); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.0) || ~((z <= 1.0))) tmp = -x; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.0], N[Not[LessEqual[z, 1.0]], $MachinePrecision]], (-x), N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\
\;\;\;\;-x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if z < -1 or 1 < z Initial program 77.0%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around inf 79.3%
neg-mul-179.3%
Simplified79.3%
if -1 < z < 1Initial program 99.9%
associate-/l*92.3%
Simplified92.3%
Taylor expanded in y around 0 59.7%
associate-/l*59.6%
Simplified59.6%
Taylor expanded in z around 0 59.4%
Final simplification70.5%
(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 87.1%
associate-/l*96.6%
Simplified96.6%
Taylor expanded in z around inf 45.9%
neg-mul-145.9%
Simplified45.9%
(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 x end
function tmp = code(x, y, z) tmp = x; end
code[x_, y_, z_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 87.1%
associate-/l*96.6%
Simplified96.6%
Taylor expanded in z around inf 45.9%
neg-mul-145.9%
Simplified45.9%
neg-sub045.9%
sub-neg45.9%
add-sqr-sqrt24.9%
sqrt-unprod21.2%
sqr-neg21.2%
sqrt-unprod1.2%
add-sqr-sqrt2.7%
Applied egg-rr2.7%
Taylor expanded in x around 0 2.7%
(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 2024163
(FPCore (x y z)
:name "Diagrams.TwoD.Segment.Bernstein:evaluateBernstein from diagrams-lib-1.3.0.3"
:precision binary64
:alt
(! :herbie-platform default (if (< x -67870776678359/25000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- (* (+ 1 y) (/ x z)) x) (if (< x 1937054408219773/50000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (* (* x (+ (- y z) 1)) (/ 1 z)) (- (* (+ 1 y) (/ x z)) x))))
(/ (* x (+ (- y z) 1.0)) z))