
(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 (- (/ y (- y z)) (/ x (- y z))))
double code(double x, double y, double z) {
return (y / (y - z)) - (x / (y - z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y / (y - z)) - (x / (y - z))
end function
public static double code(double x, double y, double z) {
return (y / (y - z)) - (x / (y - z));
}
def code(x, y, z): return (y / (y - z)) - (x / (y - z))
function code(x, y, z) return Float64(Float64(y / Float64(y - z)) - Float64(x / Float64(y - z))) end
function tmp = code(x, y, z) tmp = (y / (y - z)) - (x / (y - z)); end
code[x_, y_, z_] := N[(N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision] - N[(x / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{y - z} - \frac{x}{y - z}
\end{array}
Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.7%
neg-mul-199.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= y -5e+70)
1.0
(if (<= y -1.7e+47)
(/ (- y) z)
(if (<= y -1.75e+22) (/ (- x) y) (if (<= y 5.9e-36) (/ x z) 1.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5e+70) {
tmp = 1.0;
} else if (y <= -1.7e+47) {
tmp = -y / z;
} else if (y <= -1.75e+22) {
tmp = -x / y;
} else if (y <= 5.9e-36) {
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 <= (-5d+70)) then
tmp = 1.0d0
else if (y <= (-1.7d+47)) then
tmp = -y / z
else if (y <= (-1.75d+22)) then
tmp = -x / y
else if (y <= 5.9d-36) 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 <= -5e+70) {
tmp = 1.0;
} else if (y <= -1.7e+47) {
tmp = -y / z;
} else if (y <= -1.75e+22) {
tmp = -x / y;
} else if (y <= 5.9e-36) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5e+70: tmp = 1.0 elif y <= -1.7e+47: tmp = -y / z elif y <= -1.75e+22: tmp = -x / y elif y <= 5.9e-36: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5e+70) tmp = 1.0; elseif (y <= -1.7e+47) tmp = Float64(Float64(-y) / z); elseif (y <= -1.75e+22) tmp = Float64(Float64(-x) / y); elseif (y <= 5.9e-36) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5e+70) tmp = 1.0; elseif (y <= -1.7e+47) tmp = -y / z; elseif (y <= -1.75e+22) tmp = -x / y; elseif (y <= 5.9e-36) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5e+70], 1.0, If[LessEqual[y, -1.7e+47], N[((-y) / z), $MachinePrecision], If[LessEqual[y, -1.75e+22], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 5.9e-36], N[(x / z), $MachinePrecision], 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5 \cdot 10^{+70}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.7 \cdot 10^{+47}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{elif}\;y \leq -1.75 \cdot 10^{+22}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq 5.9 \cdot 10^{-36}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.0000000000000002e70 or 5.89999999999999995e-36 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 64.7%
if -5.0000000000000002e70 < y < -1.6999999999999999e47Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/100.0%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.6%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 65.7%
Taylor expanded in y around 0 64.9%
associate-*r/64.9%
mul-1-neg64.9%
Simplified64.9%
if -1.6999999999999999e47 < y < -1.75e22Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.7%
associate-/l*99.7%
neg-mul-199.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
div-sub100.0%
Applied egg-rr100.0%
sub-div100.0%
clear-num99.7%
Applied egg-rr99.7%
Taylor expanded in x around inf 80.6%
associate-*r/80.6%
neg-mul-180.6%
sub-neg80.6%
distribute-neg-in80.6%
remove-double-neg80.6%
Simplified80.6%
Taylor expanded in y around inf 60.9%
associate-*r/60.9%
mul-1-neg60.9%
Simplified60.9%
if -1.75e22 < y < 5.89999999999999995e-36Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.6%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 62.4%
Final simplification63.5%
(FPCore (x y z)
:precision binary64
(if (<= y -4e+38)
(/ y (- y z))
(if (<= y 2.5e-256)
(/ x (- z y))
(if (<= y 2.6e-39) (/ (- x y) z) (- 1.0 (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4e+38) {
tmp = y / (y - z);
} else if (y <= 2.5e-256) {
tmp = x / (z - y);
} else if (y <= 2.6e-39) {
tmp = (x - y) / z;
} else {
tmp = 1.0 - (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 (y <= (-4d+38)) then
tmp = y / (y - z)
else if (y <= 2.5d-256) then
tmp = x / (z - y)
else if (y <= 2.6d-39) then
tmp = (x - y) / z
else
tmp = 1.0d0 - (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4e+38) {
tmp = y / (y - z);
} else if (y <= 2.5e-256) {
tmp = x / (z - y);
} else if (y <= 2.6e-39) {
tmp = (x - y) / z;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4e+38: tmp = y / (y - z) elif y <= 2.5e-256: tmp = x / (z - y) elif y <= 2.6e-39: tmp = (x - y) / z else: tmp = 1.0 - (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4e+38) tmp = Float64(y / Float64(y - z)); elseif (y <= 2.5e-256) tmp = Float64(x / Float64(z - y)); elseif (y <= 2.6e-39) tmp = Float64(Float64(x - y) / z); else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4e+38) tmp = y / (y - z); elseif (y <= 2.5e-256) tmp = x / (z - y); elseif (y <= 2.6e-39) tmp = (x - y) / z; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4e+38], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.5e-256], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e-39], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{+38}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-256}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{-39}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -3.99999999999999991e38Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 85.5%
if -3.99999999999999991e38 < y < 2.5e-256Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.6%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
div-sub100.0%
Applied egg-rr100.0%
sub-div100.0%
clear-num99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 84.4%
associate-*r/84.4%
neg-mul-184.4%
sub-neg84.4%
distribute-neg-in84.4%
remove-double-neg84.4%
Simplified84.4%
Taylor expanded in x around 0 84.8%
if 2.5e-256 < y < 2.6e-39Initial program 99.8%
*-lft-identity99.8%
metadata-eval99.8%
associate-/r/99.7%
associate-/l*99.7%
neg-mul-199.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
+-commutative99.8%
sub-neg99.8%
Simplified99.8%
Taylor expanded in z around inf 76.7%
associate-*r/76.7%
neg-mul-176.7%
neg-sub076.7%
associate--r-76.7%
neg-sub076.7%
Simplified76.7%
Taylor expanded in y around 0 76.7%
+-commutative76.7%
mul-1-neg76.7%
sub-neg76.7%
div-sub76.7%
Simplified76.7%
if 2.6e-39 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 74.3%
div-sub74.3%
*-inverses74.3%
Simplified74.3%
Final simplification80.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -180.0) (not (<= y 6.6e-40))) (- 1.0 (/ x y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -180.0) || !(y <= 6.6e-40)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-180.0d0)) .or. (.not. (y <= 6.6d-40))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -180.0) || !(y <= 6.6e-40)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -180.0) or not (y <= 6.6e-40): tmp = 1.0 - (x / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -180.0) || !(y <= 6.6e-40)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -180.0) || ~((y <= 6.6e-40))) tmp = 1.0 - (x / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -180.0], N[Not[LessEqual[y, 6.6e-40]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -180 \lor \neg \left(y \leq 6.6 \cdot 10^{-40}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -180 or 6.59999999999999986e-40 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 73.2%
div-sub73.3%
*-inverses73.3%
Simplified73.3%
if -180 < y < 6.59999999999999986e-40Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.7%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.6%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 63.9%
Final simplification68.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.28e+70) (not (<= y 7.5e-37))) (- 1.0 (/ x y)) (/ x (- z y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.28e+70) || !(y <= 7.5e-37)) {
tmp = 1.0 - (x / y);
} else {
tmp = 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 ((y <= (-1.28d+70)) .or. (.not. (y <= 7.5d-37))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / (z - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.28e+70) || !(y <= 7.5e-37)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (z - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.28e+70) or not (y <= 7.5e-37): tmp = 1.0 - (x / y) else: tmp = x / (z - y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.28e+70) || !(y <= 7.5e-37)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / Float64(z - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.28e+70) || ~((y <= 7.5e-37))) tmp = 1.0 - (x / y); else tmp = x / (z - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.28e+70], N[Not[LessEqual[y, 7.5e-37]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.28 \cdot 10^{+70} \lor \neg \left(y \leq 7.5 \cdot 10^{-37}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z - y}\\
\end{array}
\end{array}
if y < -1.27999999999999994e70 or 7.5000000000000004e-37 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 78.0%
div-sub78.0%
*-inverses78.0%
Simplified78.0%
if -1.27999999999999994e70 < y < 7.5000000000000004e-37Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.6%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
div-sub100.0%
Applied egg-rr100.0%
sub-div99.9%
clear-num99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 75.4%
associate-*r/75.4%
neg-mul-175.4%
sub-neg75.4%
distribute-neg-in75.4%
remove-double-neg75.4%
Simplified75.4%
Taylor expanded in x around 0 75.6%
Final simplification76.7%
(FPCore (x y z) :precision binary64 (if (<= y -1.8e+36) (/ y (- y z)) (if (<= y 2.05e-35) (/ x (- z y)) (- 1.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.8e+36) {
tmp = y / (y - z);
} else if (y <= 2.05e-35) {
tmp = x / (z - y);
} else {
tmp = 1.0 - (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 (y <= (-1.8d+36)) then
tmp = y / (y - z)
else if (y <= 2.05d-35) then
tmp = x / (z - y)
else
tmp = 1.0d0 - (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.8e+36) {
tmp = y / (y - z);
} else if (y <= 2.05e-35) {
tmp = x / (z - y);
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.8e+36: tmp = y / (y - z) elif y <= 2.05e-35: tmp = x / (z - y) else: tmp = 1.0 - (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.8e+36) tmp = Float64(y / Float64(y - z)); elseif (y <= 2.05e-35) tmp = Float64(x / Float64(z - y)); else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.8e+36) tmp = y / (y - z); elseif (y <= 2.05e-35) tmp = x / (z - y); else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.8e+36], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.05e-35], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.8 \cdot 10^{+36}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;y \leq 2.05 \cdot 10^{-35}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -1.7999999999999999e36Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 85.5%
if -1.7999999999999999e36 < y < 2.05000000000000013e-35Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.7%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.6%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
div-sub100.0%
Applied egg-rr100.0%
sub-div99.9%
clear-num99.6%
Applied egg-rr99.6%
Taylor expanded in x around inf 78.2%
associate-*r/78.2%
neg-mul-178.2%
sub-neg78.2%
distribute-neg-in78.2%
remove-double-neg78.2%
Simplified78.2%
Taylor expanded in x around 0 78.4%
if 2.05000000000000013e-35 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 74.9%
div-sub75.0%
*-inverses75.0%
Simplified75.0%
Final simplification78.9%
(FPCore (x y z) :precision binary64 (if (<= y -2e+70) 1.0 (if (<= y 2.5e-35) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e+70) {
tmp = 1.0;
} else if (y <= 2.5e-35) {
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 <= (-2d+70)) then
tmp = 1.0d0
else if (y <= 2.5d-35) 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 <= -2e+70) {
tmp = 1.0;
} else if (y <= 2.5e-35) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e+70: tmp = 1.0 elif y <= 2.5e-35: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e+70) tmp = 1.0; elseif (y <= 2.5e-35) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2e+70) tmp = 1.0; elseif (y <= 2.5e-35) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e+70], 1.0, If[LessEqual[y, 2.5e-35], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+70}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-35}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.00000000000000015e70 or 2.49999999999999982e-35 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 64.7%
if -2.00000000000000015e70 < y < 2.49999999999999982e-35Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.6%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 58.8%
Final simplification61.4%
(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 99.9%
Final simplification99.9%
(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 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.7%
neg-mul-199.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around inf 35.3%
Final simplification35.3%
(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 2023279
(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)))