
(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 (- 1.0 (/ x y))))
(if (<= y -2.25e-85)
t_0
(if (<= y 9.5e-124)
(/ (- x) (- y z))
(if (<= y 2.5e+43)
(/ (- x y) z)
(if (<= y 1.35e+45) t_0 (/ y (- y z))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 - (x / y);
double tmp;
if (y <= -2.25e-85) {
tmp = t_0;
} else if (y <= 9.5e-124) {
tmp = -x / (y - z);
} else if (y <= 2.5e+43) {
tmp = (x - y) / z;
} else if (y <= 1.35e+45) {
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 = 1.0d0 - (x / y)
if (y <= (-2.25d-85)) then
tmp = t_0
else if (y <= 9.5d-124) then
tmp = -x / (y - z)
else if (y <= 2.5d+43) then
tmp = (x - y) / z
else if (y <= 1.35d+45) 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 = 1.0 - (x / y);
double tmp;
if (y <= -2.25e-85) {
tmp = t_0;
} else if (y <= 9.5e-124) {
tmp = -x / (y - z);
} else if (y <= 2.5e+43) {
tmp = (x - y) / z;
} else if (y <= 1.35e+45) {
tmp = t_0;
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 - (x / y) tmp = 0 if y <= -2.25e-85: tmp = t_0 elif y <= 9.5e-124: tmp = -x / (y - z) elif y <= 2.5e+43: tmp = (x - y) / z elif y <= 1.35e+45: tmp = t_0 else: tmp = y / (y - z) return tmp
function code(x, y, z) t_0 = Float64(1.0 - Float64(x / y)) tmp = 0.0 if (y <= -2.25e-85) tmp = t_0; elseif (y <= 9.5e-124) tmp = Float64(Float64(-x) / Float64(y - z)); elseif (y <= 2.5e+43) tmp = Float64(Float64(x - y) / z); elseif (y <= 1.35e+45) tmp = t_0; else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 - (x / y); tmp = 0.0; if (y <= -2.25e-85) tmp = t_0; elseif (y <= 9.5e-124) tmp = -x / (y - z); elseif (y <= 2.5e+43) tmp = (x - y) / z; elseif (y <= 1.35e+45) tmp = t_0; else tmp = y / (y - z); 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.25e-85], t$95$0, If[LessEqual[y, 9.5e-124], N[((-x) / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.5e+43], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 1.35e+45], t$95$0, N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \frac{x}{y}\\
\mathbf{if}\;y \leq -2.25 \cdot 10^{-85}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{-124}:\\
\;\;\;\;\frac{-x}{y - z}\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+43}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+45}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if y < -2.25000000000000002e-85 or 2.5000000000000002e43 < y < 1.34999999999999992e45Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 81.9%
div-sub81.9%
*-inverses81.9%
Simplified81.9%
if -2.25000000000000002e-85 < y < 9.49999999999999989e-124Initial 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%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 89.5%
neg-mul-189.5%
distribute-neg-frac89.5%
Simplified89.5%
if 9.49999999999999989e-124 < y < 2.5000000000000002e43Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
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%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 77.2%
associate-*r/77.2%
neg-mul-177.2%
neg-sub077.2%
associate--r-77.2%
neg-sub077.2%
Simplified77.2%
Taylor expanded in y around 0 77.2%
+-commutative77.2%
mul-1-neg77.2%
sub-neg77.2%
div-sub77.2%
Simplified77.2%
if 1.34999999999999992e45 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 84.3%
Final simplification84.3%
(FPCore (x y z)
:precision binary64
(if (<= y -1.4e-85)
(+ 1.0 (/ (- z x) y))
(if (<= y 1.2e-121)
(/ (- x) (- y z))
(if (<= y 2.7e+43)
(/ (- x y) z)
(if (<= y 3.5e+45) (- 1.0 (/ x y)) (/ y (- y z)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.4e-85) {
tmp = 1.0 + ((z - x) / y);
} else if (y <= 1.2e-121) {
tmp = -x / (y - z);
} else if (y <= 2.7e+43) {
tmp = (x - y) / z;
} else if (y <= 3.5e+45) {
tmp = 1.0 - (x / y);
} 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 <= (-1.4d-85)) then
tmp = 1.0d0 + ((z - x) / y)
else if (y <= 1.2d-121) then
tmp = -x / (y - z)
else if (y <= 2.7d+43) then
tmp = (x - y) / z
else if (y <= 3.5d+45) then
tmp = 1.0d0 - (x / y)
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 <= -1.4e-85) {
tmp = 1.0 + ((z - x) / y);
} else if (y <= 1.2e-121) {
tmp = -x / (y - z);
} else if (y <= 2.7e+43) {
tmp = (x - y) / z;
} else if (y <= 3.5e+45) {
tmp = 1.0 - (x / y);
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.4e-85: tmp = 1.0 + ((z - x) / y) elif y <= 1.2e-121: tmp = -x / (y - z) elif y <= 2.7e+43: tmp = (x - y) / z elif y <= 3.5e+45: tmp = 1.0 - (x / y) else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.4e-85) tmp = Float64(1.0 + Float64(Float64(z - x) / y)); elseif (y <= 1.2e-121) tmp = Float64(Float64(-x) / Float64(y - z)); elseif (y <= 2.7e+43) tmp = Float64(Float64(x - y) / z); elseif (y <= 3.5e+45) tmp = Float64(1.0 - Float64(x / y)); else tmp = Float64(y / Float64(y - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.4e-85) tmp = 1.0 + ((z - x) / y); elseif (y <= 1.2e-121) tmp = -x / (y - z); elseif (y <= 2.7e+43) tmp = (x - y) / z; elseif (y <= 3.5e+45) tmp = 1.0 - (x / y); else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.4e-85], N[(1.0 + N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.2e-121], N[((-x) / N[(y - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.7e+43], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[y, 3.5e+45], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.4 \cdot 10^{-85}:\\
\;\;\;\;1 + \frac{z - x}{y}\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-121}:\\
\;\;\;\;\frac{-x}{y - z}\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+43}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{+45}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if y < -1.40000000000000008e-85Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 81.6%
mul-1-neg81.6%
associate--l+81.6%
mul-1-neg81.6%
distribute-lft-out--81.6%
div-sub81.6%
mul-1-neg81.6%
unsub-neg81.6%
Simplified81.6%
if -1.40000000000000008e-85 < y < 1.20000000000000002e-121Initial 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%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around inf 89.5%
neg-mul-189.5%
distribute-neg-frac89.5%
Simplified89.5%
if 1.20000000000000002e-121 < y < 2.7000000000000002e43Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
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%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 77.2%
associate-*r/77.2%
neg-mul-177.2%
neg-sub077.2%
associate--r-77.2%
neg-sub077.2%
Simplified77.2%
Taylor expanded in y around 0 77.2%
+-commutative77.2%
mul-1-neg77.2%
sub-neg77.2%
div-sub77.2%
Simplified77.2%
if 2.7000000000000002e43 < y < 3.50000000000000023e45Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/100.0%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 100.0%
div-sub100.0%
*-inverses100.0%
Simplified100.0%
if 3.50000000000000023e45 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 84.3%
Final simplification84.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.25e-85) (not (<= y 2.12e+43))) (+ 1.0 (/ z y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.25e-85) || !(y <= 2.12e+43)) {
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 <= (-2.25d-85)) .or. (.not. (y <= 2.12d+43))) 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 <= -2.25e-85) || !(y <= 2.12e+43)) {
tmp = 1.0 + (z / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.25e-85) or not (y <= 2.12e+43): tmp = 1.0 + (z / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.25e-85) || !(y <= 2.12e+43)) 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 <= -2.25e-85) || ~((y <= 2.12e+43))) tmp = 1.0 + (z / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.25e-85], N[Not[LessEqual[y, 2.12e+43]], $MachinePrecision]], N[(1.0 + N[(z / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.25 \cdot 10^{-85} \lor \neg \left(y \leq 2.12 \cdot 10^{+43}\right):\\
\;\;\;\;1 + \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -2.25000000000000002e-85 or 2.12000000000000011e43 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 76.6%
Taylor expanded in y around inf 64.3%
if -2.25000000000000002e-85 < y < 2.12000000000000011e43Initial 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%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 66.1%
Final simplification65.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.8e-90) (not (<= y 2.12e+43))) (- 1.0 (/ x y)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.8e-90) || !(y <= 2.12e+43)) {
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 <= (-4.8d-90)) .or. (.not. (y <= 2.12d+43))) 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 <= -4.8e-90) || !(y <= 2.12e+43)) {
tmp = 1.0 - (x / y);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.8e-90) or not (y <= 2.12e+43): tmp = 1.0 - (x / y) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.8e-90) || !(y <= 2.12e+43)) 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 <= -4.8e-90) || ~((y <= 2.12e+43))) tmp = 1.0 - (x / y); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.8e-90], N[Not[LessEqual[y, 2.12e+43]], $MachinePrecision]], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{-90} \lor \neg \left(y \leq 2.12 \cdot 10^{+43}\right):\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -4.8000000000000003e-90 or 2.12000000000000011e43 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 79.6%
div-sub79.7%
*-inverses79.7%
Simplified79.7%
if -4.8000000000000003e-90 < y < 2.12000000000000011e43Initial 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%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 66.1%
Final simplification73.0%
(FPCore (x y z) :precision binary64 (if (<= y -6.5e-87) (- 1.0 (/ x y)) (if (<= y 59000.0) (/ x z) (/ y (- y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e-87) {
tmp = 1.0 - (x / y);
} else if (y <= 59000.0) {
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 <= (-6.5d-87)) then
tmp = 1.0d0 - (x / y)
else if (y <= 59000.0d0) 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 <= -6.5e-87) {
tmp = 1.0 - (x / y);
} else if (y <= 59000.0) {
tmp = x / z;
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.5e-87: tmp = 1.0 - (x / y) elif y <= 59000.0: tmp = x / z else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.5e-87) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 59000.0) 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 <= -6.5e-87) tmp = 1.0 - (x / y); elseif (y <= 59000.0) tmp = x / z; else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.5e-87], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 59000.0], N[(x / z), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{-87}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 59000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if y < -6.5000000000000003e-87Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 81.4%
div-sub81.4%
*-inverses81.4%
Simplified81.4%
if -6.5000000000000003e-87 < y < 59000Initial 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%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 67.3%
if 59000 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 80.6%
Final simplification74.7%
(FPCore (x y z) :precision binary64 (if (<= y -4.6e-28) (- 1.0 (/ x y)) (if (<= y 2.8e+43) (/ (- x y) z) (/ y (- y z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.6e-28) {
tmp = 1.0 - (x / y);
} else if (y <= 2.8e+43) {
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 <= (-4.6d-28)) then
tmp = 1.0d0 - (x / y)
else if (y <= 2.8d+43) 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 <= -4.6e-28) {
tmp = 1.0 - (x / y);
} else if (y <= 2.8e+43) {
tmp = (x - y) / z;
} else {
tmp = y / (y - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.6e-28: tmp = 1.0 - (x / y) elif y <= 2.8e+43: tmp = (x - y) / z else: tmp = y / (y - z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.6e-28) tmp = Float64(1.0 - Float64(x / y)); elseif (y <= 2.8e+43) 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 <= -4.6e-28) tmp = 1.0 - (x / y); elseif (y <= 2.8e+43) tmp = (x - y) / z; else tmp = y / (y - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.6e-28], N[(1.0 - N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.8e+43], N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision], N[(y / N[(y - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.6 \cdot 10^{-28}:\\
\;\;\;\;1 - \frac{x}{y}\\
\mathbf{elif}\;y \leq 2.8 \cdot 10^{+43}:\\
\;\;\;\;\frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{y - z}\\
\end{array}
\end{array}
if y < -4.59999999999999971e-28Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
+-commutative99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
sub-neg99.9%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 84.2%
div-sub84.2%
*-inverses84.2%
Simplified84.2%
if -4.59999999999999971e-28 < y < 2.80000000000000019e43Initial 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%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in z around inf 76.0%
associate-*r/76.0%
neg-mul-176.0%
neg-sub076.0%
associate--r-76.0%
neg-sub076.0%
Simplified76.0%
Taylor expanded in y around 0 76.0%
+-commutative76.0%
mul-1-neg76.0%
sub-neg76.0%
div-sub76.0%
Simplified76.0%
if 2.80000000000000019e43 < y Initial program 99.9%
*-lft-identity99.9%
metadata-eval99.9%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*99.9%
neg-mul-199.9%
sub-neg99.9%
distribute-neg-out99.9%
remove-double-neg99.9%
+-commutative99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around 0 83.2%
Final simplification79.8%
(FPCore (x y z) :precision binary64 (if (<= y -2.05e-85) 1.0 (if (<= y 2.5e+43) (/ x z) 1.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.05e-85) {
tmp = 1.0;
} else if (y <= 2.5e+43) {
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-85)) then
tmp = 1.0d0
else if (y <= 2.5d+43) 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-85) {
tmp = 1.0;
} else if (y <= 2.5e+43) {
tmp = x / z;
} else {
tmp = 1.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.05e-85: tmp = 1.0 elif y <= 2.5e+43: tmp = x / z else: tmp = 1.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.05e-85) tmp = 1.0; elseif (y <= 2.5e+43) 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-85) tmp = 1.0; elseif (y <= 2.5e+43) tmp = x / z; else tmp = 1.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.05e-85], 1.0, If[LessEqual[y, 2.5e+43], N[(x / z), $MachinePrecision], 1.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.05 \cdot 10^{-85}:\\
\;\;\;\;1\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+43}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if y < -2.04999999999999997e-85 or 2.5000000000000002e43 < y Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 64.1%
if -2.04999999999999997e-85 < y < 2.5000000000000002e43Initial 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%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around 0 66.1%
Final simplification65.1%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/r/99.9%
associate-/l*99.8%
neg-mul-199.8%
sub-neg99.8%
+-commutative99.8%
distribute-neg-out99.8%
remove-double-neg99.8%
sub-neg99.8%
associate-/l*100.0%
neg-mul-1100.0%
sub-neg100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
+-commutative100.0%
sub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 37.1%
Final simplification37.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 2023268
(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)))