
(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 12 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 100.0%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- z))))
(if (<= y -1.7e+131)
1.0
(if (<= y -2.1e+80)
t_0
(if (<= y -3.6e-20)
1.0
(if (<= y 4.1e-41)
(/ x z)
(if (<= y 3.4e+14)
1.0
(if (<= y 1.8e+61)
t_0
(if (<= y 4.2e+181) (/ x (- y)) 1.0)))))))))
double code(double x, double y, double z) {
double t_0 = y / -z;
double tmp;
if (y <= -1.7e+131) {
tmp = 1.0;
} else if (y <= -2.1e+80) {
tmp = t_0;
} else if (y <= -3.6e-20) {
tmp = 1.0;
} else if (y <= 4.1e-41) {
tmp = x / z;
} else if (y <= 3.4e+14) {
tmp = 1.0;
} else if (y <= 1.8e+61) {
tmp = t_0;
} else if (y <= 4.2e+181) {
tmp = x / -y;
} 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 <= (-1.7d+131)) then
tmp = 1.0d0
else if (y <= (-2.1d+80)) then
tmp = t_0
else if (y <= (-3.6d-20)) then
tmp = 1.0d0
else if (y <= 4.1d-41) then
tmp = x / z
else if (y <= 3.4d+14) then
tmp = 1.0d0
else if (y <= 1.8d+61) then
tmp = t_0
else if (y <= 4.2d+181) then
tmp = x / -y
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 <= -1.7e+131) {
tmp = 1.0;
} else if (y <= -2.1e+80) {
tmp = t_0;
} else if (y <= -3.6e-20) {
tmp = 1.0;
} else if (y <= 4.1e-41) {
tmp = x / z;
} else if (y <= 3.4e+14) {
tmp = 1.0;
} else if (y <= 1.8e+61) {
tmp = t_0;
} else if (y <= 4.2e+181) {
tmp = x / -y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): t_0 = y / -z tmp = 0 if y <= -1.7e+131: tmp = 1.0 elif y <= -2.1e+80: tmp = t_0 elif y <= -3.6e-20: tmp = 1.0 elif y <= 4.1e-41: tmp = x / z elif y <= 3.4e+14: tmp = 1.0 elif y <= 1.8e+61: tmp = t_0 elif y <= 4.2e+181: tmp = x / -y else: tmp = 1.0 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(-z)) tmp = 0.0 if (y <= -1.7e+131) tmp = 1.0; elseif (y <= -2.1e+80) tmp = t_0; elseif (y <= -3.6e-20) tmp = 1.0; elseif (y <= 4.1e-41) tmp = Float64(x / z); elseif (y <= 3.4e+14) tmp = 1.0; elseif (y <= 1.8e+61) tmp = t_0; elseif (y <= 4.2e+181) tmp = Float64(x / Float64(-y)); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / -z; tmp = 0.0; if (y <= -1.7e+131) tmp = 1.0; elseif (y <= -2.1e+80) tmp = t_0; elseif (y <= -3.6e-20) tmp = 1.0; elseif (y <= 4.1e-41) tmp = x / z; elseif (y <= 3.4e+14) tmp = 1.0; elseif (y <= 1.8e+61) tmp = t_0; elseif (y <= 4.2e+181) tmp = x / -y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / (-z)), $MachinePrecision]}, If[LessEqual[y, -1.7e+131], 1.0, If[LessEqual[y, -2.1e+80], t$95$0, If[LessEqual[y, -3.6e-20], 1.0, If[LessEqual[y, 4.1e-41], N[(x / z), $MachinePrecision], If[LessEqual[y, 3.4e+14], 1.0, If[LessEqual[y, 1.8e+61], t$95$0, If[LessEqual[y, 4.2e+181], N[(x / (-y)), $MachinePrecision], 1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{-z}\\
\mathbf{if}\;y \leq -1.7 \cdot 10^{+131}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -2.1 \cdot 10^{+80}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -3.6 \cdot 10^{-20}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{-41}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+14}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+61}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+181}:\\
\;\;\;\;\frac{x}{-y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.69999999999999993e131 or -2.10000000000000001e80 < y < -3.59999999999999974e-20 or 4.10000000000000014e-41 < y < 3.4e14 or 4.19999999999999995e181 < y Initial program 100.0%
Taylor expanded in y around inf 76.7%
if -1.69999999999999993e131 < y < -2.10000000000000001e80 or 3.4e14 < y < 1.80000000000000005e61Initial program 99.8%
div-sub99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 68.8%
Taylor expanded in x around 0 52.5%
associate-*r/52.5%
neg-mul-152.5%
Simplified52.5%
if -3.59999999999999974e-20 < y < 4.10000000000000014e-41Initial program 100.0%
Taylor expanded in y around 0 70.1%
if 1.80000000000000005e61 < y < 4.19999999999999995e181Initial program 99.9%
Taylor expanded in x around inf 56.2%
Taylor expanded in z around 0 48.0%
associate-*r/48.0%
neg-mul-148.0%
Simplified48.0%
Final simplification69.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- z))))
(if (<= y -3.4e+131)
(+ 1.0 (/ z y))
(if (<= y -2.15e+80)
t_0
(if (<= y -2.45e-20)
1.0
(if (<= y 4.1e-41)
(/ x z)
(if (<= y 25000000000000.0)
1.0
(if (<= y 2.7e+61)
t_0
(if (<= y 4.2e+181) (/ x (- y)) 1.0)))))))))
double code(double x, double y, double z) {
double t_0 = y / -z;
double tmp;
if (y <= -3.4e+131) {
tmp = 1.0 + (z / y);
} else if (y <= -2.15e+80) {
tmp = t_0;
} else if (y <= -2.45e-20) {
tmp = 1.0;
} else if (y <= 4.1e-41) {
tmp = x / z;
} else if (y <= 25000000000000.0) {
tmp = 1.0;
} else if (y <= 2.7e+61) {
tmp = t_0;
} else if (y <= 4.2e+181) {
tmp = x / -y;
} 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.4d+131)) then
tmp = 1.0d0 + (z / y)
else if (y <= (-2.15d+80)) then
tmp = t_0
else if (y <= (-2.45d-20)) then
tmp = 1.0d0
else if (y <= 4.1d-41) then
tmp = x / z
else if (y <= 25000000000000.0d0) then
tmp = 1.0d0
else if (y <= 2.7d+61) then
tmp = t_0
else if (y <= 4.2d+181) then
tmp = x / -y
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.4e+131) {
tmp = 1.0 + (z / y);
} else if (y <= -2.15e+80) {
tmp = t_0;
} else if (y <= -2.45e-20) {
tmp = 1.0;
} else if (y <= 4.1e-41) {
tmp = x / z;
} else if (y <= 25000000000000.0) {
tmp = 1.0;
} else if (y <= 2.7e+61) {
tmp = t_0;
} else if (y <= 4.2e+181) {
tmp = x / -y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): t_0 = y / -z tmp = 0 if y <= -3.4e+131: tmp = 1.0 + (z / y) elif y <= -2.15e+80: tmp = t_0 elif y <= -2.45e-20: tmp = 1.0 elif y <= 4.1e-41: tmp = x / z elif y <= 25000000000000.0: tmp = 1.0 elif y <= 2.7e+61: tmp = t_0 elif y <= 4.2e+181: tmp = x / -y else: tmp = 1.0 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(-z)) tmp = 0.0 if (y <= -3.4e+131) tmp = Float64(1.0 + Float64(z / y)); elseif (y <= -2.15e+80) tmp = t_0; elseif (y <= -2.45e-20) tmp = 1.0; elseif (y <= 4.1e-41) tmp = Float64(x / z); elseif (y <= 25000000000000.0) tmp = 1.0; elseif (y <= 2.7e+61) tmp = t_0; elseif (y <= 4.2e+181) tmp = Float64(x / Float64(-y)); 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.4e+131) tmp = 1.0 + (z / y); elseif (y <= -2.15e+80) tmp = t_0; elseif (y <= -2.45e-20) tmp = 1.0; elseif (y <= 4.1e-41) tmp = x / z; elseif (y <= 25000000000000.0) tmp = 1.0; elseif (y <= 2.7e+61) tmp = t_0; elseif (y <= 4.2e+181) tmp = x / -y; 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.4e+131], N[(1.0 + N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -2.15e+80], t$95$0, If[LessEqual[y, -2.45e-20], 1.0, If[LessEqual[y, 4.1e-41], N[(x / z), $MachinePrecision], If[LessEqual[y, 25000000000000.0], 1.0, If[LessEqual[y, 2.7e+61], t$95$0, If[LessEqual[y, 4.2e+181], N[(x / (-y)), $MachinePrecision], 1.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{-z}\\
\mathbf{if}\;y \leq -3.4 \cdot 10^{+131}:\\
\;\;\;\;1 + \frac{z}{y}\\
\mathbf{elif}\;y \leq -2.15 \cdot 10^{+80}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -2.45 \cdot 10^{-20}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{-41}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 25000000000000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+61}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+181}:\\
\;\;\;\;\frac{x}{-y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.39999999999999986e131Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 91.7%
associate-*r/91.7%
neg-mul-191.7%
Simplified91.7%
Taylor expanded in y around inf 83.7%
if -3.39999999999999986e131 < y < -2.15000000000000002e80 or 2.5e13 < y < 2.7000000000000002e61Initial program 99.8%
div-sub99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 68.8%
Taylor expanded in x around 0 52.5%
associate-*r/52.5%
neg-mul-152.5%
Simplified52.5%
if -2.15000000000000002e80 < y < -2.4500000000000001e-20 or 4.10000000000000014e-41 < y < 2.5e13 or 4.19999999999999995e181 < y Initial program 100.0%
Taylor expanded in y around inf 72.5%
if -2.4500000000000001e-20 < y < 4.10000000000000014e-41Initial program 100.0%
Taylor expanded in y around 0 70.1%
if 2.7000000000000002e61 < y < 4.19999999999999995e181Initial program 99.9%
Taylor expanded in x around inf 56.2%
Taylor expanded in z around 0 48.0%
associate-*r/48.0%
neg-mul-148.0%
Simplified48.0%
Final simplification69.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (- x y) z)))
(if (<= y -1.85e-19)
(/ y (- y z))
(if (<= y 7.2e-47)
t_0
(if (<= y 1.5e+15)
(- 1.0 (/ x y))
(if (<= y 4.1e+60) t_0 (+ 1.0 (/ (- z x) y))))))))
double code(double x, double y, double z) {
double t_0 = (x - y) / z;
double tmp;
if (y <= -1.85e-19) {
tmp = y / (y - z);
} else if (y <= 7.2e-47) {
tmp = t_0;
} else if (y <= 1.5e+15) {
tmp = 1.0 - (x / y);
} else if (y <= 4.1e+60) {
tmp = t_0;
} else {
tmp = 1.0 + ((z - 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) :: t_0
real(8) :: tmp
t_0 = (x - y) / z
if (y <= (-1.85d-19)) then
tmp = y / (y - z)
else if (y <= 7.2d-47) then
tmp = t_0
else if (y <= 1.5d+15) then
tmp = 1.0d0 - (x / y)
else if (y <= 4.1d+60) then
tmp = t_0
else
tmp = 1.0d0 + ((z - x) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x - y) / z;
double tmp;
if (y <= -1.85e-19) {
tmp = y / (y - z);
} else if (y <= 7.2e-47) {
tmp = t_0;
} else if (y <= 1.5e+15) {
tmp = 1.0 - (x / y);
} else if (y <= 4.1e+60) {
tmp = t_0;
} else {
tmp = 1.0 + ((z - x) / y);
}
return tmp;
}
def code(x, y, z): t_0 = (x - y) / z tmp = 0 if y <= -1.85e-19: tmp = y / (y - z) elif y <= 7.2e-47: tmp = t_0 elif y <= 1.5e+15: tmp = 1.0 - (x / y) elif y <= 4.1e+60: tmp = t_0 else: tmp = 1.0 + ((z - x) / y) return tmp
function code(x, y, z) t_0 = Float64(Float64(x - y) / z) tmp = 0.0 if (y <= -1.85e-19) tmp = Float64(y / Float64(y - z)); elseif (y <= 7.2e-47) tmp = t_0; elseif (y <= 1.5e+15) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 4.1e+60) tmp = t_0; else tmp = Float64(1.0 + Float64(Float64(z - x) / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - y) / z; tmp = 0.0; if (y <= -1.85e-19) tmp = y / (y - z); elseif (y <= 7.2e-47) tmp = t_0; elseif (y <= 1.5e+15) tmp = 1.0 - (x / y); elseif (y <= 4.1e+60) tmp = t_0; else tmp = 1.0 + ((z - x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -1.85e-19], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.2e-47], t$95$0, If[LessEqual[y, 1.5e+15], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.1e+60], t$95$0, N[(1.0 + N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - y}{z}\\
\mathbf{if}\;y \leq -1.85 \cdot 10^{-19}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{-47}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+15}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{+60}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{z - x}{y}\\
\end{array}
\end{array}
if y < -1.85000000000000003e-19Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 83.5%
associate-*r/83.5%
neg-mul-183.5%
Simplified83.5%
frac-2neg83.5%
div-inv83.4%
remove-double-neg83.4%
sub-neg83.4%
distribute-neg-in83.4%
remove-double-neg83.4%
Applied egg-rr83.4%
associate-*r/83.5%
*-rgt-identity83.5%
+-commutative83.5%
sub-neg83.5%
Simplified83.5%
if -1.85000000000000003e-19 < y < 7.19999999999999982e-47 or 1.5e15 < y < 4.1e60Initial program 99.9%
Taylor expanded in z around inf 84.0%
if 7.19999999999999982e-47 < y < 1.5e15Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in z around 0 82.4%
mul-1-neg82.4%
unsub-neg82.4%
Simplified82.4%
if 4.1e60 < y Initial program 99.9%
Taylor expanded in y around inf 88.3%
associate--l+88.3%
distribute-lft-out--88.3%
div-sub88.3%
mul-1-neg88.3%
unsub-neg88.3%
Simplified88.3%
Final simplification84.7%
(FPCore (x y z)
:precision binary64
(if (<= y -5.1e-19)
(/ y (- y z))
(if (<= y 3.4e-49)
(/ (- x y) z)
(if (<= y 66000000000000.0)
(- 1.0 (/ x y))
(if (<= y 4e+60) (- (/ x z) (/ y z)) (+ 1.0 (/ (- z x) y)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.1e-19) {
tmp = y / (y - z);
} else if (y <= 3.4e-49) {
tmp = (x - y) / z;
} else if (y <= 66000000000000.0) {
tmp = 1.0 - (x / y);
} else if (y <= 4e+60) {
tmp = (x / z) - (y / z);
} else {
tmp = 1.0 + ((z - 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 <= (-5.1d-19)) then
tmp = y / (y - z)
else if (y <= 3.4d-49) then
tmp = (x - y) / z
else if (y <= 66000000000000.0d0) then
tmp = 1.0d0 - (x / y)
else if (y <= 4d+60) then
tmp = (x / z) - (y / z)
else
tmp = 1.0d0 + ((z - x) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.1e-19) {
tmp = y / (y - z);
} else if (y <= 3.4e-49) {
tmp = (x - y) / z;
} else if (y <= 66000000000000.0) {
tmp = 1.0 - (x / y);
} else if (y <= 4e+60) {
tmp = (x / z) - (y / z);
} else {
tmp = 1.0 + ((z - x) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.1e-19: tmp = y / (y - z) elif y <= 3.4e-49: tmp = (x - y) / z elif y <= 66000000000000.0: tmp = 1.0 - (x / y) elif y <= 4e+60: tmp = (x / z) - (y / z) else: tmp = 1.0 + ((z - x) / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.1e-19) tmp = Float64(y / Float64(y - z)); elseif (y <= 3.4e-49) tmp = Float64(Float64(x - y) / z); elseif (y <= 66000000000000.0) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 4e+60) tmp = Float64(Float64(x / z) - Float64(y / z)); else tmp = Float64(1.0 + Float64(Float64(z - x) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.1e-19) tmp = y / (y - z); elseif (y <= 3.4e-49) tmp = (x - y) / z; elseif (y <= 66000000000000.0) tmp = 1.0 - (x / y); elseif (y <= 4e+60) tmp = (x / z) - (y / z); else tmp = 1.0 + ((z - x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.1e-19], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.4e-49], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 66000000000000.0], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4e+60], N[(N[(x / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.1 \cdot 10^{-19}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{-49}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{elif}\;y \leq 66000000000000:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 4 \cdot 10^{+60}:\\
\;\;\;\;\frac{x}{z} - \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{z - x}{y}\\
\end{array}
\end{array}
if y < -5.0999999999999998e-19Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 83.5%
associate-*r/83.5%
neg-mul-183.5%
Simplified83.5%
frac-2neg83.5%
div-inv83.4%
remove-double-neg83.4%
sub-neg83.4%
distribute-neg-in83.4%
remove-double-neg83.4%
Applied egg-rr83.4%
associate-*r/83.5%
*-rgt-identity83.5%
+-commutative83.5%
sub-neg83.5%
Simplified83.5%
if -5.0999999999999998e-19 < y < 3.40000000000000005e-49Initial program 100.0%
Taylor expanded in z around inf 84.5%
if 3.40000000000000005e-49 < y < 6.6e13Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in z around 0 82.4%
mul-1-neg82.4%
unsub-neg82.4%
Simplified82.4%
if 6.6e13 < y < 3.9999999999999998e60Initial program 99.8%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 79.1%
Taylor expanded in z around inf 79.5%
if 3.9999999999999998e60 < y Initial program 99.9%
Taylor expanded in y around inf 88.3%
associate--l+88.3%
distribute-lft-out--88.3%
div-sub88.3%
mul-1-neg88.3%
unsub-neg88.3%
Simplified88.3%
Final simplification84.8%
(FPCore (x y z)
:precision binary64
(if (or (<= x -8.6e+91)
(and (not (<= x 2.25e-42)) (or (<= x 1.55e-29) (not (<= x 5.8e+99)))))
(/ x (- z y))
(/ y (- y z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.6e+91) || (!(x <= 2.25e-42) && ((x <= 1.55e-29) || !(x <= 5.8e+99)))) {
tmp = x / (z - y);
} else {
tmp = y / (y - z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-8.6d+91)) .or. (.not. (x <= 2.25d-42)) .and. (x <= 1.55d-29) .or. (.not. (x <= 5.8d+99))) then
tmp = x / (z - y)
else
tmp = y / (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -8.6e+91) || (!(x <= 2.25e-42) && ((x <= 1.55e-29) || !(x <= 5.8e+99)))) {
tmp = x / (z - y);
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.6e+91) or (not (x <= 2.25e-42) and ((x <= 1.55e-29) or not (x <= 5.8e+99))): tmp = x / (z - y) else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.6e+91) || (!(x <= 2.25e-42) && ((x <= 1.55e-29) || !(x <= 5.8e+99)))) tmp = Float64(x / Float64(z - y)); else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -8.6e+91) || (~((x <= 2.25e-42)) && ((x <= 1.55e-29) || ~((x <= 5.8e+99))))) tmp = x / (z - y); else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.6e+91], And[N[Not[LessEqual[x, 2.25e-42]], $MachinePrecision], Or[LessEqual[x, 1.55e-29], N[Not[LessEqual[x, 5.8e+99]], $MachinePrecision]]]], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.6 \cdot 10^{+91} \lor \neg \left(x \leq 2.25 \cdot 10^{-42}\right) \land \left(x \leq 1.55 \cdot 10^{-29} \lor \neg \left(x \leq 5.8 \cdot 10^{+99}\right)\right):\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if x < -8.6000000000000001e91 or 2.25e-42 < x < 1.55000000000000013e-29 or 5.8000000000000004e99 < x Initial program 100.0%
Taylor expanded in x around inf 84.9%
if -8.6000000000000001e91 < x < 2.25e-42 or 1.55000000000000013e-29 < x < 5.8000000000000004e99Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 83.9%
associate-*r/83.9%
neg-mul-183.9%
Simplified83.9%
frac-2neg83.9%
div-inv83.7%
remove-double-neg83.7%
sub-neg83.7%
distribute-neg-in83.7%
remove-double-neg83.7%
Applied egg-rr83.7%
associate-*r/83.9%
*-rgt-identity83.9%
+-commutative83.9%
sub-neg83.9%
Simplified83.9%
Final simplification84.3%
(FPCore (x y z)
:precision binary64
(if (<= y -2.8e-19)
(/ y (- y z))
(if (or (<= y 1.05e-46) (and (not (<= y 1.35e+14)) (<= y 4.2e+60)))
(/ (- x y) z)
(- 1.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.8e-19) {
tmp = y / (y - z);
} else if ((y <= 1.05e-46) || (!(y <= 1.35e+14) && (y <= 4.2e+60))) {
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 <= (-2.8d-19)) then
tmp = y / (y - z)
else if ((y <= 1.05d-46) .or. (.not. (y <= 1.35d+14)) .and. (y <= 4.2d+60)) 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 <= -2.8e-19) {
tmp = y / (y - z);
} else if ((y <= 1.05e-46) || (!(y <= 1.35e+14) && (y <= 4.2e+60))) {
tmp = (x - y) / z;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.8e-19: tmp = y / (y - z) elif (y <= 1.05e-46) or (not (y <= 1.35e+14) and (y <= 4.2e+60)): tmp = (x - y) / z else: tmp = 1.0 - (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.8e-19) tmp = Float64(y / Float64(y - z)); elseif ((y <= 1.05e-46) || (!(y <= 1.35e+14) && (y <= 4.2e+60))) 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 <= -2.8e-19) tmp = y / (y - z); elseif ((y <= 1.05e-46) || (~((y <= 1.35e+14)) && (y <= 4.2e+60))) tmp = (x - y) / z; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.8e-19], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[y, 1.05e-46], And[N[Not[LessEqual[y, 1.35e+14]], $MachinePrecision], LessEqual[y, 4.2e+60]]], 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 -2.8 \cdot 10^{-19}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-46} \lor \neg \left(y \leq 1.35 \cdot 10^{+14}\right) \land y \leq 4.2 \cdot 10^{+60}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -2.80000000000000003e-19Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 83.5%
associate-*r/83.5%
neg-mul-183.5%
Simplified83.5%
frac-2neg83.5%
div-inv83.4%
remove-double-neg83.4%
sub-neg83.4%
distribute-neg-in83.4%
remove-double-neg83.4%
Applied egg-rr83.4%
associate-*r/83.5%
*-rgt-identity83.5%
+-commutative83.5%
sub-neg83.5%
Simplified83.5%
if -2.80000000000000003e-19 < y < 1.04999999999999994e-46 or 1.35e14 < y < 4.2000000000000002e60Initial program 99.9%
Taylor expanded in z around inf 84.0%
if 1.04999999999999994e-46 < y < 1.35e14 or 4.2000000000000002e60 < y Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in z around 0 86.9%
mul-1-neg86.9%
unsub-neg86.9%
Simplified86.9%
Final simplification84.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.3e-19) (not (<= y 1.95e-94))) (- 1.0 (/ x y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.3e-19) || !(y <= 1.95e-94)) {
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.3d-19)) .or. (.not. (y <= 1.95d-94))) 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.3e-19) || !(y <= 1.95e-94)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.3e-19) or not (y <= 1.95e-94): tmp = 1.0 - (x / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.3e-19) || !(y <= 1.95e-94)) 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.3e-19) || ~((y <= 1.95e-94))) tmp = 1.0 - (x / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.3e-19], N[Not[LessEqual[y, 1.95e-94]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.3 \cdot 10^{-19} \lor \neg \left(y \leq 1.95 \cdot 10^{-94}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -2.2999999999999998e-19 or 1.9500000000000001e-94 < y Initial program 99.9%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in z around 0 76.1%
mul-1-neg76.1%
unsub-neg76.1%
Simplified76.1%
if -2.2999999999999998e-19 < y < 1.9500000000000001e-94Initial program 100.0%
Taylor expanded in y around 0 73.2%
Final simplification75.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.3e-19) (not (<= y 7e-47))) (- 1.0 (/ x y)) (/ x (- z y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.3e-19) || !(y <= 7e-47)) {
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 <= (-3.3d-19)) .or. (.not. (y <= 7d-47))) 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 <= -3.3e-19) || !(y <= 7e-47)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (z - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.3e-19) or not (y <= 7e-47): tmp = 1.0 - (x / y) else: tmp = x / (z - y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.3e-19) || !(y <= 7e-47)) 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 <= -3.3e-19) || ~((y <= 7e-47))) tmp = 1.0 - (x / y); else tmp = x / (z - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.3e-19], N[Not[LessEqual[y, 7e-47]], $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 -3.3 \cdot 10^{-19} \lor \neg \left(y \leq 7 \cdot 10^{-47}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z - y}\\
\end{array}
\end{array}
if y < -3.2999999999999998e-19 or 6.9999999999999996e-47 < y Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in z around 0 78.1%
mul-1-neg78.1%
unsub-neg78.1%
Simplified78.1%
if -3.2999999999999998e-19 < y < 6.9999999999999996e-47Initial program 100.0%
Taylor expanded in x around inf 76.2%
Final simplification77.4%
(FPCore (x y z) :precision binary64 (if (<= y -2.4e-20) 1.0 (if (<= y 3.9e-41) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.4e-20) {
tmp = 1.0;
} else if (y <= 3.9e-41) {
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 <= (-2.4d-20)) then
tmp = 1.0d0
else if (y <= 3.9d-41) 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 <= -2.4e-20) {
tmp = 1.0;
} else if (y <= 3.9e-41) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.4e-20: tmp = 1.0 elif y <= 3.9e-41: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.4e-20) tmp = 1.0; elseif (y <= 3.9e-41) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.4e-20) tmp = 1.0; elseif (y <= 3.9e-41) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.4e-20], 1.0, If[LessEqual[y, 3.9e-41], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{-20}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{-41}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.39999999999999993e-20 or 3.89999999999999991e-41 < y Initial program 100.0%
Taylor expanded in y around inf 62.3%
if -2.39999999999999993e-20 < y < 3.89999999999999991e-41Initial program 100.0%
Taylor expanded in y around 0 70.1%
Final simplification65.3%
(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%
Taylor expanded in y around inf 42.4%
Final simplification42.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 2024046
(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)))