
(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 9 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 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.5%
associate-/l*99.4%
neg-mul-199.4%
sub-neg99.4%
+-commutative99.4%
distribute-neg-out99.4%
remove-double-neg99.4%
sub-neg99.4%
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%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -550000.0) (not (<= y 3.5e-26))) (+ 1.0 (/ z y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -550000.0) || !(y <= 3.5e-26)) {
tmp = 1.0 + (z / 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 <= (-550000.0d0)) .or. (.not. (y <= 3.5d-26))) then
tmp = 1.0d0 + (z / 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 <= -550000.0) || !(y <= 3.5e-26)) {
tmp = 1.0 + (z / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -550000.0) or not (y <= 3.5e-26): tmp = 1.0 + (z / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -550000.0) || !(y <= 3.5e-26)) tmp = Float64(1.0 + Float64(z / y)); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -550000.0) || ~((y <= 3.5e-26))) tmp = 1.0 + (z / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -550000.0], N[Not[LessEqual[y, 3.5e-26]], $MachinePrecision]], N[(1.0 + N[(z / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -550000 \lor \neg \left(y \leq 3.5 \cdot 10^{-26}\right):\\
\;\;\;\;1 + \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -5.5e5 or 3.49999999999999985e-26 < y 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 x around 0 76.0%
Taylor expanded in y around inf 62.0%
if -5.5e5 < y < 3.49999999999999985e-26Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.3%
associate-/l*99.2%
neg-mul-199.2%
sub-neg99.2%
+-commutative99.2%
distribute-neg-out99.2%
remove-double-neg99.2%
sub-neg99.2%
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 72.3%
Final simplification67.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -650000.0) (not (<= y 1.3e-48))) (- 1.0 (/ x y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -650000.0) || !(y <= 1.3e-48)) {
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 <= (-650000.0d0)) .or. (.not. (y <= 1.3d-48))) 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 <= -650000.0) || !(y <= 1.3e-48)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -650000.0) or not (y <= 1.3e-48): tmp = 1.0 - (x / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -650000.0) || !(y <= 1.3e-48)) 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 <= -650000.0) || ~((y <= 1.3e-48))) tmp = 1.0 - (x / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -650000.0], N[Not[LessEqual[y, 1.3e-48]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -650000 \lor \neg \left(y \leq 1.3 \cdot 10^{-48}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -6.5e5 or 1.29999999999999994e-48 < y 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 0 73.4%
div-sub73.4%
*-inverses73.4%
Simplified73.4%
if -6.5e5 < y < 1.29999999999999994e-48Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.3%
associate-/l*99.2%
neg-mul-199.2%
sub-neg99.2%
+-commutative99.2%
distribute-neg-out99.2%
remove-double-neg99.2%
sub-neg99.2%
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 74.0%
Final simplification73.7%
(FPCore (x y z) :precision binary64 (if (<= y -920000.0) (- 1.0 (/ x y)) (if (<= y 7.5e-34) (/ x z) (/ y (- y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -920000.0) {
tmp = 1.0 - (x / y);
} else if (y <= 7.5e-34) {
tmp = x / z;
} else {
tmp = y / (y - z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-920000.0d0)) then
tmp = 1.0d0 - (x / y)
else if (y <= 7.5d-34) then
tmp = x / z
else
tmp = y / (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -920000.0) {
tmp = 1.0 - (x / y);
} else if (y <= 7.5e-34) {
tmp = x / z;
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -920000.0: tmp = 1.0 - (x / y) elif y <= 7.5e-34: tmp = x / z else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -920000.0) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 7.5e-34) tmp = Float64(x / z); else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -920000.0) tmp = 1.0 - (x / y); elseif (y <= 7.5e-34) tmp = x / z; else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -920000.0], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 7.5e-34], N[(x / z), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -920000:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-34}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if y < -9.2e5Initial 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 79.2%
div-sub79.2%
*-inverses79.2%
Simplified79.2%
if -9.2e5 < y < 7.5000000000000004e-34Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.3%
associate-/l*99.2%
neg-mul-199.2%
sub-neg99.2%
+-commutative99.2%
distribute-neg-out99.2%
remove-double-neg99.2%
sub-neg99.2%
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 72.8%
if 7.5000000000000004e-34 < y 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 x around 0 77.5%
Final simplification75.5%
(FPCore (x y z) :precision binary64 (if (<= y -2.9e+17) (- 1.0 (/ x y)) (if (<= y 4.1e-29) (/ (- x y) z) (/ y (- y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.9e+17) {
tmp = 1.0 - (x / y);
} else if (y <= 4.1e-29) {
tmp = (x - y) / z;
} else {
tmp = y / (y - z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-2.9d+17)) then
tmp = 1.0d0 - (x / y)
else if (y <= 4.1d-29) then
tmp = (x - y) / z
else
tmp = y / (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.9e+17) {
tmp = 1.0 - (x / y);
} else if (y <= 4.1e-29) {
tmp = (x - y) / z;
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.9e+17: tmp = 1.0 - (x / y) elif y <= 4.1e-29: tmp = (x - y) / z else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.9e+17) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 4.1e-29) tmp = Float64(Float64(x - y) / z); else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.9e+17) tmp = 1.0 - (x / y); elseif (y <= 4.1e-29) tmp = (x - y) / z; else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.9e+17], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.1e-29], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.9 \cdot 10^{+17}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 4.1 \cdot 10^{-29}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if y < -2.9e17Initial 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 80.0%
div-sub80.1%
*-inverses80.1%
Simplified80.1%
if -2.9e17 < y < 4.0999999999999998e-29Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.3%
associate-/l*99.2%
neg-mul-199.2%
sub-neg99.2%
+-commutative99.2%
distribute-neg-out99.2%
remove-double-neg99.2%
sub-neg99.2%
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 83.3%
associate-*r/83.3%
neg-mul-183.3%
neg-sub083.3%
associate--r-83.3%
neg-sub083.3%
Simplified83.3%
Taylor expanded in y around 0 83.3%
+-commutative83.3%
mul-1-neg83.3%
sub-neg83.3%
div-sub83.3%
Simplified83.3%
if 4.0999999999999998e-29 < y 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 x around 0 77.5%
Final simplification81.2%
(FPCore (x y z) :precision binary64 (if (<= y -7.2e+17) (+ 1.0 (/ (- z x) y)) (if (<= y 1.05e-30) (/ (- x y) z) (/ y (- y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+17) {
tmp = 1.0 + ((z - x) / y);
} else if (y <= 1.05e-30) {
tmp = (x - y) / z;
} else {
tmp = y / (y - z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= (-7.2d+17)) then
tmp = 1.0d0 + ((z - x) / y)
else if (y <= 1.05d-30) then
tmp = (x - y) / z
else
tmp = y / (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -7.2e+17) {
tmp = 1.0 + ((z - x) / y);
} else if (y <= 1.05e-30) {
tmp = (x - y) / z;
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.2e+17: tmp = 1.0 + ((z - x) / y) elif y <= 1.05e-30: tmp = (x - y) / z else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.2e+17) tmp = Float64(1.0 + Float64(Float64(z - x) / y)); elseif (y <= 1.05e-30) tmp = Float64(Float64(x - y) / z); else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.2e+17) tmp = 1.0 + ((z - x) / y); elseif (y <= 1.05e-30) tmp = (x - y) / z; else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.2e+17], N[(1.0 + N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.05e-30], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+17}:\\
\;\;\;\;1 + \frac{z - x}{y}\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-30}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if y < -7.2e17Initial 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 80.2%
associate--l+80.2%
distribute-lft-out--80.2%
div-sub80.2%
mul-1-neg80.2%
unsub-neg80.2%
Simplified80.2%
if -7.2e17 < y < 1.0500000000000001e-30Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.3%
associate-/l*99.2%
neg-mul-199.2%
sub-neg99.2%
+-commutative99.2%
distribute-neg-out99.2%
remove-double-neg99.2%
sub-neg99.2%
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 83.3%
associate-*r/83.3%
neg-mul-183.3%
neg-sub083.3%
associate--r-83.3%
neg-sub083.3%
Simplified83.3%
Taylor expanded in y around 0 83.3%
+-commutative83.3%
mul-1-neg83.3%
sub-neg83.3%
div-sub83.3%
Simplified83.3%
if 1.0500000000000001e-30 < y 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 x around 0 77.5%
Final simplification81.2%
(FPCore (x y z) :precision binary64 (if (<= y -4500000.0) 1.0 (if (<= y 3.6e-23) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -4500000.0) {
tmp = 1.0;
} else if (y <= 3.6e-23) {
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 <= (-4500000.0d0)) then
tmp = 1.0d0
else if (y <= 3.6d-23) 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 <= -4500000.0) {
tmp = 1.0;
} else if (y <= 3.6e-23) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4500000.0: tmp = 1.0 elif y <= 3.6e-23: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4500000.0) tmp = 1.0; elseif (y <= 3.6e-23) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4500000.0) tmp = 1.0; elseif (y <= 3.6e-23) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4500000.0], 1.0, If[LessEqual[y, 3.6e-23], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4500000:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-23}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -4.5e6 or 3.5999999999999998e-23 < y 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 y around inf 61.8%
if -4.5e6 < y < 3.5999999999999998e-23Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.3%
associate-/l*99.2%
neg-mul-199.2%
sub-neg99.2%
+-commutative99.2%
distribute-neg-out99.2%
remove-double-neg99.2%
sub-neg99.2%
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 72.3%
Final simplification67.3%
(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 99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.5%
associate-/l*99.4%
neg-mul-199.4%
sub-neg99.4%
+-commutative99.4%
distribute-neg-out99.4%
remove-double-neg99.4%
sub-neg99.4%
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 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 2023310
(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)))