
(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 - y) / Float64(z - y)) end
function tmp = code(x, y, z) tmp = (x - y) / (z - y); end
code[x_, y_, z_] := N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - 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 - y) / Float64(z - y)) end
function tmp = code(x, y, z) tmp = (x - y) / (z - y); end
code[x_, y_, z_] := N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y}
\end{array}
(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 - y) / Float64(z - y)) end
function tmp = code(x, y, z) tmp = (x - y) / (z - y); end
code[x_, y_, z_] := N[(N[(x - y), $MachinePrecision] / N[(z - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - y}{z - y}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= y -3.1e+17)
1.0
(if (<= y -1.95e-22)
(- (/ x y))
(if (<= y -1.7e-41)
1.0
(if (<= y 9.2e-51)
(/ x z)
(if (<= y 340.0) 1.0 (if (<= y 2.5e+32) (/ (- y) z) 1.0)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.1e+17) {
tmp = 1.0;
} else if (y <= -1.95e-22) {
tmp = -(x / y);
} else if (y <= -1.7e-41) {
tmp = 1.0;
} else if (y <= 9.2e-51) {
tmp = x / z;
} else if (y <= 340.0) {
tmp = 1.0;
} else if (y <= 2.5e+32) {
tmp = -y / z;
} else {
tmp = 1.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) :: tmp
if (y <= (-3.1d+17)) then
tmp = 1.0d0
else if (y <= (-1.95d-22)) then
tmp = -(x / y)
else if (y <= (-1.7d-41)) then
tmp = 1.0d0
else if (y <= 9.2d-51) then
tmp = x / z
else if (y <= 340.0d0) then
tmp = 1.0d0
else if (y <= 2.5d+32) then
tmp = -y / z
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.1e+17) {
tmp = 1.0;
} else if (y <= -1.95e-22) {
tmp = -(x / y);
} else if (y <= -1.7e-41) {
tmp = 1.0;
} else if (y <= 9.2e-51) {
tmp = x / z;
} else if (y <= 340.0) {
tmp = 1.0;
} else if (y <= 2.5e+32) {
tmp = -y / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.1e+17: tmp = 1.0 elif y <= -1.95e-22: tmp = -(x / y) elif y <= -1.7e-41: tmp = 1.0 elif y <= 9.2e-51: tmp = x / z elif y <= 340.0: tmp = 1.0 elif y <= 2.5e+32: tmp = -y / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.1e+17) tmp = 1.0; elseif (y <= -1.95e-22) tmp = Float64(-Float64(x / y)); elseif (y <= -1.7e-41) tmp = 1.0; elseif (y <= 9.2e-51) tmp = Float64(x / z); elseif (y <= 340.0) tmp = 1.0; elseif (y <= 2.5e+32) tmp = Float64(Float64(-y) / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.1e+17) tmp = 1.0; elseif (y <= -1.95e-22) tmp = -(x / y); elseif (y <= -1.7e-41) tmp = 1.0; elseif (y <= 9.2e-51) tmp = x / z; elseif (y <= 340.0) tmp = 1.0; elseif (y <= 2.5e+32) tmp = -y / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.1e+17], 1.0, If[LessEqual[y, -1.95e-22], (-N[(x / y), $MachinePrecision]), If[LessEqual[y, -1.7e-41], 1.0, If[LessEqual[y, 9.2e-51], N[(x / z), $MachinePrecision], If[LessEqual[y, 340.0], 1.0, If[LessEqual[y, 2.5e+32], N[((-y) / z), $MachinePrecision], 1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{+17}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.95 \cdot 10^{-22}:\\
\;\;\;\;-\frac{x}{y}\\
\mathbf{elif}\;y \leq -1.7 \cdot 10^{-41}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{-51}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 340:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+32}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.1e17 or -1.94999999999999999e-22 < y < -1.6999999999999999e-41 or 9.20000000000000007e-51 < y < 340 or 2.4999999999999999e32 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.8%
mul-1-neg99.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 63.6%
if -3.1e17 < y < -1.94999999999999999e-22Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.7%
associate-/l*99.7%
mul-1-neg99.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 83.6%
mul-1-neg83.6%
distribute-neg-frac83.6%
Simplified83.6%
Taylor expanded in y around inf 83.6%
associate-*r/83.6%
mul-1-neg83.6%
Simplified83.6%
if -1.6999999999999999e-41 < y < 9.20000000000000007e-51Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/97.9%
associate-/l*97.7%
mul-1-neg97.7%
sub-neg97.7%
+-commutative97.7%
distribute-neg-out97.7%
remove-double-neg97.7%
sub-neg97.7%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 72.6%
if 340 < y < 2.4999999999999999e32Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.7%
associate-/l*99.3%
mul-1-neg99.3%
sub-neg99.3%
+-commutative99.3%
distribute-neg-out99.3%
remove-double-neg99.3%
sub-neg99.3%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 65.9%
Taylor expanded in y around 0 55.9%
associate-*r/55.9%
neg-mul-155.9%
Simplified55.9%
Final simplification67.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))))
(if (<= y -9.5e+16)
t_0
(if (<= y -5.8e-24)
(- (/ x y))
(if (or (<= y -1.45e-53) (not (<= y 4.5e-52))) t_0 (/ x z))))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double tmp;
if (y <= -9.5e+16) {
tmp = t_0;
} else if (y <= -5.8e-24) {
tmp = -(x / y);
} else if ((y <= -1.45e-53) || !(y <= 4.5e-52)) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y / (y - z)
if (y <= (-9.5d+16)) then
tmp = t_0
else if (y <= (-5.8d-24)) then
tmp = -(x / y)
else if ((y <= (-1.45d-53)) .or. (.not. (y <= 4.5d-52))) then
tmp = t_0
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / (y - z);
double tmp;
if (y <= -9.5e+16) {
tmp = t_0;
} else if (y <= -5.8e-24) {
tmp = -(x / y);
} else if ((y <= -1.45e-53) || !(y <= 4.5e-52)) {
tmp = t_0;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) tmp = 0 if y <= -9.5e+16: tmp = t_0 elif y <= -5.8e-24: tmp = -(x / y) elif (y <= -1.45e-53) or not (y <= 4.5e-52): tmp = t_0 else: tmp = x / z return tmp
function code(x, y, z) t_0 = Float64(y / Float64(y - z)) tmp = 0.0 if (y <= -9.5e+16) tmp = t_0; elseif (y <= -5.8e-24) tmp = Float64(-Float64(x / y)); elseif ((y <= -1.45e-53) || !(y <= 4.5e-52)) tmp = t_0; else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (y - z); tmp = 0.0; if (y <= -9.5e+16) tmp = t_0; elseif (y <= -5.8e-24) tmp = -(x / y); elseif ((y <= -1.45e-53) || ~((y <= 4.5e-52))) tmp = t_0; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -9.5e+16], t$95$0, If[LessEqual[y, -5.8e-24], (-N[(x / y), $MachinePrecision]), If[Or[LessEqual[y, -1.45e-53], N[Not[LessEqual[y, 4.5e-52]], $MachinePrecision]], t$95$0, N[(x / z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
\mathbf{if}\;y \leq -9.5 \cdot 10^{+16}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -5.8 \cdot 10^{-24}:\\
\;\;\;\;-\frac{x}{y}\\
\mathbf{elif}\;y \leq -1.45 \cdot 10^{-53} \lor \neg \left(y \leq 4.5 \cdot 10^{-52}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -9.5e16 or -5.7999999999999997e-24 < y < -1.4499999999999999e-53 or 4.5e-52 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.3%
associate-/l*99.3%
mul-1-neg99.3%
sub-neg99.3%
+-commutative99.3%
distribute-neg-out99.3%
remove-double-neg99.3%
sub-neg99.3%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 76.0%
if -9.5e16 < y < -5.7999999999999997e-24Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.8%
mul-1-neg99.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 85.9%
mul-1-neg85.9%
distribute-neg-frac85.9%
Simplified85.9%
Taylor expanded in y around inf 72.6%
associate-*r/72.6%
mul-1-neg72.6%
Simplified72.6%
if -1.4499999999999999e-53 < y < 4.5e-52Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/98.4%
associate-/l*98.3%
mul-1-neg98.3%
sub-neg98.3%
+-commutative98.3%
distribute-neg-out98.3%
remove-double-neg98.3%
sub-neg98.3%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 74.0%
Final simplification75.1%
(FPCore (x y z)
:precision binary64
(if (<= y -9.5e+18)
1.0
(if (<= y -2.45e-23)
(- (/ x y))
(if (<= y -8.2e-42) 1.0 (if (<= y 1.1e-51) (/ x z) 1.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -9.5e+18) {
tmp = 1.0;
} else if (y <= -2.45e-23) {
tmp = -(x / y);
} else if (y <= -8.2e-42) {
tmp = 1.0;
} else if (y <= 1.1e-51) {
tmp = x / z;
} else {
tmp = 1.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) :: tmp
if (y <= (-9.5d+18)) then
tmp = 1.0d0
else if (y <= (-2.45d-23)) then
tmp = -(x / y)
else if (y <= (-8.2d-42)) then
tmp = 1.0d0
else if (y <= 1.1d-51) then
tmp = x / z
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -9.5e+18) {
tmp = 1.0;
} else if (y <= -2.45e-23) {
tmp = -(x / y);
} else if (y <= -8.2e-42) {
tmp = 1.0;
} else if (y <= 1.1e-51) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -9.5e+18: tmp = 1.0 elif y <= -2.45e-23: tmp = -(x / y) elif y <= -8.2e-42: tmp = 1.0 elif y <= 1.1e-51: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -9.5e+18) tmp = 1.0; elseif (y <= -2.45e-23) tmp = Float64(-Float64(x / y)); elseif (y <= -8.2e-42) tmp = 1.0; elseif (y <= 1.1e-51) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -9.5e+18) tmp = 1.0; elseif (y <= -2.45e-23) tmp = -(x / y); elseif (y <= -8.2e-42) tmp = 1.0; elseif (y <= 1.1e-51) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -9.5e+18], 1.0, If[LessEqual[y, -2.45e-23], (-N[(x / y), $MachinePrecision]), If[LessEqual[y, -8.2e-42], 1.0, If[LessEqual[y, 1.1e-51], N[(x / z), $MachinePrecision], 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9.5 \cdot 10^{+18}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -2.45 \cdot 10^{-23}:\\
\;\;\;\;-\frac{x}{y}\\
\mathbf{elif}\;y \leq -8.2 \cdot 10^{-42}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-51}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -9.5e18 or -2.4499999999999999e-23 < y < -8.2000000000000003e-42 or 1.1e-51 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.7%
mul-1-neg99.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 59.8%
if -9.5e18 < y < -2.4499999999999999e-23Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.7%
associate-/l*99.7%
mul-1-neg99.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 83.6%
mul-1-neg83.6%
distribute-neg-frac83.6%
Simplified83.6%
Taylor expanded in y around inf 83.6%
associate-*r/83.6%
mul-1-neg83.6%
Simplified83.6%
if -8.2000000000000003e-42 < y < 1.1e-51Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/97.9%
associate-/l*97.7%
mul-1-neg97.7%
sub-neg97.7%
+-commutative97.7%
distribute-neg-out97.7%
remove-double-neg97.7%
sub-neg97.7%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 72.6%
Final simplification65.8%
(FPCore (x y z) :precision binary64 (if (<= y -2.9e-40) (/ (- y x) y) (if (<= y 1.35e-51) (/ (- x) (- y z)) (/ y (- y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.9e-40) {
tmp = (y - x) / y;
} else if (y <= 1.35e-51) {
tmp = -x / (y - z);
} else {
tmp = y / (y - z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-2.9d-40)) then
tmp = (y - x) / y
else if (y <= 1.35d-51) then
tmp = -x / (y - z)
else
tmp = y / (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.9e-40) {
tmp = (y - x) / y;
} else if (y <= 1.35e-51) {
tmp = -x / (y - z);
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.9e-40: tmp = (y - x) / y elif y <= 1.35e-51: tmp = -x / (y - z) else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.9e-40) tmp = Float64(Float64(y - x) / y); elseif (y <= 1.35e-51) tmp = Float64(Float64(-x) / Float64(y - z)); else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.9e-40) tmp = (y - x) / y; elseif (y <= 1.35e-51) tmp = -x / (y - z); else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.9e-40], N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 1.35e-51], N[((-x) / N[(y - z), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{-40}:\\
\;\;\;\;\frac{y - x}{y}\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{-51}:\\
\;\;\;\;\frac{-x}{y - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if y < -2.8999999999999999e-40Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.8%
mul-1-neg99.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 81.5%
if -2.8999999999999999e-40 < y < 1.3499999999999999e-51Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/97.9%
associate-/l*97.7%
mul-1-neg97.7%
sub-neg97.7%
+-commutative97.7%
distribute-neg-out97.7%
remove-double-neg97.7%
sub-neg97.7%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 87.3%
mul-1-neg87.3%
distribute-neg-frac87.3%
Simplified87.3%
if 1.3499999999999999e-51 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.7%
mul-1-neg99.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 78.6%
Final simplification83.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -8.5e+20) (not (<= z 2.25e+52))) (/ (- x y) z) (/ (- y x) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8.5e+20) || !(z <= 2.25e+52)) {
tmp = (x - y) / z;
} 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 ((z <= (-8.5d+20)) .or. (.not. (z <= 2.25d+52))) then
tmp = (x - y) / z
else
tmp = (y - x) / y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -8.5e+20) || !(z <= 2.25e+52)) {
tmp = (x - y) / z;
} else {
tmp = (y - x) / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8.5e+20) or not (z <= 2.25e+52): tmp = (x - y) / z else: tmp = (y - x) / y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8.5e+20) || !(z <= 2.25e+52)) tmp = Float64(Float64(x - y) / z); else tmp = Float64(Float64(y - x) / y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -8.5e+20) || ~((z <= 2.25e+52))) tmp = (x - y) / z; else tmp = (y - x) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8.5e+20], N[Not[LessEqual[z, 2.25e+52]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{+20} \lor \neg \left(z \leq 2.25 \cdot 10^{+52}\right):\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{y}\\
\end{array}
\end{array}
if z < -8.5e20 or 2.25e52 < z Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/97.9%
associate-/l*97.8%
mul-1-neg97.8%
sub-neg97.8%
+-commutative97.8%
distribute-neg-out97.8%
remove-double-neg97.8%
sub-neg97.8%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 83.9%
associate-*r/83.9%
neg-mul-183.9%
neg-sub083.9%
associate--r-83.9%
neg-sub083.9%
Simplified83.9%
if -8.5e20 < z < 2.25e52Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.7%
mul-1-neg99.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 84.1%
Final simplification84.0%
(FPCore (x y z) :precision binary64 (if (<= y -1.12e-113) (/ (- y x) y) (if (<= y 1.62e-52) (/ x z) (/ y (- y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.12e-113) {
tmp = (y - x) / y;
} else if (y <= 1.62e-52) {
tmp = x / z;
} else {
tmp = y / (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 <= (-1.12d-113)) then
tmp = (y - x) / y
else if (y <= 1.62d-52) then
tmp = x / z
else
tmp = y / (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.12e-113) {
tmp = (y - x) / y;
} else if (y <= 1.62e-52) {
tmp = x / z;
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.12e-113: tmp = (y - x) / y elif y <= 1.62e-52: tmp = x / z else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.12e-113) tmp = Float64(Float64(y - x) / y); elseif (y <= 1.62e-52) tmp = Float64(x / z); else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.12e-113) tmp = (y - x) / y; elseif (y <= 1.62e-52) tmp = x / z; else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.12e-113], N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 1.62e-52], N[(x / z), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.12 \cdot 10^{-113}:\\
\;\;\;\;\frac{y - x}{y}\\
\mathbf{elif}\;y \leq 1.62 \cdot 10^{-52}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if y < -1.1200000000000001e-113Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/98.8%
associate-/l*98.8%
mul-1-neg98.8%
sub-neg98.8%
+-commutative98.8%
distribute-neg-out98.8%
remove-double-neg98.8%
sub-neg98.8%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 77.2%
if -1.1200000000000001e-113 < y < 1.61999999999999995e-52Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/98.4%
associate-/l*98.2%
mul-1-neg98.2%
sub-neg98.2%
+-commutative98.2%
distribute-neg-out98.2%
remove-double-neg98.2%
sub-neg98.2%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 75.7%
if 1.61999999999999995e-52 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.7%
mul-1-neg99.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 78.6%
Final simplification77.1%
(FPCore (x y z) :precision binary64 (if (<= y -9e-41) 1.0 (if (<= y 7e-52) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -9e-41) {
tmp = 1.0;
} else if (y <= 7e-52) {
tmp = x / z;
} else {
tmp = 1.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) :: tmp
if (y <= (-9d-41)) then
tmp = 1.0d0
else if (y <= 7d-52) then
tmp = x / z
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -9e-41) {
tmp = 1.0;
} else if (y <= 7e-52) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -9e-41: tmp = 1.0 elif y <= 7e-52: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -9e-41) tmp = 1.0; elseif (y <= 7e-52) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -9e-41) tmp = 1.0; elseif (y <= 7e-52) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -9e-41], 1.0, If[LessEqual[y, 7e-52], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{-41}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-52}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -9e-41 or 7.0000000000000001e-52 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.7%
mul-1-neg99.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 57.8%
if -9e-41 < y < 7.0000000000000001e-52Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/97.9%
associate-/l*97.7%
mul-1-neg97.7%
sub-neg97.7%
+-commutative97.7%
distribute-neg-out97.7%
remove-double-neg97.7%
sub-neg97.7%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 72.6%
Final simplification64.1%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.0%
associate-/l*98.9%
mul-1-neg98.9%
sub-neg98.9%
+-commutative98.9%
distribute-neg-out98.9%
remove-double-neg98.9%
sub-neg98.9%
associate-/l*100.0%
mul-1-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 36.4%
Final simplification36.4%
(FPCore (x y z) :precision binary64 (- (/ x (- z y)) (/ y (- z y))))
double code(double x, double y, double z) {
return (x / (z - y)) - (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 / (z - y)) - (y / (z - y))
end function
public static double code(double x, double y, double z) {
return (x / (z - y)) - (y / (z - y));
}
def code(x, y, z): return (x / (z - y)) - (y / (z - y))
function code(x, y, z) return Float64(Float64(x / Float64(z - y)) - Float64(y / Float64(z - y))) end
function tmp = code(x, y, z) tmp = (x / (z - y)) - (y / (z - y)); end
code[x_, y_, z_] := N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z - y} - \frac{y}{z - y}
\end{array}
herbie shell --seed 2023301
(FPCore (x y z)
:name "Graphics.Rasterific.Shading:$sgradientColorAt from Rasterific-0.6.1"
:precision binary64
:herbie-target
(- (/ x (- z y)) (/ y (- z y)))
(/ (- x y) (- z y)))