
(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 11 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 (- z y)) (/ y (- y z))))
double code(double x, double y, double z) {
return (x / (z - y)) + (y / (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 = (x / (z - y)) + (y / (y - z))
end function
public static double code(double x, double y, double z) {
return (x / (z - y)) + (y / (y - z));
}
def code(x, y, z): return (x / (z - y)) + (y / (y - z))
function code(x, y, z) return Float64(Float64(x / Float64(z - y)) + Float64(y / Float64(y - z))) end
function tmp = code(x, y, z) tmp = (x / (z - y)) + (y / (y - z)); end
code[x_, y_, z_] := N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] + N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z - y} + \frac{y}{y - z}
\end{array}
Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -7.4e-111)
t_0
(if (<= y 1.25e-203)
(/ x z)
(if (<= y 1.26e-203)
(/ x (- y))
(if (<= y 2.3e-142)
(/ x z)
(if (<= y 5e-114)
(/ (- y) z)
(if (or (<= y 2.5e-30) (not (<= y 100000000000.0)))
t_0
(/ x z)))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -7.4e-111) {
tmp = t_0;
} else if (y <= 1.25e-203) {
tmp = x / z;
} else if (y <= 1.26e-203) {
tmp = x / -y;
} else if (y <= 2.3e-142) {
tmp = x / z;
} else if (y <= 5e-114) {
tmp = -y / z;
} else if ((y <= 2.5e-30) || !(y <= 100000000000.0)) {
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 = 1.0d0 - (x / y)
if (y <= (-7.4d-111)) then
tmp = t_0
else if (y <= 1.25d-203) then
tmp = x / z
else if (y <= 1.26d-203) then
tmp = x / -y
else if (y <= 2.3d-142) then
tmp = x / z
else if (y <= 5d-114) then
tmp = -y / z
else if ((y <= 2.5d-30) .or. (.not. (y <= 100000000000.0d0))) 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 = 1.0 - (x / y);
double tmp;
if (y <= -7.4e-111) {
tmp = t_0;
} else if (y <= 1.25e-203) {
tmp = x / z;
} else if (y <= 1.26e-203) {
tmp = x / -y;
} else if (y <= 2.3e-142) {
tmp = x / z;
} else if (y <= 5e-114) {
tmp = -y / z;
} else if ((y <= 2.5e-30) || !(y <= 100000000000.0)) {
tmp = t_0;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -7.4e-111: tmp = t_0 elif y <= 1.25e-203: tmp = x / z elif y <= 1.26e-203: tmp = x / -y elif y <= 2.3e-142: tmp = x / z elif y <= 5e-114: tmp = -y / z elif (y <= 2.5e-30) or not (y <= 100000000000.0): tmp = t_0 else: tmp = x / z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -7.4e-111) tmp = t_0; elseif (y <= 1.25e-203) tmp = Float64(x / z); elseif (y <= 1.26e-203) tmp = Float64(x / Float64(-y)); elseif (y <= 2.3e-142) tmp = Float64(x / z); elseif (y <= 5e-114) tmp = Float64(Float64(-y) / z); elseif ((y <= 2.5e-30) || !(y <= 100000000000.0)) tmp = t_0; else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -7.4e-111) tmp = t_0; elseif (y <= 1.25e-203) tmp = x / z; elseif (y <= 1.26e-203) tmp = x / -y; elseif (y <= 2.3e-142) tmp = x / z; elseif (y <= 5e-114) tmp = -y / z; elseif ((y <= 2.5e-30) || ~((y <= 100000000000.0))) tmp = t_0; else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7.4e-111], t$95$0, If[LessEqual[y, 1.25e-203], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.26e-203], N[(x / (-y)), $MachinePrecision], If[LessEqual[y, 2.3e-142], N[(x / z), $MachinePrecision], If[LessEqual[y, 5e-114], N[((-y) / z), $MachinePrecision], If[Or[LessEqual[y, 2.5e-30], N[Not[LessEqual[y, 100000000000.0]], $MachinePrecision]], t$95$0, N[(x / z), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -7.4 \cdot 10^{-111}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{-203}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 1.26 \cdot 10^{-203}:\\
\;\;\;\;\frac{x}{-y}\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-142}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 5 \cdot 10^{-114}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-30} \lor \neg \left(y \leq 100000000000\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -7.4000000000000003e-111 or 4.99999999999999989e-114 < y < 2.49999999999999986e-30 or 1e11 < y Initial program 100.0%
Taylor expanded in z around 0 71.9%
div-sub71.9%
sub-neg71.9%
*-inverses71.9%
metadata-eval71.9%
distribute-lft-in71.9%
metadata-eval71.9%
+-commutative71.9%
mul-1-neg71.9%
unsub-neg71.9%
Simplified71.9%
if -7.4000000000000003e-111 < y < 1.25e-203 or 1.25999999999999998e-203 < y < 2.30000000000000002e-142 or 2.49999999999999986e-30 < y < 1e11Initial program 99.9%
Taylor expanded in y around 0 74.9%
if 1.25e-203 < y < 1.25999999999999998e-203Initial program 100.0%
Taylor expanded in x around inf 100.0%
Taylor expanded in z around 0 100.0%
associate-*r/100.0%
neg-mul-1100.0%
Simplified100.0%
if 2.30000000000000002e-142 < y < 4.99999999999999989e-114Initial program 100.0%
Taylor expanded in z around inf 95.6%
Taylor expanded in x around 0 59.4%
neg-mul-159.4%
distribute-neg-frac259.4%
Simplified59.4%
Final simplification72.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (- x y) z)) (t_1 (- 1.0 (/ x y))) (t_2 (/ x (- z y))))
(if (<= y -7e-19)
t_1
(if (<= y 1.25e-158)
t_2
(if (<= y 1.6e-113)
t_0
(if (<= y 1.05e-30)
t_2
(if (<= y 2700000000.0) t_0 (if (<= y 2.9e+137) t_2 t_1))))))))
double code(double x, double y, double z) {
double t_0 = (x - y) / z;
double t_1 = 1.0 - (x / y);
double t_2 = x / (z - y);
double tmp;
if (y <= -7e-19) {
tmp = t_1;
} else if (y <= 1.25e-158) {
tmp = t_2;
} else if (y <= 1.6e-113) {
tmp = t_0;
} else if (y <= 1.05e-30) {
tmp = t_2;
} else if (y <= 2700000000.0) {
tmp = t_0;
} else if (y <= 2.9e+137) {
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 = 1.0d0 - (x / y)
t_2 = x / (z - y)
if (y <= (-7d-19)) then
tmp = t_1
else if (y <= 1.25d-158) then
tmp = t_2
else if (y <= 1.6d-113) then
tmp = t_0
else if (y <= 1.05d-30) then
tmp = t_2
else if (y <= 2700000000.0d0) then
tmp = t_0
else if (y <= 2.9d+137) 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 = 1.0 - (x / y);
double t_2 = x / (z - y);
double tmp;
if (y <= -7e-19) {
tmp = t_1;
} else if (y <= 1.25e-158) {
tmp = t_2;
} else if (y <= 1.6e-113) {
tmp = t_0;
} else if (y <= 1.05e-30) {
tmp = t_2;
} else if (y <= 2700000000.0) {
tmp = t_0;
} else if (y <= 2.9e+137) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (x - y) / z t_1 = 1.0 - (x / y) t_2 = x / (z - y) tmp = 0 if y <= -7e-19: tmp = t_1 elif y <= 1.25e-158: tmp = t_2 elif y <= 1.6e-113: tmp = t_0 elif y <= 1.05e-30: tmp = t_2 elif y <= 2700000000.0: tmp = t_0 elif y <= 2.9e+137: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(x - y) / z) t_1 = Float64(1.0 - Float64(x / y)) t_2 = Float64(x / Float64(z - y)) tmp = 0.0 if (y <= -7e-19) tmp = t_1; elseif (y <= 1.25e-158) tmp = t_2; elseif (y <= 1.6e-113) tmp = t_0; elseif (y <= 1.05e-30) tmp = t_2; elseif (y <= 2700000000.0) tmp = t_0; elseif (y <= 2.9e+137) 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 = 1.0 - (x / y); t_2 = x / (z - y); tmp = 0.0; if (y <= -7e-19) tmp = t_1; elseif (y <= 1.25e-158) tmp = t_2; elseif (y <= 1.6e-113) tmp = t_0; elseif (y <= 1.05e-30) tmp = t_2; elseif (y <= 2700000000.0) tmp = t_0; elseif (y <= 2.9e+137) 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[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7e-19], t$95$1, If[LessEqual[y, 1.25e-158], t$95$2, If[LessEqual[y, 1.6e-113], t$95$0, If[LessEqual[y, 1.05e-30], t$95$2, If[LessEqual[y, 2700000000.0], t$95$0, If[LessEqual[y, 2.9e+137], t$95$2, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - y}{z}\\
t_1 := 1 - \frac{x}{y}\\
t_2 := \frac{x}{z - y}\\
\mathbf{if}\;y \leq -7 \cdot 10^{-19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{-158}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{-113}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-30}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 2700000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+137}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -7.00000000000000031e-19 or 2.89999999999999985e137 < y Initial program 100.0%
Taylor expanded in z around 0 84.3%
div-sub84.4%
sub-neg84.4%
*-inverses84.4%
metadata-eval84.4%
distribute-lft-in84.4%
metadata-eval84.4%
+-commutative84.4%
mul-1-neg84.4%
unsub-neg84.4%
Simplified84.4%
if -7.00000000000000031e-19 < y < 1.24999999999999993e-158 or 1.6000000000000001e-113 < y < 1.0500000000000001e-30 or 2.7e9 < y < 2.89999999999999985e137Initial program 100.0%
Taylor expanded in x around inf 80.4%
if 1.24999999999999993e-158 < y < 1.6000000000000001e-113 or 1.0500000000000001e-30 < y < 2.7e9Initial program 99.9%
Taylor expanded in z around inf 82.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ x (- y))))
(if (<= y -8.2e+151)
1.0
(if (<= y -1.15e+106)
t_0
(if (<= y -36000000000000.0)
1.0
(if (<= y 5.2e-5)
(/ x z)
(if (<= y 4.2e+95) (/ (- y) z) (if (<= y 7.5e+152) t_0 1.0))))))))
double code(double x, double y, double z) {
double t_0 = x / -y;
double tmp;
if (y <= -8.2e+151) {
tmp = 1.0;
} else if (y <= -1.15e+106) {
tmp = t_0;
} else if (y <= -36000000000000.0) {
tmp = 1.0;
} else if (y <= 5.2e-5) {
tmp = x / z;
} else if (y <= 4.2e+95) {
tmp = -y / z;
} else if (y <= 7.5e+152) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x / -y
if (y <= (-8.2d+151)) then
tmp = 1.0d0
else if (y <= (-1.15d+106)) then
tmp = t_0
else if (y <= (-36000000000000.0d0)) then
tmp = 1.0d0
else if (y <= 5.2d-5) then
tmp = x / z
else if (y <= 4.2d+95) then
tmp = -y / z
else if (y <= 7.5d+152) then
tmp = t_0
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x / -y;
double tmp;
if (y <= -8.2e+151) {
tmp = 1.0;
} else if (y <= -1.15e+106) {
tmp = t_0;
} else if (y <= -36000000000000.0) {
tmp = 1.0;
} else if (y <= 5.2e-5) {
tmp = x / z;
} else if (y <= 4.2e+95) {
tmp = -y / z;
} else if (y <= 7.5e+152) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): t_0 = x / -y tmp = 0 if y <= -8.2e+151: tmp = 1.0 elif y <= -1.15e+106: tmp = t_0 elif y <= -36000000000000.0: tmp = 1.0 elif y <= 5.2e-5: tmp = x / z elif y <= 4.2e+95: tmp = -y / z elif y <= 7.5e+152: tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y, z) t_0 = Float64(x / Float64(-y)) tmp = 0.0 if (y <= -8.2e+151) tmp = 1.0; elseif (y <= -1.15e+106) tmp = t_0; elseif (y <= -36000000000000.0) tmp = 1.0; elseif (y <= 5.2e-5) tmp = Float64(x / z); elseif (y <= 4.2e+95) tmp = Float64(Float64(-y) / z); elseif (y <= 7.5e+152) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x / -y; tmp = 0.0; if (y <= -8.2e+151) tmp = 1.0; elseif (y <= -1.15e+106) tmp = t_0; elseif (y <= -36000000000000.0) tmp = 1.0; elseif (y <= 5.2e-5) tmp = x / z; elseif (y <= 4.2e+95) tmp = -y / z; elseif (y <= 7.5e+152) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x / (-y)), $MachinePrecision]}, If[LessEqual[y, -8.2e+151], 1.0, If[LessEqual[y, -1.15e+106], t$95$0, If[LessEqual[y, -36000000000000.0], 1.0, If[LessEqual[y, 5.2e-5], N[(x / z), $MachinePrecision], If[LessEqual[y, 4.2e+95], N[((-y) / z), $MachinePrecision], If[LessEqual[y, 7.5e+152], t$95$0, 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{-y}\\
\mathbf{if}\;y \leq -8.2 \cdot 10^{+151}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.15 \cdot 10^{+106}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -36000000000000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{-5}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+95}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+152}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -8.1999999999999996e151 or -1.1500000000000001e106 < y < -3.6e13 or 7.50000000000000046e152 < y Initial program 100.0%
Taylor expanded in y around inf 75.0%
if -8.1999999999999996e151 < y < -1.1500000000000001e106 or 4.2e95 < y < 7.50000000000000046e152Initial program 100.0%
Taylor expanded in x around inf 79.1%
Taylor expanded in z around 0 57.0%
associate-*r/57.0%
neg-mul-157.0%
Simplified57.0%
if -3.6e13 < y < 5.19999999999999968e-5Initial program 99.9%
Taylor expanded in y around 0 59.3%
if 5.19999999999999968e-5 < y < 4.2e95Initial program 100.0%
Taylor expanded in z around inf 66.7%
Taylor expanded in x around 0 46.8%
neg-mul-146.8%
distribute-neg-frac246.8%
Simplified46.8%
Final simplification63.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))) (t_1 (- 1.0 (/ x y))) (t_2 (/ x (- z y))))
(if (<= y -7.8e-19)
t_1
(if (<= y 3.3e-49)
t_2
(if (<= y 8.5e+54)
t_0
(if (<= y 7.5e+152) t_2 (if (<= y 2.5e+249) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double t_1 = 1.0 - (x / y);
double t_2 = x / (z - y);
double tmp;
if (y <= -7.8e-19) {
tmp = t_1;
} else if (y <= 3.3e-49) {
tmp = t_2;
} else if (y <= 8.5e+54) {
tmp = t_0;
} else if (y <= 7.5e+152) {
tmp = t_2;
} else if (y <= 2.5e+249) {
tmp = t_0;
} 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 = y / (y - z)
t_1 = 1.0d0 - (x / y)
t_2 = x / (z - y)
if (y <= (-7.8d-19)) then
tmp = t_1
else if (y <= 3.3d-49) then
tmp = t_2
else if (y <= 8.5d+54) then
tmp = t_0
else if (y <= 7.5d+152) then
tmp = t_2
else if (y <= 2.5d+249) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / (y - z);
double t_1 = 1.0 - (x / y);
double t_2 = x / (z - y);
double tmp;
if (y <= -7.8e-19) {
tmp = t_1;
} else if (y <= 3.3e-49) {
tmp = t_2;
} else if (y <= 8.5e+54) {
tmp = t_0;
} else if (y <= 7.5e+152) {
tmp = t_2;
} else if (y <= 2.5e+249) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) t_1 = 1.0 - (x / y) t_2 = x / (z - y) tmp = 0 if y <= -7.8e-19: tmp = t_1 elif y <= 3.3e-49: tmp = t_2 elif y <= 8.5e+54: tmp = t_0 elif y <= 7.5e+152: tmp = t_2 elif y <= 2.5e+249: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(y - z)) t_1 = Float64(1.0 - Float64(x / y)) t_2 = Float64(x / Float64(z - y)) tmp = 0.0 if (y <= -7.8e-19) tmp = t_1; elseif (y <= 3.3e-49) tmp = t_2; elseif (y <= 8.5e+54) tmp = t_0; elseif (y <= 7.5e+152) tmp = t_2; elseif (y <= 2.5e+249) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (y - z); t_1 = 1.0 - (x / y); t_2 = x / (z - y); tmp = 0.0; if (y <= -7.8e-19) tmp = t_1; elseif (y <= 3.3e-49) tmp = t_2; elseif (y <= 8.5e+54) tmp = t_0; elseif (y <= 7.5e+152) tmp = t_2; elseif (y <= 2.5e+249) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7.8e-19], t$95$1, If[LessEqual[y, 3.3e-49], t$95$2, If[LessEqual[y, 8.5e+54], t$95$0, If[LessEqual[y, 7.5e+152], t$95$2, If[LessEqual[y, 2.5e+249], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
t_1 := 1 - \frac{x}{y}\\
t_2 := \frac{x}{z - y}\\
\mathbf{if}\;y \leq -7.8 \cdot 10^{-19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{-49}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{+54}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+152}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+249}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -7.7999999999999999e-19 or 2.4999999999999998e249 < y Initial program 100.0%
Taylor expanded in z around 0 84.5%
div-sub84.6%
sub-neg84.6%
*-inverses84.6%
metadata-eval84.6%
distribute-lft-in84.6%
metadata-eval84.6%
+-commutative84.6%
mul-1-neg84.6%
unsub-neg84.6%
Simplified84.6%
if -7.7999999999999999e-19 < y < 3.3e-49 or 8.4999999999999995e54 < y < 7.50000000000000046e152Initial program 100.0%
Taylor expanded in x around inf 80.1%
if 3.3e-49 < y < 8.4999999999999995e54 or 7.50000000000000046e152 < y < 2.4999999999999998e249Initial program 99.9%
Taylor expanded in x around 0 73.0%
neg-mul-173.0%
distribute-neg-frac73.0%
Simplified73.0%
frac-2neg73.0%
div-inv72.9%
remove-double-neg72.9%
sub-neg72.9%
distribute-neg-in72.9%
remove-double-neg72.9%
Applied egg-rr72.9%
associate-*r/73.0%
*-rgt-identity73.0%
+-commutative73.0%
unsub-neg73.0%
Simplified73.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ x (- z y))))
(if (<= y -5.5e-19)
t_0
(if (<= y 2.7e-31)
t_1
(if (<= y 16000000000.0)
(- (/ x z) (/ y z))
(if (<= y 2.9e+137) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double t_1 = x / (z - y);
double tmp;
if (y <= -5.5e-19) {
tmp = t_0;
} else if (y <= 2.7e-31) {
tmp = t_1;
} else if (y <= 16000000000.0) {
tmp = (x / z) - (y / z);
} else if (y <= 2.9e+137) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
t_1 = x / (z - y)
if (y <= (-5.5d-19)) then
tmp = t_0
else if (y <= 2.7d-31) then
tmp = t_1
else if (y <= 16000000000.0d0) then
tmp = (x / z) - (y / z)
else if (y <= 2.9d+137) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double t_1 = x / (z - y);
double tmp;
if (y <= -5.5e-19) {
tmp = t_0;
} else if (y <= 2.7e-31) {
tmp = t_1;
} else if (y <= 16000000000.0) {
tmp = (x / z) - (y / z);
} else if (y <= 2.9e+137) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) t_1 = x / (z - y) tmp = 0 if y <= -5.5e-19: tmp = t_0 elif y <= 2.7e-31: tmp = t_1 elif y <= 16000000000.0: tmp = (x / z) - (y / z) elif y <= 2.9e+137: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) t_1 = Float64(x / Float64(z - y)) tmp = 0.0 if (y <= -5.5e-19) tmp = t_0; elseif (y <= 2.7e-31) tmp = t_1; elseif (y <= 16000000000.0) tmp = Float64(Float64(x / z) - Float64(y / z)); elseif (y <= 2.9e+137) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); t_1 = x / (z - y); tmp = 0.0; if (y <= -5.5e-19) tmp = t_0; elseif (y <= 2.7e-31) tmp = t_1; elseif (y <= 16000000000.0) tmp = (x / z) - (y / z); elseif (y <= 2.9e+137) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.5e-19], t$95$0, If[LessEqual[y, 2.7e-31], t$95$1, If[LessEqual[y, 16000000000.0], N[(N[(x / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.9e+137], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
t_1 := \frac{x}{z - y}\\
\mathbf{if}\;y \leq -5.5 \cdot 10^{-19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-31}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 16000000000:\\
\;\;\;\;\frac{x}{z} - \frac{y}{z}\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+137}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.4999999999999996e-19 or 2.89999999999999985e137 < y Initial program 100.0%
Taylor expanded in z around 0 84.3%
div-sub84.4%
sub-neg84.4%
*-inverses84.4%
metadata-eval84.4%
distribute-lft-in84.4%
metadata-eval84.4%
+-commutative84.4%
mul-1-neg84.4%
unsub-neg84.4%
Simplified84.4%
if -5.4999999999999996e-19 < y < 2.70000000000000014e-31 or 1.6e10 < y < 2.89999999999999985e137Initial program 100.0%
Taylor expanded in x around inf 78.0%
if 2.70000000000000014e-31 < y < 1.6e10Initial program 99.8%
Taylor expanded in z around inf 76.3%
div-sub76.4%
Applied egg-rr76.4%
(FPCore (x y z) :precision binary64 (if (<= y -2.85e+23) 1.0 (if (<= y 2.9e-5) (/ x z) (if (<= y 3.2e+86) (/ (- y) z) 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.85e+23) {
tmp = 1.0;
} else if (y <= 2.9e-5) {
tmp = x / z;
} else if (y <= 3.2e+86) {
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 <= (-2.85d+23)) then
tmp = 1.0d0
else if (y <= 2.9d-5) then
tmp = x / z
else if (y <= 3.2d+86) 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 <= -2.85e+23) {
tmp = 1.0;
} else if (y <= 2.9e-5) {
tmp = x / z;
} else if (y <= 3.2e+86) {
tmp = -y / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.85e+23: tmp = 1.0 elif y <= 2.9e-5: tmp = x / z elif y <= 3.2e+86: tmp = -y / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.85e+23) tmp = 1.0; elseif (y <= 2.9e-5) tmp = Float64(x / z); elseif (y <= 3.2e+86) 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 <= -2.85e+23) tmp = 1.0; elseif (y <= 2.9e-5) tmp = x / z; elseif (y <= 3.2e+86) tmp = -y / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.85e+23], 1.0, If[LessEqual[y, 2.9e-5], N[(x / z), $MachinePrecision], If[LessEqual[y, 3.2e+86], N[((-y) / z), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.85 \cdot 10^{+23}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{-5}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+86}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.85e23 or 3.2e86 < y Initial program 100.0%
Taylor expanded in y around inf 64.1%
if -2.85e23 < y < 2.9e-5Initial program 99.9%
Taylor expanded in y around 0 58.1%
if 2.9e-5 < y < 3.2e86Initial program 100.0%
Taylor expanded in z around inf 66.7%
Taylor expanded in x around 0 46.8%
neg-mul-146.8%
distribute-neg-frac246.8%
Simplified46.8%
Final simplification59.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.05e-19) (not (<= y 2e+112))) (- 1.0 (/ x y)) (/ x (- z y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.05e-19) || !(y <= 2e+112)) {
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 <= (-2.05d-19)) .or. (.not. (y <= 2d+112))) 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 <= -2.05e-19) || !(y <= 2e+112)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (z - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.05e-19) or not (y <= 2e+112): tmp = 1.0 - (x / y) else: tmp = x / (z - y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.05e-19) || !(y <= 2e+112)) 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 <= -2.05e-19) || ~((y <= 2e+112))) tmp = 1.0 - (x / y); else tmp = x / (z - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.05e-19], N[Not[LessEqual[y, 2e+112]], $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 -2.05 \cdot 10^{-19} \lor \neg \left(y \leq 2 \cdot 10^{+112}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z - y}\\
\end{array}
\end{array}
if y < -2.04999999999999993e-19 or 1.9999999999999999e112 < y Initial program 100.0%
Taylor expanded in z around 0 83.1%
div-sub83.1%
sub-neg83.1%
*-inverses83.1%
metadata-eval83.1%
distribute-lft-in83.1%
metadata-eval83.1%
+-commutative83.1%
mul-1-neg83.1%
unsub-neg83.1%
Simplified83.1%
if -2.04999999999999993e-19 < y < 1.9999999999999999e112Initial program 99.9%
Taylor expanded in x around inf 74.9%
Final simplification78.3%
(FPCore (x y z) :precision binary64 (if (<= y -6e+30) 1.0 (if (<= y 2e+112) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -6e+30) {
tmp = 1.0;
} else if (y <= 2e+112) {
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 <= (-6d+30)) then
tmp = 1.0d0
else if (y <= 2d+112) 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 <= -6e+30) {
tmp = 1.0;
} else if (y <= 2e+112) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6e+30: tmp = 1.0 elif y <= 2e+112: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6e+30) tmp = 1.0; elseif (y <= 2e+112) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6e+30) tmp = 1.0; elseif (y <= 2e+112) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6e+30], 1.0, If[LessEqual[y, 2e+112], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{+30}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2 \cdot 10^{+112}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.99999999999999956e30 or 1.9999999999999999e112 < y Initial program 100.0%
Taylor expanded in y around inf 66.0%
if -5.99999999999999956e30 < y < 1.9999999999999999e112Initial program 99.9%
Taylor expanded in y around 0 54.2%
(FPCore (x y z) :precision binary64 (/ (- y x) (- y z)))
double code(double x, double y, double z) {
return (y - 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 - x) / (y - z)
end function
public static double code(double x, double y, double z) {
return (y - x) / (y - z);
}
def code(x, y, z): return (y - x) / (y - z)
function code(x, y, z) return Float64(Float64(y - x) / Float64(y - z)) end
function tmp = code(x, y, z) tmp = (y - x) / (y - z); end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y - x}{y - z}
\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%
Taylor expanded in y around inf 32.1%
(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 2024107
(FPCore (x y z)
:name "Graphics.Rasterific.Shading:$sgradientColorAt from Rasterific-0.6.1"
:precision binary64
:alt
(- (/ x (- z y)) (/ y (- z y)))
(/ (- x y) (- z y)))