
(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 (/ (- 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 (/ (- x y) z)))
(if (<= z -4.2e+134)
t_0
(if (<= z -7.5e-11)
(/ y (- y z))
(if (or (<= z -5.8e-60)
(and (not (<= z 13600.0))
(or (<= z 4.8e+36) (not (<= z 8e+65)))))
t_0
(/ (- y x) y))))))
double code(double x, double y, double z) {
double t_0 = (x - y) / z;
double tmp;
if (z <= -4.2e+134) {
tmp = t_0;
} else if (z <= -7.5e-11) {
tmp = y / (y - z);
} else if ((z <= -5.8e-60) || (!(z <= 13600.0) && ((z <= 4.8e+36) || !(z <= 8e+65)))) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (x - y) / z
if (z <= (-4.2d+134)) then
tmp = t_0
else if (z <= (-7.5d-11)) then
tmp = y / (y - z)
else if ((z <= (-5.8d-60)) .or. (.not. (z <= 13600.0d0)) .and. (z <= 4.8d+36) .or. (.not. (z <= 8d+65))) then
tmp = t_0
else
tmp = (y - x) / y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x - y) / z;
double tmp;
if (z <= -4.2e+134) {
tmp = t_0;
} else if (z <= -7.5e-11) {
tmp = y / (y - z);
} else if ((z <= -5.8e-60) || (!(z <= 13600.0) && ((z <= 4.8e+36) || !(z <= 8e+65)))) {
tmp = t_0;
} else {
tmp = (y - x) / y;
}
return tmp;
}
def code(x, y, z): t_0 = (x - y) / z tmp = 0 if z <= -4.2e+134: tmp = t_0 elif z <= -7.5e-11: tmp = y / (y - z) elif (z <= -5.8e-60) or (not (z <= 13600.0) and ((z <= 4.8e+36) or not (z <= 8e+65))): tmp = t_0 else: tmp = (y - x) / y return tmp
function code(x, y, z) t_0 = Float64(Float64(x - y) / z) tmp = 0.0 if (z <= -4.2e+134) tmp = t_0; elseif (z <= -7.5e-11) tmp = Float64(y / Float64(y - z)); elseif ((z <= -5.8e-60) || (!(z <= 13600.0) && ((z <= 4.8e+36) || !(z <= 8e+65)))) tmp = t_0; else tmp = Float64(Float64(y - x) / y); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - y) / z; tmp = 0.0; if (z <= -4.2e+134) tmp = t_0; elseif (z <= -7.5e-11) tmp = y / (y - z); elseif ((z <= -5.8e-60) || (~((z <= 13600.0)) && ((z <= 4.8e+36) || ~((z <= 8e+65))))) tmp = t_0; else tmp = (y - x) / y; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[z, -4.2e+134], t$95$0, If[LessEqual[z, -7.5e-11], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -5.8e-60], And[N[Not[LessEqual[z, 13600.0]], $MachinePrecision], Or[LessEqual[z, 4.8e+36], N[Not[LessEqual[z, 8e+65]], $MachinePrecision]]]], t$95$0, N[(N[(y - x), $MachinePrecision] / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - y}{z}\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+134}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -7.5 \cdot 10^{-11}:\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{elif}\;z \leq -5.8 \cdot 10^{-60} \lor \neg \left(z \leq 13600\right) \land \left(z \leq 4.8 \cdot 10^{+36} \lor \neg \left(z \leq 8 \cdot 10^{+65}\right)\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{y - x}{y}\\
\end{array}
\end{array}
if z < -4.2000000000000002e134 or -7.5e-11 < z < -5.7999999999999999e-60 or 13600 < z < 4.79999999999999985e36 or 7.9999999999999999e65 < z 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 inf 87.1%
associate-*r/87.1%
neg-mul-187.1%
neg-sub087.1%
associate--r-87.1%
neg-sub087.1%
Simplified87.1%
Taylor expanded in y around 0 87.1%
+-commutative87.1%
mul-1-neg87.1%
sub-neg87.1%
div-sub87.1%
Simplified87.1%
if -4.2000000000000002e134 < z < -7.5e-11Initial 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 72.2%
if -5.7999999999999999e-60 < z < 13600 or 4.79999999999999985e36 < z < 7.9999999999999999e65Initial 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 83.6%
Final simplification83.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (/ z y))))
(if (<= y -2.05e+96)
t_0
(if (<= y -1.9e-42) (/ (- x) y) (if (<= y 132000000.0) (/ x z) t_0)))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z / y);
double tmp;
if (y <= -2.05e+96) {
tmp = t_0;
} else if (y <= -1.9e-42) {
tmp = -x / y;
} else if (y <= 132000000.0) {
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 + (z / y)
if (y <= (-2.05d+96)) then
tmp = t_0
else if (y <= (-1.9d-42)) then
tmp = -x / y
else if (y <= 132000000.0d0) 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 + (z / y);
double tmp;
if (y <= -2.05e+96) {
tmp = t_0;
} else if (y <= -1.9e-42) {
tmp = -x / y;
} else if (y <= 132000000.0) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z / y) tmp = 0 if y <= -2.05e+96: tmp = t_0 elif y <= -1.9e-42: tmp = -x / y elif y <= 132000000.0: tmp = x / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z / y)) tmp = 0.0 if (y <= -2.05e+96) tmp = t_0; elseif (y <= -1.9e-42) tmp = Float64(Float64(-x) / y); elseif (y <= 132000000.0) tmp = Float64(x / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z / y); tmp = 0.0; if (y <= -2.05e+96) tmp = t_0; elseif (y <= -1.9e-42) tmp = -x / y; elseif (y <= 132000000.0) tmp = x / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.05e+96], t$95$0, If[LessEqual[y, -1.9e-42], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 132000000.0], N[(x / z), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{z}{y}\\
\mathbf{if}\;y \leq -2.05 \cdot 10^{+96}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.9 \cdot 10^{-42}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq 132000000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2.04999999999999999e96 or 1.32e8 < 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 x around 0 76.5%
Taylor expanded in y around inf 60.2%
if -2.04999999999999999e96 < y < -1.90000000000000009e-42Initial 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 69.0%
Taylor expanded in y around 0 48.6%
neg-mul-148.6%
distribute-neg-frac48.6%
Simplified48.6%
if -1.90000000000000009e-42 < y < 1.32e8Initial 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 62.6%
Final simplification60.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.6e+19) (not (<= x 6.2e-35))) (/ (- x) (- y z)) (/ y (- y z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.6e+19) || !(x <= 6.2e-35)) {
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 ((x <= (-1.6d+19)) .or. (.not. (x <= 6.2d-35))) 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 ((x <= -1.6e+19) || !(x <= 6.2e-35)) {
tmp = -x / (y - z);
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.6e+19) or not (x <= 6.2e-35): tmp = -x / (y - z) else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.6e+19) || !(x <= 6.2e-35)) tmp = Float64(Float64(-x) / Float64(y - z)); else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.6e+19) || ~((x <= 6.2e-35))) tmp = -x / (y - z); else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.6e+19], N[Not[LessEqual[x, 6.2e-35]], $MachinePrecision]], N[((-x) / N[(y - z), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+19} \lor \neg \left(x \leq 6.2 \cdot 10^{-35}\right):\\
\;\;\;\;\frac{-x}{y - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if x < -1.6e19 or 6.20000000000000024e-35 < x 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 x around inf 79.1%
neg-mul-179.1%
distribute-neg-frac79.1%
Simplified79.1%
if -1.6e19 < x < 6.20000000000000024e-35Initial 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 85.5%
Final simplification82.2%
(FPCore (x y z) :precision binary64 (if (<= y -2.7e+96) 1.0 (if (<= y -9e-43) (/ (- x) y) (if (<= y 140000000.0) (/ x z) 1.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+96) {
tmp = 1.0;
} else if (y <= -9e-43) {
tmp = -x / y;
} else if (y <= 140000000.0) {
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+96)) then
tmp = 1.0d0
else if (y <= (-9d-43)) then
tmp = -x / y
else if (y <= 140000000.0d0) 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+96) {
tmp = 1.0;
} else if (y <= -9e-43) {
tmp = -x / y;
} else if (y <= 140000000.0) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.7e+96: tmp = 1.0 elif y <= -9e-43: tmp = -x / y elif y <= 140000000.0: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.7e+96) tmp = 1.0; elseif (y <= -9e-43) tmp = Float64(Float64(-x) / y); elseif (y <= 140000000.0) 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+96) tmp = 1.0; elseif (y <= -9e-43) tmp = -x / y; elseif (y <= 140000000.0) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.7e+96], 1.0, If[LessEqual[y, -9e-43], N[((-x) / y), $MachinePrecision], If[LessEqual[y, 140000000.0], N[(x / z), $MachinePrecision], 1.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+96}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq -9 \cdot 10^{-43}:\\
\;\;\;\;\frac{-x}{y}\\
\mathbf{elif}\;y \leq 140000000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.70000000000000022e96 or 1.4e8 < 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 60.1%
if -2.70000000000000022e96 < y < -9.0000000000000005e-43Initial 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 69.0%
Taylor expanded in y around 0 48.6%
neg-mul-148.6%
distribute-neg-frac48.6%
Simplified48.6%
if -9.0000000000000005e-43 < y < 1.4e8Initial 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 62.6%
Final simplification60.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -1e-49) (not (<= y 2.6e-49))) (/ y (- y z)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1e-49) || !(y <= 2.6e-49)) {
tmp = y / (y - z);
} 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 <= (-1d-49)) .or. (.not. (y <= 2.6d-49))) then
tmp = y / (y - z)
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1e-49) || !(y <= 2.6e-49)) {
tmp = y / (y - z);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1e-49) or not (y <= 2.6e-49): tmp = y / (y - z) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1e-49) || !(y <= 2.6e-49)) tmp = Float64(y / Float64(y - z)); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1e-49) || ~((y <= 2.6e-49))) tmp = y / (y - z); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1e-49], N[Not[LessEqual[y, 2.6e-49]], $MachinePrecision]], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-49} \lor \neg \left(y \leq 2.6 \cdot 10^{-49}\right):\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -9.99999999999999936e-50 or 2.59999999999999995e-49 < 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 x around 0 70.6%
if -9.99999999999999936e-50 < y < 2.59999999999999995e-49Initial 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 67.2%
Final simplification69.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.6e-45) (not (<= y 6.2e-47))) (/ y (- y z)) (/ (- x y) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.6e-45) || !(y <= 6.2e-47)) {
tmp = y / (y - z);
} 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 <= (-6.6d-45)) .or. (.not. (y <= 6.2d-47))) then
tmp = y / (y - z)
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 <= -6.6e-45) || !(y <= 6.2e-47)) {
tmp = y / (y - z);
} else {
tmp = (x - y) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.6e-45) or not (y <= 6.2e-47): tmp = y / (y - z) else: tmp = (x - y) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.6e-45) || !(y <= 6.2e-47)) tmp = Float64(y / Float64(y - z)); else tmp = Float64(Float64(x - y) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.6e-45) || ~((y <= 6.2e-47))) tmp = y / (y - z); else tmp = (x - y) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.6e-45], N[Not[LessEqual[y, 6.2e-47]], $MachinePrecision]], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.6 \cdot 10^{-45} \lor \neg \left(y \leq 6.2 \cdot 10^{-47}\right):\\
\;\;\;\;\frac{y}{y - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x - y}{z}\\
\end{array}
\end{array}
if y < -6.6000000000000001e-45 or 6.1999999999999996e-47 < 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 x around 0 70.0%
if -6.6000000000000001e-45 < y < 6.1999999999999996e-47Initial 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 inf 79.0%
associate-*r/79.0%
neg-mul-179.0%
neg-sub079.0%
associate--r-79.0%
neg-sub079.0%
Simplified79.0%
Taylor expanded in y around 0 79.0%
+-commutative79.0%
mul-1-neg79.0%
sub-neg79.0%
div-sub79.0%
Simplified79.0%
Final simplification73.9%
(FPCore (x y z) :precision binary64 (if (<= y -7e-45) 1.0 (if (<= y 132000000.0) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -7e-45) {
tmp = 1.0;
} else if (y <= 132000000.0) {
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 <= (-7d-45)) then
tmp = 1.0d0
else if (y <= 132000000.0d0) 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 <= -7e-45) {
tmp = 1.0;
} else if (y <= 132000000.0) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7e-45: tmp = 1.0 elif y <= 132000000.0: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7e-45) tmp = 1.0; elseif (y <= 132000000.0) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7e-45) tmp = 1.0; elseif (y <= 132000000.0) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7e-45], 1.0, If[LessEqual[y, 132000000.0], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7 \cdot 10^{-45}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 132000000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -7e-45 or 1.32e8 < 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 54.1%
if -7e-45 < y < 1.32e8Initial 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 63.1%
Final simplification58.3%
(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 32.5%
Final simplification32.5%
(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 2023238
(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)))