
(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 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.6%
associate-/l*99.5%
neg-mul-199.5%
sub-neg99.5%
+-commutative99.5%
distribute-neg-out99.5%
remove-double-neg99.5%
sub-neg99.5%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (- x y) z)) (t_1 (/ (- x) (- y z))) (t_2 (- 1.0 (/ x y))))
(if (<= x -1.4e+82)
t_1
(if (<= x -7.1e-38)
t_2
(if (<= x -5e-75)
t_0
(if (<= x 5.4e-56)
(/ y (- y z))
(if (<= x 19000000000.0) t_0 (if (<= x 2.3e+24) t_2 t_1))))))))
double code(double x, double y, double z) {
double t_0 = (x - y) / z;
double t_1 = -x / (y - z);
double t_2 = 1.0 - (x / y);
double tmp;
if (x <= -1.4e+82) {
tmp = t_1;
} else if (x <= -7.1e-38) {
tmp = t_2;
} else if (x <= -5e-75) {
tmp = t_0;
} else if (x <= 5.4e-56) {
tmp = y / (y - z);
} else if (x <= 19000000000.0) {
tmp = t_0;
} else if (x <= 2.3e+24) {
tmp = t_2;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (x - y) / z
t_1 = -x / (y - z)
t_2 = 1.0d0 - (x / y)
if (x <= (-1.4d+82)) then
tmp = t_1
else if (x <= (-7.1d-38)) then
tmp = t_2
else if (x <= (-5d-75)) then
tmp = t_0
else if (x <= 5.4d-56) then
tmp = y / (y - z)
else if (x <= 19000000000.0d0) then
tmp = t_0
else if (x <= 2.3d+24) then
tmp = t_2
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x - y) / z;
double t_1 = -x / (y - z);
double t_2 = 1.0 - (x / y);
double tmp;
if (x <= -1.4e+82) {
tmp = t_1;
} else if (x <= -7.1e-38) {
tmp = t_2;
} else if (x <= -5e-75) {
tmp = t_0;
} else if (x <= 5.4e-56) {
tmp = y / (y - z);
} else if (x <= 19000000000.0) {
tmp = t_0;
} else if (x <= 2.3e+24) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (x - y) / z t_1 = -x / (y - z) t_2 = 1.0 - (x / y) tmp = 0 if x <= -1.4e+82: tmp = t_1 elif x <= -7.1e-38: tmp = t_2 elif x <= -5e-75: tmp = t_0 elif x <= 5.4e-56: tmp = y / (y - z) elif x <= 19000000000.0: tmp = t_0 elif x <= 2.3e+24: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(x - y) / z) t_1 = Float64(Float64(-x) / Float64(y - z)) t_2 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (x <= -1.4e+82) tmp = t_1; elseif (x <= -7.1e-38) tmp = t_2; elseif (x <= -5e-75) tmp = t_0; elseif (x <= 5.4e-56) tmp = Float64(y / Float64(y - z)); elseif (x <= 19000000000.0) tmp = t_0; elseif (x <= 2.3e+24) tmp = t_2; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - y) / z; t_1 = -x / (y - z); t_2 = 1.0 - (x / y); tmp = 0.0; if (x <= -1.4e+82) tmp = t_1; elseif (x <= -7.1e-38) tmp = t_2; elseif (x <= -5e-75) tmp = t_0; elseif (x <= 5.4e-56) tmp = y / (y - z); elseif (x <= 19000000000.0) tmp = t_0; elseif (x <= 2.3e+24) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[((-x) / N[(y - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.4e+82], t$95$1, If[LessEqual[x, -7.1e-38], t$95$2, If[LessEqual[x, -5e-75], t$95$0, If[LessEqual[x, 5.4e-56], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 19000000000.0], t$95$0, If[LessEqual[x, 2.3e+24], t$95$2, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - y}{z}\\
t_1 := \frac{-x}{y - z}\\
t_2 := 1 - \frac{x}{y}\\
\mathbf{if}\;x \leq -1.4 \cdot 10^{+82}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -7.1 \cdot 10^{-38}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;x \leq -5 \cdot 10^{-75}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{-56}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;x \leq 19000000000:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.3 \cdot 10^{+24}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -1.4e82 or 2.2999999999999999e24 < x Initial 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%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around inf 81.6%
neg-mul-181.6%
distribute-neg-frac81.6%
Simplified81.6%
if -1.4e82 < x < -7.1000000000000002e-38 or 1.9e10 < x < 2.2999999999999999e24Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
associate-/l*100.0%
neg-mul-1100.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 78.3%
div-sub78.3%
*-inverses78.3%
Simplified78.3%
if -7.1000000000000002e-38 < x < -4.99999999999999979e-75 or 5.3999999999999999e-56 < x < 1.9e10Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/97.7%
associate-/l*97.6%
neg-mul-197.6%
sub-neg97.6%
+-commutative97.6%
distribute-neg-out97.6%
remove-double-neg97.6%
sub-neg97.6%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around inf 78.4%
associate-*r/78.4%
neg-mul-178.4%
neg-sub078.4%
associate--r-78.4%
neg-sub078.4%
Simplified78.4%
Taylor expanded in y around 0 78.4%
+-commutative78.4%
mul-1-neg78.4%
sub-neg78.4%
div-sub78.4%
Simplified78.4%
if -4.99999999999999979e-75 < x < 5.3999999999999999e-56Initial 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%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 89.0%
Final simplification83.8%
(FPCore (x y z) :precision binary64 (if (<= y -1.3e+28) 1.0 (if (<= y 3.2e-51) (/ x z) (if (<= y 2.6e+77) (/ (- y) z) 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.3e+28) {
tmp = 1.0;
} else if (y <= 3.2e-51) {
tmp = x / z;
} else if (y <= 2.6e+77) {
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 <= (-1.3d+28)) then
tmp = 1.0d0
else if (y <= 3.2d-51) then
tmp = x / z
else if (y <= 2.6d+77) 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 <= -1.3e+28) {
tmp = 1.0;
} else if (y <= 3.2e-51) {
tmp = x / z;
} else if (y <= 2.6e+77) {
tmp = -y / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.3e+28: tmp = 1.0 elif y <= 3.2e-51: tmp = x / z elif y <= 2.6e+77: tmp = -y / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.3e+28) tmp = 1.0; elseif (y <= 3.2e-51) tmp = Float64(x / z); elseif (y <= 2.6e+77) 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 <= -1.3e+28) tmp = 1.0; elseif (y <= 3.2e-51) tmp = x / z; elseif (y <= 2.6e+77) tmp = -y / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.3e+28], 1.0, If[LessEqual[y, 3.2e-51], N[(x / z), $MachinePrecision], If[LessEqual[y, 2.6e+77], N[((-y) / z), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.3 \cdot 10^{+28}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{-51}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+77}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.3000000000000001e28 or 2.6000000000000002e77 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
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*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around inf 59.5%
if -1.3000000000000001e28 < y < 3.2e-51Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.3%
associate-/l*99.2%
neg-mul-199.2%
sub-neg99.2%
+-commutative99.2%
distribute-neg-out99.2%
remove-double-neg99.2%
sub-neg99.2%
associate-/l*100.0%
neg-mul-1100.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 68.8%
if 3.2e-51 < y < 2.6000000000000002e77Initial 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%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 48.5%
Taylor expanded in y around 0 34.1%
associate-*r/34.1%
mul-1-neg34.1%
Simplified34.1%
Final simplification61.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.2e-54) (not (<= y 7.4e-53))) (- 1.0 (/ x y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.2e-54) || !(y <= 7.4e-53)) {
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 <= (-2.2d-54)) .or. (.not. (y <= 7.4d-53))) 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 <= -2.2e-54) || !(y <= 7.4e-53)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.2e-54) or not (y <= 7.4e-53): tmp = 1.0 - (x / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.2e-54) || !(y <= 7.4e-53)) 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 <= -2.2e-54) || ~((y <= 7.4e-53))) tmp = 1.0 - (x / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.2e-54], N[Not[LessEqual[y, 7.4e-53]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{-54} \lor \neg \left(y \leq 7.4 \cdot 10^{-53}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -2.2e-54 or 7.39999999999999965e-53 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
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*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around 0 69.5%
div-sub69.6%
*-inverses69.6%
Simplified69.6%
if -2.2e-54 < y < 7.39999999999999965e-53Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.3%
associate-/l*99.2%
neg-mul-199.2%
sub-neg99.2%
+-commutative99.2%
distribute-neg-out99.2%
remove-double-neg99.2%
sub-neg99.2%
associate-/l*100.0%
neg-mul-1100.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 71.6%
Final simplification70.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -1200000000000.0) (not (<= z 5.2e-9))) (/ (- x y) z) (- 1.0 (/ x y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1200000000000.0) || !(z <= 5.2e-9)) {
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 ((z <= (-1200000000000.0d0)) .or. (.not. (z <= 5.2d-9))) 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 ((z <= -1200000000000.0) || !(z <= 5.2e-9)) {
tmp = (x - y) / z;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1200000000000.0) or not (z <= 5.2e-9): tmp = (x - y) / z else: tmp = 1.0 - (x / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1200000000000.0) || !(z <= 5.2e-9)) 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 ((z <= -1200000000000.0) || ~((z <= 5.2e-9))) tmp = (x - y) / z; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1200000000000.0], N[Not[LessEqual[z, 5.2e-9]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1200000000000 \lor \neg \left(z \leq 5.2 \cdot 10^{-9}\right):\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if z < -1.2e12 or 5.2000000000000002e-9 < z Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.4%
associate-/l*99.2%
neg-mul-199.2%
sub-neg99.2%
+-commutative99.2%
distribute-neg-out99.2%
remove-double-neg99.2%
sub-neg99.2%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around inf 75.0%
associate-*r/75.0%
neg-mul-175.0%
neg-sub075.0%
associate--r-75.0%
neg-sub075.0%
Simplified75.0%
Taylor expanded in y around 0 75.0%
+-commutative75.0%
mul-1-neg75.0%
sub-neg75.0%
div-sub75.0%
Simplified75.0%
if -1.2e12 < z < 5.2000000000000002e-9Initial 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%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 78.7%
div-sub78.7%
*-inverses78.7%
Simplified78.7%
Final simplification76.8%
(FPCore (x y z) :precision binary64 (if (<= y -1.7e-91) (/ y (- y z)) (if (<= y 6.6e-47) (/ x z) (- 1.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.7e-91) {
tmp = y / (y - z);
} else if (y <= 6.6e-47) {
tmp = x / 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 <= (-1.7d-91)) then
tmp = y / (y - z)
else if (y <= 6.6d-47) then
tmp = x / 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 <= -1.7e-91) {
tmp = y / (y - z);
} else if (y <= 6.6e-47) {
tmp = x / z;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.7e-91: tmp = y / (y - z) elif y <= 6.6e-47: tmp = x / z else: tmp = 1.0 - (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.7e-91) tmp = Float64(y / Float64(y - z)); elseif (y <= 6.6e-47) tmp = Float64(x / 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 <= -1.7e-91) tmp = y / (y - z); elseif (y <= 6.6e-47) tmp = x / z; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.7e-91], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.6e-47], N[(x / z), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{-91}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;y \leq 6.6 \cdot 10^{-47}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -1.70000000000000013e-91Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.2%
associate-/l*99.0%
neg-mul-199.0%
sub-neg99.0%
+-commutative99.0%
distribute-neg-out99.0%
remove-double-neg99.0%
sub-neg99.0%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 68.6%
if -1.70000000000000013e-91 < y < 6.60000000000000007e-47Initial 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%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 75.0%
if 6.60000000000000007e-47 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
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*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around 0 71.8%
div-sub71.8%
*-inverses71.8%
Simplified71.8%
Final simplification72.0%
(FPCore (x y z) :precision binary64 (if (<= y -8.2e+33) 1.0 (if (<= y 3.6e+71) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.2e+33) {
tmp = 1.0;
} else if (y <= 3.6e+71) {
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 <= (-8.2d+33)) then
tmp = 1.0d0
else if (y <= 3.6d+71) 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 <= -8.2e+33) {
tmp = 1.0;
} else if (y <= 3.6e+71) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.2e+33: tmp = 1.0 elif y <= 3.6e+71: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.2e+33) tmp = 1.0; elseif (y <= 3.6e+71) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.2e+33) tmp = 1.0; elseif (y <= 3.6e+71) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.2e+33], 1.0, If[LessEqual[y, 3.6e+71], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+33}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{+71}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -8.1999999999999999e33 or 3.6e71 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
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*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around inf 58.8%
if -8.1999999999999999e33 < y < 3.6e71Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.4%
associate-/l*99.3%
neg-mul-199.3%
sub-neg99.3%
+-commutative99.3%
distribute-neg-out99.3%
remove-double-neg99.3%
sub-neg99.3%
associate-/l*100.0%
neg-mul-1100.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 60.3%
Final simplification59.6%
(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 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.6%
associate-/l*99.5%
neg-mul-199.5%
sub-neg99.5%
+-commutative99.5%
distribute-neg-out99.5%
remove-double-neg99.5%
sub-neg99.5%
associate-/l*100.0%
neg-mul-1100.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 33.4%
Final simplification33.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 2023320
(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)))