
(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 (- (/ 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%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -1.8e-55)
t_0
(if (<= y 6.6e+18)
(/ x z)
(if (or (<= y 2.1e+108) (not (<= y 6.5e+231))) (/ y (- y z)) t_0)))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -1.8e-55) {
tmp = t_0;
} else if (y <= 6.6e+18) {
tmp = x / z;
} else if ((y <= 2.1e+108) || !(y <= 6.5e+231)) {
tmp = y / (y - z);
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
if (y <= (-1.8d-55)) then
tmp = t_0
else if (y <= 6.6d+18) then
tmp = x / z
else if ((y <= 2.1d+108) .or. (.not. (y <= 6.5d+231))) then
tmp = y / (y - z)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -1.8e-55) {
tmp = t_0;
} else if (y <= 6.6e+18) {
tmp = x / z;
} else if ((y <= 2.1e+108) || !(y <= 6.5e+231)) {
tmp = y / (y - z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -1.8e-55: tmp = t_0 elif y <= 6.6e+18: tmp = x / z elif (y <= 2.1e+108) or not (y <= 6.5e+231): tmp = y / (y - z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -1.8e-55) tmp = t_0; elseif (y <= 6.6e+18) tmp = Float64(x / z); elseif ((y <= 2.1e+108) || !(y <= 6.5e+231)) tmp = Float64(y / Float64(y - z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -1.8e-55) tmp = t_0; elseif (y <= 6.6e+18) tmp = x / z; elseif ((y <= 2.1e+108) || ~((y <= 6.5e+231))) tmp = y / (y - z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.8e-55], t$95$0, If[LessEqual[y, 6.6e+18], N[(x / z), $MachinePrecision], If[Or[LessEqual[y, 2.1e+108], N[Not[LessEqual[y, 6.5e+231]], $MachinePrecision]], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -1.8 \cdot 10^{-55}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 6.6 \cdot 10^{+18}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{+108} \lor \neg \left(y \leq 6.5 \cdot 10^{+231}\right):\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.8e-55 or 2.1000000000000001e108 < y < 6.49999999999999933e231Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 76.4%
div-sub76.4%
*-inverses76.4%
Simplified76.4%
if -1.8e-55 < y < 6.6e18Initial program 99.9%
sub-neg99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
sub-neg99.9%
neg-mul-199.9%
associate-/r*99.9%
div-sub99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.8%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.9%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
unsub-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 71.0%
if 6.6e18 < y < 2.1000000000000001e108 or 6.49999999999999933e231 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*100.0%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 87.5%
Final simplification75.6%
(FPCore (x y z) :precision binary64 (if (<= z -3.8e+50) (/ (- x y) z) (if (<= z 1.4e+44) (- 1.0 (/ x y)) (- (/ x z) (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.8e+50) {
tmp = (x - y) / z;
} else if (z <= 1.4e+44) {
tmp = 1.0 - (x / y);
} else {
tmp = (x / z) - (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.8d+50)) then
tmp = (x - y) / z
else if (z <= 1.4d+44) then
tmp = 1.0d0 - (x / y)
else
tmp = (x / z) - (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -3.8e+50) {
tmp = (x - y) / z;
} else if (z <= 1.4e+44) {
tmp = 1.0 - (x / y);
} else {
tmp = (x / z) - (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.8e+50: tmp = (x - y) / z elif z <= 1.4e+44: tmp = 1.0 - (x / y) else: tmp = (x / z) - (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.8e+50) tmp = Float64(Float64(x - y) / z); elseif (z <= 1.4e+44) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(Float64(x / z) - Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -3.8e+50) tmp = (x - y) / z; elseif (z <= 1.4e+44) tmp = 1.0 - (x / y); else tmp = (x / z) - (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.8e+50], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 1.4e+44], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(N[(x / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.8 \cdot 10^{+50}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{elif}\;z \leq 1.4 \cdot 10^{+44}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z} - \frac{y}{z}\\
\end{array}
\end{array}
if z < -3.79999999999999987e50Initial program 99.9%
sub-neg99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
sub-neg99.9%
neg-mul-199.9%
associate-/r*99.9%
div-sub99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.8%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.9%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
unsub-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around inf 84.2%
associate-*r/84.2%
neg-mul-184.2%
neg-sub084.2%
associate--r-84.2%
neg-sub084.2%
Simplified84.2%
Taylor expanded in y around 0 84.2%
+-commutative84.2%
mul-1-neg84.2%
sub-neg84.2%
div-sub84.2%
Simplified84.2%
if -3.79999999999999987e50 < z < 1.4e44Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 75.5%
div-sub75.5%
*-inverses75.5%
Simplified75.5%
if 1.4e44 < z Initial program 99.9%
sub-neg99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
sub-neg99.9%
neg-mul-199.9%
associate-/r*99.9%
div-sub99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.8%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.8%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
unsub-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around inf 77.6%
associate-*r/77.6%
neg-mul-177.6%
neg-sub077.6%
associate--r-77.6%
neg-sub077.6%
Simplified77.6%
Taylor expanded in y around 0 77.7%
+-commutative77.7%
mul-1-neg77.7%
sub-neg77.7%
div-sub77.6%
Simplified77.6%
div-sub77.7%
Applied egg-rr77.7%
Final simplification77.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.3e-55) (not (<= y 155000000.0))) (- 1.0 (/ x y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.3e-55) || !(y <= 155000000.0)) {
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 <= (-4.3d-55)) .or. (.not. (y <= 155000000.0d0))) 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 <= -4.3e-55) || !(y <= 155000000.0)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.3e-55) or not (y <= 155000000.0): tmp = 1.0 - (x / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.3e-55) || !(y <= 155000000.0)) 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 <= -4.3e-55) || ~((y <= 155000000.0))) tmp = 1.0 - (x / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.3e-55], N[Not[LessEqual[y, 155000000.0]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.3 \cdot 10^{-55} \lor \neg \left(y \leq 155000000\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -4.3000000000000001e-55 or 1.55e8 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 73.2%
div-sub73.2%
*-inverses73.2%
Simplified73.2%
if -4.3000000000000001e-55 < y < 1.55e8Initial program 99.9%
sub-neg99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
sub-neg99.9%
neg-mul-199.9%
associate-/r*99.9%
div-sub99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.8%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.9%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
unsub-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 71.0%
Final simplification72.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -9.6e+48) (not (<= z 1.9e+44))) (/ (- x y) z) (- 1.0 (/ x y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9.6e+48) || !(z <= 1.9e+44)) {
tmp = (x - y) / 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 ((z <= (-9.6d+48)) .or. (.not. (z <= 1.9d+44))) then
tmp = (x - y) / 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 ((z <= -9.6e+48) || !(z <= 1.9e+44)) {
tmp = (x - y) / z;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -9.6e+48) or not (z <= 1.9e+44): tmp = (x - y) / z else: tmp = 1.0 - (x / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -9.6e+48) || !(z <= 1.9e+44)) tmp = Float64(Float64(x - y) / z); else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -9.6e+48) || ~((z <= 1.9e+44))) tmp = (x - y) / z; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -9.6e+48], N[Not[LessEqual[z, 1.9e+44]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.6 \cdot 10^{+48} \lor \neg \left(z \leq 1.9 \cdot 10^{+44}\right):\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if z < -9.6000000000000004e48 or 1.9000000000000001e44 < z Initial program 99.9%
sub-neg99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
sub-neg99.9%
neg-mul-199.9%
associate-/r*99.9%
div-sub99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.8%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.9%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
unsub-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in z around inf 81.1%
associate-*r/81.1%
neg-mul-181.1%
neg-sub081.1%
associate--r-81.1%
neg-sub081.1%
Simplified81.1%
Taylor expanded in y around 0 81.1%
+-commutative81.1%
mul-1-neg81.1%
sub-neg81.1%
div-sub81.1%
Simplified81.1%
if -9.6000000000000004e48 < z < 1.9000000000000001e44Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 75.5%
div-sub75.5%
*-inverses75.5%
Simplified75.5%
Final simplification77.9%
(FPCore (x y z) :precision binary64 (if (<= y -26.5) 1.0 (if (<= y 2e+45) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -26.5) {
tmp = 1.0;
} else if (y <= 2e+45) {
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 <= (-26.5d0)) then
tmp = 1.0d0
else if (y <= 2d+45) 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 <= -26.5) {
tmp = 1.0;
} else if (y <= 2e+45) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -26.5: tmp = 1.0 elif y <= 2e+45: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -26.5) tmp = 1.0; elseif (y <= 2e+45) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -26.5) tmp = 1.0; elseif (y <= 2e+45) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -26.5], 1.0, If[LessEqual[y, 2e+45], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -26.5:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2 \cdot 10^{+45}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -26.5 or 1.9999999999999999e45 < y Initial program 100.0%
sub-neg100.0%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.9%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 58.9%
if -26.5 < y < 1.9999999999999999e45Initial program 99.9%
sub-neg99.9%
remove-double-neg99.9%
distribute-neg-in99.9%
+-commutative99.9%
sub-neg99.9%
neg-mul-199.9%
associate-/r*99.9%
div-sub99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.8%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
remove-double-neg99.9%
neg-mul-199.9%
associate-/l*99.9%
associate-/r/99.9%
metadata-eval99.9%
*-lft-identity99.9%
unsub-neg99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in y around 0 66.0%
Final simplification62.5%
(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%
remove-double-neg100.0%
distribute-neg-in100.0%
+-commutative100.0%
sub-neg100.0%
neg-mul-1100.0%
associate-/r*100.0%
div-sub100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
remove-double-neg100.0%
neg-mul-1100.0%
associate-/l*99.8%
associate-/r/100.0%
metadata-eval100.0%
*-lft-identity100.0%
unsub-neg100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 33.1%
Final simplification33.1%
(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 2024036
(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)))