
(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 8 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 (/ (- x) y)))
(if (<= y -9.2e+62)
1.0
(if (<= y -1.12e+18)
t_0
(if (<= y -5.5e-37)
1.0
(if (<= y 2.1e-153)
(/ x z)
(if (<= y 1.05e+42) t_0 (if (<= y 1.65e+49) (/ x z) 1.0))))))))
double code(double x, double y, double z) {
double t_0 = -x / y;
double tmp;
if (y <= -9.2e+62) {
tmp = 1.0;
} else if (y <= -1.12e+18) {
tmp = t_0;
} else if (y <= -5.5e-37) {
tmp = 1.0;
} else if (y <= 2.1e-153) {
tmp = x / z;
} else if (y <= 1.05e+42) {
tmp = t_0;
} else if (y <= 1.65e+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) :: t_0
real(8) :: tmp
t_0 = -x / y
if (y <= (-9.2d+62)) then
tmp = 1.0d0
else if (y <= (-1.12d+18)) then
tmp = t_0
else if (y <= (-5.5d-37)) then
tmp = 1.0d0
else if (y <= 2.1d-153) then
tmp = x / z
else if (y <= 1.05d+42) then
tmp = t_0
else if (y <= 1.65d+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 t_0 = -x / y;
double tmp;
if (y <= -9.2e+62) {
tmp = 1.0;
} else if (y <= -1.12e+18) {
tmp = t_0;
} else if (y <= -5.5e-37) {
tmp = 1.0;
} else if (y <= 2.1e-153) {
tmp = x / z;
} else if (y <= 1.05e+42) {
tmp = t_0;
} else if (y <= 1.65e+49) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): t_0 = -x / y tmp = 0 if y <= -9.2e+62: tmp = 1.0 elif y <= -1.12e+18: tmp = t_0 elif y <= -5.5e-37: tmp = 1.0 elif y <= 2.1e-153: tmp = x / z elif y <= 1.05e+42: tmp = t_0 elif y <= 1.65e+49: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) t_0 = Float64(Float64(-x) / y) tmp = 0.0 if (y <= -9.2e+62) tmp = 1.0; elseif (y <= -1.12e+18) tmp = t_0; elseif (y <= -5.5e-37) tmp = 1.0; elseif (y <= 2.1e-153) tmp = Float64(x / z); elseif (y <= 1.05e+42) tmp = t_0; elseif (y <= 1.65e+49) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -x / y; tmp = 0.0; if (y <= -9.2e+62) tmp = 1.0; elseif (y <= -1.12e+18) tmp = t_0; elseif (y <= -5.5e-37) tmp = 1.0; elseif (y <= 2.1e-153) tmp = x / z; elseif (y <= 1.05e+42) tmp = t_0; elseif (y <= 1.65e+49) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[((-x) / y), $MachinePrecision]}, If[LessEqual[y, -9.2e+62], 1.0, If[LessEqual[y, -1.12e+18], t$95$0, If[LessEqual[y, -5.5e-37], 1.0, If[LessEqual[y, 2.1e-153], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.05e+42], t$95$0, If[LessEqual[y, 1.65e+49], N[(x / z), $MachinePrecision], 1.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-x}{y}\\
\mathbf{if}\;y \leq -9.2 \cdot 10^{+62}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -1.12 \cdot 10^{+18}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -5.5 \cdot 10^{-37}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{-153}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+42}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{+49}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -9.19999999999999936e62 or -1.12e18 < y < -5.4999999999999998e-37 or 1.6499999999999999e49 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 64.8%
if -9.19999999999999936e62 < y < -1.12e18 or 2.10000000000000004e-153 < y < 1.04999999999999998e42Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 58.9%
Taylor expanded in y around 0 43.9%
neg-mul-143.9%
distribute-neg-frac43.9%
Simplified43.9%
if -5.4999999999999998e-37 < y < 2.10000000000000004e-153 or 1.04999999999999998e42 < y < 1.6499999999999999e49Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 80.1%
Final simplification66.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))))
(if (<= y -1.55e-65)
t_0
(if (<= y 2.1e-153)
(/ x z)
(if (<= y 9.8e-80) (/ (- x) y) (if (<= y 2.85e-52) (/ x z) t_0))))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double tmp;
if (y <= -1.55e-65) {
tmp = t_0;
} else if (y <= 2.1e-153) {
tmp = x / z;
} else if (y <= 9.8e-80) {
tmp = -x / y;
} else if (y <= 2.85e-52) {
tmp = x / 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 = y / (y - z)
if (y <= (-1.55d-65)) then
tmp = t_0
else if (y <= 2.1d-153) then
tmp = x / z
else if (y <= 9.8d-80) then
tmp = -x / y
else if (y <= 2.85d-52) then
tmp = x / z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / (y - z);
double tmp;
if (y <= -1.55e-65) {
tmp = t_0;
} else if (y <= 2.1e-153) {
tmp = x / z;
} else if (y <= 9.8e-80) {
tmp = -x / y;
} else if (y <= 2.85e-52) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) tmp = 0 if y <= -1.55e-65: tmp = t_0 elif y <= 2.1e-153: tmp = x / z elif y <= 9.8e-80: tmp = -x / y elif y <= 2.85e-52: tmp = x / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(y - z)) tmp = 0.0 if (y <= -1.55e-65) tmp = t_0; elseif (y <= 2.1e-153) tmp = Float64(x / z); elseif (y <= 9.8e-80) tmp = Float64(Float64(-x) / y); elseif (y <= 2.85e-52) tmp = Float64(x / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (y - z); tmp = 0.0; if (y <= -1.55e-65) tmp = t_0; elseif (y <= 2.1e-153) tmp = x / z; elseif (y <= 9.8e-80) tmp = -x / y; elseif (y <= 2.85e-52) tmp = x / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.55e-65], t$95$0, If[LessEqual[y, 2.1e-153], N[(x / z), $MachinePrecision], If[LessEqual[y, 9.8e-80], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 2.85e-52], N[(x / z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
\mathbf{if}\;y \leq -1.55 \cdot 10^{-65}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{-153}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 9.8 \cdot 10^{-80}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq 2.85 \cdot 10^{-52}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.55000000000000008e-65 or 2.8499999999999999e-52 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 67.7%
if -1.55000000000000008e-65 < y < 2.10000000000000004e-153 or 9.79999999999999981e-80 < y < 2.8499999999999999e-52Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 79.0%
if 2.10000000000000004e-153 < y < 9.79999999999999981e-80Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 72.1%
Taylor expanded in y around 0 59.2%
neg-mul-159.2%
distribute-neg-frac59.2%
Simplified59.2%
Final simplification71.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))) (t_1 (/ (- x y) z)))
(if (<= y -3.8e-35)
t_0
(if (<= y 2.1e-153)
t_1
(if (<= y 3.3e-82) (/ (- x) y) (if (<= y 4.1e+49) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double t_1 = (x - y) / z;
double tmp;
if (y <= -3.8e-35) {
tmp = t_0;
} else if (y <= 2.1e-153) {
tmp = t_1;
} else if (y <= 3.3e-82) {
tmp = -x / y;
} else if (y <= 4.1e+49) {
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 = y / (y - z)
t_1 = (x - y) / z
if (y <= (-3.8d-35)) then
tmp = t_0
else if (y <= 2.1d-153) then
tmp = t_1
else if (y <= 3.3d-82) then
tmp = -x / y
else if (y <= 4.1d+49) 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 = y / (y - z);
double t_1 = (x - y) / z;
double tmp;
if (y <= -3.8e-35) {
tmp = t_0;
} else if (y <= 2.1e-153) {
tmp = t_1;
} else if (y <= 3.3e-82) {
tmp = -x / y;
} else if (y <= 4.1e+49) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) t_1 = (x - y) / z tmp = 0 if y <= -3.8e-35: tmp = t_0 elif y <= 2.1e-153: tmp = t_1 elif y <= 3.3e-82: tmp = -x / y elif y <= 4.1e+49: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(y - z)) t_1 = Float64(Float64(x - y) / z) tmp = 0.0 if (y <= -3.8e-35) tmp = t_0; elseif (y <= 2.1e-153) tmp = t_1; elseif (y <= 3.3e-82) tmp = Float64(Float64(-x) / y); elseif (y <= 4.1e+49) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (y - z); t_1 = (x - y) / z; tmp = 0.0; if (y <= -3.8e-35) tmp = t_0; elseif (y <= 2.1e-153) tmp = t_1; elseif (y <= 3.3e-82) tmp = -x / y; elseif (y <= 4.1e+49) tmp = t_1; else tmp = t_0; 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[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[y, -3.8e-35], t$95$0, If[LessEqual[y, 2.1e-153], t$95$1, If[LessEqual[y, 3.3e-82], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 4.1e+49], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
t_1 := \frac{x - y}{z}\\
\mathbf{if}\;y \leq -3.8 \cdot 10^{-35}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{-153}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 3.3 \cdot 10^{-82}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{+49}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -3.8000000000000001e-35 or 4.1e49 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 71.6%
if -3.8000000000000001e-35 < y < 2.10000000000000004e-153 or 3.30000000000000022e-82 < y < 4.1e49Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 79.9%
associate-*r/79.9%
neg-mul-179.9%
neg-sub079.9%
associate--r-79.9%
neg-sub079.9%
Simplified79.9%
Taylor expanded in y around 0 79.9%
+-commutative79.9%
mul-1-neg79.9%
sub-neg79.9%
div-sub79.9%
Simplified79.9%
if 2.10000000000000004e-153 < y < 3.30000000000000022e-82Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 72.1%
Taylor expanded in y around 0 59.2%
neg-mul-159.2%
distribute-neg-frac59.2%
Simplified59.2%
Final simplification74.7%
(FPCore (x y z) :precision binary64 (if (<= y -4.3e-35) (/ (- y x) y) (if (<= y 2.8e+94) (/ (- x) (- y z)) (/ y (- y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.3e-35) {
tmp = (y - x) / y;
} else if (y <= 2.8e+94) {
tmp = -x / (y - z);
} 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 (y <= (-4.3d-35)) then
tmp = (y - x) / y
else if (y <= 2.8d+94) then
tmp = -x / (y - z)
else
tmp = y / (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.3e-35) {
tmp = (y - x) / y;
} else if (y <= 2.8e+94) {
tmp = -x / (y - z);
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.3e-35: tmp = (y - x) / y elif y <= 2.8e+94: tmp = -x / (y - z) else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.3e-35) tmp = Float64(Float64(y - x) / y); elseif (y <= 2.8e+94) tmp = Float64(Float64(-x) / Float64(y - z)); else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.3e-35) tmp = (y - x) / y; elseif (y <= 2.8e+94) tmp = -x / (y - z); else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.3e-35], N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[y, 2.8e+94], N[((-x) / N[(y - z), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.3 \cdot 10^{-35}:\\
\;\;\;\;\frac{y - x}{y}\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{+94}:\\
\;\;\;\;\frac{-x}{y - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if y < -4.3000000000000002e-35Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 78.7%
if -4.3000000000000002e-35 < y < 2.79999999999999998e94Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 83.0%
neg-mul-183.0%
distribute-neg-frac83.0%
Simplified83.0%
if 2.79999999999999998e94 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.7%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 83.4%
Final simplification81.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -8.5e-61) (not (<= z 7.6e+74))) (/ (- x y) z) (/ (- y x) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8.5e-61) || !(z <= 7.6e+74)) {
tmp = (x - y) / z;
} else {
tmp = (y - x) / y;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-8.5d-61)) .or. (.not. (z <= 7.6d+74))) then
tmp = (x - y) / z
else
tmp = (y - x) / y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -8.5e-61) || !(z <= 7.6e+74)) {
tmp = (x - y) / z;
} else {
tmp = (y - x) / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8.5e-61) or not (z <= 7.6e+74): tmp = (x - y) / z else: tmp = (y - x) / y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8.5e-61) || !(z <= 7.6e+74)) tmp = Float64(Float64(x - y) / z); else tmp = Float64(Float64(y - x) / y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -8.5e-61) || ~((z <= 7.6e+74))) tmp = (x - y) / z; else tmp = (y - x) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8.5e-61], N[Not[LessEqual[z, 7.6e+74]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.5 \cdot 10^{-61} \lor \neg \left(z \leq 7.6 \cdot 10^{+74}\right):\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{y}\\
\end{array}
\end{array}
if z < -8.50000000000000016e-61 or 7.5999999999999997e74 < z Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 79.1%
associate-*r/79.1%
neg-mul-179.1%
neg-sub079.1%
associate--r-79.1%
neg-sub079.1%
Simplified79.1%
Taylor expanded in y around 0 79.1%
+-commutative79.1%
mul-1-neg79.1%
sub-neg79.1%
div-sub79.1%
Simplified79.1%
if -8.50000000000000016e-61 < z < 7.5999999999999997e74Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 81.4%
Final simplification80.4%
(FPCore (x y z) :precision binary64 (if (<= y -3.9e-38) 1.0 (if (<= y 1.45e+52) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.9e-38) {
tmp = 1.0;
} else if (y <= 1.45e+52) {
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 <= (-3.9d-38)) then
tmp = 1.0d0
else if (y <= 1.45d+52) 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 <= -3.9e-38) {
tmp = 1.0;
} else if (y <= 1.45e+52) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.9e-38: tmp = 1.0 elif y <= 1.45e+52: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.9e-38) tmp = 1.0; elseif (y <= 1.45e+52) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.9e-38) tmp = 1.0; elseif (y <= 1.45e+52) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.9e-38], 1.0, If[LessEqual[y, 1.45e+52], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.9 \cdot 10^{-38}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+52}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.8999999999999999e-38 or 1.45e52 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 59.6%
if -3.8999999999999999e-38 < y < 1.45e52Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 65.0%
Final simplification62.3%
(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%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 34.6%
Final simplification34.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 2024019
(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)))