
(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 9 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-5) (not (<= z 3e-44))) (* x (/ (+ (- y z) 1.0) z)) (/ (+ x (* x y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-5) || !(z <= 3e-44)) {
tmp = x * (((y - z) + 1.0) / z);
} else {
tmp = (x + (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 ((z <= (-1d-5)) .or. (.not. (z <= 3d-44))) then
tmp = x * (((y - z) + 1.0d0) / z)
else
tmp = (x + (x * y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1e-5) || !(z <= 3e-44)) {
tmp = x * (((y - z) + 1.0) / z);
} else {
tmp = (x + (x * y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e-5) or not (z <= 3e-44): tmp = x * (((y - z) + 1.0) / z) else: tmp = (x + (x * y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e-5) || !(z <= 3e-44)) tmp = Float64(x * Float64(Float64(Float64(y - z) + 1.0) / z)); else tmp = Float64(Float64(x + Float64(x * y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1e-5) || ~((z <= 3e-44))) tmp = x * (((y - z) + 1.0) / z); else tmp = (x + (x * y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e-5], N[Not[LessEqual[z, 3e-44]], $MachinePrecision]], N[(x * N[(N[(N[(y - z), $MachinePrecision] + 1.0), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-5} \lor \neg \left(z \leq 3 \cdot 10^{-44}\right):\\
\;\;\;\;x \cdot \frac{\left(y - z\right) + 1}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\end{array}
\end{array}
if z < -1.00000000000000008e-5 or 3.0000000000000002e-44 < z Initial program 77.1%
Taylor expanded in x around 0 77.1%
associate--l+77.1%
+-commutative77.1%
associate-*r/99.9%
+-commutative99.9%
Simplified99.9%
if -1.00000000000000008e-5 < z < 3.0000000000000002e-44Initial program 99.8%
distribute-lft-in99.8%
fma-def99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in z around 0 99.8%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* y (/ x z))))
(if (<= z -4.7e+16)
(- x)
(if (<= z -1.8e-70)
t_0
(if (<= z -1.6e-157)
(/ x z)
(if (<= z 4.5e-262)
t_0
(if (<= z 1.85e-165)
(/ x z)
(if (<= z 5.8e-46)
t_0
(if (<= z 0.0132) (/ x z) (if (<= z 4.8e+28) t_0 (- x)))))))))))
double code(double x, double y, double z) {
double t_0 = y * (x / z);
double tmp;
if (z <= -4.7e+16) {
tmp = -x;
} else if (z <= -1.8e-70) {
tmp = t_0;
} else if (z <= -1.6e-157) {
tmp = x / z;
} else if (z <= 4.5e-262) {
tmp = t_0;
} else if (z <= 1.85e-165) {
tmp = x / z;
} else if (z <= 5.8e-46) {
tmp = t_0;
} else if (z <= 0.0132) {
tmp = x / z;
} else if (z <= 4.8e+28) {
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 <= (-4.7d+16)) then
tmp = -x
else if (z <= (-1.8d-70)) then
tmp = t_0
else if (z <= (-1.6d-157)) then
tmp = x / z
else if (z <= 4.5d-262) then
tmp = t_0
else if (z <= 1.85d-165) then
tmp = x / z
else if (z <= 5.8d-46) then
tmp = t_0
else if (z <= 0.0132d0) then
tmp = x / z
else if (z <= 4.8d+28) 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 <= -4.7e+16) {
tmp = -x;
} else if (z <= -1.8e-70) {
tmp = t_0;
} else if (z <= -1.6e-157) {
tmp = x / z;
} else if (z <= 4.5e-262) {
tmp = t_0;
} else if (z <= 1.85e-165) {
tmp = x / z;
} else if (z <= 5.8e-46) {
tmp = t_0;
} else if (z <= 0.0132) {
tmp = x / z;
} else if (z <= 4.8e+28) {
tmp = t_0;
} else {
tmp = -x;
}
return tmp;
}
def code(x, y, z): t_0 = y * (x / z) tmp = 0 if z <= -4.7e+16: tmp = -x elif z <= -1.8e-70: tmp = t_0 elif z <= -1.6e-157: tmp = x / z elif z <= 4.5e-262: tmp = t_0 elif z <= 1.85e-165: tmp = x / z elif z <= 5.8e-46: tmp = t_0 elif z <= 0.0132: tmp = x / z elif z <= 4.8e+28: 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 <= -4.7e+16) tmp = Float64(-x); elseif (z <= -1.8e-70) tmp = t_0; elseif (z <= -1.6e-157) tmp = Float64(x / z); elseif (z <= 4.5e-262) tmp = t_0; elseif (z <= 1.85e-165) tmp = Float64(x / z); elseif (z <= 5.8e-46) tmp = t_0; elseif (z <= 0.0132) tmp = Float64(x / z); elseif (z <= 4.8e+28) 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 <= -4.7e+16) tmp = -x; elseif (z <= -1.8e-70) tmp = t_0; elseif (z <= -1.6e-157) tmp = x / z; elseif (z <= 4.5e-262) tmp = t_0; elseif (z <= 1.85e-165) tmp = x / z; elseif (z <= 5.8e-46) tmp = t_0; elseif (z <= 0.0132) tmp = x / z; elseif (z <= 4.8e+28) 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, -4.7e+16], (-x), If[LessEqual[z, -1.8e-70], t$95$0, If[LessEqual[z, -1.6e-157], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.5e-262], t$95$0, If[LessEqual[z, 1.85e-165], N[(x / z), $MachinePrecision], If[LessEqual[z, 5.8e-46], t$95$0, If[LessEqual[z, 0.0132], N[(x / z), $MachinePrecision], If[LessEqual[z, 4.8e+28], t$95$0, (-x)]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -4.7 \cdot 10^{+16}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq -1.8 \cdot 10^{-70}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.6 \cdot 10^{-157}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 4.5 \cdot 10^{-262}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.85 \cdot 10^{-165}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 5.8 \cdot 10^{-46}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 0.0132:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{+28}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-x\\
\end{array}
\end{array}
if z < -4.7e16 or 4.79999999999999962e28 < z Initial program 73.6%
Taylor expanded in z around inf 79.5%
neg-mul-179.5%
Simplified79.5%
if -4.7e16 < z < -1.8000000000000001e-70 or -1.6000000000000001e-157 < z < 4.49999999999999998e-262 or 1.85000000000000001e-165 < z < 5.80000000000000009e-46 or 0.0132 < z < 4.79999999999999962e28Initial program 99.8%
Taylor expanded in y around inf 68.4%
associate-/l*61.0%
associate-/r/72.9%
Simplified72.9%
if -1.8000000000000001e-70 < z < -1.6000000000000001e-157 or 4.49999999999999998e-262 < z < 1.85000000000000001e-165 or 5.80000000000000009e-46 < z < 0.0132Initial program 99.8%
distribute-lft-in99.8%
fma-def99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in z around 0 95.5%
Taylor expanded in y around 0 73.5%
Final simplification76.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (+ (- y z) 1.0))) (if (<= (/ (* x t_0) z) 1e-40) (* 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 (((x * t_0) / z) <= 1e-40) {
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 (((x * t_0) / z) <= 1d-40) 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 (((x * t_0) / z) <= 1e-40) {
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 ((x * t_0) / z) <= 1e-40: 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 (Float64(Float64(x * t_0) / z) <= 1e-40) 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 (((x * t_0) / z) <= 1e-40) 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[LessEqual[N[(N[(x * t$95$0), $MachinePrecision] / z), $MachinePrecision], 1e-40], 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}\;\frac{x \cdot t_0}{z} \leq 10^{-40}:\\
\;\;\;\;x \cdot \frac{t_0}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{x}{z}\\
\end{array}
\end{array}
if (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) < 9.9999999999999993e-41Initial program 89.6%
Taylor expanded in x around 0 89.6%
associate--l+89.6%
+-commutative89.6%
associate-*r/97.5%
+-commutative97.5%
Simplified97.5%
if 9.9999999999999993e-41 < (/.f64 (*.f64 x (+.f64 (-.f64 y z) 1)) z) Initial program 84.0%
associate-/l*93.2%
associate-/r/99.8%
Applied egg-rr99.8%
Final simplification98.4%
(FPCore (x y z) :precision binary64 (if (<= z -2.9e+17) (- x) (if (<= z 1.8e-43) (/ (+ x (* x y)) z) (- (/ x z) x))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.9e+17) {
tmp = -x;
} else if (z <= 1.8e-43) {
tmp = (x + (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 (z <= (-2.9d+17)) then
tmp = -x
else if (z <= 1.8d-43) then
tmp = (x + (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 (z <= -2.9e+17) {
tmp = -x;
} else if (z <= 1.8e-43) {
tmp = (x + (x * y)) / z;
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.9e+17: tmp = -x elif z <= 1.8e-43: tmp = (x + (x * y)) / z else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.9e+17) tmp = Float64(-x); elseif (z <= 1.8e-43) tmp = Float64(Float64(x + Float64(x * y)) / z); else tmp = Float64(Float64(x / z) - x); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.9e+17) tmp = -x; elseif (z <= 1.8e-43) tmp = (x + (x * y)) / z; else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.9e+17], (-x), If[LessEqual[z, 1.8e-43], N[(N[(x + N[(x * y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.9 \cdot 10^{+17}:\\
\;\;\;\;-x\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{-43}:\\
\;\;\;\;\frac{x + x \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if z < -2.9e17Initial program 72.0%
Taylor expanded in z around inf 83.7%
neg-mul-183.7%
Simplified83.7%
if -2.9e17 < z < 1.7999999999999999e-43Initial program 99.8%
distribute-lft-in99.8%
fma-def99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in z around 0 99.3%
if 1.7999999999999999e-43 < z Initial program 80.9%
Taylor expanded in y around 0 61.4%
associate-/l*74.1%
Simplified74.1%
Taylor expanded in z around 0 74.1%
neg-mul-174.1%
+-commutative74.1%
unsub-neg74.1%
Simplified74.1%
Final simplification88.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.4e+14) (not (<= y 27000000000000.0))) (* y (/ x z)) (- (/ x z) x)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.4e+14) || !(y <= 27000000000000.0)) {
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 <= (-1.4d+14)) .or. (.not. (y <= 27000000000000.0d0))) 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 <= -1.4e+14) || !(y <= 27000000000000.0)) {
tmp = y * (x / z);
} else {
tmp = (x / z) - x;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.4e+14) or not (y <= 27000000000000.0): tmp = y * (x / z) else: tmp = (x / z) - x return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.4e+14) || !(y <= 27000000000000.0)) 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 <= -1.4e+14) || ~((y <= 27000000000000.0))) tmp = y * (x / z); else tmp = (x / z) - x; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.4e+14], N[Not[LessEqual[y, 27000000000000.0]], $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 -1.4 \cdot 10^{+14} \lor \neg \left(y \leq 27000000000000\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - x\\
\end{array}
\end{array}
if y < -1.4e14 or 2.7e13 < y Initial program 87.2%
Taylor expanded in y around inf 74.2%
associate-/l*70.4%
associate-/r/74.8%
Simplified74.8%
if -1.4e14 < y < 2.7e13Initial program 87.5%
Taylor expanded in y around 0 85.0%
associate-/l*97.4%
Simplified97.4%
Taylor expanded in z around 0 97.4%
neg-mul-197.4%
+-commutative97.4%
unsub-neg97.4%
Simplified97.4%
Final simplification86.8%
(FPCore (x y z) :precision binary64 (if (<= y -5e+14) (* y (/ x z)) (if (<= y 28000000000000.0) (- (/ x z) x) (/ y (/ z x)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e+14) {
tmp = y * (x / z);
} else if (y <= 28000000000000.0) {
tmp = (x / z) - x;
} else {
tmp = 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 <= (-5d+14)) then
tmp = y * (x / z)
else if (y <= 28000000000000.0d0) then
tmp = (x / z) - x
else
tmp = y / (z / x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5e+14) {
tmp = y * (x / z);
} else if (y <= 28000000000000.0) {
tmp = (x / z) - x;
} else {
tmp = y / (z / x);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e+14: tmp = y * (x / z) elif y <= 28000000000000.0: tmp = (x / z) - x else: tmp = y / (z / x) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5e+14) tmp = Float64(y * Float64(x / z)); elseif (y <= 28000000000000.0) tmp = Float64(Float64(x / z) - x); else tmp = Float64(y / Float64(z / x)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5e+14) tmp = y * (x / z); elseif (y <= 28000000000000.0) tmp = (x / z) - x; else tmp = y / (z / x); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e+14], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 28000000000000.0], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+14}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 28000000000000:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\
\end{array}
\end{array}
if y < -5e14Initial program 85.1%
Taylor expanded in y around inf 74.4%
associate-/l*74.3%
associate-/r/75.9%
Simplified75.9%
if -5e14 < y < 2.8e13Initial program 87.5%
Taylor expanded in y around 0 85.0%
associate-/l*97.4%
Simplified97.4%
Taylor expanded in z around 0 97.4%
neg-mul-197.4%
+-commutative97.4%
unsub-neg97.4%
Simplified97.4%
if 2.8e13 < y Initial program 89.2%
Taylor expanded in y around inf 74.1%
associate-/l*66.8%
associate-/r/73.8%
Simplified73.8%
*-commutative73.8%
clear-num73.7%
un-div-inv73.8%
Applied egg-rr73.8%
Final simplification86.8%
(FPCore (x y z) :precision binary64 (if (<= y -5.8e+15) (* y (/ x z)) (if (<= y 22000000000000.0) (- (/ x z) x) (/ (* x y) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.8e+15) {
tmp = y * (x / z);
} else if (y <= 22000000000000.0) {
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 <= (-5.8d+15)) then
tmp = y * (x / z)
else if (y <= 22000000000000.0d0) 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 <= -5.8e+15) {
tmp = y * (x / z);
} else if (y <= 22000000000000.0) {
tmp = (x / z) - x;
} else {
tmp = (x * y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.8e+15: tmp = y * (x / z) elif y <= 22000000000000.0: tmp = (x / z) - x else: tmp = (x * y) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.8e+15) tmp = Float64(y * Float64(x / z)); elseif (y <= 22000000000000.0) tmp = Float64(Float64(x / z) - x); else tmp = Float64(Float64(x * y) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.8e+15) tmp = y * (x / z); elseif (y <= 22000000000000.0) tmp = (x / z) - x; else tmp = (x * y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.8e+15], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 22000000000000.0], N[(N[(x / z), $MachinePrecision] - x), $MachinePrecision], N[(N[(x * y), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.8 \cdot 10^{+15}:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;y \leq 22000000000000:\\
\;\;\;\;\frac{x}{z} - x\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y}{z}\\
\end{array}
\end{array}
if y < -5.8e15Initial program 85.1%
Taylor expanded in y around inf 74.4%
associate-/l*74.3%
associate-/r/75.9%
Simplified75.9%
if -5.8e15 < y < 2.2e13Initial program 87.5%
Taylor expanded in y around 0 85.0%
associate-/l*97.4%
Simplified97.4%
Taylor expanded in z around 0 97.4%
neg-mul-197.4%
+-commutative97.4%
unsub-neg97.4%
Simplified97.4%
if 2.2e13 < y Initial program 89.2%
Taylor expanded in y around inf 74.1%
Final simplification86.9%
(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 75.4%
Taylor expanded in z around inf 75.8%
neg-mul-175.8%
Simplified75.8%
if -1 < z < 1Initial program 99.8%
distribute-lft-in99.8%
fma-def99.8%
*-rgt-identity99.8%
Simplified99.8%
Taylor expanded in z around 0 97.6%
Taylor expanded in y around 0 55.0%
Final simplification65.6%
(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.4%
Taylor expanded in z around inf 40.1%
neg-mul-140.1%
Simplified40.1%
Final simplification40.1%
(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 2023291
(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))