
(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 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))) (t_1 (/ x (- z y))))
(if (<= y -1.35e+33)
t_0
(if (<= y -2.02e-23)
t_1
(if (<= y -2.95e-61)
t_0
(if (<= y 5.8e-35)
t_1
(if (<= y 4.4e+37)
t_0
(if (<= y 1.05e+80) t_1 (if (<= y 5.4e+90) 1.0 t_0)))))))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double t_1 = x / (z - y);
double tmp;
if (y <= -1.35e+33) {
tmp = t_0;
} else if (y <= -2.02e-23) {
tmp = t_1;
} else if (y <= -2.95e-61) {
tmp = t_0;
} else if (y <= 5.8e-35) {
tmp = t_1;
} else if (y <= 4.4e+37) {
tmp = t_0;
} else if (y <= 1.05e+80) {
tmp = t_1;
} else if (y <= 5.4e+90) {
tmp = 1.0;
} 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 / (z - y)
if (y <= (-1.35d+33)) then
tmp = t_0
else if (y <= (-2.02d-23)) then
tmp = t_1
else if (y <= (-2.95d-61)) then
tmp = t_0
else if (y <= 5.8d-35) then
tmp = t_1
else if (y <= 4.4d+37) then
tmp = t_0
else if (y <= 1.05d+80) then
tmp = t_1
else if (y <= 5.4d+90) then
tmp = 1.0d0
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 / (z - y);
double tmp;
if (y <= -1.35e+33) {
tmp = t_0;
} else if (y <= -2.02e-23) {
tmp = t_1;
} else if (y <= -2.95e-61) {
tmp = t_0;
} else if (y <= 5.8e-35) {
tmp = t_1;
} else if (y <= 4.4e+37) {
tmp = t_0;
} else if (y <= 1.05e+80) {
tmp = t_1;
} else if (y <= 5.4e+90) {
tmp = 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) t_1 = x / (z - y) tmp = 0 if y <= -1.35e+33: tmp = t_0 elif y <= -2.02e-23: tmp = t_1 elif y <= -2.95e-61: tmp = t_0 elif y <= 5.8e-35: tmp = t_1 elif y <= 4.4e+37: tmp = t_0 elif y <= 1.05e+80: tmp = t_1 elif y <= 5.4e+90: tmp = 1.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(y - z)) t_1 = Float64(x / Float64(z - y)) tmp = 0.0 if (y <= -1.35e+33) tmp = t_0; elseif (y <= -2.02e-23) tmp = t_1; elseif (y <= -2.95e-61) tmp = t_0; elseif (y <= 5.8e-35) tmp = t_1; elseif (y <= 4.4e+37) tmp = t_0; elseif (y <= 1.05e+80) tmp = t_1; elseif (y <= 5.4e+90) tmp = 1.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (y - z); t_1 = x / (z - y); tmp = 0.0; if (y <= -1.35e+33) tmp = t_0; elseif (y <= -2.02e-23) tmp = t_1; elseif (y <= -2.95e-61) tmp = t_0; elseif (y <= 5.8e-35) tmp = t_1; elseif (y <= 4.4e+37) tmp = t_0; elseif (y <= 1.05e+80) tmp = t_1; elseif (y <= 5.4e+90) tmp = 1.0; 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[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.35e+33], t$95$0, If[LessEqual[y, -2.02e-23], t$95$1, If[LessEqual[y, -2.95e-61], t$95$0, If[LessEqual[y, 5.8e-35], t$95$1, If[LessEqual[y, 4.4e+37], t$95$0, If[LessEqual[y, 1.05e+80], t$95$1, If[LessEqual[y, 5.4e+90], 1.0, t$95$0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
t_1 := \frac{x}{z - y}\\
\mathbf{if}\;y \leq -1.35 \cdot 10^{+33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2.02 \cdot 10^{-23}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -2.95 \cdot 10^{-61}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{-35}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{+37}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{+80}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 5.4 \cdot 10^{+90}:\\
\;\;\;\;1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -1.34999999999999996e33 or -2.02000000000000001e-23 < y < -2.94999999999999986e-61 or 5.8000000000000004e-35 < y < 4.4000000000000001e37 or 5.4e90 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.5%
associate-/l*99.5%
neg-mul-199.5%
sub-neg99.5%
+-commutative99.5%
distribute-neg-out99.5%
remove-double-neg99.5%
sub-neg99.5%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 85.5%
if -1.34999999999999996e33 < y < -2.02000000000000001e-23 or -2.94999999999999986e-61 < y < 5.8000000000000004e-35 or 4.4000000000000001e37 < y < 1.05000000000000001e80Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.4%
associate-/l*99.2%
neg-mul-199.2%
sub-neg99.2%
+-commutative99.2%
distribute-neg-out99.2%
remove-double-neg99.2%
sub-neg99.2%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 82.5%
neg-mul-182.5%
distribute-neg-frac82.5%
Simplified82.5%
Taylor expanded in x around 0 82.5%
*-commutative82.5%
associate-*l/82.5%
associate-*r/82.2%
metadata-eval82.2%
associate-/r*82.2%
neg-mul-182.2%
associate-*r/82.5%
*-rgt-identity82.5%
neg-sub082.5%
sub-neg82.5%
+-commutative82.5%
associate--r+82.5%
neg-sub082.5%
remove-double-neg82.5%
Simplified82.5%
if 1.05000000000000001e80 < y < 5.4e90Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.6%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.6%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 76.8%
Final simplification83.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -2.3e-9)
t_0
(if (<= y -9.5e-62)
(/ (- y) z)
(if (or (<= y -5.5e-64) (not (<= y 1.35e-42))) t_0 (/ x z))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -2.3e-9) {
tmp = t_0;
} else if (y <= -9.5e-62) {
tmp = -y / z;
} else if ((y <= -5.5e-64) || !(y <= 1.35e-42)) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
if (y <= (-2.3d-9)) then
tmp = t_0
else if (y <= (-9.5d-62)) then
tmp = -y / z
else if ((y <= (-5.5d-64)) .or. (.not. (y <= 1.35d-42))) then
tmp = t_0
else
tmp = x / 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 <= -2.3e-9) {
tmp = t_0;
} else if (y <= -9.5e-62) {
tmp = -y / z;
} else if ((y <= -5.5e-64) || !(y <= 1.35e-42)) {
tmp = t_0;
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -2.3e-9: tmp = t_0 elif y <= -9.5e-62: tmp = -y / z elif (y <= -5.5e-64) or not (y <= 1.35e-42): tmp = t_0 else: tmp = x / z return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -2.3e-9) tmp = t_0; elseif (y <= -9.5e-62) tmp = Float64(Float64(-y) / z); elseif ((y <= -5.5e-64) || !(y <= 1.35e-42)) tmp = t_0; else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -2.3e-9) tmp = t_0; elseif (y <= -9.5e-62) tmp = -y / z; elseif ((y <= -5.5e-64) || ~((y <= 1.35e-42))) tmp = t_0; else tmp = x / 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, -2.3e-9], t$95$0, If[LessEqual[y, -9.5e-62], N[((-y) / z), $MachinePrecision], If[Or[LessEqual[y, -5.5e-64], N[Not[LessEqual[y, 1.35e-42]], $MachinePrecision]], t$95$0, N[(x / z), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -2.3 \cdot 10^{-9}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -9.5 \cdot 10^{-62}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{elif}\;y \leq -5.5 \cdot 10^{-64} \lor \neg \left(y \leq 1.35 \cdot 10^{-42}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -2.2999999999999999e-9 or -9.49999999999999951e-62 < y < -5.4999999999999999e-64 or 1.35e-42 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.7%
neg-mul-199.7%
sub-neg99.7%
+-commutative99.7%
distribute-neg-out99.7%
remove-double-neg99.7%
sub-neg99.7%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around 0 70.9%
div-sub70.9%
*-inverses70.9%
Simplified70.9%
if -2.2999999999999999e-9 < y < -9.49999999999999951e-62Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/96.9%
associate-/l*96.8%
neg-mul-196.8%
sub-neg96.8%
+-commutative96.8%
distribute-neg-out96.8%
remove-double-neg96.8%
sub-neg96.8%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 66.4%
Taylor expanded in y around 0 58.7%
associate-*r/58.7%
neg-mul-158.7%
Simplified58.7%
if -5.4999999999999999e-64 < y < 1.35e-42Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.3%
associate-/l*99.1%
neg-mul-199.1%
sub-neg99.1%
+-commutative99.1%
distribute-neg-out99.1%
remove-double-neg99.1%
sub-neg99.1%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 78.9%
Final simplification73.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))))
(if (<= y -5e+110)
t_0
(if (<= y -1.75e-9)
(- 1.0 (/ x y))
(if (<= y 1.15e+79) (/ (- x y) z) t_0)))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double tmp;
if (y <= -5e+110) {
tmp = t_0;
} else if (y <= -1.75e-9) {
tmp = 1.0 - (x / y);
} else if (y <= 1.15e+79) {
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 = y / (y - z)
if (y <= (-5d+110)) then
tmp = t_0
else if (y <= (-1.75d-9)) then
tmp = 1.0d0 - (x / y)
else if (y <= 1.15d+79) 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 = y / (y - z);
double tmp;
if (y <= -5e+110) {
tmp = t_0;
} else if (y <= -1.75e-9) {
tmp = 1.0 - (x / y);
} else if (y <= 1.15e+79) {
tmp = (x - y) / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) tmp = 0 if y <= -5e+110: tmp = t_0 elif y <= -1.75e-9: tmp = 1.0 - (x / y) elif y <= 1.15e+79: tmp = (x - y) / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(y - z)) tmp = 0.0 if (y <= -5e+110) tmp = t_0; elseif (y <= -1.75e-9) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 1.15e+79) tmp = Float64(Float64(x - y) / 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 <= -5e+110) tmp = t_0; elseif (y <= -1.75e-9) tmp = 1.0 - (x / y); elseif (y <= 1.15e+79) tmp = (x - y) / 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, -5e+110], t$95$0, If[LessEqual[y, -1.75e-9], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.15e+79], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
\mathbf{if}\;y \leq -5 \cdot 10^{+110}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.75 \cdot 10^{-9}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{+79}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -4.99999999999999978e110 or 1.15e79 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 89.4%
if -4.99999999999999978e110 < y < -1.75e-9Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.9%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.6%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around 0 70.8%
div-sub70.8%
*-inverses70.8%
Simplified70.8%
if -1.75e-9 < y < 1.15e79Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.2%
associate-/l*99.0%
neg-mul-199.0%
sub-neg99.0%
+-commutative99.0%
distribute-neg-out99.0%
remove-double-neg99.0%
sub-neg99.0%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 80.6%
associate-*r/80.6%
neg-mul-180.6%
neg-sub080.6%
associate--r-80.6%
neg-sub080.6%
Simplified80.6%
Taylor expanded in y around 0 80.6%
+-commutative80.6%
mul-1-neg80.6%
sub-neg80.6%
div-sub80.6%
Simplified80.6%
Final simplification83.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))))
(if (<= y -5.6e+109)
t_0
(if (<= y -1.42e-8)
(+ 1.0 (/ (- z x) y))
(if (<= y 1.2e+79) (/ (- x y) z) t_0)))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double tmp;
if (y <= -5.6e+109) {
tmp = t_0;
} else if (y <= -1.42e-8) {
tmp = 1.0 + ((z - x) / y);
} else if (y <= 1.2e+79) {
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 = y / (y - z)
if (y <= (-5.6d+109)) then
tmp = t_0
else if (y <= (-1.42d-8)) then
tmp = 1.0d0 + ((z - x) / y)
else if (y <= 1.2d+79) 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 = y / (y - z);
double tmp;
if (y <= -5.6e+109) {
tmp = t_0;
} else if (y <= -1.42e-8) {
tmp = 1.0 + ((z - x) / y);
} else if (y <= 1.2e+79) {
tmp = (x - y) / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) tmp = 0 if y <= -5.6e+109: tmp = t_0 elif y <= -1.42e-8: tmp = 1.0 + ((z - x) / y) elif y <= 1.2e+79: tmp = (x - y) / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(y - z)) tmp = 0.0 if (y <= -5.6e+109) tmp = t_0; elseif (y <= -1.42e-8) tmp = Float64(1.0 + Float64(Float64(z - x) / y)); elseif (y <= 1.2e+79) tmp = Float64(Float64(x - y) / 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 <= -5.6e+109) tmp = t_0; elseif (y <= -1.42e-8) tmp = 1.0 + ((z - x) / y); elseif (y <= 1.2e+79) tmp = (x - y) / 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, -5.6e+109], t$95$0, If[LessEqual[y, -1.42e-8], N[(1.0 + N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.2e+79], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
\mathbf{if}\;y \leq -5.6 \cdot 10^{+109}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.42 \cdot 10^{-8}:\\
\;\;\;\;1 + \frac{z - x}{y}\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+79}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -5.6000000000000004e109 or 1.19999999999999993e79 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 89.4%
if -5.6000000000000004e109 < y < -1.41999999999999998e-8Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.9%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.6%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around inf 73.8%
associate--l+73.8%
distribute-lft-out--73.8%
div-sub73.8%
mul-1-neg73.8%
unsub-neg73.8%
Simplified73.8%
if -1.41999999999999998e-8 < y < 1.19999999999999993e79Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.2%
associate-/l*99.0%
neg-mul-199.0%
sub-neg99.0%
+-commutative99.0%
distribute-neg-out99.0%
remove-double-neg99.0%
sub-neg99.0%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 80.6%
associate-*r/80.6%
neg-mul-180.6%
neg-sub080.6%
associate--r-80.6%
neg-sub080.6%
Simplified80.6%
Taylor expanded in y around 0 80.6%
+-commutative80.6%
mul-1-neg80.6%
sub-neg80.6%
div-sub80.6%
Simplified80.6%
Final simplification83.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.8e+53) (not (<= y 1.65e+85))) (- 1.0 (/ x y)) (/ x (- z y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.8e+53) || !(y <= 1.65e+85)) {
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 <= (-1.8d+53)) .or. (.not. (y <= 1.65d+85))) 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 <= -1.8e+53) || !(y <= 1.65e+85)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (z - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.8e+53) or not (y <= 1.65e+85): tmp = 1.0 - (x / y) else: tmp = x / (z - y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.8e+53) || !(y <= 1.65e+85)) 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 <= -1.8e+53) || ~((y <= 1.65e+85))) tmp = 1.0 - (x / y); else tmp = x / (z - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.8e+53], N[Not[LessEqual[y, 1.65e+85]], $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 -1.8 \cdot 10^{+53} \lor \neg \left(y \leq 1.65 \cdot 10^{+85}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z - y}\\
\end{array}
\end{array}
if y < -1.8e53 or 1.65e85 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around 0 77.4%
div-sub77.4%
*-inverses77.4%
Simplified77.4%
if -1.8e53 < y < 1.65e85Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.2%
associate-/l*99.0%
neg-mul-199.0%
sub-neg99.0%
+-commutative99.0%
distribute-neg-out99.0%
remove-double-neg99.0%
sub-neg99.0%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 74.0%
neg-mul-174.0%
distribute-neg-frac74.0%
Simplified74.0%
Taylor expanded in x around 0 74.0%
*-commutative74.0%
associate-*l/74.0%
associate-*r/73.7%
metadata-eval73.7%
associate-/r*73.7%
neg-mul-173.7%
associate-*r/74.0%
*-rgt-identity74.0%
neg-sub074.0%
sub-neg74.0%
+-commutative74.0%
associate--r+74.0%
neg-sub074.0%
remove-double-neg74.0%
Simplified74.0%
Final simplification75.4%
(FPCore (x y z) :precision binary64 (if (<= y -1.65e+53) 1.0 (if (<= y 1.35e+80) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.65e+53) {
tmp = 1.0;
} else if (y <= 1.35e+80) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.65d+53)) then
tmp = 1.0d0
else if (y <= 1.35d+80) then
tmp = x / z
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.65e+53) {
tmp = 1.0;
} else if (y <= 1.35e+80) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.65e+53: tmp = 1.0 elif y <= 1.35e+80: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.65e+53) tmp = 1.0; elseif (y <= 1.35e+80) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.65e+53) tmp = 1.0; elseif (y <= 1.35e+80) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.65e+53], 1.0, If[LessEqual[y, 1.35e+80], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65 \cdot 10^{+53}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+80}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.6500000000000001e53 or 1.34999999999999991e80 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.8%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around inf 68.9%
if -1.6500000000000001e53 < y < 1.34999999999999991e80Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.2%
associate-/l*99.0%
neg-mul-199.0%
sub-neg99.0%
+-commutative99.0%
distribute-neg-out99.0%
remove-double-neg99.0%
sub-neg99.0%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 63.1%
Final simplification65.6%
(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%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.5%
associate-/l*99.3%
neg-mul-199.3%
sub-neg99.3%
+-commutative99.3%
distribute-neg-out99.3%
remove-double-neg99.3%
sub-neg99.3%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around inf 36.7%
Final simplification36.7%
(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 2023290
(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)))