
(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
(if (<= y -1.35e+34)
1.0
(if (<= y 2e-40)
(/ x z)
(if (<= y 4.8e-9)
(/ (- y) z)
(if (<= y 7.5e+28) 1.0 (if (<= y 6.8e+155) (/ (- x) y) 1.0))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.35e+34) {
tmp = 1.0;
} else if (y <= 2e-40) {
tmp = x / z;
} else if (y <= 4.8e-9) {
tmp = -y / z;
} else if (y <= 7.5e+28) {
tmp = 1.0;
} else if (y <= 6.8e+155) {
tmp = -x / y;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-1.35d+34)) then
tmp = 1.0d0
else if (y <= 2d-40) then
tmp = x / z
else if (y <= 4.8d-9) then
tmp = -y / z
else if (y <= 7.5d+28) then
tmp = 1.0d0
else if (y <= 6.8d+155) then
tmp = -x / y
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.35e+34) {
tmp = 1.0;
} else if (y <= 2e-40) {
tmp = x / z;
} else if (y <= 4.8e-9) {
tmp = -y / z;
} else if (y <= 7.5e+28) {
tmp = 1.0;
} else if (y <= 6.8e+155) {
tmp = -x / y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.35e+34: tmp = 1.0 elif y <= 2e-40: tmp = x / z elif y <= 4.8e-9: tmp = -y / z elif y <= 7.5e+28: tmp = 1.0 elif y <= 6.8e+155: tmp = -x / y else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.35e+34) tmp = 1.0; elseif (y <= 2e-40) tmp = Float64(x / z); elseif (y <= 4.8e-9) tmp = Float64(Float64(-y) / z); elseif (y <= 7.5e+28) tmp = 1.0; elseif (y <= 6.8e+155) tmp = Float64(Float64(-x) / y); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.35e+34) tmp = 1.0; elseif (y <= 2e-40) tmp = x / z; elseif (y <= 4.8e-9) tmp = -y / z; elseif (y <= 7.5e+28) tmp = 1.0; elseif (y <= 6.8e+155) tmp = -x / y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.35e+34], 1.0, If[LessEqual[y, 2e-40], N[(x / z), $MachinePrecision], If[LessEqual[y, 4.8e-9], N[((-y) / z), $MachinePrecision], If[LessEqual[y, 7.5e+28], 1.0, If[LessEqual[y, 6.8e+155], N[((-x) / y), $MachinePrecision], 1.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{+34}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-40}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{-9}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{+28}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{+155}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.35e34 or 4.8e-9 < y < 7.4999999999999998e28 or 6.8000000000000002e155 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.9%
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%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around inf 71.8%
if -1.35e34 < y < 1.9999999999999999e-40Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 61.7%
if 1.9999999999999999e-40 < y < 4.8e-9Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
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%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 86.5%
Taylor expanded in y around 0 86.5%
associate-*r/86.5%
neg-mul-186.5%
Simplified86.5%
if 7.4999999999999998e28 < y < 6.8000000000000002e155Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
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%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 53.9%
neg-mul-153.9%
distribute-neg-frac53.9%
Simplified53.9%
Taylor expanded in y around inf 50.2%
associate-*r/50.2%
mul-1-neg50.2%
Simplified50.2%
Final simplification64.6%
(FPCore (x y z)
:precision binary64
(if (or (<= x -1.5e-48)
(not
(or (<= x 2.35e-46)
(and (not (<= x 2020000000000.0)) (<= x 2.15e+36)))))
(/ x (- z y))
(/ y (- y z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.5e-48) || !((x <= 2.35e-46) || (!(x <= 2020000000000.0) && (x <= 2.15e+36)))) {
tmp = x / (z - y);
} else {
tmp = y / (y - z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-1.5d-48)) .or. (.not. (x <= 2.35d-46) .or. (.not. (x <= 2020000000000.0d0)) .and. (x <= 2.15d+36))) then
tmp = x / (z - y)
else
tmp = y / (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.5e-48) || !((x <= 2.35e-46) || (!(x <= 2020000000000.0) && (x <= 2.15e+36)))) {
tmp = x / (z - y);
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.5e-48) or not ((x <= 2.35e-46) or (not (x <= 2020000000000.0) and (x <= 2.15e+36))): tmp = x / (z - y) else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.5e-48) || !((x <= 2.35e-46) || (!(x <= 2020000000000.0) && (x <= 2.15e+36)))) tmp = Float64(x / Float64(z - y)); else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.5e-48) || ~(((x <= 2.35e-46) || (~((x <= 2020000000000.0)) && (x <= 2.15e+36))))) tmp = x / (z - y); else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.5e-48], N[Not[Or[LessEqual[x, 2.35e-46], And[N[Not[LessEqual[x, 2020000000000.0]], $MachinePrecision], LessEqual[x, 2.15e+36]]]], $MachinePrecision]], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \cdot 10^{-48} \lor \neg \left(x \leq 2.35 \cdot 10^{-46} \lor \neg \left(x \leq 2020000000000\right) \land x \leq 2.15 \cdot 10^{+36}\right):\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if x < -1.5e-48 or 2.34999999999999983e-46 < x < 2.02e12 or 2.15000000000000002e36 < x Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.7%
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%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 80.3%
neg-mul-180.3%
distribute-neg-frac80.3%
Simplified80.3%
frac-2neg80.3%
div-inv79.9%
remove-double-neg79.9%
Applied egg-rr79.9%
Taylor expanded in x around 0 80.3%
if -1.5e-48 < x < 2.34999999999999983e-46 or 2.02e12 < x < 2.15000000000000002e36Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
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*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 86.8%
Final simplification83.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -7.2e-40)
t_0
(if (<= y 1.7e-41) (/ x z) (if (<= y 225000.0) (/ (- y) z) t_0)))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -7.2e-40) {
tmp = t_0;
} else if (y <= 1.7e-41) {
tmp = x / z;
} else if (y <= 225000.0) {
tmp = -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 <= (-7.2d-40)) then
tmp = t_0
else if (y <= 1.7d-41) then
tmp = x / z
else if (y <= 225000.0d0) then
tmp = -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 <= -7.2e-40) {
tmp = t_0;
} else if (y <= 1.7e-41) {
tmp = x / z;
} else if (y <= 225000.0) {
tmp = -y / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -7.2e-40: tmp = t_0 elif y <= 1.7e-41: tmp = x / z elif y <= 225000.0: tmp = -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 <= -7.2e-40) tmp = t_0; elseif (y <= 1.7e-41) tmp = Float64(x / z); elseif (y <= 225000.0) tmp = Float64(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 <= -7.2e-40) tmp = t_0; elseif (y <= 1.7e-41) tmp = x / z; elseif (y <= 225000.0) tmp = -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, -7.2e-40], t$95$0, If[LessEqual[y, 1.7e-41], N[(x / z), $MachinePrecision], If[LessEqual[y, 225000.0], N[((-y) / z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -7.2 \cdot 10^{-40}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-41}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 225000:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -7.2e-40 or 225000 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 76.7%
div-sub76.7%
*-inverses76.7%
Simplified76.7%
if -7.2e-40 < y < 1.6999999999999999e-41Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 64.9%
if 1.6999999999999999e-41 < y < 225000Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 80.7%
Taylor expanded in y around 0 70.8%
associate-*r/70.8%
neg-mul-170.8%
Simplified70.8%
Final simplification70.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -9e+34)
t_0
(if (<= y 8e-39) (/ x (- z y)) (if (<= y 225000.0) (/ (- y) z) t_0)))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -9e+34) {
tmp = t_0;
} else if (y <= 8e-39) {
tmp = x / (z - y);
} else if (y <= 225000.0) {
tmp = -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 <= (-9d+34)) then
tmp = t_0
else if (y <= 8d-39) then
tmp = x / (z - y)
else if (y <= 225000.0d0) then
tmp = -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 <= -9e+34) {
tmp = t_0;
} else if (y <= 8e-39) {
tmp = x / (z - y);
} else if (y <= 225000.0) {
tmp = -y / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -9e+34: tmp = t_0 elif y <= 8e-39: tmp = x / (z - y) elif y <= 225000.0: tmp = -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 <= -9e+34) tmp = t_0; elseif (y <= 8e-39) tmp = Float64(x / Float64(z - y)); elseif (y <= 225000.0) tmp = Float64(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 <= -9e+34) tmp = t_0; elseif (y <= 8e-39) tmp = x / (z - y); elseif (y <= 225000.0) tmp = -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, -9e+34], t$95$0, If[LessEqual[y, 8e-39], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 225000.0], N[((-y) / z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -9 \cdot 10^{+34}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-39}:\\
\;\;\;\;\frac{x}{z - y}\\
\mathbf{elif}\;y \leq 225000:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -9.0000000000000001e34 or 225000 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 81.2%
div-sub81.2%
*-inverses81.2%
Simplified81.2%
if -9.0000000000000001e34 < y < 7.99999999999999943e-39Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 75.7%
neg-mul-175.7%
distribute-neg-frac75.7%
Simplified75.7%
frac-2neg75.7%
div-inv75.4%
remove-double-neg75.4%
Applied egg-rr75.4%
Taylor expanded in x around 0 75.7%
if 7.99999999999999943e-39 < y < 225000Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 80.7%
Taylor expanded in y around 0 70.8%
associate-*r/70.8%
neg-mul-170.8%
Simplified70.8%
Final simplification77.9%
(FPCore (x y z) :precision binary64 (if (<= y -7.2e+33) 1.0 (if (<= y 2.9e+28) (/ x z) (if (<= y 6.8e+155) (/ (- x) y) 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+33) {
tmp = 1.0;
} else if (y <= 2.9e+28) {
tmp = x / z;
} else if (y <= 6.8e+155) {
tmp = -x / y;
} else {
tmp = 1.0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-7.2d+33)) then
tmp = 1.0d0
else if (y <= 2.9d+28) then
tmp = x / z
else if (y <= 6.8d+155) then
tmp = -x / y
else
tmp = 1.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+33) {
tmp = 1.0;
} else if (y <= 2.9e+28) {
tmp = x / z;
} else if (y <= 6.8e+155) {
tmp = -x / y;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.2e+33: tmp = 1.0 elif y <= 2.9e+28: tmp = x / z elif y <= 6.8e+155: tmp = -x / y else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.2e+33) tmp = 1.0; elseif (y <= 2.9e+28) tmp = Float64(x / z); elseif (y <= 6.8e+155) tmp = Float64(Float64(-x) / y); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.2e+33) tmp = 1.0; elseif (y <= 2.9e+28) tmp = x / z; elseif (y <= 6.8e+155) tmp = -x / y; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.2e+33], 1.0, If[LessEqual[y, 2.9e+28], N[(x / z), $MachinePrecision], If[LessEqual[y, 6.8e+155], N[((-x) / y), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+33}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{+28}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 6.8 \cdot 10^{+155}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -7.2000000000000005e33 or 6.8000000000000002e155 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
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*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 75.7%
if -7.2000000000000005e33 < y < 2.9000000000000001e28Initial 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%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 57.7%
if 2.9000000000000001e28 < y < 6.8000000000000002e155Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.8%
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%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 53.9%
neg-mul-153.9%
distribute-neg-frac53.9%
Simplified53.9%
Taylor expanded in y around inf 50.2%
associate-*r/50.2%
mul-1-neg50.2%
Simplified50.2%
Final simplification62.2%
(FPCore (x y z) :precision binary64 (if (<= y -1.05e+37) 1.0 (if (<= y 900000000.0) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.05e+37) {
tmp = 1.0;
} else if (y <= 900000000.0) {
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.05d+37)) then
tmp = 1.0d0
else if (y <= 900000000.0d0) 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.05e+37) {
tmp = 1.0;
} else if (y <= 900000000.0) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.05e+37: tmp = 1.0 elif y <= 900000000.0: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.05e+37) tmp = 1.0; elseif (y <= 900000000.0) 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.05e+37) tmp = 1.0; elseif (y <= 900000000.0) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.05e+37], 1.0, If[LessEqual[y, 900000000.0], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+37}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 900000000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.0500000000000001e37 or 9e8 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 60.9%
if -1.0500000000000001e37 < y < 9e8Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 59.2%
Final simplification59.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 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 32.8%
Final simplification32.8%
(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 2023336
(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)))