
(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 -1e+35) (not (<= z 5e+30))) (- (* x (/ y z)) x) (* (/ x z) (+ 1.0 (- y z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e+35) || !(z <= 5e+30)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) * (1.0 + (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 ((z <= (-1d+35)) .or. (.not. (z <= 5d+30))) then
tmp = (x * (y / z)) - x
else
tmp = (x / z) * (1.0d0 + (y - z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1e+35) || !(z <= 5e+30)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) * (1.0 + (y - z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e+35) or not (z <= 5e+30): tmp = (x * (y / z)) - x else: tmp = (x / z) * (1.0 + (y - z)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e+35) || !(z <= 5e+30)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(x / z) * Float64(1.0 + Float64(y - z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1e+35) || ~((z <= 5e+30))) tmp = (x * (y / z)) - x; else tmp = (x / z) * (1.0 + (y - z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e+35], N[Not[LessEqual[z, 5e+30]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] * N[(1.0 + N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+35} \lor \neg \left(z \leq 5 \cdot 10^{+30}\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} \cdot \left(1 + \left(y - z\right)\right)\\
\end{array}
\end{array}
if z < -9.9999999999999997e34 or 4.9999999999999998e30 < z Initial program 75.3%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around 0 88.8%
neg-mul-188.8%
+-commutative88.8%
unsub-neg88.8%
associate-/l*93.0%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in y around inf 99.9%
if -9.9999999999999997e34 < z < 4.9999999999999998e30Initial program 99.9%
associate-/l*96.7%
Simplified96.7%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -8.2e+32)
(- x)
(if (<= z -3.2e-66)
t_0
(if (<= z -4.5e-260)
(/ x z)
(if (<= z 1.2e-180)
t_0
(if (<= z 9e-17)
(/ x z)
(if (<= z 8.5e+37)
t_0
(if (<= z 1.66e+74)
(- x)
(if (<= z 5e+141) (* x (/ y z)) (- x)))))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -8.2e+32) {
tmp = -x;
} else if (z <= -3.2e-66) {
tmp = t_0;
} else if (z <= -4.5e-260) {
tmp = x / z;
} else if (z <= 1.2e-180) {
tmp = t_0;
} else if (z <= 9e-17) {
tmp = x / z;
} else if (z <= 8.5e+37) {
tmp = t_0;
} else if (z <= 1.66e+74) {
tmp = -x;
} else if (z <= 5e+141) {
tmp = x * (y / 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) :: t_0
real(8) :: tmp
t_0 = y * (x / z)
if (z <= (-8.2d+32)) then
tmp = -x
else if (z <= (-3.2d-66)) then
tmp = t_0
else if (z <= (-4.5d-260)) then
tmp = x / z
else if (z <= 1.2d-180) then
tmp = t_0
else if (z <= 9d-17) then
tmp = x / z
else if (z <= 8.5d+37) then
tmp = t_0
else if (z <= 1.66d+74) then
tmp = -x
else if (z <= 5d+141) then
tmp = x * (y / z)
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 <= -8.2e+32) {
tmp = -x;
} else if (z <= -3.2e-66) {
tmp = t_0;
} else if (z <= -4.5e-260) {
tmp = x / z;
} else if (z <= 1.2e-180) {
tmp = t_0;
} else if (z <= 9e-17) {
tmp = x / z;
} else if (z <= 8.5e+37) {
tmp = t_0;
} else if (z <= 1.66e+74) {
tmp = -x;
} else if (z <= 5e+141) {
tmp = x * (y / z);
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -8.2e+32: tmp = -x elif z <= -3.2e-66: tmp = t_0 elif z <= -4.5e-260: tmp = x / z elif z <= 1.2e-180: tmp = t_0 elif z <= 9e-17: tmp = x / z elif z <= 8.5e+37: tmp = t_0 elif z <= 1.66e+74: tmp = -x elif z <= 5e+141: tmp = x * (y / z) else: tmp = -x return tmp
function code(x, y, z) t_0 = Float64(y * Float64(x / z)) tmp = 0.0 if (z <= -8.2e+32) tmp = Float64(-x); elseif (z <= -3.2e-66) tmp = t_0; elseif (z <= -4.5e-260) tmp = Float64(x / z); elseif (z <= 1.2e-180) tmp = t_0; elseif (z <= 9e-17) tmp = Float64(x / z); elseif (z <= 8.5e+37) tmp = t_0; elseif (z <= 1.66e+74) tmp = Float64(-x); elseif (z <= 5e+141) tmp = Float64(x * Float64(y / z)); 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 <= -8.2e+32) tmp = -x; elseif (z <= -3.2e-66) tmp = t_0; elseif (z <= -4.5e-260) tmp = x / z; elseif (z <= 1.2e-180) tmp = t_0; elseif (z <= 9e-17) tmp = x / z; elseif (z <= 8.5e+37) tmp = t_0; elseif (z <= 1.66e+74) tmp = -x; elseif (z <= 5e+141) tmp = x * (y / z); 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, -8.2e+32], (-x), If[LessEqual[z, -3.2e-66], t$95$0, If[LessEqual[z, -4.5e-260], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.2e-180], t$95$0, If[LessEqual[z, 9e-17], N[(x / z), $MachinePrecision], If[LessEqual[z, 8.5e+37], t$95$0, If[LessEqual[z, 1.66e+74], (-x), If[LessEqual[z, 5e+141], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], (-x)]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -8.2 \cdot 10^{+32}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -3.2 \cdot 10^{-66}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -4.5 \cdot 10^{-260}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 1.2 \cdot 10^{-180}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 9 \cdot 10^{-17}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{+37}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.66 \cdot 10^{+74}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 5 \cdot 10^{+141}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -8.19999999999999961e32 or 8.4999999999999999e37 < z < 1.66000000000000001e74 or 5.00000000000000025e141 < z Initial program 72.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around inf 76.1%
neg-mul-176.1%
Simplified76.1%
if -8.19999999999999961e32 < z < -3.19999999999999982e-66 or -4.4999999999999997e-260 < z < 1.1999999999999999e-180 or 8.99999999999999957e-17 < z < 8.4999999999999999e37Initial program 99.8%
associate-/l*95.1%
Simplified95.1%
Taylor expanded in y around inf 66.9%
*-commutative66.9%
associate-/l*62.2%
Simplified62.2%
associate-/r/73.4%
Applied egg-rr73.4%
if -3.19999999999999982e-66 < z < -4.4999999999999997e-260 or 1.1999999999999999e-180 < z < 8.99999999999999957e-17Initial program 99.9%
associate-/l*98.4%
Simplified98.4%
Taylor expanded in y around 0 72.3%
Taylor expanded in z around 0 72.3%
if 1.66000000000000001e74 < z < 5.00000000000000025e141Initial program 92.0%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around inf 76.0%
associate-/l*44.1%
associate-/r/76.0%
Simplified76.0%
Final simplification74.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -5.2e+32)
(- x)
(if (<= z -3.1e-62)
t_0
(if (<= z -1.6e-259)
(/ x z)
(if (<= z 1e-181)
t_0
(if (<= z 3.5e-16) (/ x z) (if (<= z 1.65e+38) t_0 (- x)))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -5.2e+32) {
tmp = -x;
} else if (z <= -3.1e-62) {
tmp = t_0;
} else if (z <= -1.6e-259) {
tmp = x / z;
} else if (z <= 1e-181) {
tmp = t_0;
} else if (z <= 3.5e-16) {
tmp = x / z;
} else if (z <= 1.65e+38) {
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 <= (-5.2d+32)) then
tmp = -x
else if (z <= (-3.1d-62)) then
tmp = t_0
else if (z <= (-1.6d-259)) then
tmp = x / z
else if (z <= 1d-181) then
tmp = t_0
else if (z <= 3.5d-16) then
tmp = x / z
else if (z <= 1.65d+38) 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 <= -5.2e+32) {
tmp = -x;
} else if (z <= -3.1e-62) {
tmp = t_0;
} else if (z <= -1.6e-259) {
tmp = x / z;
} else if (z <= 1e-181) {
tmp = t_0;
} else if (z <= 3.5e-16) {
tmp = x / z;
} else if (z <= 1.65e+38) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -5.2e+32: tmp = -x elif z <= -3.1e-62: tmp = t_0 elif z <= -1.6e-259: tmp = x / z elif z <= 1e-181: tmp = t_0 elif z <= 3.5e-16: tmp = x / z elif z <= 1.65e+38: 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 <= -5.2e+32) tmp = Float64(-x); elseif (z <= -3.1e-62) tmp = t_0; elseif (z <= -1.6e-259) tmp = Float64(x / z); elseif (z <= 1e-181) tmp = t_0; elseif (z <= 3.5e-16) tmp = Float64(x / z); elseif (z <= 1.65e+38) 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 <= -5.2e+32) tmp = -x; elseif (z <= -3.1e-62) tmp = t_0; elseif (z <= -1.6e-259) tmp = x / z; elseif (z <= 1e-181) tmp = t_0; elseif (z <= 3.5e-16) tmp = x / z; elseif (z <= 1.65e+38) 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, -5.2e+32], (-x), If[LessEqual[z, -3.1e-62], t$95$0, If[LessEqual[z, -1.6e-259], N[(x / z), $MachinePrecision], If[LessEqual[z, 1e-181], t$95$0, If[LessEqual[z, 3.5e-16], N[(x / z), $MachinePrecision], If[LessEqual[z, 1.65e+38], t$95$0, (-x)]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -5.2 \cdot 10^{+32}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -3.1 \cdot 10^{-62}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.6 \cdot 10^{-259}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 10^{-181}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-16}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{+38}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -5.2000000000000004e32 or 1.65e38 < z Initial program 74.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around inf 71.1%
neg-mul-171.1%
Simplified71.1%
if -5.2000000000000004e32 < z < -3.0999999999999999e-62 or -1.59999999999999994e-259 < z < 1.00000000000000005e-181 or 3.50000000000000017e-16 < z < 1.65e38Initial program 99.8%
associate-/l*95.1%
Simplified95.1%
Taylor expanded in y around inf 66.9%
*-commutative66.9%
associate-/l*62.2%
Simplified62.2%
associate-/r/73.4%
Applied egg-rr73.4%
if -3.0999999999999999e-62 < z < -1.59999999999999994e-259 or 1.00000000000000005e-181 < z < 3.50000000000000017e-16Initial program 99.9%
associate-/l*98.4%
Simplified98.4%
Taylor expanded in y around 0 72.3%
Taylor expanded in z around 0 72.3%
Final simplification72.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.0) (not (<= y 2.5e-43))) (- (* x (/ y z)) x) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.0) || !(y <= 2.5e-43)) {
tmp = (x * (y / z)) - 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 <= (-1.0d0)) .or. (.not. (y <= 2.5d-43))) then
tmp = (x * (y / z)) - 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 <= -1.0) || !(y <= 2.5e-43)) {
tmp = (x * (y / z)) - x;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.0) or not (y <= 2.5e-43): tmp = (x * (y / z)) - x else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.0) || !(y <= 2.5e-43)) tmp = Float64(Float64(x * Float64(y / z)) - x); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.0) || ~((y <= 2.5e-43))) tmp = (x * (y / z)) - x; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.0], N[Not[LessEqual[y, 2.5e-43]], $MachinePrecision]], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 2.5 \cdot 10^{-43}\right):\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1 or 2.50000000000000009e-43 < y Initial program 86.8%
associate-/l*96.6%
Simplified96.6%
Taylor expanded in z around 0 90.2%
neg-mul-190.2%
+-commutative90.2%
unsub-neg90.2%
associate-/l*93.9%
associate-/r/96.4%
Simplified96.4%
Taylor expanded in y around inf 94.2%
if -1 < y < 2.50000000000000009e-43Initial program 90.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around 0 100.0%
neg-mul-1100.0%
+-commutative100.0%
unsub-neg100.0%
associate-/l*99.8%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in y around 0 99.1%
Final simplification96.4%
(FPCore (x y z) :precision binary64 (if (<= y -1.0) (- (/ x (/ z y)) x) (if (<= y 2.5e-43) (- (/ x z) x) (- (* x (/ y z)) x))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = (x / (z / y)) - x;
} else if (y <= 2.5e-43) {
tmp = (x / z) - x;
} else {
tmp = (x * (y / 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 <= (-1.0d0)) then
tmp = (x / (z / y)) - x
else if (y <= 2.5d-43) then
tmp = (x / z) - x
else
tmp = (x * (y / z)) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.0) {
tmp = (x / (z / y)) - x;
} else if (y <= 2.5e-43) {
tmp = (x / z) - x;
} else {
tmp = (x * (y / z)) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.0: tmp = (x / (z / y)) - x elif y <= 2.5e-43: tmp = (x / z) - x else: tmp = (x * (y / z)) - x return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.0) tmp = Float64(Float64(x / Float64(z / y)) - x); elseif (y <= 2.5e-43) tmp = Float64(Float64(x / z) - x); else tmp = Float64(Float64(x * Float64(y / z)) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.0) tmp = (x / (z / y)) - x; elseif (y <= 2.5e-43) tmp = (x / z) - x; else tmp = (x * (y / z)) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.0], N[(N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[y, 2.5e-43], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1:\\
\;\;\;\;\frac{x}{\frac{z}{y}} - x\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-43}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\end{array}
\end{array}
if y < -1Initial program 86.9%
associate-/l*97.3%
Simplified97.3%
Taylor expanded in z around 0 88.4%
neg-mul-188.4%
+-commutative88.4%
unsub-neg88.4%
associate-/l*95.5%
associate-/r/96.9%
Simplified96.9%
*-commutative96.9%
clear-num96.8%
un-div-inv97.3%
Applied egg-rr97.3%
Taylor expanded in y around inf 94.4%
if -1 < y < 2.50000000000000009e-43Initial program 90.4%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around 0 100.0%
neg-mul-1100.0%
+-commutative100.0%
unsub-neg100.0%
associate-/l*99.8%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in y around 0 99.1%
if 2.50000000000000009e-43 < y Initial program 86.6%
associate-/l*95.9%
Simplified95.9%
Taylor expanded in z around 0 91.9%
neg-mul-191.9%
+-commutative91.9%
unsub-neg91.9%
associate-/l*92.4%
associate-/r/95.9%
Simplified95.9%
Taylor expanded in y around inf 94.4%
Final simplification96.6%
(FPCore (x y z) :precision binary64 (if (<= z -1.1) (- (* x (/ y z)) x) (if (<= z 5.2e-16) (/ (+ x (* x y)) z) (- (/ x (/ z y)) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.1) {
tmp = (x * (y / z)) - x;
} else if (z <= 5.2e-16) {
tmp = (x + (x * y)) / z;
} else {
tmp = (x / (z / y)) - 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.1d0)) then
tmp = (x * (y / z)) - x
else if (z <= 5.2d-16) then
tmp = (x + (x * y)) / z
else
tmp = (x / (z / y)) - x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1.1) {
tmp = (x * (y / z)) - x;
} else if (z <= 5.2e-16) {
tmp = (x + (x * y)) / z;
} else {
tmp = (x / (z / y)) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.1: tmp = (x * (y / z)) - x elif z <= 5.2e-16: tmp = (x + (x * y)) / z else: tmp = (x / (z / y)) - x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.1) tmp = Float64(Float64(x * Float64(y / z)) - x); elseif (z <= 5.2e-16) tmp = Float64(Float64(x + Float64(x * y)) / z); else tmp = Float64(Float64(x / Float64(z / y)) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.1) tmp = (x * (y / z)) - x; elseif (z <= 5.2e-16) tmp = (x + (x * y)) / z; else tmp = (x / (z / y)) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.1], N[(N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision], If[LessEqual[z, 5.2e-16], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.1:\\
\;\;\;\;x \cdot \frac{y}{z} - x\\
\mathbf{elif}\;z \leq 5.2 \cdot 10^{-16}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y}} - x\\
\end{array}
\end{array}
if z < -1.1000000000000001Initial program 79.5%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around 0 87.3%
neg-mul-187.3%
+-commutative87.3%
unsub-neg87.3%
associate-/l*96.2%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in y around inf 98.8%
if -1.1000000000000001 < z < 5.1999999999999997e-16Initial program 99.9%
associate-/l*96.3%
Simplified96.3%
Taylor expanded in z around 0 99.5%
*-commutative99.5%
distribute-lft-in99.5%
*-rgt-identity99.5%
Simplified99.5%
if 5.1999999999999997e-16 < z Initial program 76.5%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around 0 92.1%
neg-mul-192.1%
+-commutative92.1%
unsub-neg92.1%
associate-/l*91.6%
associate-/r/99.9%
Simplified99.9%
*-commutative99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in y around inf 98.9%
Final simplification99.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -320.0) (not (<= y 4.7e+39))) (* x (/ y z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -320.0) || !(y <= 4.7e+39)) {
tmp = x * (y / 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 <= (-320.0d0)) .or. (.not. (y <= 4.7d+39))) then
tmp = x * (y / 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 <= -320.0) || !(y <= 4.7e+39)) {
tmp = x * (y / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -320.0) or not (y <= 4.7e+39): tmp = x * (y / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -320.0) || !(y <= 4.7e+39)) tmp = Float64(x * Float64(y / z)); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -320.0) || ~((y <= 4.7e+39))) tmp = x * (y / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -320.0], N[Not[LessEqual[y, 4.7e+39]], $MachinePrecision]], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -320 \lor \neg \left(y \leq 4.7 \cdot 10^{+39}\right):\\
\;\;\;\;x \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -320 or 4.6999999999999999e39 < y Initial program 87.6%
associate-/l*96.2%
Simplified96.2%
Taylor expanded in y around inf 71.4%
associate-/l*72.7%
associate-/r/74.8%
Simplified74.8%
if -320 < y < 4.6999999999999999e39Initial program 89.3%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around 0 99.3%
neg-mul-199.3%
+-commutative99.3%
unsub-neg99.3%
associate-/l*99.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in y around 0 97.1%
Final simplification86.3%
(FPCore (x y z) :precision binary64 (if (<= y -310.0) (/ x (/ z y)) (if (<= y 3.6e+39) (- (/ x z) x) (* x (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -310.0) {
tmp = x / (z / y);
} else if (y <= 3.6e+39) {
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 <= (-310.0d0)) then
tmp = x / (z / y)
else if (y <= 3.6d+39) 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 <= -310.0) {
tmp = x / (z / y);
} else if (y <= 3.6e+39) {
tmp = (x / z) - x;
} else {
tmp = x * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -310.0: tmp = x / (z / y) elif y <= 3.6e+39: tmp = (x / z) - x else: tmp = x * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -310.0) tmp = Float64(x / Float64(z / y)); elseif (y <= 3.6e+39) 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 <= -310.0) tmp = x / (z / y); elseif (y <= 3.6e+39) tmp = (x / z) - x; else tmp = x * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -310.0], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.6e+39], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -310:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{+39}:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -310Initial program 86.5%
associate-/l*97.2%
Simplified97.2%
Taylor expanded in y around inf 68.5%
*-commutative68.5%
associate-/l*74.7%
Simplified74.7%
if -310 < y < 3.59999999999999984e39Initial program 89.3%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around 0 99.3%
neg-mul-199.3%
+-commutative99.3%
unsub-neg99.3%
associate-/l*99.9%
associate-/r/99.9%
Simplified99.9%
Taylor expanded in y around 0 97.1%
if 3.59999999999999984e39 < y Initial program 88.7%
associate-/l*95.1%
Simplified95.1%
Taylor expanded in y around inf 74.4%
associate-/l*72.6%
associate-/r/75.4%
Simplified75.4%
Final simplification86.4%
(FPCore (x y z) :precision binary64 (- (/ x (/ z (+ 1.0 y))) x))
double code(double x, double y, double z) {
return (x / (z / (1.0 + y))) - 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 / (z / (1.0d0 + y))) - x
end function
public static double code(double x, double y, double z) {
return (x / (z / (1.0 + y))) - x;
}
def code(x, y, z): return (x / (z / (1.0 + y))) - x
function code(x, y, z) return Float64(Float64(x / Float64(z / Float64(1.0 + y))) - x) end
function tmp = code(x, y, z) tmp = (x / (z / (1.0 + y))) - x; end
code[x_, y_, z_] := N[(N[(x / N[(z / N[(1.0 + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{z}{1 + y}} - x
\end{array}
Initial program 88.4%
associate-/l*98.1%
Simplified98.1%
Taylor expanded in z around 0 94.7%
neg-mul-194.7%
+-commutative94.7%
unsub-neg94.7%
associate-/l*96.6%
associate-/r/98.0%
Simplified98.0%
*-commutative98.0%
clear-num97.9%
un-div-inv98.2%
Applied egg-rr98.2%
Final simplification98.2%
(FPCore (x y z) :precision binary64 (- (* x (/ (+ 1.0 y) z)) x))
double code(double x, double y, double z) {
return (x * ((1.0 + y) / z)) - 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 * ((1.0d0 + y) / z)) - x
end function
public static double code(double x, double y, double z) {
return (x * ((1.0 + y) / z)) - x;
}
def code(x, y, z): return (x * ((1.0 + y) / z)) - x
function code(x, y, z) return Float64(Float64(x * Float64(Float64(1.0 + y) / z)) - x) end
function tmp = code(x, y, z) tmp = (x * ((1.0 + y) / z)) - x; end
code[x_, y_, z_] := N[(N[(x * N[(N[(1.0 + y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{1 + y}{z} - x
\end{array}
Initial program 88.4%
associate-/l*98.1%
Simplified98.1%
Taylor expanded in z around 0 94.7%
neg-mul-194.7%
+-commutative94.7%
unsub-neg94.7%
associate-/l*96.6%
associate-/r/98.0%
Simplified98.0%
Final simplification98.0%
(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 77.2%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around inf 65.8%
neg-mul-165.8%
Simplified65.8%
if -1 < z < 1Initial program 99.9%
associate-/l*96.4%
Simplified96.4%
Taylor expanded in y around 0 57.8%
Taylor expanded in z around 0 57.5%
Final simplification61.7%
(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 88.4%
associate-/l*98.1%
Simplified98.1%
Taylor expanded in z around inf 34.7%
neg-mul-134.7%
Simplified34.7%
Final simplification34.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 2023258
(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))