
(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 7 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
(let* ((t_0 (/ y (- y z))) (t_1 (- 1.0 (/ x y))))
(if (<= y -4.7e+210)
t_0
(if (<= y -3e+68)
t_1
(if (<= y -4.2e-95)
t_0
(if (<= y 1.8e-31) (/ x z) (if (<= y 1.1e+42) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double t_1 = 1.0 - (x / y);
double tmp;
if (y <= -4.7e+210) {
tmp = t_0;
} else if (y <= -3e+68) {
tmp = t_1;
} else if (y <= -4.2e-95) {
tmp = t_0;
} else if (y <= 1.8e-31) {
tmp = x / z;
} else if (y <= 1.1e+42) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y / (y - z)
t_1 = 1.0d0 - (x / y)
if (y <= (-4.7d+210)) then
tmp = t_0
else if (y <= (-3d+68)) then
tmp = t_1
else if (y <= (-4.2d-95)) then
tmp = t_0
else if (y <= 1.8d-31) then
tmp = x / z
else if (y <= 1.1d+42) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / (y - z);
double t_1 = 1.0 - (x / y);
double tmp;
if (y <= -4.7e+210) {
tmp = t_0;
} else if (y <= -3e+68) {
tmp = t_1;
} else if (y <= -4.2e-95) {
tmp = t_0;
} else if (y <= 1.8e-31) {
tmp = x / z;
} else if (y <= 1.1e+42) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) t_1 = 1.0 - (x / y) tmp = 0 if y <= -4.7e+210: tmp = t_0 elif y <= -3e+68: tmp = t_1 elif y <= -4.2e-95: tmp = t_0 elif y <= 1.8e-31: tmp = x / z elif y <= 1.1e+42: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(y - z)) t_1 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -4.7e+210) tmp = t_0; elseif (y <= -3e+68) tmp = t_1; elseif (y <= -4.2e-95) tmp = t_0; elseif (y <= 1.8e-31) tmp = Float64(x / z); elseif (y <= 1.1e+42) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (y - z); t_1 = 1.0 - (x / y); tmp = 0.0; if (y <= -4.7e+210) tmp = t_0; elseif (y <= -3e+68) tmp = t_1; elseif (y <= -4.2e-95) tmp = t_0; elseif (y <= 1.8e-31) tmp = x / z; elseif (y <= 1.1e+42) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.7e+210], t$95$0, If[LessEqual[y, -3e+68], t$95$1, If[LessEqual[y, -4.2e-95], t$95$0, If[LessEqual[y, 1.8e-31], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.1e+42], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
t_1 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -4.7 \cdot 10^{+210}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -3 \cdot 10^{+68}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -4.2 \cdot 10^{-95}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{-31}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+42}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -4.7000000000000001e210 or -3.0000000000000002e68 < y < -4.2e-95 or 1.80000000000000002e-31 < y < 1.1000000000000001e42Initial 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 74.4%
if -4.7000000000000001e210 < y < -3.0000000000000002e68 or 1.1000000000000001e42 < 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 83.4%
div-sub83.4%
*-inverses83.4%
Simplified83.4%
if -4.2e-95 < y < 1.80000000000000002e-31Initial 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 y around 0 77.3%
Final simplification78.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))) (t_1 (- 1.0 (/ x y))))
(if (<= y -6e+212)
t_0
(if (<= y -2e+73)
t_1
(if (<= y -3.4e-14)
t_0
(if (<= y 1.95e-33)
(/ (- x) (- y z))
(if (<= y 1.9e+43) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double t_1 = 1.0 - (x / y);
double tmp;
if (y <= -6e+212) {
tmp = t_0;
} else if (y <= -2e+73) {
tmp = t_1;
} else if (y <= -3.4e-14) {
tmp = t_0;
} else if (y <= 1.95e-33) {
tmp = -x / (y - z);
} else if (y <= 1.9e+43) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = y / (y - z)
t_1 = 1.0d0 - (x / y)
if (y <= (-6d+212)) then
tmp = t_0
else if (y <= (-2d+73)) then
tmp = t_1
else if (y <= (-3.4d-14)) then
tmp = t_0
else if (y <= 1.95d-33) then
tmp = -x / (y - z)
else if (y <= 1.9d+43) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / (y - z);
double t_1 = 1.0 - (x / y);
double tmp;
if (y <= -6e+212) {
tmp = t_0;
} else if (y <= -2e+73) {
tmp = t_1;
} else if (y <= -3.4e-14) {
tmp = t_0;
} else if (y <= 1.95e-33) {
tmp = -x / (y - z);
} else if (y <= 1.9e+43) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) t_1 = 1.0 - (x / y) tmp = 0 if y <= -6e+212: tmp = t_0 elif y <= -2e+73: tmp = t_1 elif y <= -3.4e-14: tmp = t_0 elif y <= 1.95e-33: tmp = -x / (y - z) elif y <= 1.9e+43: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(y / Float64(y - z)) t_1 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -6e+212) tmp = t_0; elseif (y <= -2e+73) tmp = t_1; elseif (y <= -3.4e-14) tmp = t_0; elseif (y <= 1.95e-33) tmp = Float64(Float64(-x) / Float64(y - z)); elseif (y <= 1.9e+43) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (y - z); t_1 = 1.0 - (x / y); tmp = 0.0; if (y <= -6e+212) tmp = t_0; elseif (y <= -2e+73) tmp = t_1; elseif (y <= -3.4e-14) tmp = t_0; elseif (y <= 1.95e-33) tmp = -x / (y - z); elseif (y <= 1.9e+43) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -6e+212], t$95$0, If[LessEqual[y, -2e+73], t$95$1, If[LessEqual[y, -3.4e-14], t$95$0, If[LessEqual[y, 1.95e-33], N[((-x) / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.9e+43], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
t_1 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -6 \cdot 10^{+212}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2 \cdot 10^{+73}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -3.4 \cdot 10^{-14}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{-33}:\\
\;\;\;\;\frac{-x}{y - z}\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{+43}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < -6e212 or -1.99999999999999997e73 < y < -3.40000000000000003e-14 or 1.94999999999999987e-33 < y < 1.90000000000000004e43Initial 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 85.5%
if -6e212 < y < -1.99999999999999997e73 or 1.90000000000000004e43 < 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 83.4%
div-sub83.4%
*-inverses83.4%
Simplified83.4%
if -3.40000000000000003e-14 < y < 1.94999999999999987e-33Initial 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 85.3%
neg-mul-185.3%
distribute-neg-frac85.3%
Simplified85.3%
Final simplification84.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.35e-27) (not (<= y 1.9e-28))) (- 1.0 (/ x y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.35e-27) || !(y <= 1.9e-28)) {
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 <= (-2.35d-27)) .or. (.not. (y <= 1.9d-28))) 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 <= -2.35e-27) || !(y <= 1.9e-28)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.35e-27) or not (y <= 1.9e-28): tmp = 1.0 - (x / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.35e-27) || !(y <= 1.9e-28)) 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 <= -2.35e-27) || ~((y <= 1.9e-28))) tmp = 1.0 - (x / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.35e-27], N[Not[LessEqual[y, 1.9e-28]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.35 \cdot 10^{-27} \lor \neg \left(y \leq 1.9 \cdot 10^{-28}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -2.35000000000000016e-27 or 1.90000000000000005e-28 < 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 z around 0 73.0%
div-sub73.1%
*-inverses73.1%
Simplified73.1%
if -2.35000000000000016e-27 < y < 1.90000000000000005e-28Initial 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 y around 0 73.4%
Final simplification73.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -6.7e+14) (not (<= z 5.8e+31))) (/ (- x y) z) (- 1.0 (/ x y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -6.7e+14) || !(z <= 5.8e+31)) {
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 <= (-6.7d+14)) .or. (.not. (z <= 5.8d+31))) 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 <= -6.7e+14) || !(z <= 5.8e+31)) {
tmp = (x - y) / z;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -6.7e+14) or not (z <= 5.8e+31): tmp = (x - y) / z else: tmp = 1.0 - (x / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -6.7e+14) || !(z <= 5.8e+31)) 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 <= -6.7e+14) || ~((z <= 5.8e+31))) tmp = (x - y) / z; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -6.7e+14], N[Not[LessEqual[z, 5.8e+31]], $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 -6.7 \cdot 10^{+14} \lor \neg \left(z \leq 5.8 \cdot 10^{+31}\right):\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if z < -6.7e14 or 5.8000000000000001e31 < z Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.6%
neg-mul-199.6%
sub-neg99.6%
+-commutative99.6%
distribute-neg-out99.6%
remove-double-neg99.6%
sub-neg99.6%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
Simplified100.0%
clear-num99.6%
associate-/r/99.6%
Applied egg-rr99.6%
Taylor expanded in y around 0 81.7%
Taylor expanded in z around 0 82.0%
associate-*r/82.0%
neg-mul-182.0%
neg-sub082.0%
associate--r-82.0%
neg-sub082.0%
+-commutative82.0%
sub-neg82.0%
Simplified82.0%
if -6.7e14 < z < 5.8000000000000001e31Initial 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 79.5%
div-sub79.5%
*-inverses79.5%
Simplified79.5%
Final simplification80.7%
(FPCore (x y z) :precision binary64 (if (<= y -3.4e-25) 1.0 (if (<= y 1.95e-27) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.4e-25) {
tmp = 1.0;
} else if (y <= 1.95e-27) {
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.4d-25)) then
tmp = 1.0d0
else if (y <= 1.95d-27) 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.4e-25) {
tmp = 1.0;
} else if (y <= 1.95e-27) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.4e-25: tmp = 1.0 elif y <= 1.95e-27: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.4e-25) tmp = 1.0; elseif (y <= 1.95e-27) 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.4e-25) tmp = 1.0; elseif (y <= 1.95e-27) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.4e-25], 1.0, If[LessEqual[y, 1.95e-27], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{-25}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{-27}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -3.40000000000000002e-25 or 1.94999999999999986e-27 < 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 54.4%
if -3.40000000000000002e-25 < y < 1.94999999999999986e-27Initial 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 y around 0 73.4%
Final simplification63.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%
*-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 34.0%
Final simplification34.0%
(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 2023299
(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)))