
(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 12 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 (- (/ y (- y z)) (/ x (- y z))))
double code(double x, double y, double z) {
return (y / (y - z)) - (x / (y - z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y / (y - z)) - (x / (y - z))
end function
public static double code(double x, double y, double z) {
return (y / (y - z)) - (x / (y - z));
}
def code(x, y, z): return (y / (y - z)) - (x / (y - z))
function code(x, y, z) return Float64(Float64(y / Float64(y - z)) - Float64(x / Float64(y - z))) end
function tmp = code(x, y, z) tmp = (y / (y - z)) - (x / (y - z)); end
code[x_, y_, z_] := N[(N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision] - N[(x / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y}{y - z} - \frac{x}{y - z}
\end{array}
Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= y -4.5e+102)
(- 1.0 (/ x y))
(if (<= y -1.22e-55)
(/ (- x y) z)
(if (<= y 1.25e+57) (/ (- x) (- y z)) (/ (- y x) y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.5e+102) {
tmp = 1.0 - (x / y);
} else if (y <= -1.22e-55) {
tmp = (x - y) / z;
} else if (y <= 1.25e+57) {
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 (y <= (-4.5d+102)) then
tmp = 1.0d0 - (x / y)
else if (y <= (-1.22d-55)) then
tmp = (x - y) / z
else if (y <= 1.25d+57) 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 (y <= -4.5e+102) {
tmp = 1.0 - (x / y);
} else if (y <= -1.22e-55) {
tmp = (x - y) / z;
} else if (y <= 1.25e+57) {
tmp = -x / (y - z);
} else {
tmp = (y - x) / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.5e+102: tmp = 1.0 - (x / y) elif y <= -1.22e-55: tmp = (x - y) / z elif y <= 1.25e+57: tmp = -x / (y - z) else: tmp = (y - x) / y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.5e+102) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= -1.22e-55) tmp = Float64(Float64(x - y) / z); elseif (y <= 1.25e+57) tmp = Float64(Float64(-x) / Float64(y - z)); else tmp = Float64(Float64(y - x) / y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.5e+102) tmp = 1.0 - (x / y); elseif (y <= -1.22e-55) tmp = (x - y) / z; elseif (y <= 1.25e+57) tmp = -x / (y - z); else tmp = (y - x) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.5e+102], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.22e-55], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 1.25e+57], N[((-x) / N[(y - z), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{+102}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq -1.22 \cdot 10^{-55}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{+57}:\\
\;\;\;\;\frac{-x}{y - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{y}\\
\end{array}
\end{array}
if y < -4.50000000000000021e102Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
neg-sub099.9%
associate-+l-99.9%
sub0-neg99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
neg-sub099.9%
associate-+l-99.9%
sub0-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
*-lft-identity99.9%
Simplified99.9%
Taylor expanded in z around 0 82.8%
div-sub82.8%
*-inverses82.8%
Simplified82.8%
if -4.50000000000000021e102 < y < -1.22e-55Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
neg-sub099.9%
associate-+l-99.9%
sub0-neg99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
neg-sub099.9%
associate-+l-99.9%
sub0-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
*-lft-identity99.9%
Simplified99.9%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 77.7%
associate-*r/42.2%
neg-mul-142.2%
Simplified77.7%
Taylor expanded in z around inf 68.0%
cancel-sign-sub-inv68.0%
metadata-eval68.0%
*-lft-identity68.0%
+-commutative68.0%
mul-1-neg68.0%
unsub-neg68.0%
Simplified68.0%
if -1.22e-55 < y < 1.24999999999999993e57Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 88.7%
neg-mul-188.7%
distribute-neg-frac88.7%
Simplified88.7%
if 1.24999999999999993e57 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in z around 0 77.8%
Final simplification82.9%
(FPCore (x y z)
:precision binary64
(if (<= y -4.8e+102)
(- 1.0 (/ x y))
(if (<= y -9.6e-58)
(- (/ x z) (/ y z))
(if (<= y 4.2e+55) (/ (- x) (- y z)) (/ (- y x) y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.8e+102) {
tmp = 1.0 - (x / y);
} else if (y <= -9.6e-58) {
tmp = (x / z) - (y / z);
} else if (y <= 4.2e+55) {
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 (y <= (-4.8d+102)) then
tmp = 1.0d0 - (x / y)
else if (y <= (-9.6d-58)) then
tmp = (x / z) - (y / z)
else if (y <= 4.2d+55) 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 (y <= -4.8e+102) {
tmp = 1.0 - (x / y);
} else if (y <= -9.6e-58) {
tmp = (x / z) - (y / z);
} else if (y <= 4.2e+55) {
tmp = -x / (y - z);
} else {
tmp = (y - x) / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.8e+102: tmp = 1.0 - (x / y) elif y <= -9.6e-58: tmp = (x / z) - (y / z) elif y <= 4.2e+55: tmp = -x / (y - z) else: tmp = (y - x) / y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.8e+102) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= -9.6e-58) tmp = Float64(Float64(x / z) - Float64(y / z)); elseif (y <= 4.2e+55) tmp = Float64(Float64(-x) / Float64(y - z)); else tmp = Float64(Float64(y - x) / y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.8e+102) tmp = 1.0 - (x / y); elseif (y <= -9.6e-58) tmp = (x / z) - (y / z); elseif (y <= 4.2e+55) tmp = -x / (y - z); else tmp = (y - x) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.8e+102], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -9.6e-58], N[(N[(x / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.2e+55], N[((-x) / N[(y - z), $MachinePrecision]), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{+102}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq -9.6 \cdot 10^{-58}:\\
\;\;\;\;\frac{x}{z} - \frac{y}{z}\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+55}:\\
\;\;\;\;\frac{-x}{y - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{y}\\
\end{array}
\end{array}
if y < -4.79999999999999989e102Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
neg-sub099.9%
associate-+l-99.9%
sub0-neg99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
neg-sub099.9%
associate-+l-99.9%
sub0-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
*-lft-identity99.9%
Simplified99.9%
Taylor expanded in z around 0 82.8%
div-sub82.8%
*-inverses82.8%
Simplified82.8%
if -4.79999999999999989e102 < y < -9.6000000000000002e-58Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
neg-sub099.9%
associate-+l-99.9%
sub0-neg99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
neg-sub099.9%
associate-+l-99.9%
sub0-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
*-lft-identity99.9%
Simplified99.9%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 77.7%
associate-*r/42.2%
neg-mul-142.2%
Simplified77.7%
Taylor expanded in y around 0 68.1%
mul-1-neg68.1%
Simplified68.1%
Taylor expanded in y around 0 68.1%
mul-1-neg68.1%
+-commutative68.1%
sub-neg68.1%
Simplified68.1%
if -9.6000000000000002e-58 < y < 4.2000000000000001e55Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 88.7%
neg-mul-188.7%
distribute-neg-frac88.7%
Simplified88.7%
if 4.2000000000000001e55 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in z around 0 77.8%
Final simplification82.9%
(FPCore (x y z) :precision binary64 (if (<= y -7.2e+104) 1.0 (if (<= y -6.5e-29) (/ (- x) y) (if (<= y 4.6e+55) (/ x z) 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+104) {
tmp = 1.0;
} else if (y <= -6.5e-29) {
tmp = -x / y;
} else if (y <= 4.6e+55) {
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 <= (-7.2d+104)) then
tmp = 1.0d0
else if (y <= (-6.5d-29)) then
tmp = -x / y
else if (y <= 4.6d+55) 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 <= -7.2e+104) {
tmp = 1.0;
} else if (y <= -6.5e-29) {
tmp = -x / y;
} else if (y <= 4.6e+55) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.2e+104: tmp = 1.0 elif y <= -6.5e-29: tmp = -x / y elif y <= 4.6e+55: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.2e+104) tmp = 1.0; elseif (y <= -6.5e-29) tmp = Float64(Float64(-x) / y); elseif (y <= 4.6e+55) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.2e+104) tmp = 1.0; elseif (y <= -6.5e-29) tmp = -x / y; elseif (y <= 4.6e+55) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.2e+104], 1.0, If[LessEqual[y, -6.5e-29], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 4.6e+55], N[(x / z), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+104}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -6.5 \cdot 10^{-29}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{+55}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -7.20000000000000001e104 or 4.59999999999999975e55 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in y around inf 63.4%
if -7.20000000000000001e104 < y < -6.5e-29Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around inf 49.8%
neg-mul-149.8%
distribute-neg-frac49.8%
Simplified49.8%
Taylor expanded in y around inf 36.5%
associate-*r/36.5%
mul-1-neg36.5%
Simplified36.5%
if -6.5e-29 < y < 4.59999999999999975e55Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in y around 0 72.3%
Final simplification65.6%
(FPCore (x y z) :precision binary64 (if (<= y -4.5e+102) 1.0 (if (<= y -9.8e-26) (/ (- y) z) (if (<= y 3.2e+55) (/ x z) 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.5e+102) {
tmp = 1.0;
} else if (y <= -9.8e-26) {
tmp = -y / z;
} else if (y <= 3.2e+55) {
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 <= (-4.5d+102)) then
tmp = 1.0d0
else if (y <= (-9.8d-26)) then
tmp = -y / z
else if (y <= 3.2d+55) 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 <= -4.5e+102) {
tmp = 1.0;
} else if (y <= -9.8e-26) {
tmp = -y / z;
} else if (y <= 3.2e+55) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.5e+102: tmp = 1.0 elif y <= -9.8e-26: tmp = -y / z elif y <= 3.2e+55: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.5e+102) tmp = 1.0; elseif (y <= -9.8e-26) tmp = Float64(Float64(-y) / z); elseif (y <= 3.2e+55) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.5e+102) tmp = 1.0; elseif (y <= -9.8e-26) tmp = -y / z; elseif (y <= 3.2e+55) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.5e+102], 1.0, If[LessEqual[y, -9.8e-26], N[((-y) / z), $MachinePrecision], If[LessEqual[y, 3.2e+55], N[(x / z), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{+102}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -9.8 \cdot 10^{-26}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+55}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.50000000000000021e102 or 3.2000000000000003e55 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in y around inf 62.7%
if -4.50000000000000021e102 < y < -9.7999999999999998e-26Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 54.3%
Taylor expanded in y around 0 45.8%
associate-*r/45.8%
neg-mul-145.8%
Simplified45.8%
if -9.7999999999999998e-26 < y < 3.2000000000000003e55Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in y around 0 72.3%
Final simplification66.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -7.6e-29) (not (<= y 3.2e+55))) (- 1.0 (/ x y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.6e-29) || !(y <= 3.2e+55)) {
tmp = 1.0 - (x / y);
} 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) :: tmp
if ((y <= (-7.6d-29)) .or. (.not. (y <= 3.2d+55))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -7.6e-29) || !(y <= 3.2e+55)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7.6e-29) or not (y <= 3.2e+55): tmp = 1.0 - (x / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7.6e-29) || !(y <= 3.2e+55)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7.6e-29) || ~((y <= 3.2e+55))) tmp = 1.0 - (x / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.6e-29], N[Not[LessEqual[y, 3.2e+55]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.6 \cdot 10^{-29} \lor \neg \left(y \leq 3.2 \cdot 10^{+55}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -7.59999999999999951e-29 or 3.2000000000000003e55 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in z around 0 72.5%
div-sub72.5%
*-inverses72.5%
Simplified72.5%
if -7.59999999999999951e-29 < y < 3.2000000000000003e55Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in y around 0 72.3%
Final simplification72.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.5e+102) (not (<= y 3e+55))) (- 1.0 (/ x y)) (/ (- x y) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.5e+102) || !(y <= 3e+55)) {
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 <= (-4.5d+102)) .or. (.not. (y <= 3d+55))) 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 <= -4.5e+102) || !(y <= 3e+55)) {
tmp = 1.0 - (x / y);
} else {
tmp = (x - y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.5e+102) or not (y <= 3e+55): tmp = 1.0 - (x / y) else: tmp = (x - y) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.5e+102) || !(y <= 3e+55)) 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 <= -4.5e+102) || ~((y <= 3e+55))) tmp = 1.0 - (x / y); else tmp = (x - y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.5e+102], N[Not[LessEqual[y, 3e+55]], $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 -4.5 \cdot 10^{+102} \lor \neg \left(y \leq 3 \cdot 10^{+55}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{z}\\
\end{array}
\end{array}
if y < -4.50000000000000021e102 or 3.00000000000000017e55 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in z around 0 79.8%
div-sub79.9%
*-inverses79.9%
Simplified79.9%
if -4.50000000000000021e102 < y < 3.00000000000000017e55Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 88.3%
associate-*r/21.4%
neg-mul-121.4%
Simplified88.3%
Taylor expanded in z around inf 79.0%
cancel-sign-sub-inv79.0%
metadata-eval79.0%
*-lft-identity79.0%
+-commutative79.0%
mul-1-neg79.0%
unsub-neg79.0%
Simplified79.0%
Final simplification79.3%
(FPCore (x y z) :precision binary64 (if (<= y -7.2e-34) (/ y (- y z)) (if (<= y 3e+55) (/ x z) (- 1.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e-34) {
tmp = y / (y - z);
} else if (y <= 3e+55) {
tmp = x / z;
} else {
tmp = 1.0 - (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 (y <= (-7.2d-34)) then
tmp = y / (y - z)
else if (y <= 3d+55) then
tmp = x / z
else
tmp = 1.0d0 - (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e-34) {
tmp = y / (y - z);
} else if (y <= 3e+55) {
tmp = x / z;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.2e-34: tmp = y / (y - z) elif y <= 3e+55: tmp = x / z else: tmp = 1.0 - (x / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.2e-34) tmp = Float64(y / Float64(y - z)); elseif (y <= 3e+55) tmp = Float64(x / z); else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.2e-34) tmp = y / (y - z); elseif (y <= 3e+55) tmp = x / z; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.2e-34], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3e+55], N[(x / z), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{-34}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+55}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -7.20000000000000016e-34Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
neg-sub099.9%
associate-+l-99.9%
sub0-neg99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
neg-sub099.9%
associate-+l-99.9%
sub0-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
*-lft-identity99.9%
Simplified99.9%
Taylor expanded in x around 0 68.7%
if -7.20000000000000016e-34 < y < 3.00000000000000017e55Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in y around 0 73.1%
if 3.00000000000000017e55 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in z around 0 77.8%
div-sub77.8%
*-inverses77.8%
Simplified77.8%
Final simplification73.0%
(FPCore (x y z) :precision binary64 (if (<= y -5.2e+102) (- 1.0 (/ x y)) (if (<= y 9e+55) (/ (- x y) z) (/ (- y x) y))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.2e+102) {
tmp = 1.0 - (x / y);
} else if (y <= 9e+55) {
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 (y <= (-5.2d+102)) then
tmp = 1.0d0 - (x / y)
else if (y <= 9d+55) 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 (y <= -5.2e+102) {
tmp = 1.0 - (x / y);
} else if (y <= 9e+55) {
tmp = (x - y) / z;
} else {
tmp = (y - x) / y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.2e+102: tmp = 1.0 - (x / y) elif y <= 9e+55: tmp = (x - y) / z else: tmp = (y - x) / y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.2e+102) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 9e+55) 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 (y <= -5.2e+102) tmp = 1.0 - (x / y); elseif (y <= 9e+55) tmp = (x - y) / z; else tmp = (y - x) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.2e+102], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9e+55], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{+102}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+55}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{y}\\
\end{array}
\end{array}
if y < -5.20000000000000013e102Initial program 99.9%
sub-neg99.9%
+-commutative99.9%
neg-sub099.9%
associate-+l-99.9%
sub0-neg99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
neg-sub099.9%
associate-+l-99.9%
sub0-neg99.9%
neg-mul-199.9%
times-frac99.9%
metadata-eval99.9%
*-lft-identity99.9%
Simplified99.9%
Taylor expanded in z around 0 82.8%
div-sub82.8%
*-inverses82.8%
Simplified82.8%
if -5.20000000000000013e102 < y < 8.99999999999999996e55Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 88.3%
associate-*r/21.4%
neg-mul-121.4%
Simplified88.3%
Taylor expanded in z around inf 79.0%
cancel-sign-sub-inv79.0%
metadata-eval79.0%
*-lft-identity79.0%
+-commutative79.0%
mul-1-neg79.0%
unsub-neg79.0%
Simplified79.0%
if 8.99999999999999996e55 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in z around 0 77.8%
Final simplification79.3%
(FPCore (x y z) :precision binary64 (if (<= y -1.5e+104) 1.0 (if (<= y 5.3e+56) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.5e+104) {
tmp = 1.0;
} else if (y <= 5.3e+56) {
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.5d+104)) then
tmp = 1.0d0
else if (y <= 5.3d+56) 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.5e+104) {
tmp = 1.0;
} else if (y <= 5.3e+56) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.5e+104: tmp = 1.0 elif y <= 5.3e+56: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.5e+104) tmp = 1.0; elseif (y <= 5.3e+56) 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.5e+104) tmp = 1.0; elseif (y <= 5.3e+56) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.5e+104], 1.0, If[LessEqual[y, 5.3e+56], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{+104}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 5.3 \cdot 10^{+56}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.49999999999999984e104 or 5.3000000000000002e56 < y Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in y around inf 63.4%
if -1.49999999999999984e104 < y < 5.3000000000000002e56Initial program 100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in y around 0 64.2%
Final simplification63.9%
(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 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%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
neg-sub0100.0%
associate-+l-100.0%
sub0-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in y around inf 27.7%
Final simplification27.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 2023200
(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)))