
(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
(let* ((t_0 (+ 1.0 (/ z y))) (t_1 (/ (- y) z)))
(if (<= y -5e+93)
t_0
(if (<= y -6.5e-69)
t_1
(if (<= y 3.3e-51)
(/ x z)
(if (<= y 0.0002) 1.0 (if (<= y 2.4e+73) t_1 t_0)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z / y);
double t_1 = -y / z;
double tmp;
if (y <= -5e+93) {
tmp = t_0;
} else if (y <= -6.5e-69) {
tmp = t_1;
} else if (y <= 3.3e-51) {
tmp = x / z;
} else if (y <= 0.0002) {
tmp = 1.0;
} else if (y <= 2.4e+73) {
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 + (z / y)
t_1 = -y / z
if (y <= (-5d+93)) then
tmp = t_0
else if (y <= (-6.5d-69)) then
tmp = t_1
else if (y <= 3.3d-51) then
tmp = x / z
else if (y <= 0.0002d0) then
tmp = 1.0d0
else if (y <= 2.4d+73) 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 + (z / y);
double t_1 = -y / z;
double tmp;
if (y <= -5e+93) {
tmp = t_0;
} else if (y <= -6.5e-69) {
tmp = t_1;
} else if (y <= 3.3e-51) {
tmp = x / z;
} else if (y <= 0.0002) {
tmp = 1.0;
} else if (y <= 2.4e+73) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z / y) t_1 = -y / z tmp = 0 if y <= -5e+93: tmp = t_0 elif y <= -6.5e-69: tmp = t_1 elif y <= 3.3e-51: tmp = x / z elif y <= 0.0002: tmp = 1.0 elif y <= 2.4e+73: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z / y)) t_1 = Float64(Float64(-y) / z) tmp = 0.0 if (y <= -5e+93) tmp = t_0; elseif (y <= -6.5e-69) tmp = t_1; elseif (y <= 3.3e-51) tmp = Float64(x / z); elseif (y <= 0.0002) tmp = 1.0; elseif (y <= 2.4e+73) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z / y); t_1 = -y / z; tmp = 0.0; if (y <= -5e+93) tmp = t_0; elseif (y <= -6.5e-69) tmp = t_1; elseif (y <= 3.3e-51) tmp = x / z; elseif (y <= 0.0002) tmp = 1.0; elseif (y <= 2.4e+73) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-y) / z), $MachinePrecision]}, If[LessEqual[y, -5e+93], t$95$0, If[LessEqual[y, -6.5e-69], t$95$1, If[LessEqual[y, 3.3e-51], N[(x / z), $MachinePrecision], If[LessEqual[y, 0.0002], 1.0, If[LessEqual[y, 2.4e+73], t$95$1, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{z}{y}\\
t_1 := \frac{-y}{z}\\
\mathbf{if}\;y \leq -5 \cdot 10^{+93}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{-69}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{-51}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 0.0002:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+73}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -5.0000000000000001e93 or 2.40000000000000002e73 < 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 y around inf 86.7%
associate--l+86.7%
distribute-lft-out--86.7%
div-sub86.7%
mul-1-neg86.7%
unsub-neg86.7%
Simplified86.7%
Taylor expanded in x around 0 66.7%
neg-mul-166.7%
distribute-neg-frac66.7%
Simplified66.7%
div-inv66.7%
cancel-sign-sub66.7%
div-inv66.7%
+-commutative66.7%
Applied egg-rr66.7%
if -5.0000000000000001e93 < y < -6.49999999999999951e-69 or 2.0000000000000001e-4 < y < 2.40000000000000002e73Initial 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%
Taylor expanded in z around inf 62.6%
associate-*r/62.6%
neg-mul-162.6%
neg-sub062.6%
associate--r-62.6%
neg-sub062.6%
Simplified62.6%
Taylor expanded in y around inf 48.8%
mul-1-neg48.8%
distribute-neg-frac48.8%
Simplified48.8%
if -6.49999999999999951e-69 < y < 3.29999999999999973e-51Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/98.6%
associate-/l*98.5%
neg-mul-198.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-out98.5%
remove-double-neg98.5%
sub-neg98.5%
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 0 84.4%
if 3.29999999999999973e-51 < y < 2.0000000000000001e-4Initial 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%
Taylor expanded in y around inf 60.5%
Final simplification69.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (- x y) z)) (t_1 (+ 1.0 (/ (- z x) y))))
(if (<= y -20000.0)
t_1
(if (<= y 1.1e-50)
t_0
(if (<= y 12200.0) (- 1.0 (/ x y)) (if (<= y 2.2e+71) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = (x - y) / z;
double t_1 = 1.0 + ((z - x) / y);
double tmp;
if (y <= -20000.0) {
tmp = t_1;
} else if (y <= 1.1e-50) {
tmp = t_0;
} else if (y <= 12200.0) {
tmp = 1.0 - (x / y);
} else if (y <= 2.2e+71) {
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) :: tmp
t_0 = (x - y) / z
t_1 = 1.0d0 + ((z - x) / y)
if (y <= (-20000.0d0)) then
tmp = t_1
else if (y <= 1.1d-50) then
tmp = t_0
else if (y <= 12200.0d0) then
tmp = 1.0d0 - (x / y)
else if (y <= 2.2d+71) 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 = (x - y) / z;
double t_1 = 1.0 + ((z - x) / y);
double tmp;
if (y <= -20000.0) {
tmp = t_1;
} else if (y <= 1.1e-50) {
tmp = t_0;
} else if (y <= 12200.0) {
tmp = 1.0 - (x / y);
} else if (y <= 2.2e+71) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (x - y) / z t_1 = 1.0 + ((z - x) / y) tmp = 0 if y <= -20000.0: tmp = t_1 elif y <= 1.1e-50: tmp = t_0 elif y <= 12200.0: tmp = 1.0 - (x / y) elif y <= 2.2e+71: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(x - y) / z) t_1 = Float64(1.0 + Float64(Float64(z - x) / y)) tmp = 0.0 if (y <= -20000.0) tmp = t_1; elseif (y <= 1.1e-50) tmp = t_0; elseif (y <= 12200.0) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 2.2e+71) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - y) / z; t_1 = 1.0 + ((z - x) / y); tmp = 0.0; if (y <= -20000.0) tmp = t_1; elseif (y <= 1.1e-50) tmp = t_0; elseif (y <= 12200.0) tmp = 1.0 - (x / y); elseif (y <= 2.2e+71) tmp = t_0; 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[(N[(z - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -20000.0], t$95$1, If[LessEqual[y, 1.1e-50], t$95$0, If[LessEqual[y, 12200.0], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.2e+71], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - y}{z}\\
t_1 := 1 + \frac{z - x}{y}\\
\mathbf{if}\;y \leq -20000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-50}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 12200:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+71}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -2e4 or 2.19999999999999995e71 < 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 82.8%
associate--l+82.8%
distribute-lft-out--82.8%
div-sub82.8%
mul-1-neg82.8%
unsub-neg82.8%
Simplified82.8%
if -2e4 < y < 1.0999999999999999e-50 or 12200 < y < 2.19999999999999995e71Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/98.9%
associate-/l*98.8%
neg-mul-198.8%
sub-neg98.8%
+-commutative98.8%
distribute-neg-out98.8%
remove-double-neg98.8%
sub-neg98.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 inf 86.4%
associate-*r/86.4%
neg-mul-186.4%
neg-sub086.4%
associate--r-86.4%
neg-sub086.4%
Simplified86.4%
Taylor expanded in y around 0 86.4%
+-commutative86.4%
mul-1-neg86.4%
sub-neg86.4%
div-sub86.4%
Simplified86.4%
if 1.0999999999999999e-50 < y < 12200Initial 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%
Taylor expanded in z around 0 87.1%
div-sub87.1%
*-inverses87.1%
Simplified87.1%
Final simplification84.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (- y) z)))
(if (<= y -3.35e+93)
1.0
(if (<= y -6.5e-69)
t_0
(if (<= y 4.25e-50)
(/ x z)
(if (<= y 9e-5) 1.0 (if (<= y 5.2e+54) t_0 1.0)))))))
double code(double x, double y, double z) {
double t_0 = -y / z;
double tmp;
if (y <= -3.35e+93) {
tmp = 1.0;
} else if (y <= -6.5e-69) {
tmp = t_0;
} else if (y <= 4.25e-50) {
tmp = x / z;
} else if (y <= 9e-5) {
tmp = 1.0;
} else if (y <= 5.2e+54) {
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 = -y / z
if (y <= (-3.35d+93)) then
tmp = 1.0d0
else if (y <= (-6.5d-69)) then
tmp = t_0
else if (y <= 4.25d-50) then
tmp = x / z
else if (y <= 9d-5) then
tmp = 1.0d0
else if (y <= 5.2d+54) 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 = -y / z;
double tmp;
if (y <= -3.35e+93) {
tmp = 1.0;
} else if (y <= -6.5e-69) {
tmp = t_0;
} else if (y <= 4.25e-50) {
tmp = x / z;
} else if (y <= 9e-5) {
tmp = 1.0;
} else if (y <= 5.2e+54) {
tmp = t_0;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): t_0 = -y / z tmp = 0 if y <= -3.35e+93: tmp = 1.0 elif y <= -6.5e-69: tmp = t_0 elif y <= 4.25e-50: tmp = x / z elif y <= 9e-5: tmp = 1.0 elif y <= 5.2e+54: tmp = t_0 else: tmp = 1.0 return tmp
function code(x, y, z) t_0 = Float64(Float64(-y) / z) tmp = 0.0 if (y <= -3.35e+93) tmp = 1.0; elseif (y <= -6.5e-69) tmp = t_0; elseif (y <= 4.25e-50) tmp = Float64(x / z); elseif (y <= 9e-5) tmp = 1.0; elseif (y <= 5.2e+54) tmp = t_0; else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -y / z; tmp = 0.0; if (y <= -3.35e+93) tmp = 1.0; elseif (y <= -6.5e-69) tmp = t_0; elseif (y <= 4.25e-50) tmp = x / z; elseif (y <= 9e-5) tmp = 1.0; elseif (y <= 5.2e+54) tmp = t_0; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-y) / z), $MachinePrecision]}, If[LessEqual[y, -3.35e+93], 1.0, If[LessEqual[y, -6.5e-69], t$95$0, If[LessEqual[y, 4.25e-50], N[(x / z), $MachinePrecision], If[LessEqual[y, 9e-5], 1.0, If[LessEqual[y, 5.2e+54], t$95$0, 1.0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-y}{z}\\
\mathbf{if}\;y \leq -3.35 \cdot 10^{+93}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{-69}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4.25 \cdot 10^{-50}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 9 \cdot 10^{-5}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{+54}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.34999999999999983e93 or 4.25000000000000006e-50 < y < 9.00000000000000057e-5 or 5.20000000000000013e54 < 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 y around inf 63.6%
if -3.34999999999999983e93 < y < -6.49999999999999951e-69 or 9.00000000000000057e-5 < y < 5.20000000000000013e54Initial 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%
Taylor expanded in z around inf 65.1%
associate-*r/65.1%
neg-mul-165.1%
neg-sub065.1%
associate--r-65.1%
neg-sub065.1%
Simplified65.1%
Taylor expanded in y around inf 51.9%
mul-1-neg51.9%
distribute-neg-frac51.9%
Simplified51.9%
if -6.49999999999999951e-69 < y < 4.25000000000000006e-50Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/98.6%
associate-/l*98.5%
neg-mul-198.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-out98.5%
remove-double-neg98.5%
sub-neg98.5%
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 0 84.4%
Final simplification69.4%
(FPCore (x y z)
:precision binary64
(if (or (<= y -92000.0)
(not (or (<= y 9e-52) (and (not (<= y 0.000155)) (<= y 1.45e+52)))))
(- 1.0 (/ x y))
(/ (- x y) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -92000.0) || !((y <= 9e-52) || (!(y <= 0.000155) && (y <= 1.45e+52)))) {
tmp = 1.0 - (x / y);
} else {
tmp = (x - 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 <= (-92000.0d0)) .or. (.not. (y <= 9d-52) .or. (.not. (y <= 0.000155d0)) .and. (y <= 1.45d+52))) then
tmp = 1.0d0 - (x / y)
else
tmp = (x - y) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -92000.0) || !((y <= 9e-52) || (!(y <= 0.000155) && (y <= 1.45e+52)))) {
tmp = 1.0 - (x / y);
} else {
tmp = (x - y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -92000.0) or not ((y <= 9e-52) or (not (y <= 0.000155) and (y <= 1.45e+52))): tmp = 1.0 - (x / y) else: tmp = (x - y) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -92000.0) || !((y <= 9e-52) || (!(y <= 0.000155) && (y <= 1.45e+52)))) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(Float64(x - y) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -92000.0) || ~(((y <= 9e-52) || (~((y <= 0.000155)) && (y <= 1.45e+52))))) tmp = 1.0 - (x / y); else tmp = (x - y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -92000.0], N[Not[Or[LessEqual[y, 9e-52], And[N[Not[LessEqual[y, 0.000155]], $MachinePrecision], LessEqual[y, 1.45e+52]]]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -92000 \lor \neg \left(y \leq 9 \cdot 10^{-52} \lor \neg \left(y \leq 0.000155\right) \land y \leq 1.45 \cdot 10^{+52}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{z}\\
\end{array}
\end{array}
if y < -92000 or 9.0000000000000001e-52 < y < 1.55e-4 or 1.45e52 < 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 81.7%
div-sub81.7%
*-inverses81.7%
Simplified81.7%
if -92000 < y < 9.0000000000000001e-52 or 1.55e-4 < y < 1.45e52Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/98.8%
associate-/l*98.7%
neg-mul-198.7%
sub-neg98.7%
+-commutative98.7%
distribute-neg-out98.7%
remove-double-neg98.7%
sub-neg98.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%
Taylor expanded in z around inf 87.5%
associate-*r/87.5%
neg-mul-187.5%
neg-sub087.5%
associate--r-87.5%
neg-sub087.5%
Simplified87.5%
Taylor expanded in y around 0 87.5%
+-commutative87.5%
mul-1-neg87.5%
sub-neg87.5%
div-sub87.5%
Simplified87.5%
Final simplification84.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -3.2e-49)
t_0
(if (<= y 1.45e-50)
(/ x z)
(if (or (<= y 6.5e+23) (not (<= y 1.4e+51))) t_0 (/ (- y) z))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -3.2e-49) {
tmp = t_0;
} else if (y <= 1.45e-50) {
tmp = x / z;
} else if ((y <= 6.5e+23) || !(y <= 1.4e+51)) {
tmp = t_0;
} else {
tmp = -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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
if (y <= (-3.2d-49)) then
tmp = t_0
else if (y <= 1.45d-50) then
tmp = x / z
else if ((y <= 6.5d+23) .or. (.not. (y <= 1.4d+51))) then
tmp = t_0
else
tmp = -y / 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 <= -3.2e-49) {
tmp = t_0;
} else if (y <= 1.45e-50) {
tmp = x / z;
} else if ((y <= 6.5e+23) || !(y <= 1.4e+51)) {
tmp = t_0;
} else {
tmp = -y / z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -3.2e-49: tmp = t_0 elif y <= 1.45e-50: tmp = x / z elif (y <= 6.5e+23) or not (y <= 1.4e+51): tmp = t_0 else: tmp = -y / z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -3.2e-49) tmp = t_0; elseif (y <= 1.45e-50) tmp = Float64(x / z); elseif ((y <= 6.5e+23) || !(y <= 1.4e+51)) tmp = t_0; else tmp = Float64(Float64(-y) / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -3.2e-49) tmp = t_0; elseif (y <= 1.45e-50) tmp = x / z; elseif ((y <= 6.5e+23) || ~((y <= 1.4e+51))) tmp = t_0; else tmp = -y / 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, -3.2e-49], t$95$0, If[LessEqual[y, 1.45e-50], N[(x / z), $MachinePrecision], If[Or[LessEqual[y, 6.5e+23], N[Not[LessEqual[y, 1.4e+51]], $MachinePrecision]], t$95$0, N[((-y) / z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -3.2 \cdot 10^{-49}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{-50}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+23} \lor \neg \left(y \leq 1.4 \cdot 10^{+51}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-y}{z}\\
\end{array}
\end{array}
if y < -3.20000000000000002e-49 or 1.45000000000000004e-50 < y < 6.4999999999999996e23 or 1.40000000000000002e51 < 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 79.1%
div-sub79.1%
*-inverses79.1%
Simplified79.1%
if -3.20000000000000002e-49 < y < 1.45000000000000004e-50Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/98.7%
associate-/l*98.6%
neg-mul-198.6%
sub-neg98.6%
+-commutative98.6%
distribute-neg-out98.6%
remove-double-neg98.6%
sub-neg98.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 y around 0 81.0%
if 6.4999999999999996e23 < y < 1.40000000000000002e51Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.6%
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%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 88.2%
associate-*r/88.2%
neg-mul-188.2%
neg-sub088.2%
associate--r-88.2%
neg-sub088.2%
Simplified88.2%
Taylor expanded in y around inf 61.8%
mul-1-neg61.8%
distribute-neg-frac61.8%
Simplified61.8%
Final simplification79.3%
(FPCore (x y z) :precision binary64 (if (<= y -6e-71) (/ y (- y z)) (if (<= y 1.85e-50) (/ x z) (- 1.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6e-71) {
tmp = y / (y - z);
} else if (y <= 1.85e-50) {
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 <= (-6d-71)) then
tmp = y / (y - z)
else if (y <= 1.85d-50) 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 <= -6e-71) {
tmp = y / (y - z);
} else if (y <= 1.85e-50) {
tmp = x / z;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6e-71: tmp = y / (y - z) elif y <= 1.85e-50: tmp = x / z else: tmp = 1.0 - (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6e-71) tmp = Float64(y / Float64(y - z)); elseif (y <= 1.85e-50) 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 <= -6e-71) tmp = y / (y - z); elseif (y <= 1.85e-50) tmp = x / z; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6e-71], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.85e-50], N[(x / z), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{-71}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{-50}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -6.0000000000000003e-71Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
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*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 x around 0 76.8%
if -6.0000000000000003e-71 < y < 1.85e-50Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/98.6%
associate-/l*98.5%
neg-mul-198.5%
sub-neg98.5%
+-commutative98.5%
distribute-neg-out98.5%
remove-double-neg98.5%
sub-neg98.5%
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 0 84.4%
if 1.85e-50 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*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.7%
div-sub74.7%
*-inverses74.7%
Simplified74.7%
Final simplification78.9%
(FPCore (x y z) :precision binary64 (if (<= y -1.32e-48) 1.0 (if (<= y 1.05e-49) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.32e-48) {
tmp = 1.0;
} else if (y <= 1.05e-49) {
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 <= (-1.32d-48)) then
tmp = 1.0d0
else if (y <= 1.05d-49) 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 <= -1.32e-48) {
tmp = 1.0;
} else if (y <= 1.05e-49) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.32e-48: tmp = 1.0 elif y <= 1.05e-49: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.32e-48) tmp = 1.0; elseif (y <= 1.05e-49) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.32e-48) tmp = 1.0; elseif (y <= 1.05e-49) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.32e-48], 1.0, If[LessEqual[y, 1.05e-49], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.32 \cdot 10^{-48}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-49}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.32e-48 or 1.0499999999999999e-49 < 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 y around inf 52.9%
if -1.32e-48 < y < 1.0499999999999999e-49Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/98.7%
associate-/l*98.6%
neg-mul-198.6%
sub-neg98.6%
+-commutative98.6%
distribute-neg-out98.6%
remove-double-neg98.6%
sub-neg98.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 y around 0 81.0%
Final simplification64.2%
(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.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%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 33.6%
Final simplification33.6%
(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 2023271
(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)))