
(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
(if (or (<= x -1.5e-5)
(not (or (<= x 1.3e-23) (and (not (<= x 4e+32)) (<= x 1.12e+70)))))
(/ (- x) (- y z))
(/ y (- y z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.5e-5) || !((x <= 1.3e-23) || (!(x <= 4e+32) && (x <= 1.12e+70)))) {
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.5d-5)) .or. (.not. (x <= 1.3d-23) .or. (.not. (x <= 4d+32)) .and. (x <= 1.12d+70))) 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.5e-5) || !((x <= 1.3e-23) || (!(x <= 4e+32) && (x <= 1.12e+70)))) {
tmp = -x / (y - z);
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.5e-5) or not ((x <= 1.3e-23) or (not (x <= 4e+32) and (x <= 1.12e+70))): tmp = -x / (y - z) else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.5e-5) || !((x <= 1.3e-23) || (!(x <= 4e+32) && (x <= 1.12e+70)))) 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.5e-5) || ~(((x <= 1.3e-23) || (~((x <= 4e+32)) && (x <= 1.12e+70))))) tmp = -x / (y - z); else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.5e-5], N[Not[Or[LessEqual[x, 1.3e-23], And[N[Not[LessEqual[x, 4e+32]], $MachinePrecision], LessEqual[x, 1.12e+70]]]], $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.5 \cdot 10^{-5} \lor \neg \left(x \leq 1.3 \cdot 10^{-23} \lor \neg \left(x \leq 4 \cdot 10^{+32}\right) \land x \leq 1.12 \cdot 10^{+70}\right):\\
\;\;\;\;\frac{-x}{y - z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if x < -1.50000000000000004e-5 or 1.3e-23 < x < 4.00000000000000021e32 or 1.11999999999999993e70 < 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 80.9%
neg-mul-180.9%
distribute-neg-frac80.9%
Simplified80.9%
if -1.50000000000000004e-5 < x < 1.3e-23 or 4.00000000000000021e32 < x < 1.11999999999999993e70Initial 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 82.4%
Final simplification81.7%
(FPCore (x y z)
:precision binary64
(if (<= y -1.65e+42)
1.0
(if (<= y 1e-91)
(/ x z)
(if (<= y 8e+21) (/ (- y) z) (if (<= y 4.3e+40) (/ x z) 1.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.65e+42) {
tmp = 1.0;
} else if (y <= 1e-91) {
tmp = x / z;
} else if (y <= 8e+21) {
tmp = -y / z;
} else if (y <= 4.3e+40) {
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 <= (-1.65d+42)) then
tmp = 1.0d0
else if (y <= 1d-91) then
tmp = x / z
else if (y <= 8d+21) then
tmp = -y / z
else if (y <= 4.3d+40) 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 <= -1.65e+42) {
tmp = 1.0;
} else if (y <= 1e-91) {
tmp = x / z;
} else if (y <= 8e+21) {
tmp = -y / z;
} else if (y <= 4.3e+40) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.65e+42: tmp = 1.0 elif y <= 1e-91: tmp = x / z elif y <= 8e+21: tmp = -y / z elif y <= 4.3e+40: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.65e+42) tmp = 1.0; elseif (y <= 1e-91) tmp = Float64(x / z); elseif (y <= 8e+21) tmp = Float64(Float64(-y) / z); elseif (y <= 4.3e+40) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.65e+42) tmp = 1.0; elseif (y <= 1e-91) tmp = x / z; elseif (y <= 8e+21) tmp = -y / z; elseif (y <= 4.3e+40) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.65e+42], 1.0, If[LessEqual[y, 1e-91], N[(x / z), $MachinePrecision], If[LessEqual[y, 8e+21], N[((-y) / z), $MachinePrecision], If[LessEqual[y, 4.3e+40], N[(x / z), $MachinePrecision], 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.65 \cdot 10^{+42}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 10^{-91}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+21}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{elif}\;y \leq 4.3 \cdot 10^{+40}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.6499999999999999e42 or 4.3000000000000002e40 < y Initial 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 y around inf 71.1%
if -1.6499999999999999e42 < y < 1.00000000000000002e-91 or 8e21 < y < 4.3000000000000002e40Initial 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 66.3%
if 1.00000000000000002e-91 < y < 8e21Initial 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 55.1%
Taylor expanded in y around 0 35.3%
mul-1-neg35.3%
distribute-neg-frac35.3%
Simplified35.3%
Final simplification64.0%
(FPCore (x y z)
:precision binary64
(if (<= y -1.05e+42)
(+ 1.0 (/ z y))
(if (<= y 1.02e-91)
(/ x z)
(if (<= y 2.8e+21) (/ (- y) z) (if (<= y 9.5e+40) (/ x z) 1.0)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.05e+42) {
tmp = 1.0 + (z / y);
} else if (y <= 1.02e-91) {
tmp = x / z;
} else if (y <= 2.8e+21) {
tmp = -y / z;
} else if (y <= 9.5e+40) {
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 <= (-1.05d+42)) then
tmp = 1.0d0 + (z / y)
else if (y <= 1.02d-91) then
tmp = x / z
else if (y <= 2.8d+21) then
tmp = -y / z
else if (y <= 9.5d+40) 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 <= -1.05e+42) {
tmp = 1.0 + (z / y);
} else if (y <= 1.02e-91) {
tmp = x / z;
} else if (y <= 2.8e+21) {
tmp = -y / z;
} else if (y <= 9.5e+40) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.05e+42: tmp = 1.0 + (z / y) elif y <= 1.02e-91: tmp = x / z elif y <= 2.8e+21: tmp = -y / z elif y <= 9.5e+40: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.05e+42) tmp = Float64(1.0 + Float64(z / y)); elseif (y <= 1.02e-91) tmp = Float64(x / z); elseif (y <= 2.8e+21) tmp = Float64(Float64(-y) / z); elseif (y <= 9.5e+40) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.05e+42) tmp = 1.0 + (z / y); elseif (y <= 1.02e-91) tmp = x / z; elseif (y <= 2.8e+21) tmp = -y / z; elseif (y <= 9.5e+40) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.05e+42], N[(1.0 + N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.02e-91], N[(x / z), $MachinePrecision], If[LessEqual[y, 2.8e+21], N[((-y) / z), $MachinePrecision], If[LessEqual[y, 9.5e+40], N[(x / z), $MachinePrecision], 1.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+42}:\\
\;\;\;\;1 + \frac{z}{y}\\
\mathbf{elif}\;y \leq 1.02 \cdot 10^{-91}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{+21}:\\
\;\;\;\;\frac{-y}{z}\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{+40}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -1.04999999999999998e42Initial 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 79.1%
Taylor expanded in y around inf 67.4%
if -1.04999999999999998e42 < y < 1.01999999999999994e-91 or 2.8e21 < y < 9.5000000000000003e40Initial 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 66.3%
if 1.01999999999999994e-91 < y < 2.8e21Initial 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 55.1%
Taylor expanded in y around 0 35.3%
mul-1-neg35.3%
distribute-neg-frac35.3%
Simplified35.3%
if 9.5000000000000003e40 < y Initial 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 y around inf 74.3%
Final simplification64.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ y (- y z))))
(if (<= y -3.5e-31)
t_0
(if (<= y 2.85e-92) (/ x z) (if (<= y 9.2e+59) t_0 (- 1.0 (/ x y)))))))
double code(double x, double y, double z) {
double t_0 = y / (y - z);
double tmp;
if (y <= -3.5e-31) {
tmp = t_0;
} else if (y <= 2.85e-92) {
tmp = x / z;
} else if (y <= 9.2e+59) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = y / (y - z)
if (y <= (-3.5d-31)) then
tmp = t_0
else if (y <= 2.85d-92) then
tmp = x / z
else if (y <= 9.2d+59) then
tmp = t_0
else
tmp = 1.0d0 - (x / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y / (y - z);
double tmp;
if (y <= -3.5e-31) {
tmp = t_0;
} else if (y <= 2.85e-92) {
tmp = x / z;
} else if (y <= 9.2e+59) {
tmp = t_0;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y, z): t_0 = y / (y - z) tmp = 0 if y <= -3.5e-31: tmp = t_0 elif y <= 2.85e-92: tmp = x / z elif y <= 9.2e+59: tmp = t_0 else: tmp = 1.0 - (x / y) return tmp
function code(x, y, z) t_0 = Float64(y / Float64(y - z)) tmp = 0.0 if (y <= -3.5e-31) tmp = t_0; elseif (y <= 2.85e-92) tmp = Float64(x / z); elseif (y <= 9.2e+59) tmp = t_0; else tmp = Float64(1.0 - Float64(x / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y / (y - z); tmp = 0.0; if (y <= -3.5e-31) tmp = t_0; elseif (y <= 2.85e-92) tmp = x / z; elseif (y <= 9.2e+59) tmp = t_0; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -3.5e-31], t$95$0, If[LessEqual[y, 2.85e-92], N[(x / z), $MachinePrecision], If[LessEqual[y, 9.2e+59], t$95$0, N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{y - z}\\
\mathbf{if}\;y \leq -3.5 \cdot 10^{-31}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.85 \cdot 10^{-92}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{+59}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if y < -3.49999999999999985e-31 or 2.85000000000000004e-92 < y < 9.20000000000000032e59Initial 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 65.9%
if -3.49999999999999985e-31 < y < 2.85000000000000004e-92Initial 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 70.4%
if 9.20000000000000032e59 < y Initial 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 z around 0 92.2%
div-sub92.3%
*-inverses92.3%
Simplified92.3%
Final simplification73.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -7.5e+41) (not (<= y 6e-86))) (- 1.0 (/ x y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.5e+41) || !(y <= 6e-86)) {
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 <= (-7.5d+41)) .or. (.not. (y <= 6d-86))) 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 <= -7.5e+41) || !(y <= 6e-86)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7.5e+41) or not (y <= 6e-86): tmp = 1.0 - (x / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7.5e+41) || !(y <= 6e-86)) 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 <= -7.5e+41) || ~((y <= 6e-86))) tmp = 1.0 - (x / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.5e+41], N[Not[LessEqual[y, 6e-86]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{+41} \lor \neg \left(y \leq 6 \cdot 10^{-86}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -7.50000000000000072e41 or 6.0000000000000002e-86 < y Initial 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 z around 0 73.9%
div-sub73.9%
*-inverses73.9%
Simplified73.9%
if -7.50000000000000072e41 < y < 6.0000000000000002e-86Initial 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.3%
Final simplification71.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.2e-75) (not (<= z 1.8e-22))) (/ (- x y) z) (- 1.0 (/ x y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.2e-75) || !(z <= 1.8e-22)) {
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 <= (-5.2d-75)) .or. (.not. (z <= 1.8d-22))) 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 <= -5.2e-75) || !(z <= 1.8e-22)) {
tmp = (x - y) / z;
} else {
tmp = 1.0 - (x / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.2e-75) or not (z <= 1.8e-22): tmp = (x - y) / z else: tmp = 1.0 - (x / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.2e-75) || !(z <= 1.8e-22)) 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 <= -5.2e-75) || ~((z <= 1.8e-22))) tmp = (x - y) / z; else tmp = 1.0 - (x / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.2e-75], N[Not[LessEqual[z, 1.8e-22]], $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 -5.2 \cdot 10^{-75} \lor \neg \left(z \leq 1.8 \cdot 10^{-22}\right):\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{x}{y}\\
\end{array}
\end{array}
if z < -5.2e-75 or 1.7999999999999999e-22 < 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 72.7%
associate-*r/72.7%
neg-mul-172.7%
neg-sub072.7%
associate--r-72.7%
neg-sub072.7%
Simplified72.7%
Taylor expanded in y around 0 72.7%
+-commutative72.7%
mul-1-neg72.7%
sub-neg72.7%
div-sub72.7%
Simplified72.7%
if -5.2e-75 < z < 1.7999999999999999e-22Initial 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 84.0%
div-sub84.0%
*-inverses84.0%
Simplified84.0%
Final simplification77.5%
(FPCore (x y z) :precision binary64 (if (<= y -2e+46) 1.0 (if (<= y 4.8e+40) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e+46) {
tmp = 1.0;
} else if (y <= 4.8e+40) {
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 <= (-2d+46)) then
tmp = 1.0d0
else if (y <= 4.8d+40) 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 <= -2e+46) {
tmp = 1.0;
} else if (y <= 4.8e+40) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e+46: tmp = 1.0 elif y <= 4.8e+40: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e+46) tmp = 1.0; elseif (y <= 4.8e+40) tmp = Float64(x / z); else tmp = 1.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2e+46) tmp = 1.0; elseif (y <= 4.8e+40) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e+46], 1.0, If[LessEqual[y, 4.8e+40], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+46}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+40}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2e46 or 4.8e40 < y Initial 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 y around inf 71.1%
if -2e46 < y < 4.8e40Initial 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 56.7%
Final simplification62.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 35.8%
Final simplification35.8%
(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 2023185
(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)))