
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
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)) / y
end function
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
def code(x, y, z): return (x * (y - z)) / y
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* x (- y z)) y))
double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
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)) / y
end function
public static double code(double x, double y, double z) {
return (x * (y - z)) / y;
}
def code(x, y, z): return (x * (y - z)) / y
function code(x, y, z) return Float64(Float64(x * Float64(y - z)) / y) end
function tmp = code(x, y, z) tmp = (x * (y - z)) / y; end
code[x_, y_, z_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot \left(y - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (if (<= z -2e+48) (- x (/ z (/ y x))) (* x (- 1.0 (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2e+48) {
tmp = x - (z / (y / x));
} else {
tmp = x * (1.0 - (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) :: tmp
if (z <= (-2d+48)) then
tmp = x - (z / (y / x))
else
tmp = x * (1.0d0 - (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2e+48) {
tmp = x - (z / (y / x));
} else {
tmp = x * (1.0 - (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2e+48: tmp = x - (z / (y / x)) else: tmp = x * (1.0 - (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2e+48) tmp = Float64(x - Float64(z / Float64(y / x))); else tmp = Float64(x * Float64(1.0 - Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2e+48) tmp = x - (z / (y / x)); else tmp = x * (1.0 - (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2e+48], N[(x - N[(z / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2 \cdot 10^{+48}:\\
\;\;\;\;x - \frac{z}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\
\end{array}
\end{array}
if z < -2.00000000000000009e48Initial program 94.2%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6490.1%
Simplified90.1%
flip3--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip3--N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f6490.1%
Applied egg-rr90.1%
associate-/r/N/A
/-rgt-identityN/A
*-commutativeN/A
*-inversesN/A
div-subN/A
associate-/r/N/A
div-subN/A
un-div-invN/A
associate-/r/N/A
associate-*r*N/A
div-invN/A
*-inversesN/A
*-lft-identityN/A
--lowering--.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6499.8%
Applied egg-rr99.8%
if -2.00000000000000009e48 < z Initial program 84.4%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6497.9%
Simplified97.9%
(FPCore (x y z) :precision binary64 (if (<= z -5e-37) (* z (/ x (- 0.0 y))) (if (<= z 1.05e+23) x (- 0.0 (/ (* z x) y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5e-37) {
tmp = z * (x / (0.0 - y));
} else if (z <= 1.05e+23) {
tmp = x;
} else {
tmp = 0.0 - ((z * x) / 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) :: tmp
if (z <= (-5d-37)) then
tmp = z * (x / (0.0d0 - y))
else if (z <= 1.05d+23) then
tmp = x
else
tmp = 0.0d0 - ((z * x) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5e-37) {
tmp = z * (x / (0.0 - y));
} else if (z <= 1.05e+23) {
tmp = x;
} else {
tmp = 0.0 - ((z * x) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5e-37: tmp = z * (x / (0.0 - y)) elif z <= 1.05e+23: tmp = x else: tmp = 0.0 - ((z * x) / y) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5e-37) tmp = Float64(z * Float64(x / Float64(0.0 - y))); elseif (z <= 1.05e+23) tmp = x; else tmp = Float64(0.0 - Float64(Float64(z * x) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5e-37) tmp = z * (x / (0.0 - y)); elseif (z <= 1.05e+23) tmp = x; else tmp = 0.0 - ((z * x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5e-37], N[(z * N[(x / N[(0.0 - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.05e+23], x, N[(0.0 - N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{-37}:\\
\;\;\;\;z \cdot \frac{x}{0 - y}\\
\mathbf{elif}\;z \leq 1.05 \cdot 10^{+23}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;0 - \frac{z \cdot x}{y}\\
\end{array}
\end{array}
if z < -4.9999999999999997e-37Initial program 95.1%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6491.8%
Simplified91.8%
flip3--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip3--N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f6491.7%
Applied egg-rr91.7%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6464.4%
Simplified64.4%
clear-numN/A
associate-/r/N/A
sub0-negN/A
distribute-frac-neg2N/A
clear-numN/A
distribute-lft-neg-inN/A
associate-/r/N/A
div-invN/A
clear-numN/A
distribute-rgt-neg-inN/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
/-lowering-/.f6481.5%
Applied egg-rr81.5%
if -4.9999999999999997e-37 < z < 1.0500000000000001e23Initial program 80.5%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6499.9%
Simplified99.9%
Taylor expanded in z around 0
Simplified74.6%
if 1.0500000000000001e23 < z Initial program 88.5%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6493.4%
Simplified93.4%
flip3--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip3--N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f6493.2%
Applied egg-rr93.2%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6466.2%
Simplified66.2%
clear-numN/A
associate-/r/N/A
sub0-negN/A
distribute-frac-neg2N/A
clear-numN/A
distribute-lft-neg-inN/A
associate-/r/N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6474.2%
Applied egg-rr74.2%
associate-/r/N/A
associate-*l/N/A
/-lowering-/.f64N/A
*-lowering-*.f6476.0%
Applied egg-rr76.0%
Final simplification77.1%
(FPCore (x y z) :precision binary64 (if (<= z -5.9e-36) (/ z (/ (- 0.0 y) x)) (if (<= z 6.8e+21) x (- 0.0 (/ (* z x) y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.9e-36) {
tmp = z / ((0.0 - y) / x);
} else if (z <= 6.8e+21) {
tmp = x;
} else {
tmp = 0.0 - ((z * x) / 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) :: tmp
if (z <= (-5.9d-36)) then
tmp = z / ((0.0d0 - y) / x)
else if (z <= 6.8d+21) then
tmp = x
else
tmp = 0.0d0 - ((z * x) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5.9e-36) {
tmp = z / ((0.0 - y) / x);
} else if (z <= 6.8e+21) {
tmp = x;
} else {
tmp = 0.0 - ((z * x) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.9e-36: tmp = z / ((0.0 - y) / x) elif z <= 6.8e+21: tmp = x else: tmp = 0.0 - ((z * x) / y) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.9e-36) tmp = Float64(z / Float64(Float64(0.0 - y) / x)); elseif (z <= 6.8e+21) tmp = x; else tmp = Float64(0.0 - Float64(Float64(z * x) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.9e-36) tmp = z / ((0.0 - y) / x); elseif (z <= 6.8e+21) tmp = x; else tmp = 0.0 - ((z * x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.9e-36], N[(z / N[(N[(0.0 - y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.8e+21], x, N[(0.0 - N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.9 \cdot 10^{-36}:\\
\;\;\;\;\frac{z}{\frac{0 - y}{x}}\\
\mathbf{elif}\;z \leq 6.8 \cdot 10^{+21}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;0 - \frac{z \cdot x}{y}\\
\end{array}
\end{array}
if z < -5.89999999999999995e-36Initial program 95.1%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6491.8%
Simplified91.8%
flip3--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip3--N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f6491.7%
Applied egg-rr91.7%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6464.4%
Simplified64.4%
clear-numN/A
associate-/r/N/A
sub0-negN/A
distribute-frac-neg2N/A
clear-numN/A
distribute-lft-neg-inN/A
associate-/r/N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6481.5%
Applied egg-rr81.5%
if -5.89999999999999995e-36 < z < 6.8e21Initial program 80.5%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6499.9%
Simplified99.9%
Taylor expanded in z around 0
Simplified74.6%
if 6.8e21 < z Initial program 88.5%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6493.4%
Simplified93.4%
flip3--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip3--N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f6493.2%
Applied egg-rr93.2%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6466.2%
Simplified66.2%
clear-numN/A
associate-/r/N/A
sub0-negN/A
distribute-frac-neg2N/A
clear-numN/A
distribute-lft-neg-inN/A
associate-/r/N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6474.2%
Applied egg-rr74.2%
associate-/r/N/A
associate-*l/N/A
/-lowering-/.f64N/A
*-lowering-*.f6476.0%
Applied egg-rr76.0%
Final simplification77.1%
(FPCore (x y z) :precision binary64 (if (<= z -8.5e-36) (/ z (/ (- 0.0 y) x)) (if (<= z 3.3e+22) x (- 0.0 (* x (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -8.5e-36) {
tmp = z / ((0.0 - y) / x);
} else if (z <= 3.3e+22) {
tmp = x;
} else {
tmp = 0.0 - (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) :: tmp
if (z <= (-8.5d-36)) then
tmp = z / ((0.0d0 - y) / x)
else if (z <= 3.3d+22) then
tmp = x
else
tmp = 0.0d0 - (x * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -8.5e-36) {
tmp = z / ((0.0 - y) / x);
} else if (z <= 3.3e+22) {
tmp = x;
} else {
tmp = 0.0 - (x * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -8.5e-36: tmp = z / ((0.0 - y) / x) elif z <= 3.3e+22: tmp = x else: tmp = 0.0 - (x * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -8.5e-36) tmp = Float64(z / Float64(Float64(0.0 - y) / x)); elseif (z <= 3.3e+22) tmp = x; else tmp = Float64(0.0 - Float64(x * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -8.5e-36) tmp = z / ((0.0 - y) / x); elseif (z <= 3.3e+22) tmp = x; else tmp = 0.0 - (x * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -8.5e-36], N[(z / N[(N[(0.0 - y), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.3e+22], x, N[(0.0 - N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{-36}:\\
\;\;\;\;\frac{z}{\frac{0 - y}{x}}\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{+22}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;0 - x \cdot \frac{z}{y}\\
\end{array}
\end{array}
if z < -8.5000000000000007e-36Initial program 95.1%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6491.8%
Simplified91.8%
flip3--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip3--N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f6491.7%
Applied egg-rr91.7%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6464.4%
Simplified64.4%
clear-numN/A
associate-/r/N/A
sub0-negN/A
distribute-frac-neg2N/A
clear-numN/A
distribute-lft-neg-inN/A
associate-/r/N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6481.5%
Applied egg-rr81.5%
if -8.5000000000000007e-36 < z < 3.2999999999999998e22Initial program 80.5%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6499.9%
Simplified99.9%
Taylor expanded in z around 0
Simplified74.6%
if 3.2999999999999998e22 < z Initial program 88.5%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6493.4%
Simplified93.4%
flip3--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip3--N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f6493.2%
Applied egg-rr93.2%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6466.2%
Simplified66.2%
clear-numN/A
associate-/r/N/A
sub0-negN/A
distribute-frac-neg2N/A
clear-numN/A
distribute-lft-neg-inN/A
associate-/r/N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6474.2%
Applied egg-rr74.2%
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f6474.5%
Applied egg-rr74.5%
Final simplification76.7%
(FPCore (x y z) :precision binary64 (let* ((t_0 (- 0.0 (* x (/ z y))))) (if (<= z -1.15e-36) t_0 (if (<= z 7.5e+21) x t_0))))
double code(double x, double y, double z) {
double t_0 = 0.0 - (x * (z / y));
double tmp;
if (z <= -1.15e-36) {
tmp = t_0;
} else if (z <= 7.5e+21) {
tmp = x;
} 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 = 0.0d0 - (x * (z / y))
if (z <= (-1.15d-36)) then
tmp = t_0
else if (z <= 7.5d+21) then
tmp = x
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 0.0 - (x * (z / y));
double tmp;
if (z <= -1.15e-36) {
tmp = t_0;
} else if (z <= 7.5e+21) {
tmp = x;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 0.0 - (x * (z / y)) tmp = 0 if z <= -1.15e-36: tmp = t_0 elif z <= 7.5e+21: tmp = x else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(0.0 - Float64(x * Float64(z / y))) tmp = 0.0 if (z <= -1.15e-36) tmp = t_0; elseif (z <= 7.5e+21) tmp = x; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 0.0 - (x * (z / y)); tmp = 0.0; if (z <= -1.15e-36) tmp = t_0; elseif (z <= 7.5e+21) tmp = x; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(0.0 - N[(x * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.15e-36], t$95$0, If[LessEqual[z, 7.5e+21], x, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0 - x \cdot \frac{z}{y}\\
\mathbf{if}\;z \leq -1.15 \cdot 10^{-36}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{+21}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.14999999999999998e-36 or 7.5e21 < z Initial program 92.3%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6492.4%
Simplified92.4%
flip3--N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f64N/A
clear-numN/A
flip3--N/A
/-lowering-/.f64N/A
--lowering--.f64N/A
/-lowering-/.f6492.4%
Applied egg-rr92.4%
Taylor expanded in z around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f64N/A
/-lowering-/.f6465.2%
Simplified65.2%
clear-numN/A
associate-/r/N/A
sub0-negN/A
distribute-frac-neg2N/A
clear-numN/A
distribute-lft-neg-inN/A
associate-/r/N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6478.4%
Applied egg-rr78.4%
associate-/r/N/A
*-lowering-*.f64N/A
/-lowering-/.f6473.9%
Applied egg-rr73.9%
if -1.14999999999999998e-36 < z < 7.5e21Initial program 80.5%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6499.9%
Simplified99.9%
Taylor expanded in z around 0
Simplified74.6%
Final simplification74.2%
(FPCore (x y z) :precision binary64 (if (<= z -2.1e+47) (* (/ x y) (- y z)) (* x (- 1.0 (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.1e+47) {
tmp = (x / y) * (y - z);
} else {
tmp = x * (1.0 - (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) :: tmp
if (z <= (-2.1d+47)) then
tmp = (x / y) * (y - z)
else
tmp = x * (1.0d0 - (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.1e+47) {
tmp = (x / y) * (y - z);
} else {
tmp = x * (1.0 - (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.1e+47: tmp = (x / y) * (y - z) else: tmp = x * (1.0 - (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.1e+47) tmp = Float64(Float64(x / y) * Float64(y - z)); else tmp = Float64(x * Float64(1.0 - Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.1e+47) tmp = (x / y) * (y - z); else tmp = x * (1.0 - (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.1e+47], N[(N[(x / y), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.1 \cdot 10^{+47}:\\
\;\;\;\;\frac{x}{y} \cdot \left(y - z\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - \frac{z}{y}\right)\\
\end{array}
\end{array}
if z < -2.1e47Initial program 94.2%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6490.1%
Simplified90.1%
*-inversesN/A
div-subN/A
associate-/l*N/A
*-commutativeN/A
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f64N/A
/-lowering-/.f64N/A
--lowering--.f6496.3%
Applied egg-rr96.3%
if -2.1e47 < z Initial program 84.4%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6497.9%
Simplified97.9%
(FPCore (x y z) :precision binary64 (if (<= x 2e+34) x (* y (/ x y))))
double code(double x, double y, double z) {
double tmp;
if (x <= 2e+34) {
tmp = x;
} else {
tmp = y * (x / 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) :: tmp
if (x <= 2d+34) then
tmp = x
else
tmp = y * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 2e+34) {
tmp = x;
} else {
tmp = y * (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 2e+34: tmp = x else: tmp = y * (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 2e+34) tmp = x; else tmp = Float64(y * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 2e+34) tmp = x; else tmp = y * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 2e+34], x, N[(y * N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{+34}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{y}\\
\end{array}
\end{array}
if x < 1.99999999999999989e34Initial program 88.9%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6494.7%
Simplified94.7%
Taylor expanded in z around 0
Simplified45.8%
if 1.99999999999999989e34 < x Initial program 80.3%
Taylor expanded in y around inf
*-lowering-*.f6428.6%
Simplified28.6%
associate-*l/N/A
*-lowering-*.f64N/A
/-lowering-/.f6450.0%
Applied egg-rr50.0%
Final simplification46.8%
(FPCore (x y z) :precision binary64 (* x (- 1.0 (/ z y))))
double code(double x, double y, double z) {
return x * (1.0 - (z / y));
}
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 - (z / y))
end function
public static double code(double x, double y, double z) {
return x * (1.0 - (z / y));
}
def code(x, y, z): return x * (1.0 - (z / y))
function code(x, y, z) return Float64(x * Float64(1.0 - Float64(z / y))) end
function tmp = code(x, y, z) tmp = x * (1.0 - (z / y)); end
code[x_, y_, z_] := N[(x * N[(1.0 - N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(1 - \frac{z}{y}\right)
\end{array}
Initial program 86.9%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6495.9%
Simplified95.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 86.9%
associate-/l*N/A
*-lowering-*.f64N/A
div-subN/A
--lowering--.f64N/A
*-inversesN/A
/-lowering-/.f6495.9%
Simplified95.9%
Taylor expanded in z around 0
Simplified45.6%
(FPCore (x y z) :precision binary64 (if (< z -2.060202331921739e+104) (- x (/ (* z x) y)) (if (< z 1.6939766013828526e+213) (/ x (/ y (- y z))) (* (- y z) (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (z < -2.060202331921739e+104) {
tmp = x - ((z * x) / y);
} else if (z < 1.6939766013828526e+213) {
tmp = x / (y / (y - z));
} else {
tmp = (y - z) * (x / 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) :: tmp
if (z < (-2.060202331921739d+104)) then
tmp = x - ((z * x) / y)
else if (z < 1.6939766013828526d+213) then
tmp = x / (y / (y - z))
else
tmp = (y - z) * (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z < -2.060202331921739e+104) {
tmp = x - ((z * x) / y);
} else if (z < 1.6939766013828526e+213) {
tmp = x / (y / (y - z));
} else {
tmp = (y - z) * (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z < -2.060202331921739e+104: tmp = x - ((z * x) / y) elif z < 1.6939766013828526e+213: tmp = x / (y / (y - z)) else: tmp = (y - z) * (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (z < -2.060202331921739e+104) tmp = Float64(x - Float64(Float64(z * x) / y)); elseif (z < 1.6939766013828526e+213) tmp = Float64(x / Float64(y / Float64(y - z))); else tmp = Float64(Float64(y - z) * Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z < -2.060202331921739e+104) tmp = x - ((z * x) / y); elseif (z < 1.6939766013828526e+213) tmp = x / (y / (y - z)); else tmp = (y - z) * (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Less[z, -2.060202331921739e+104], N[(x - N[(N[(z * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[Less[z, 1.6939766013828526e+213], N[(x / N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y - z), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z < -2.060202331921739 \cdot 10^{+104}:\\
\;\;\;\;x - \frac{z \cdot x}{y}\\
\mathbf{elif}\;z < 1.6939766013828526 \cdot 10^{+213}:\\
\;\;\;\;\frac{x}{\frac{y}{y - z}}\\
\mathbf{else}:\\
\;\;\;\;\left(y - z\right) \cdot \frac{x}{y}\\
\end{array}
\end{array}
herbie shell --seed 2024161
(FPCore (x y z)
:name "Diagrams.Backend.Cairo.Internal:setTexture from diagrams-cairo-1.3.0.3"
:precision binary64
:alt
(! :herbie-platform default (if (< z -206020233192173900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (- x (/ (* z x) y)) (if (< z 1693976601382852600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ x (/ y (- y z))) (* (- y z) (/ x y)))))
(/ (* x (- y z)) y))