
(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 (/ x (- y))))
(if (<= y -3e+144)
1.0
(if (<= y -2.1e+80)
t_0
(if (<= y -4.5e-20)
1.0
(if (<= y 2.7e-5)
(/ x z)
(if (<= y 3.9e+102) (/ 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 <= -3e+144) {
tmp = 1.0;
} else if (y <= -2.1e+80) {
tmp = t_0;
} else if (y <= -4.5e-20) {
tmp = 1.0;
} else if (y <= 2.7e-5) {
tmp = x / z;
} else if (y <= 3.9e+102) {
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 <= (-3d+144)) then
tmp = 1.0d0
else if (y <= (-2.1d+80)) then
tmp = t_0
else if (y <= (-4.5d-20)) then
tmp = 1.0d0
else if (y <= 2.7d-5) then
tmp = x / z
else if (y <= 3.9d+102) 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 <= -3e+144) {
tmp = 1.0;
} else if (y <= -2.1e+80) {
tmp = t_0;
} else if (y <= -4.5e-20) {
tmp = 1.0;
} else if (y <= 2.7e-5) {
tmp = x / z;
} else if (y <= 3.9e+102) {
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 <= -3e+144: tmp = 1.0 elif y <= -2.1e+80: tmp = t_0 elif y <= -4.5e-20: tmp = 1.0 elif y <= 2.7e-5: tmp = x / z elif y <= 3.9e+102: 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 <= -3e+144) tmp = 1.0; elseif (y <= -2.1e+80) tmp = t_0; elseif (y <= -4.5e-20) tmp = 1.0; elseif (y <= 2.7e-5) tmp = Float64(x / z); elseif (y <= 3.9e+102) tmp = Float64(y / Float64(-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 <= -3e+144) tmp = 1.0; elseif (y <= -2.1e+80) tmp = t_0; elseif (y <= -4.5e-20) tmp = 1.0; elseif (y <= 2.7e-5) tmp = x / z; elseif (y <= 3.9e+102) 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, -3e+144], 1.0, If[LessEqual[y, -2.1e+80], t$95$0, If[LessEqual[y, -4.5e-20], 1.0, If[LessEqual[y, 2.7e-5], N[(x / z), $MachinePrecision], If[LessEqual[y, 3.9e+102], 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 -3 \cdot 10^{+144}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -2.1 \cdot 10^{+80}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -4.5 \cdot 10^{-20}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{-5}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{+102}:\\
\;\;\;\;\frac{y}{-z}\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+152}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.9999999999999999e144 or -2.10000000000000001e80 < y < -4.5000000000000001e-20 or 7.50000000000000046e152 < y Initial program 99.9%
Taylor expanded in y around inf 73.5%
if -2.9999999999999999e144 < y < -2.10000000000000001e80 or 3.8999999999999998e102 < y < 7.50000000000000046e152Initial program 100.0%
Taylor expanded in x around inf 78.1%
Taylor expanded in z around 0 58.2%
associate-*r/58.2%
neg-mul-158.2%
Simplified58.2%
if -4.5000000000000001e-20 < y < 2.6999999999999999e-5Initial program 99.9%
Taylor expanded in y around 0 61.9%
if 2.6999999999999999e-5 < y < 3.8999999999999998e102Initial 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 simplification64.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -9.5e-111)
t_0
(if (<= y 3.8e-119)
(/ x z)
(if (or (<= y 6.8e-25) (not (<= y 8e+51))) t_0 (/ y (- z)))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -9.5e-111) {
tmp = t_0;
} else if (y <= 3.8e-119) {
tmp = x / z;
} else if ((y <= 6.8e-25) || !(y <= 8e+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 <= (-9.5d-111)) then
tmp = t_0
else if (y <= 3.8d-119) then
tmp = x / z
else if ((y <= 6.8d-25) .or. (.not. (y <= 8d+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 <= -9.5e-111) {
tmp = t_0;
} else if (y <= 3.8e-119) {
tmp = x / z;
} else if ((y <= 6.8e-25) || !(y <= 8e+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 <= -9.5e-111: tmp = t_0 elif y <= 3.8e-119: tmp = x / z elif (y <= 6.8e-25) or not (y <= 8e+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 <= -9.5e-111) tmp = t_0; elseif (y <= 3.8e-119) tmp = Float64(x / z); elseif ((y <= 6.8e-25) || !(y <= 8e+51)) tmp = t_0; else tmp = Float64(y / Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -9.5e-111) tmp = t_0; elseif (y <= 3.8e-119) tmp = x / z; elseif ((y <= 6.8e-25) || ~((y <= 8e+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, -9.5e-111], t$95$0, If[LessEqual[y, 3.8e-119], N[(x / z), $MachinePrecision], If[Or[LessEqual[y, 6.8e-25], N[Not[LessEqual[y, 8e+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 -9.5 \cdot 10^{-111}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-119}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{-25} \lor \neg \left(y \leq 8 \cdot 10^{+51}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{-z}\\
\end{array}
\end{array}
if y < -9.4999999999999995e-111 or 3.79999999999999975e-119 < y < 6.80000000000000003e-25 or 8e51 < y Initial program 100.0%
Taylor expanded in z around 0 71.8%
div-sub71.8%
sub-neg71.8%
*-inverses71.8%
metadata-eval71.8%
distribute-lft-in71.8%
metadata-eval71.8%
+-commutative71.8%
mul-1-neg71.8%
unsub-neg71.8%
Simplified71.8%
if -9.4999999999999995e-111 < y < 3.79999999999999975e-119Initial program 99.9%
Taylor expanded in y around 0 76.2%
if 6.80000000000000003e-25 < y < 8e51Initial program 99.8%
Taylor expanded in z around inf 79.2%
Taylor expanded in x around 0 49.1%
neg-mul-149.1%
distribute-neg-frac249.1%
Simplified49.1%
Final simplification71.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))) (t_1 (/ x (- z y))))
(if (<= y -1.8e-19)
t_0
(if (<= y 2.9e-26)
t_1
(if (<= y 2.9e+55) (/ y (- 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 <= -1.8e-19) {
tmp = t_0;
} else if (y <= 2.9e-26) {
tmp = t_1;
} else if (y <= 2.9e+55) {
tmp = y / (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 <= (-1.8d-19)) then
tmp = t_0
else if (y <= 2.9d-26) then
tmp = t_1
else if (y <= 2.9d+55) then
tmp = y / (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 <= -1.8e-19) {
tmp = t_0;
} else if (y <= 2.9e-26) {
tmp = t_1;
} else if (y <= 2.9e+55) {
tmp = y / (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 <= -1.8e-19: tmp = t_0 elif y <= 2.9e-26: tmp = t_1 elif y <= 2.9e+55: tmp = y / (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 <= -1.8e-19) tmp = t_0; elseif (y <= 2.9e-26) tmp = t_1; elseif (y <= 2.9e+55) tmp = Float64(y / 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 <= -1.8e-19) tmp = t_0; elseif (y <= 2.9e-26) tmp = t_1; elseif (y <= 2.9e+55) tmp = y / (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, -1.8e-19], t$95$0, If[LessEqual[y, 2.9e-26], t$95$1, If[LessEqual[y, 2.9e+55], N[(y / 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 -1.8 \cdot 10^{-19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{-26}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+55}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+137}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.8000000000000001e-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 -1.8000000000000001e-19 < y < 2.8999999999999998e-26 or 2.8999999999999999e55 < y < 2.89999999999999985e137Initial program 100.0%
Taylor expanded in x around inf 79.0%
if 2.8999999999999998e-26 < y < 2.8999999999999999e55Initial program 99.8%
Taylor expanded in x around 0 65.8%
neg-mul-165.8%
distribute-neg-frac65.8%
Simplified65.8%
frac-2neg65.8%
div-inv65.6%
remove-double-neg65.6%
sub-neg65.6%
distribute-neg-in65.6%
remove-double-neg65.6%
Applied egg-rr65.6%
associate-*r/65.8%
*-rgt-identity65.8%
+-commutative65.8%
unsub-neg65.8%
Simplified65.8%
(FPCore (x y z)
:precision binary64
(if (<= y -2.4e-20)
1.0
(if (<= y 6.5e-5)
(/ x z)
(if (<= y 1.55e+108) (/ y (- z)) (if (<= y 2.9e+137) (/ 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 <= 6.5e-5) {
tmp = x / z;
} else if (y <= 1.55e+108) {
tmp = y / -z;
} else if (y <= 2.9e+137) {
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 <= 6.5d-5) then
tmp = x / z
else if (y <= 1.55d+108) then
tmp = y / -z
else if (y <= 2.9d+137) 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 <= 6.5e-5) {
tmp = x / z;
} else if (y <= 1.55e+108) {
tmp = y / -z;
} else if (y <= 2.9e+137) {
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 <= 6.5e-5: tmp = x / z elif y <= 1.55e+108: tmp = y / -z elif y <= 2.9e+137: 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 <= 6.5e-5) tmp = Float64(x / z); elseif (y <= 1.55e+108) tmp = Float64(y / Float64(-z)); elseif (y <= 2.9e+137) 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 <= 6.5e-5) tmp = x / z; elseif (y <= 1.55e+108) tmp = y / -z; elseif (y <= 2.9e+137) 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, 6.5e-5], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.55e+108], N[(y / (-z)), $MachinePrecision], If[LessEqual[y, 2.9e+137], 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 6.5 \cdot 10^{-5}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 1.55 \cdot 10^{+108}:\\
\;\;\;\;\frac{y}{-z}\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+137}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.39999999999999993e-20 or 2.89999999999999985e137 < y Initial program 100.0%
Taylor expanded in y around inf 65.5%
if -2.39999999999999993e-20 < y < 6.49999999999999943e-5 or 1.5500000000000001e108 < y < 2.89999999999999985e137Initial program 99.9%
Taylor expanded in y around 0 61.0%
if 6.49999999999999943e-5 < y < 1.5500000000000001e108Initial 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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -5.5e-19)
t_0
(if (<= y 2.3e-30)
(/ x (- z y))
(if (<= y 7e+119) (- (/ x z) (/ y z)) t_0)))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -5.5e-19) {
tmp = t_0;
} else if (y <= 2.3e-30) {
tmp = x / (z - y);
} else if (y <= 7e+119) {
tmp = (x / z) - (y / z);
} 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) :: tmp
t_0 = 1.0d0 - (x / y)
if (y <= (-5.5d-19)) then
tmp = t_0
else if (y <= 2.3d-30) then
tmp = x / (z - y)
else if (y <= 7d+119) then
tmp = (x / z) - (y / z)
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 tmp;
if (y <= -5.5e-19) {
tmp = t_0;
} else if (y <= 2.3e-30) {
tmp = x / (z - y);
} else if (y <= 7e+119) {
tmp = (x / z) - (y / z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -5.5e-19: tmp = t_0 elif y <= 2.3e-30: tmp = x / (z - y) elif y <= 7e+119: tmp = (x / z) - (y / z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -5.5e-19) tmp = t_0; elseif (y <= 2.3e-30) tmp = Float64(x / Float64(z - y)); elseif (y <= 7e+119) tmp = Float64(Float64(x / z) - Float64(y / z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -5.5e-19) tmp = t_0; elseif (y <= 2.3e-30) tmp = x / (z - y); elseif (y <= 7e+119) tmp = (x / z) - (y / z); 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]}, If[LessEqual[y, -5.5e-19], t$95$0, If[LessEqual[y, 2.3e-30], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7e+119], N[(N[(x / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -5.5 \cdot 10^{-19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-30}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{elif}\;y \leq 7 \cdot 10^{+119}:\\
\;\;\;\;\frac{x}{z} - \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.4999999999999996e-19 or 7.0000000000000001e119 < y Initial program 100.0%
Taylor expanded in z around 0 83.8%
div-sub83.9%
sub-neg83.9%
*-inverses83.9%
metadata-eval83.9%
distribute-lft-in83.9%
metadata-eval83.9%
+-commutative83.9%
mul-1-neg83.9%
unsub-neg83.9%
Simplified83.9%
if -5.4999999999999996e-19 < y < 2.29999999999999984e-30Initial program 99.9%
Taylor expanded in x around inf 80.5%
if 2.29999999999999984e-30 < y < 7.0000000000000001e119Initial program 99.9%
Taylor expanded in z around inf 69.5%
div-sub69.6%
Applied egg-rr69.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -5.5e-19)
t_0
(if (<= y 2.5e-30) (/ x (- z y)) (if (<= y 7e+119) (/ (- x y) z) t_0)))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -5.5e-19) {
tmp = t_0;
} else if (y <= 2.5e-30) {
tmp = x / (z - y);
} else if (y <= 7e+119) {
tmp = (x - y) / z;
} 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) :: tmp
t_0 = 1.0d0 - (x / y)
if (y <= (-5.5d-19)) then
tmp = t_0
else if (y <= 2.5d-30) then
tmp = x / (z - y)
else if (y <= 7d+119) then
tmp = (x - y) / z
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 tmp;
if (y <= -5.5e-19) {
tmp = t_0;
} else if (y <= 2.5e-30) {
tmp = x / (z - y);
} else if (y <= 7e+119) {
tmp = (x - y) / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -5.5e-19: tmp = t_0 elif y <= 2.5e-30: tmp = x / (z - y) elif y <= 7e+119: tmp = (x - y) / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -5.5e-19) tmp = t_0; elseif (y <= 2.5e-30) tmp = Float64(x / Float64(z - y)); elseif (y <= 7e+119) tmp = Float64(Float64(x - y) / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -5.5e-19) tmp = t_0; elseif (y <= 2.5e-30) tmp = x / (z - y); elseif (y <= 7e+119) tmp = (x - y) / z; 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]}, If[LessEqual[y, -5.5e-19], t$95$0, If[LessEqual[y, 2.5e-30], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7e+119], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -5.5 \cdot 10^{-19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-30}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{elif}\;y \leq 7 \cdot 10^{+119}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -5.4999999999999996e-19 or 7.0000000000000001e119 < y Initial program 100.0%
Taylor expanded in z around 0 83.8%
div-sub83.9%
sub-neg83.9%
*-inverses83.9%
metadata-eval83.9%
distribute-lft-in83.9%
metadata-eval83.9%
+-commutative83.9%
mul-1-neg83.9%
unsub-neg83.9%
Simplified83.9%
if -5.4999999999999996e-19 < y < 2.49999999999999986e-30Initial program 99.9%
Taylor expanded in x around inf 80.5%
if 2.49999999999999986e-30 < y < 7.0000000000000001e119Initial program 99.9%
Taylor expanded in z around inf 69.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.05e-19) (not (<= y 2.9e+137))) (- 1.0 (/ x y)) (/ x (- z y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.05e-19) || !(y <= 2.9e+137)) {
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 <= 2.9d+137))) 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 <= 2.9e+137)) {
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 <= 2.9e+137): 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 <= 2.9e+137)) 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 <= 2.9e+137))) 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, 2.9e+137]], $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.9 \cdot 10^{+137}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z - y}\\
\end{array}
\end{array}
if y < -2.04999999999999993e-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 -2.04999999999999993e-19 < y < 2.89999999999999985e137Initial program 99.9%
Taylor expanded in x around inf 74.9%
Final simplification78.7%
(FPCore (x y z) :precision binary64 (if (<= y -5.1e-20) 1.0 (if (<= y 2.9e+137) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.1e-20) {
tmp = 1.0;
} else if (y <= 2.9e+137) {
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 <= (-5.1d-20)) then
tmp = 1.0d0
else if (y <= 2.9d+137) 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 <= -5.1e-20) {
tmp = 1.0;
} else if (y <= 2.9e+137) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.1e-20: tmp = 1.0 elif y <= 2.9e+137: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.1e-20) tmp = 1.0; elseif (y <= 2.9e+137) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.1e-20) tmp = 1.0; elseif (y <= 2.9e+137) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.1e-20], 1.0, If[LessEqual[y, 2.9e+137], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.1 \cdot 10^{-20}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+137}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.10000000000000019e-20 or 2.89999999999999985e137 < y Initial program 100.0%
Taylor expanded in y around inf 65.5%
if -5.10000000000000019e-20 < y < 2.89999999999999985e137Initial program 99.9%
Taylor expanded in y around 0 56.4%
(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)))