
(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 (or (<= z -7.8e-66)
(and (not (<= z 2e-93)) (or (<= z 6.4e+38) (not (<= z 1.45e+97)))))
(/ (- x y) z)
(/ (- y x) y)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -7.8e-66) || (!(z <= 2e-93) && ((z <= 6.4e+38) || !(z <= 1.45e+97)))) {
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 <= (-7.8d-66)) .or. (.not. (z <= 2d-93)) .and. (z <= 6.4d+38) .or. (.not. (z <= 1.45d+97))) 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 <= -7.8e-66) || (!(z <= 2e-93) && ((z <= 6.4e+38) || !(z <= 1.45e+97)))) {
tmp = (x - y) / z;
} else {
tmp = (y - x) / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -7.8e-66) or (not (z <= 2e-93) and ((z <= 6.4e+38) or not (z <= 1.45e+97))): tmp = (x - y) / z else: tmp = (y - x) / y return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -7.8e-66) || (!(z <= 2e-93) && ((z <= 6.4e+38) || !(z <= 1.45e+97)))) 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 <= -7.8e-66) || (~((z <= 2e-93)) && ((z <= 6.4e+38) || ~((z <= 1.45e+97))))) tmp = (x - y) / z; else tmp = (y - x) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -7.8e-66], And[N[Not[LessEqual[z, 2e-93]], $MachinePrecision], Or[LessEqual[z, 6.4e+38], N[Not[LessEqual[z, 1.45e+97]], $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 -7.8 \cdot 10^{-66} \lor \neg \left(z \leq 2 \cdot 10^{-93}\right) \land \left(z \leq 6.4 \cdot 10^{+38} \lor \neg \left(z \leq 1.45 \cdot 10^{+97}\right)\right):\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{y}\\
\end{array}
\end{array}
if z < -7.79999999999999965e-66 or 1.9999999999999998e-93 < z < 6.3999999999999997e38 or 1.44999999999999994e97 < z 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%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around inf 79.7%
associate-*r/79.7%
neg-mul-179.7%
neg-sub079.7%
associate--r-79.7%
neg-sub079.7%
Simplified79.7%
Taylor expanded in y around 0 79.7%
+-commutative79.7%
mul-1-neg79.7%
sub-neg79.7%
div-sub79.7%
Simplified79.7%
if -7.79999999999999965e-66 < z < 1.9999999999999998e-93 or 6.3999999999999997e38 < z < 1.44999999999999994e97Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*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 89.2%
Final simplification83.8%
(FPCore (x y z)
:precision binary64
(if (<= z -3.9e-66)
(- (/ x z) (/ y z))
(if (or (<= z 2.15e-93) (and (not (<= z 5.3e+38)) (<= z 2.2e+98)))
(/ (- y x) y)
(/ (- x y) z))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.9e-66) {
tmp = (x / z) - (y / z);
} else if ((z <= 2.15e-93) || (!(z <= 5.3e+38) && (z <= 2.2e+98))) {
tmp = (y - 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 (z <= (-3.9d-66)) then
tmp = (x / z) - (y / z)
else if ((z <= 2.15d-93) .or. (.not. (z <= 5.3d+38)) .and. (z <= 2.2d+98)) then
tmp = (y - 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 (z <= -3.9e-66) {
tmp = (x / z) - (y / z);
} else if ((z <= 2.15e-93) || (!(z <= 5.3e+38) && (z <= 2.2e+98))) {
tmp = (y - x) / y;
} else {
tmp = (x - y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.9e-66: tmp = (x / z) - (y / z) elif (z <= 2.15e-93) or (not (z <= 5.3e+38) and (z <= 2.2e+98)): tmp = (y - x) / y else: tmp = (x - y) / z return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.9e-66) tmp = Float64(Float64(x / z) - Float64(y / z)); elseif ((z <= 2.15e-93) || (!(z <= 5.3e+38) && (z <= 2.2e+98))) tmp = Float64(Float64(y - x) / y); else tmp = Float64(Float64(x - y) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.9e-66) tmp = (x / z) - (y / z); elseif ((z <= 2.15e-93) || (~((z <= 5.3e+38)) && (z <= 2.2e+98))) tmp = (y - x) / y; else tmp = (x - y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.9e-66], N[(N[(x / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, 2.15e-93], And[N[Not[LessEqual[z, 5.3e+38]], $MachinePrecision], LessEqual[z, 2.2e+98]]], N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.9 \cdot 10^{-66}:\\
\;\;\;\;\frac{x}{z} - \frac{y}{z}\\
\mathbf{elif}\;z \leq 2.15 \cdot 10^{-93} \lor \neg \left(z \leq 5.3 \cdot 10^{+38}\right) \land z \leq 2.2 \cdot 10^{+98}:\\
\;\;\;\;\frac{y - x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{z}\\
\end{array}
\end{array}
if z < -3.89999999999999983e-66Initial 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 z around inf 77.3%
associate-*r/77.3%
neg-mul-177.3%
neg-sub077.3%
associate--r-77.3%
neg-sub077.3%
Simplified77.3%
Taylor expanded in y around 0 77.4%
+-commutative77.4%
mul-1-neg77.4%
unsub-neg77.4%
Applied egg-rr77.4%
if -3.89999999999999983e-66 < z < 2.14999999999999981e-93 or 5.30000000000000024e38 < z < 2.20000000000000009e98Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*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 89.2%
if 2.14999999999999981e-93 < z < 5.30000000000000024e38 or 2.20000000000000009e98 < z Initial 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 z around inf 82.0%
associate-*r/82.0%
neg-mul-182.0%
neg-sub082.0%
associate--r-82.0%
neg-sub082.0%
Simplified82.0%
Taylor expanded in y around 0 82.0%
+-commutative82.0%
mul-1-neg82.0%
sub-neg82.0%
div-sub82.0%
Simplified82.0%
Final simplification83.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))))
(if (<= y -3.5e+38)
t_0
(if (<= y -1.35e-111) (/ (- x) y) (if (<= y 2400000.0) (/ x z) t_0)))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double tmp;
if (y <= -3.5e+38) {
tmp = t_0;
} else if (y <= -1.35e-111) {
tmp = -x / y;
} else if (y <= 2400000.0) {
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 <= (-3.5d+38)) then
tmp = t_0
else if (y <= (-1.35d-111)) then
tmp = -x / y
else if (y <= 2400000.0d0) 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 <= -3.5e+38) {
tmp = t_0;
} else if (y <= -1.35e-111) {
tmp = -x / y;
} else if (y <= 2400000.0) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) tmp = 0 if y <= -3.5e+38: tmp = t_0 elif y <= -1.35e-111: tmp = -x / y elif y <= 2400000.0: 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 <= -3.5e+38) tmp = t_0; elseif (y <= -1.35e-111) tmp = Float64(Float64(-x) / y); elseif (y <= 2400000.0) 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 <= -3.5e+38) tmp = t_0; elseif (y <= -1.35e-111) tmp = -x / y; elseif (y <= 2400000.0) 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, -3.5e+38], t$95$0, If[LessEqual[y, -1.35e-111], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 2400000.0], N[(x / z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
\mathbf{if}\;y \leq -3.5 \cdot 10^{+38}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.35 \cdot 10^{-111}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq 2400000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -3.50000000000000002e38 or 2.4e6 < 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%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 71.5%
if -3.50000000000000002e38 < y < -1.34999999999999994e-111Initial 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 z around 0 73.9%
Taylor expanded in y around 0 55.4%
associate-*r/55.4%
neg-mul-155.4%
Simplified55.4%
if -1.34999999999999994e-111 < y < 2.4e6Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
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 66.2%
Final simplification67.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))))
(if (<= y -6.6e+38)
t_0
(if (<= y -1.55e-87) (/ (- x) y) (if (<= y 2.5e+62) (/ (- x y) z) t_0)))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double tmp;
if (y <= -6.6e+38) {
tmp = t_0;
} else if (y <= -1.55e-87) {
tmp = -x / y;
} else if (y <= 2.5e+62) {
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 <= (-6.6d+38)) then
tmp = t_0
else if (y <= (-1.55d-87)) then
tmp = -x / y
else if (y <= 2.5d+62) 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 <= -6.6e+38) {
tmp = t_0;
} else if (y <= -1.55e-87) {
tmp = -x / y;
} else if (y <= 2.5e+62) {
tmp = (x - y) / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) tmp = 0 if y <= -6.6e+38: tmp = t_0 elif y <= -1.55e-87: tmp = -x / y elif y <= 2.5e+62: 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 <= -6.6e+38) tmp = t_0; elseif (y <= -1.55e-87) tmp = Float64(Float64(-x) / y); elseif (y <= 2.5e+62) 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 <= -6.6e+38) tmp = t_0; elseif (y <= -1.55e-87) tmp = -x / y; elseif (y <= 2.5e+62) 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, -6.6e+38], t$95$0, If[LessEqual[y, -1.55e-87], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 2.5e+62], 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 -6.6 \cdot 10^{+38}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.55 \cdot 10^{-87}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+62}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -6.5999999999999998e38 or 2.50000000000000014e62 < 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%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 76.3%
if -6.5999999999999998e38 < y < -1.54999999999999999e-87Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
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 74.8%
Taylor expanded in y around 0 58.0%
associate-*r/58.0%
neg-mul-158.0%
Simplified58.0%
if -1.54999999999999999e-87 < y < 2.50000000000000014e62Initial 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 inf 74.6%
associate-*r/74.6%
neg-mul-174.6%
neg-sub074.6%
associate--r-74.6%
neg-sub074.6%
Simplified74.6%
Taylor expanded in y around 0 74.6%
+-commutative74.6%
mul-1-neg74.6%
sub-neg74.6%
div-sub74.6%
Simplified74.6%
Final simplification73.8%
(FPCore (x y z) :precision binary64 (if (<= y -3.2e+153) 1.0 (if (<= y -6.2e-111) (/ (- x) y) (if (<= y 2.1e+66) (/ x z) 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.2e+153) {
tmp = 1.0;
} else if (y <= -6.2e-111) {
tmp = -x / y;
} else if (y <= 2.1e+66) {
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.2d+153)) then
tmp = 1.0d0
else if (y <= (-6.2d-111)) then
tmp = -x / y
else if (y <= 2.1d+66) 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.2e+153) {
tmp = 1.0;
} else if (y <= -6.2e-111) {
tmp = -x / y;
} else if (y <= 2.1e+66) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.2e+153: tmp = 1.0 elif y <= -6.2e-111: tmp = -x / y elif y <= 2.1e+66: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.2e+153) tmp = 1.0; elseif (y <= -6.2e-111) tmp = Float64(Float64(-x) / y); elseif (y <= 2.1e+66) 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.2e+153) tmp = 1.0; elseif (y <= -6.2e-111) tmp = -x / y; elseif (y <= 2.1e+66) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.2e+153], 1.0, If[LessEqual[y, -6.2e-111], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 2.1e+66], N[(x / z), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{+153}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -6.2 \cdot 10^{-111}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+66}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.2000000000000001e153 or 2.10000000000000005e66 < 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 67.8%
if -3.2000000000000001e153 < y < -6.20000000000000029e-111Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.7%
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 z around 0 64.2%
Taylor expanded in y around 0 46.3%
associate-*r/46.3%
neg-mul-146.3%
Simplified46.3%
if -6.20000000000000029e-111 < y < 2.10000000000000005e66Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
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.5%
Final simplification61.0%
(FPCore (x y z) :precision binary64 (if (<= y -8.2e+89) 1.0 (if (<= y 1.4e+62) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.2e+89) {
tmp = 1.0;
} else if (y <= 1.4e+62) {
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 <= (-8.2d+89)) then
tmp = 1.0d0
else if (y <= 1.4d+62) 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 <= -8.2e+89) {
tmp = 1.0;
} else if (y <= 1.4e+62) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.2e+89: tmp = 1.0 elif y <= 1.4e+62: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.2e+89) tmp = 1.0; elseif (y <= 1.4e+62) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.2e+89) tmp = 1.0; elseif (y <= 1.4e+62) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.2e+89], 1.0, If[LessEqual[y, 1.4e+62], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+89}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+62}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -8.1999999999999997e89 or 1.40000000000000007e62 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
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*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 62.4%
if -8.1999999999999997e89 < y < 1.40000000000000007e62Initial 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 53.4%
Final simplification56.8%
(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 31.2%
Final simplification31.2%
(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 2023318
(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)))