
(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
(if (<= y -1300.0)
1.0
(if (<= y -3.5e-129)
(/ (- x) y)
(if (<= y 2.6e-98)
(/ x z)
(if (<= y 4.5e-27) (/ (- y) z) (if (<= y 1.52e+35) (/ x z) 1.0))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1300.0) {
tmp = 1.0;
} else if (y <= -3.5e-129) {
tmp = -x / y;
} else if (y <= 2.6e-98) {
tmp = x / z;
} else if (y <= 4.5e-27) {
tmp = -y / z;
} else if (y <= 1.52e+35) {
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 <= (-1300.0d0)) then
tmp = 1.0d0
else if (y <= (-3.5d-129)) then
tmp = -x / y
else if (y <= 2.6d-98) then
tmp = x / z
else if (y <= 4.5d-27) then
tmp = -y / z
else if (y <= 1.52d+35) 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 <= -1300.0) {
tmp = 1.0;
} else if (y <= -3.5e-129) {
tmp = -x / y;
} else if (y <= 2.6e-98) {
tmp = x / z;
} else if (y <= 4.5e-27) {
tmp = -y / z;
} else if (y <= 1.52e+35) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1300.0: tmp = 1.0 elif y <= -3.5e-129: tmp = -x / y elif y <= 2.6e-98: tmp = x / z elif y <= 4.5e-27: tmp = -y / z elif y <= 1.52e+35: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1300.0) tmp = 1.0; elseif (y <= -3.5e-129) tmp = Float64(Float64(-x) / y); elseif (y <= 2.6e-98) tmp = Float64(x / z); elseif (y <= 4.5e-27) tmp = Float64(Float64(-y) / z); elseif (y <= 1.52e+35) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1300.0) tmp = 1.0; elseif (y <= -3.5e-129) tmp = -x / y; elseif (y <= 2.6e-98) tmp = x / z; elseif (y <= 4.5e-27) tmp = -y / z; elseif (y <= 1.52e+35) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1300.0], 1.0, If[LessEqual[y, -3.5e-129], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 2.6e-98], N[(x / z), $MachinePrecision], If[LessEqual[y, 4.5e-27], N[((-y) / z), $MachinePrecision], If[LessEqual[y, 1.52e+35], N[(x / z), $MachinePrecision], 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1300:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -3.5 \cdot 10^{-129}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{-98}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{-27}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{elif}\;y \leq 1.52 \cdot 10^{+35}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1300 or 1.5200000000000001e35 < 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 58.7%
if -1300 < y < -3.4999999999999997e-129Initial program 99.9%
sub-neg99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
sub-neg99.9%
neg-mul-199.9%
associate-/r*99.9%
div-sub99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.9%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.9%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
unsub-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around inf 67.1%
neg-mul-167.1%
distribute-neg-frac67.1%
Simplified67.1%
Taylor expanded in y around inf 42.9%
associate-*r/42.9%
mul-1-neg42.9%
Simplified42.9%
if -3.4999999999999997e-129 < y < 2.60000000000000013e-98 or 4.5000000000000002e-27 < y < 1.5200000000000001e35Initial 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*100.0%
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 84.5%
if 2.60000000000000013e-98 < y < 4.5000000000000002e-27Initial 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*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 83.5%
associate-*r/83.5%
sub-neg83.5%
mul-1-neg83.5%
distribute-lft-in83.5%
neg-mul-183.5%
neg-mul-183.5%
mul-1-neg83.5%
remove-double-neg83.5%
+-commutative83.5%
unsub-neg83.5%
Simplified83.5%
Taylor expanded in x around 0 66.6%
neg-mul-166.6%
distribute-neg-frac66.6%
Simplified66.6%
Final simplification66.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -3.5e-129)
t_0
(if (<= y 2.6e-98)
(/ x z)
(if (or (<= y 1e+61) (not (<= y 1.75e+174))) (/ y (- y z)) t_0)))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -3.5e-129) {
tmp = t_0;
} else if (y <= 2.6e-98) {
tmp = x / z;
} else if ((y <= 1e+61) || !(y <= 1.75e+174)) {
tmp = y / (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 <= (-3.5d-129)) then
tmp = t_0
else if (y <= 2.6d-98) then
tmp = x / z
else if ((y <= 1d+61) .or. (.not. (y <= 1.75d+174))) then
tmp = y / (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 <= -3.5e-129) {
tmp = t_0;
} else if (y <= 2.6e-98) {
tmp = x / z;
} else if ((y <= 1e+61) || !(y <= 1.75e+174)) {
tmp = y / (y - z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -3.5e-129: tmp = t_0 elif y <= 2.6e-98: tmp = x / z elif (y <= 1e+61) or not (y <= 1.75e+174): tmp = y / (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 <= -3.5e-129) tmp = t_0; elseif (y <= 2.6e-98) tmp = Float64(x / z); elseif ((y <= 1e+61) || !(y <= 1.75e+174)) tmp = Float64(y / 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 <= -3.5e-129) tmp = t_0; elseif (y <= 2.6e-98) tmp = x / z; elseif ((y <= 1e+61) || ~((y <= 1.75e+174))) tmp = y / (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, -3.5e-129], t$95$0, If[LessEqual[y, 2.6e-98], N[(x / z), $MachinePrecision], If[Or[LessEqual[y, 1e+61], N[Not[LessEqual[y, 1.75e+174]], $MachinePrecision]], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -3.5 \cdot 10^{-129}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{-98}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 10^{+61} \lor \neg \left(y \leq 1.75 \cdot 10^{+174}\right):\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -3.4999999999999997e-129 or 9.99999999999999949e60 < y < 1.7500000000000001e174Initial 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 72.5%
div-sub72.5%
*-inverses72.5%
Simplified72.5%
if -3.4999999999999997e-129 < y < 2.60000000000000013e-98Initial 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.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
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 87.3%
if 2.60000000000000013e-98 < y < 9.99999999999999949e60 or 1.7500000000000001e174 < 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.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 0 73.6%
Final simplification77.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -1.95e-131)
t_0
(if (<= y 2.6e-98)
(/ x z)
(if (<= y 3.6e-27) (/ (- y) z) (if (<= y 1.75e+31) (/ x z) t_0))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -1.95e-131) {
tmp = t_0;
} else if (y <= 2.6e-98) {
tmp = x / z;
} else if (y <= 3.6e-27) {
tmp = -y / z;
} else if (y <= 1.75e+31) {
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 = 1.0d0 - (x / y)
if (y <= (-1.95d-131)) then
tmp = t_0
else if (y <= 2.6d-98) then
tmp = x / z
else if (y <= 3.6d-27) then
tmp = -y / z
else if (y <= 1.75d+31) 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 = 1.0 - (x / y);
double tmp;
if (y <= -1.95e-131) {
tmp = t_0;
} else if (y <= 2.6e-98) {
tmp = x / z;
} else if (y <= 3.6e-27) {
tmp = -y / z;
} else if (y <= 1.75e+31) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -1.95e-131: tmp = t_0 elif y <= 2.6e-98: tmp = x / z elif y <= 3.6e-27: tmp = -y / z elif y <= 1.75e+31: tmp = x / 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 <= -1.95e-131) tmp = t_0; elseif (y <= 2.6e-98) tmp = Float64(x / z); elseif (y <= 3.6e-27) tmp = Float64(Float64(-y) / z); elseif (y <= 1.75e+31) tmp = Float64(x / 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 <= -1.95e-131) tmp = t_0; elseif (y <= 2.6e-98) tmp = x / z; elseif (y <= 3.6e-27) tmp = -y / z; elseif (y <= 1.75e+31) tmp = x / 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, -1.95e-131], t$95$0, If[LessEqual[y, 2.6e-98], N[(x / z), $MachinePrecision], If[LessEqual[y, 3.6e-27], N[((-y) / z), $MachinePrecision], If[LessEqual[y, 1.75e+31], N[(x / z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -1.95 \cdot 10^{-131}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{-98}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-27}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{elif}\;y \leq 1.75 \cdot 10^{+31}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.9500000000000001e-131 or 1.75e31 < 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 z around 0 72.4%
div-sub72.4%
*-inverses72.4%
Simplified72.4%
if -1.9500000000000001e-131 < y < 2.60000000000000013e-98 or 3.5999999999999999e-27 < y < 1.75e31Initial 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.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
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 85.3%
if 2.60000000000000013e-98 < y < 3.5999999999999999e-27Initial 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*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
Taylor expanded in z around inf 83.5%
associate-*r/83.5%
sub-neg83.5%
mul-1-neg83.5%
distribute-lft-in83.5%
neg-mul-183.5%
neg-mul-183.5%
mul-1-neg83.5%
remove-double-neg83.5%
+-commutative83.5%
unsub-neg83.5%
Simplified83.5%
Taylor expanded in x around 0 66.6%
neg-mul-166.6%
distribute-neg-frac66.6%
Simplified66.6%
Final simplification76.7%
(FPCore (x y z) :precision binary64 (if (<= y -1050000.0) 1.0 (if (<= y -2.5e-130) (/ (- x) y) (if (<= y 2.35e+35) (/ x z) 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1050000.0) {
tmp = 1.0;
} else if (y <= -2.5e-130) {
tmp = -x / y;
} else if (y <= 2.35e+35) {
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 <= (-1050000.0d0)) then
tmp = 1.0d0
else if (y <= (-2.5d-130)) then
tmp = -x / y
else if (y <= 2.35d+35) 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 <= -1050000.0) {
tmp = 1.0;
} else if (y <= -2.5e-130) {
tmp = -x / y;
} else if (y <= 2.35e+35) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1050000.0: tmp = 1.0 elif y <= -2.5e-130: tmp = -x / y elif y <= 2.35e+35: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1050000.0) tmp = 1.0; elseif (y <= -2.5e-130) tmp = Float64(Float64(-x) / y); elseif (y <= 2.35e+35) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1050000.0) tmp = 1.0; elseif (y <= -2.5e-130) tmp = -x / y; elseif (y <= 2.35e+35) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1050000.0], 1.0, If[LessEqual[y, -2.5e-130], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 2.35e+35], N[(x / z), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1050000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -2.5 \cdot 10^{-130}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq 2.35 \cdot 10^{+35}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.05e6 or 2.35000000000000017e35 < 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 58.7%
if -1.05e6 < y < -2.4999999999999998e-130Initial program 99.9%
sub-neg99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
sub-neg99.9%
neg-mul-199.9%
associate-/r*99.9%
div-sub99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.9%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.9%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
unsub-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around inf 67.1%
neg-mul-167.1%
distribute-neg-frac67.1%
Simplified67.1%
Taylor expanded in y around inf 42.9%
associate-*r/42.9%
mul-1-neg42.9%
Simplified42.9%
if -2.4999999999999998e-130 < y < 2.35000000000000017e35Initial 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*100.0%
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 78.1%
Final simplification65.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -2200.0) (not (<= x 0.0006))) (/ (- x) (- y z)) (/ y (- y z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2200.0) || !(x <= 0.0006)) {
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 ((x <= (-2200.0d0)) .or. (.not. (x <= 0.0006d0))) 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 ((x <= -2200.0) || !(x <= 0.0006)) {
tmp = -x / (y - z);
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2200.0) or not (x <= 0.0006): tmp = -x / (y - z) else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2200.0) || !(x <= 0.0006)) 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 ((x <= -2200.0) || ~((x <= 0.0006))) tmp = -x / (y - z); else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2200.0], N[Not[LessEqual[x, 0.0006]], $MachinePrecision]], N[((-x) / N[(y - z), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2200 \lor \neg \left(x \leq 0.0006\right):\\
\;\;\;\;\frac{-x}{y - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if x < -2200 or 5.99999999999999947e-4 < x 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.8%
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 78.3%
neg-mul-178.3%
distribute-neg-frac78.3%
Simplified78.3%
if -2200 < x < 5.99999999999999947e-4Initial 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.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 82.0%
Final simplification80.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.4e-91) (not (<= y 7.6e+47))) (- 1.0 (/ x y)) (/ (- x y) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e-91) || !(y <= 7.6e+47)) {
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 <= (-3.4d-91)) .or. (.not. (y <= 7.6d+47))) 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 <= -3.4e-91) || !(y <= 7.6e+47)) {
tmp = 1.0 - (x / y);
} else {
tmp = (x - y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.4e-91) or not (y <= 7.6e+47): tmp = 1.0 - (x / y) else: tmp = (x - y) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.4e-91) || !(y <= 7.6e+47)) 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 <= -3.4e-91) || ~((y <= 7.6e+47))) tmp = 1.0 - (x / y); else tmp = (x - y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.4e-91], N[Not[LessEqual[y, 7.6e+47]], $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 -3.4 \cdot 10^{-91} \lor \neg \left(y \leq 7.6 \cdot 10^{+47}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{z}\\
\end{array}
\end{array}
if y < -3.40000000000000027e-91 or 7.6000000000000007e47 < 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 z around 0 74.7%
div-sub74.7%
*-inverses74.7%
Simplified74.7%
if -3.40000000000000027e-91 < y < 7.6000000000000007e47Initial 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*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
clear-num99.6%
inv-pow99.6%
Applied egg-rr99.6%
Taylor expanded in z around inf 86.6%
associate-*r/86.6%
sub-neg86.6%
mul-1-neg86.6%
distribute-lft-in86.6%
neg-mul-186.6%
neg-mul-186.6%
mul-1-neg86.6%
remove-double-neg86.6%
+-commutative86.6%
unsub-neg86.6%
Simplified86.6%
Final simplification80.1%
(FPCore (x y z) :precision binary64 (if (<= y -5.4e+36) 1.0 (if (<= y 1.26e+35) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.4e+36) {
tmp = 1.0;
} else if (y <= 1.26e+35) {
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.4d+36)) then
tmp = 1.0d0
else if (y <= 1.26d+35) 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.4e+36) {
tmp = 1.0;
} else if (y <= 1.26e+35) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.4e+36: tmp = 1.0 elif y <= 1.26e+35: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.4e+36) tmp = 1.0; elseif (y <= 1.26e+35) 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.4e+36) tmp = 1.0; elseif (y <= 1.26e+35) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.4e+36], 1.0, If[LessEqual[y, 1.26e+35], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.4 \cdot 10^{+36}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.26 \cdot 10^{+35}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -5.4000000000000002e36 or 1.26e35 < 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 60.7%
if -5.4000000000000002e36 < y < 1.26e35Initial 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.9%
Final simplification63.5%
(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 33.4%
Final simplification33.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 2024020
(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)))