
(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 10 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 (- z y)) (/ y (- y z))))
double code(double x, double y, double z) {
return (x / (z - y)) + (y / (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 = (x / (z - y)) + (y / (y - z))
end function
public static double code(double x, double y, double z) {
return (x / (z - y)) + (y / (y - z));
}
def code(x, y, z): return (x / (z - y)) + (y / (y - z))
function code(x, y, z) return Float64(Float64(x / Float64(z - y)) + Float64(y / Float64(y - z))) end
function tmp = code(x, y, z) tmp = (x / (z - y)) + (y / (y - z)); end
code[x_, y_, z_] := N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] + N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{z - y} + \frac{y}{y - z}
\end{array}
Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ x (- z y))))
(if (<= x -4.5e+28)
t_0
(if (<= x -9.5e-40)
(- 1.0 (/ x y))
(if (or (<= x -1.9e-47) (not (<= x 8.1e-19))) t_0 (/ y (- y z)))))))
double code(double x, double y, double z) {
double t_0 = x / (z - y);
double tmp;
if (x <= -4.5e+28) {
tmp = t_0;
} else if (x <= -9.5e-40) {
tmp = 1.0 - (x / y);
} else if ((x <= -1.9e-47) || !(x <= 8.1e-19)) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x / (z - y)
if (x <= (-4.5d+28)) then
tmp = t_0
else if (x <= (-9.5d-40)) then
tmp = 1.0d0 - (x / y)
else if ((x <= (-1.9d-47)) .or. (.not. (x <= 8.1d-19))) then
tmp = t_0
else
tmp = y / (y - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x / (z - y);
double tmp;
if (x <= -4.5e+28) {
tmp = t_0;
} else if (x <= -9.5e-40) {
tmp = 1.0 - (x / y);
} else if ((x <= -1.9e-47) || !(x <= 8.1e-19)) {
tmp = t_0;
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): t_0 = x / (z - y) tmp = 0 if x <= -4.5e+28: tmp = t_0 elif x <= -9.5e-40: tmp = 1.0 - (x / y) elif (x <= -1.9e-47) or not (x <= 8.1e-19): tmp = t_0 else: tmp = y / (y - z) return tmp
function code(x, y, z) t_0 = Float64(x / Float64(z - y)) tmp = 0.0 if (x <= -4.5e+28) tmp = t_0; elseif (x <= -9.5e-40) tmp = Float64(1.0 - Float64(x / y)); elseif ((x <= -1.9e-47) || !(x <= 8.1e-19)) tmp = t_0; else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x / (z - y); tmp = 0.0; if (x <= -4.5e+28) tmp = t_0; elseif (x <= -9.5e-40) tmp = 1.0 - (x / y); elseif ((x <= -1.9e-47) || ~((x <= 8.1e-19))) tmp = t_0; else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.5e+28], t$95$0, If[LessEqual[x, -9.5e-40], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -1.9e-47], N[Not[LessEqual[x, 8.1e-19]], $MachinePrecision]], t$95$0, N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z - y}\\
\mathbf{if}\;x \leq -4.5 \cdot 10^{+28}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -9.5 \cdot 10^{-40}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq -1.9 \cdot 10^{-47} \lor \neg \left(x \leq 8.1 \cdot 10^{-19}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if x < -4.4999999999999997e28 or -9.5000000000000006e-40 < x < -1.90000000000000007e-47 or 8.10000000000000023e-19 < x Initial program 100.0%
Taylor expanded in x around inf 79.2%
if -4.4999999999999997e28 < x < -9.5000000000000006e-40Initial program 99.8%
Taylor expanded in z around 0 86.3%
div-sub86.3%
sub-neg86.3%
*-inverses86.3%
metadata-eval86.3%
distribute-lft-in86.3%
metadata-eval86.3%
+-commutative86.3%
mul-1-neg86.3%
unsub-neg86.3%
Simplified86.3%
if -1.90000000000000007e-47 < x < 8.10000000000000023e-19Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
sub-div100.0%
clear-num98.2%
Applied egg-rr98.2%
Taylor expanded in x around 0 84.8%
mul-1-neg84.8%
distribute-neg-frac284.8%
neg-sub084.8%
associate-+l-84.8%
neg-sub084.8%
+-commutative84.8%
unsub-neg84.8%
Simplified84.8%
Final simplification82.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (- 1.0 (/ x y))))
(if (<= y -2.9e-109)
t_0
(if (<= y 8.5e-156)
(/ x z)
(if (<= y 2.8e-112) (/ y (- z)) (if (<= y 5.2e-102) (/ x z) t_0))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -2.9e-109) {
tmp = t_0;
} else if (y <= 8.5e-156) {
tmp = x / z;
} else if (y <= 2.8e-112) {
tmp = y / -z;
} else if (y <= 5.2e-102) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = 1.0d0 - (x / y)
if (y <= (-2.9d-109)) then
tmp = t_0
else if (y <= 8.5d-156) then
tmp = x / z
else if (y <= 2.8d-112) then
tmp = y / -z
else if (y <= 5.2d-102) then
tmp = x / z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -2.9e-109) {
tmp = t_0;
} else if (y <= 8.5e-156) {
tmp = x / z;
} else if (y <= 2.8e-112) {
tmp = y / -z;
} else if (y <= 5.2e-102) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -2.9e-109: tmp = t_0 elif y <= 8.5e-156: tmp = x / z elif y <= 2.8e-112: tmp = y / -z elif y <= 5.2e-102: tmp = x / 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 <= -2.9e-109) tmp = t_0; elseif (y <= 8.5e-156) tmp = Float64(x / z); elseif (y <= 2.8e-112) tmp = Float64(y / Float64(-z)); elseif (y <= 5.2e-102) tmp = Float64(x / 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 <= -2.9e-109) tmp = t_0; elseif (y <= 8.5e-156) tmp = x / z; elseif (y <= 2.8e-112) tmp = y / -z; elseif (y <= 5.2e-102) tmp = x / 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, -2.9e-109], t$95$0, If[LessEqual[y, 8.5e-156], N[(x / z), $MachinePrecision], If[LessEqual[y, 2.8e-112], N[(y / (-z)), $MachinePrecision], If[LessEqual[y, 5.2e-102], N[(x / z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -2.9 \cdot 10^{-109}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 8.5 \cdot 10^{-156}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{-112}:\\
\;\;\;\;\frac{y}{-z}\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{-102}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -2.9e-109 or 5.19999999999999973e-102 < y Initial program 100.0%
Taylor expanded in z around 0 69.2%
div-sub69.2%
sub-neg69.2%
*-inverses69.2%
metadata-eval69.2%
distribute-lft-in69.2%
metadata-eval69.2%
+-commutative69.2%
mul-1-neg69.2%
unsub-neg69.2%
Simplified69.2%
if -2.9e-109 < y < 8.5e-156 or 2.80000000000000023e-112 < y < 5.19999999999999973e-102Initial program 100.0%
Taylor expanded in y around 0 82.0%
if 8.5e-156 < y < 2.80000000000000023e-112Initial program 100.0%
Taylor expanded in z around inf 70.4%
Taylor expanded in x around 0 57.2%
neg-mul-157.2%
distribute-neg-frac57.2%
Simplified57.2%
Final simplification72.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ x (- z y))))
(if (<= x -9.4e+27)
t_0
(if (<= x -1.4e-42)
(- 1.0 (/ x y))
(if (<= x -4.5e-74)
(/ (- x y) z)
(if (<= x 7.2e-20) (/ y (- y z)) t_0))))))
double code(double x, double y, double z) {
double t_0 = x / (z - y);
double tmp;
if (x <= -9.4e+27) {
tmp = t_0;
} else if (x <= -1.4e-42) {
tmp = 1.0 - (x / y);
} else if (x <= -4.5e-74) {
tmp = (x - y) / z;
} else if (x <= 7.2e-20) {
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 = x / (z - y)
if (x <= (-9.4d+27)) then
tmp = t_0
else if (x <= (-1.4d-42)) then
tmp = 1.0d0 - (x / y)
else if (x <= (-4.5d-74)) then
tmp = (x - y) / z
else if (x <= 7.2d-20) 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 = x / (z - y);
double tmp;
if (x <= -9.4e+27) {
tmp = t_0;
} else if (x <= -1.4e-42) {
tmp = 1.0 - (x / y);
} else if (x <= -4.5e-74) {
tmp = (x - y) / z;
} else if (x <= 7.2e-20) {
tmp = y / (y - z);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x / (z - y) tmp = 0 if x <= -9.4e+27: tmp = t_0 elif x <= -1.4e-42: tmp = 1.0 - (x / y) elif x <= -4.5e-74: tmp = (x - y) / z elif x <= 7.2e-20: tmp = y / (y - z) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x / Float64(z - y)) tmp = 0.0 if (x <= -9.4e+27) tmp = t_0; elseif (x <= -1.4e-42) tmp = Float64(1.0 - Float64(x / y)); elseif (x <= -4.5e-74) tmp = Float64(Float64(x - y) / z); elseif (x <= 7.2e-20) tmp = Float64(y / Float64(y - z)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x / (z - y); tmp = 0.0; if (x <= -9.4e+27) tmp = t_0; elseif (x <= -1.4e-42) tmp = 1.0 - (x / y); elseif (x <= -4.5e-74) tmp = (x - y) / z; elseif (x <= 7.2e-20) tmp = y / (y - z); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9.4e+27], t$95$0, If[LessEqual[x, -1.4e-42], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4.5e-74], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[x, 7.2e-20], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z - y}\\
\mathbf{if}\;x \leq -9.4 \cdot 10^{+27}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-42}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;x \leq -4.5 \cdot 10^{-74}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-20}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -9.39999999999999952e27 or 7.19999999999999948e-20 < x Initial program 100.0%
Taylor expanded in x around inf 78.4%
if -9.39999999999999952e27 < x < -1.39999999999999999e-42Initial program 99.8%
Taylor expanded in z around 0 88.0%
div-sub88.0%
sub-neg88.0%
*-inverses88.0%
metadata-eval88.0%
distribute-lft-in88.0%
metadata-eval88.0%
+-commutative88.0%
mul-1-neg88.0%
unsub-neg88.0%
Simplified88.0%
if -1.39999999999999999e-42 < x < -4.4999999999999999e-74Initial program 100.0%
Taylor expanded in z around inf 79.9%
if -4.4999999999999999e-74 < x < 7.19999999999999948e-20Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
sub-div100.0%
clear-num98.1%
Applied egg-rr98.1%
Taylor expanded in x around 0 86.2%
mul-1-neg86.2%
distribute-neg-frac286.2%
neg-sub086.2%
associate-+l-86.2%
neg-sub086.2%
+-commutative86.2%
unsub-neg86.2%
Simplified86.2%
Final simplification82.7%
(FPCore (x y z)
:precision binary64
(if (<= y -2.05e-91)
1.0
(if (<= y 1e-155)
(/ x z)
(if (<= y 1.1e-81) (/ y (- z)) (if (<= y 0.0013) (/ x z) 1.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.05e-91) {
tmp = 1.0;
} else if (y <= 1e-155) {
tmp = x / z;
} else if (y <= 1.1e-81) {
tmp = y / -z;
} else if (y <= 0.0013) {
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 <= (-2.05d-91)) then
tmp = 1.0d0
else if (y <= 1d-155) then
tmp = x / z
else if (y <= 1.1d-81) then
tmp = y / -z
else if (y <= 0.0013d0) 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 <= -2.05e-91) {
tmp = 1.0;
} else if (y <= 1e-155) {
tmp = x / z;
} else if (y <= 1.1e-81) {
tmp = y / -z;
} else if (y <= 0.0013) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.05e-91: tmp = 1.0 elif y <= 1e-155: tmp = x / z elif y <= 1.1e-81: tmp = y / -z elif y <= 0.0013: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.05e-91) tmp = 1.0; elseif (y <= 1e-155) tmp = Float64(x / z); elseif (y <= 1.1e-81) tmp = Float64(y / Float64(-z)); elseif (y <= 0.0013) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.05e-91) tmp = 1.0; elseif (y <= 1e-155) tmp = x / z; elseif (y <= 1.1e-81) tmp = y / -z; elseif (y <= 0.0013) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.05e-91], 1.0, If[LessEqual[y, 1e-155], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.1e-81], N[(y / (-z)), $MachinePrecision], If[LessEqual[y, 0.0013], N[(x / z), $MachinePrecision], 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.05 \cdot 10^{-91}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 10^{-155}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{-81}:\\
\;\;\;\;\frac{y}{-z}\\
\mathbf{elif}\;y \leq 0.0013:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.05000000000000012e-91 or 0.0012999999999999999 < y Initial program 100.0%
Taylor expanded in y around inf 59.6%
if -2.05000000000000012e-91 < y < 1.00000000000000001e-155 or 1.1e-81 < y < 0.0012999999999999999Initial program 99.9%
Taylor expanded in y around 0 71.9%
if 1.00000000000000001e-155 < y < 1.1e-81Initial program 100.0%
Taylor expanded in z around inf 66.4%
Taylor expanded in x around 0 51.0%
neg-mul-151.0%
distribute-neg-frac51.0%
Simplified51.0%
Final simplification63.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.7e+35) (not (<= z 1.45e+53))) (/ (- x y) z) (- (/ x (- z y)) -1.0)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.7e+35) || !(z <= 1.45e+53)) {
tmp = (x - y) / z;
} else {
tmp = (x / (z - y)) - -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 ((z <= (-2.7d+35)) .or. (.not. (z <= 1.45d+53))) then
tmp = (x - y) / z
else
tmp = (x / (z - y)) - (-1.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.7e+35) || !(z <= 1.45e+53)) {
tmp = (x - y) / z;
} else {
tmp = (x / (z - y)) - -1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.7e+35) or not (z <= 1.45e+53): tmp = (x - y) / z else: tmp = (x / (z - y)) - -1.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.7e+35) || !(z <= 1.45e+53)) tmp = Float64(Float64(x - y) / z); else tmp = Float64(Float64(x / Float64(z - y)) - -1.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.7e+35) || ~((z <= 1.45e+53))) tmp = (x - y) / z; else tmp = (x / (z - y)) - -1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.7e+35], N[Not[LessEqual[z, 1.45e+53]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], N[(N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.7 \cdot 10^{+35} \lor \neg \left(z \leq 1.45 \cdot 10^{+53}\right):\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z - y} - -1\\
\end{array}
\end{array}
if z < -2.70000000000000003e35 or 1.4500000000000001e53 < z Initial program 100.0%
Taylor expanded in z around inf 82.5%
if -2.70000000000000003e35 < z < 1.4500000000000001e53Initial program 100.0%
div-sub100.0%
Applied egg-rr100.0%
Taylor expanded in y around inf 87.9%
Final simplification85.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.7e-89) (not (<= y 0.04))) (- 1.0 (/ x y)) (/ x (- z y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.7e-89) || !(y <= 0.04)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (z - 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 <= (-2.7d-89)) .or. (.not. (y <= 0.04d0))) then
tmp = 1.0d0 - (x / y)
else
tmp = x / (z - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.7e-89) || !(y <= 0.04)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / (z - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.7e-89) or not (y <= 0.04): tmp = 1.0 - (x / y) else: tmp = x / (z - y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.7e-89) || !(y <= 0.04)) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(x / Float64(z - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.7e-89) || ~((y <= 0.04))) tmp = 1.0 - (x / y); else tmp = x / (z - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.7e-89], N[Not[LessEqual[y, 0.04]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / N[(z - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{-89} \lor \neg \left(y \leq 0.04\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z - y}\\
\end{array}
\end{array}
if y < -2.69999999999999988e-89 or 0.0400000000000000008 < y Initial program 100.0%
Taylor expanded in z around 0 74.7%
div-sub74.7%
sub-neg74.7%
*-inverses74.7%
metadata-eval74.7%
distribute-lft-in74.7%
metadata-eval74.7%
+-commutative74.7%
mul-1-neg74.7%
unsub-neg74.7%
Simplified74.7%
if -2.69999999999999988e-89 < y < 0.0400000000000000008Initial program 99.9%
Taylor expanded in x around inf 75.9%
Final simplification75.3%
(FPCore (x y z) :precision binary64 (if (<= y -2.7e-89) 1.0 (if (<= y 0.00165) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e-89) {
tmp = 1.0;
} else if (y <= 0.00165) {
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 <= (-2.7d-89)) then
tmp = 1.0d0
else if (y <= 0.00165d0) 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 <= -2.7e-89) {
tmp = 1.0;
} else if (y <= 0.00165) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.7e-89: tmp = 1.0 elif y <= 0.00165: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.7e-89) tmp = 1.0; elseif (y <= 0.00165) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.7e-89) tmp = 1.0; elseif (y <= 0.00165) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.7e-89], 1.0, If[LessEqual[y, 0.00165], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{-89}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 0.00165:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.69999999999999988e-89 or 0.00165 < y Initial program 100.0%
Taylor expanded in y around inf 59.6%
if -2.69999999999999988e-89 < y < 0.00165Initial program 99.9%
Taylor expanded in y around 0 63.9%
Final simplification61.6%
(FPCore (x y z) :precision binary64 (/ (- y x) (- y z)))
double code(double x, double y, double z) {
return (y - 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 - x) / (y - z)
end function
public static double code(double x, double y, double z) {
return (y - x) / (y - z);
}
def code(x, y, z): return (y - x) / (y - z)
function code(x, y, z) return Float64(Float64(y - x) / Float64(y - z)) end
function tmp = code(x, y, z) tmp = (y - x) / (y - z); end
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] / N[(y - z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{y - x}{y - z}
\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%
Taylor expanded in y around inf 36.1%
Final simplification36.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 2024067
(FPCore (x y z)
:name "Graphics.Rasterific.Shading:$sgradientColorAt from Rasterific-0.6.1"
:precision binary64
:alt
(- (/ x (- z y)) (/ y (- z y)))
(/ (- x y) (- z y)))