
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - 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 = 1.0d0 + ((4.0d0 * ((x + (y * 0.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - 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 = 1.0d0 + ((4.0d0 * ((x + (y * 0.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (+ 4.0 (/ (* 4.0 (- x z)) y)))
double code(double x, double y, double z) {
return 4.0 + ((4.0 * (x - 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 = 4.0d0 + ((4.0d0 * (x - z)) / y)
end function
public static double code(double x, double y, double z) {
return 4.0 + ((4.0 * (x - z)) / y);
}
def code(x, y, z): return 4.0 + ((4.0 * (x - z)) / y)
function code(x, y, z) return Float64(4.0 + Float64(Float64(4.0 * Float64(x - z)) / y)) end
function tmp = code(x, y, z) tmp = 4.0 + ((4.0 * (x - z)) / y); end
code[x_, y_, z_] := N[(4.0 + N[(N[(4.0 * N[(x - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 + \frac{4 \cdot \left(x - z\right)}{y}
\end{array}
Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
sub-neg99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (* 4.0 x) y))) (t_1 (+ 1.0 (* -4.0 (/ z y)))))
(if (<= z -110000.0)
t_1
(if (<= z -3.6e-56)
t_0
(if (<= z -4e-165)
4.0
(if (<= z -1.2e-261)
t_0
(if (<= z 1.55e-81)
4.0
(if (<= z 2.7e-40)
t_0
(if (<= z 62000000000000.0) 4.0 t_1)))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + ((4.0 * x) / y);
double t_1 = 1.0 + (-4.0 * (z / y));
double tmp;
if (z <= -110000.0) {
tmp = t_1;
} else if (z <= -3.6e-56) {
tmp = t_0;
} else if (z <= -4e-165) {
tmp = 4.0;
} else if (z <= -1.2e-261) {
tmp = t_0;
} else if (z <= 1.55e-81) {
tmp = 4.0;
} else if (z <= 2.7e-40) {
tmp = t_0;
} else if (z <= 62000000000000.0) {
tmp = 4.0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = 1.0d0 + ((4.0d0 * x) / y)
t_1 = 1.0d0 + ((-4.0d0) * (z / y))
if (z <= (-110000.0d0)) then
tmp = t_1
else if (z <= (-3.6d-56)) then
tmp = t_0
else if (z <= (-4d-165)) then
tmp = 4.0d0
else if (z <= (-1.2d-261)) then
tmp = t_0
else if (z <= 1.55d-81) then
tmp = 4.0d0
else if (z <= 2.7d-40) then
tmp = t_0
else if (z <= 62000000000000.0d0) then
tmp = 4.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 + ((4.0 * x) / y);
double t_1 = 1.0 + (-4.0 * (z / y));
double tmp;
if (z <= -110000.0) {
tmp = t_1;
} else if (z <= -3.6e-56) {
tmp = t_0;
} else if (z <= -4e-165) {
tmp = 4.0;
} else if (z <= -1.2e-261) {
tmp = t_0;
} else if (z <= 1.55e-81) {
tmp = 4.0;
} else if (z <= 2.7e-40) {
tmp = t_0;
} else if (z <= 62000000000000.0) {
tmp = 4.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((4.0 * x) / y) t_1 = 1.0 + (-4.0 * (z / y)) tmp = 0 if z <= -110000.0: tmp = t_1 elif z <= -3.6e-56: tmp = t_0 elif z <= -4e-165: tmp = 4.0 elif z <= -1.2e-261: tmp = t_0 elif z <= 1.55e-81: tmp = 4.0 elif z <= 2.7e-40: tmp = t_0 elif z <= 62000000000000.0: tmp = 4.0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(Float64(4.0 * x) / y)) t_1 = Float64(1.0 + Float64(-4.0 * Float64(z / y))) tmp = 0.0 if (z <= -110000.0) tmp = t_1; elseif (z <= -3.6e-56) tmp = t_0; elseif (z <= -4e-165) tmp = 4.0; elseif (z <= -1.2e-261) tmp = t_0; elseif (z <= 1.55e-81) tmp = 4.0; elseif (z <= 2.7e-40) tmp = t_0; elseif (z <= 62000000000000.0) tmp = 4.0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + ((4.0 * x) / y); t_1 = 1.0 + (-4.0 * (z / y)); tmp = 0.0; if (z <= -110000.0) tmp = t_1; elseif (z <= -3.6e-56) tmp = t_0; elseif (z <= -4e-165) tmp = 4.0; elseif (z <= -1.2e-261) tmp = t_0; elseif (z <= 1.55e-81) tmp = 4.0; elseif (z <= 2.7e-40) tmp = t_0; elseif (z <= 62000000000000.0) tmp = 4.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -110000.0], t$95$1, If[LessEqual[z, -3.6e-56], t$95$0, If[LessEqual[z, -4e-165], 4.0, If[LessEqual[z, -1.2e-261], t$95$0, If[LessEqual[z, 1.55e-81], 4.0, If[LessEqual[z, 2.7e-40], t$95$0, If[LessEqual[z, 62000000000000.0], 4.0, t$95$1]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{4 \cdot x}{y}\\
t_1 := 1 + -4 \cdot \frac{z}{y}\\
\mathbf{if}\;z \leq -110000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -3.6 \cdot 10^{-56}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -4 \cdot 10^{-165}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq -1.2 \cdot 10^{-261}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.55 \cdot 10^{-81}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq 2.7 \cdot 10^{-40}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 62000000000000:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.1e5 or 6.2e13 < z Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
sub-neg99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around inf 71.1%
*-commutative71.1%
Simplified71.1%
if -1.1e5 < z < -3.59999999999999978e-56 or -4e-165 < z < -1.20000000000000007e-261 or 1.54999999999999994e-81 < z < 2.7e-40Initial program 99.9%
associate-*l/99.7%
sub-neg99.7%
sub-neg99.7%
+-commutative99.7%
fma-def99.6%
Simplified99.6%
Taylor expanded in x around inf 66.3%
associate-*r/66.3%
Simplified66.3%
if -3.59999999999999978e-56 < z < -4e-165 or -1.20000000000000007e-261 < z < 1.54999999999999994e-81 or 2.7e-40 < z < 6.2e13Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
sub-neg99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around inf 66.4%
Final simplification68.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (/ 4.0 (/ y (- x z))))))
(if (<= z -3.1e+204)
t_0
(if (<= z -7.4e+110)
(+ 4.0 (* -4.0 (/ z y)))
(if (or (<= z -1.4e-17) (not (<= z 2.55e+14)))
t_0
(+ 4.0 (* 4.0 (/ x y))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (4.0 / (y / (x - z)));
double tmp;
if (z <= -3.1e+204) {
tmp = t_0;
} else if (z <= -7.4e+110) {
tmp = 4.0 + (-4.0 * (z / y));
} else if ((z <= -1.4e-17) || !(z <= 2.55e+14)) {
tmp = t_0;
} else {
tmp = 4.0 + (4.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 = 1.0d0 + (4.0d0 / (y / (x - z)))
if (z <= (-3.1d+204)) then
tmp = t_0
else if (z <= (-7.4d+110)) then
tmp = 4.0d0 + ((-4.0d0) * (z / y))
else if ((z <= (-1.4d-17)) .or. (.not. (z <= 2.55d+14))) then
tmp = t_0
else
tmp = 4.0d0 + (4.0d0 * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 + (4.0 / (y / (x - z)));
double tmp;
if (z <= -3.1e+204) {
tmp = t_0;
} else if (z <= -7.4e+110) {
tmp = 4.0 + (-4.0 * (z / y));
} else if ((z <= -1.4e-17) || !(z <= 2.55e+14)) {
tmp = t_0;
} else {
tmp = 4.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (4.0 / (y / (x - z))) tmp = 0 if z <= -3.1e+204: tmp = t_0 elif z <= -7.4e+110: tmp = 4.0 + (-4.0 * (z / y)) elif (z <= -1.4e-17) or not (z <= 2.55e+14): tmp = t_0 else: tmp = 4.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(4.0 / Float64(y / Float64(x - z)))) tmp = 0.0 if (z <= -3.1e+204) tmp = t_0; elseif (z <= -7.4e+110) tmp = Float64(4.0 + Float64(-4.0 * Float64(z / y))); elseif ((z <= -1.4e-17) || !(z <= 2.55e+14)) tmp = t_0; else tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (4.0 / (y / (x - z))); tmp = 0.0; if (z <= -3.1e+204) tmp = t_0; elseif (z <= -7.4e+110) tmp = 4.0 + (-4.0 * (z / y)); elseif ((z <= -1.4e-17) || ~((z <= 2.55e+14))) tmp = t_0; else tmp = 4.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(4.0 / N[(y / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.1e+204], t$95$0, If[LessEqual[z, -7.4e+110], N[(4.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[z, -1.4e-17], N[Not[LessEqual[z, 2.55e+14]], $MachinePrecision]], t$95$0, N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{4}{\frac{y}{x - z}}\\
\mathbf{if}\;z \leq -3.1 \cdot 10^{+204}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -7.4 \cdot 10^{+110}:\\
\;\;\;\;4 + -4 \cdot \frac{z}{y}\\
\mathbf{elif}\;z \leq -1.4 \cdot 10^{-17} \lor \neg \left(z \leq 2.55 \cdot 10^{+14}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -3.1000000000000002e204 or -7.40000000000000024e110 < z < -1.3999999999999999e-17 or 2.55e14 < z Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
sub-neg99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 87.8%
associate-*r/87.8%
associate-/l*87.6%
Simplified87.6%
if -3.1000000000000002e204 < z < -7.40000000000000024e110Initial program 99.9%
associate-*l/99.7%
sub-neg99.7%
sub-neg99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
if -1.3999999999999999e-17 < z < 2.55e14Initial program 99.9%
associate-*l/99.7%
sub-neg99.7%
sub-neg99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around inf 96.8%
Final simplification92.9%
(FPCore (x y z)
:precision binary64
(if (or (<= x -1.4e+156)
(and (not (<= x 1.2e+139))
(or (<= x 4.2e+168) (not (<= x 2.8e+188)))))
(+ 1.0 (/ (* 4.0 x) y))
(+ 4.0 (* -4.0 (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.4e+156) || (!(x <= 1.2e+139) && ((x <= 4.2e+168) || !(x <= 2.8e+188)))) {
tmp = 1.0 + ((4.0 * x) / y);
} else {
tmp = 4.0 + (-4.0 * (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 ((x <= (-1.4d+156)) .or. (.not. (x <= 1.2d+139)) .and. (x <= 4.2d+168) .or. (.not. (x <= 2.8d+188))) then
tmp = 1.0d0 + ((4.0d0 * x) / y)
else
tmp = 4.0d0 + ((-4.0d0) * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.4e+156) || (!(x <= 1.2e+139) && ((x <= 4.2e+168) || !(x <= 2.8e+188)))) {
tmp = 1.0 + ((4.0 * x) / y);
} else {
tmp = 4.0 + (-4.0 * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.4e+156) or (not (x <= 1.2e+139) and ((x <= 4.2e+168) or not (x <= 2.8e+188))): tmp = 1.0 + ((4.0 * x) / y) else: tmp = 4.0 + (-4.0 * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.4e+156) || (!(x <= 1.2e+139) && ((x <= 4.2e+168) || !(x <= 2.8e+188)))) tmp = Float64(1.0 + Float64(Float64(4.0 * x) / y)); else tmp = Float64(4.0 + Float64(-4.0 * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.4e+156) || (~((x <= 1.2e+139)) && ((x <= 4.2e+168) || ~((x <= 2.8e+188))))) tmp = 1.0 + ((4.0 * x) / y); else tmp = 4.0 + (-4.0 * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.4e+156], And[N[Not[LessEqual[x, 1.2e+139]], $MachinePrecision], Or[LessEqual[x, 4.2e+168], N[Not[LessEqual[x, 2.8e+188]], $MachinePrecision]]]], N[(1.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.4 \cdot 10^{+156} \lor \neg \left(x \leq 1.2 \cdot 10^{+139}\right) \land \left(x \leq 4.2 \cdot 10^{+168} \lor \neg \left(x \leq 2.8 \cdot 10^{+188}\right)\right):\\
\;\;\;\;1 + \frac{4 \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < -1.39999999999999994e156 or 1.20000000000000004e139 < x < 4.20000000000000006e168 or 2.7999999999999998e188 < x Initial program 99.9%
associate-*l/99.7%
sub-neg99.7%
sub-neg99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in x around inf 87.0%
associate-*r/87.0%
Simplified87.0%
if -1.39999999999999994e156 < x < 1.20000000000000004e139 or 4.20000000000000006e168 < x < 2.7999999999999998e188Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
sub-neg99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around 0 85.4%
Final simplification85.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.56e-17) (not (<= z 62000000000000.0))) (+ 1.0 (* -4.0 (/ z y))) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.56e-17) || !(z <= 62000000000000.0)) {
tmp = 1.0 + (-4.0 * (z / y));
} else {
tmp = 4.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 <= (-1.56d-17)) .or. (.not. (z <= 62000000000000.0d0))) then
tmp = 1.0d0 + ((-4.0d0) * (z / y))
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.56e-17) || !(z <= 62000000000000.0)) {
tmp = 1.0 + (-4.0 * (z / y));
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.56e-17) or not (z <= 62000000000000.0): tmp = 1.0 + (-4.0 * (z / y)) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.56e-17) || !(z <= 62000000000000.0)) tmp = Float64(1.0 + Float64(-4.0 * Float64(z / y))); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.56e-17) || ~((z <= 62000000000000.0))) tmp = 1.0 + (-4.0 * (z / y)); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.56e-17], N[Not[LessEqual[z, 62000000000000.0]], $MachinePrecision]], N[(1.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.56 \cdot 10^{-17} \lor \neg \left(z \leq 62000000000000\right):\\
\;\;\;\;1 + -4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if z < -1.56000000000000002e-17 or 6.2e13 < z Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
sub-neg99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around inf 68.1%
*-commutative68.1%
Simplified68.1%
if -1.56000000000000002e-17 < z < 6.2e13Initial program 99.9%
associate-*l/99.7%
sub-neg99.7%
sub-neg99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around inf 53.8%
Final simplification61.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -116000.0) (not (<= z 4.3e+88))) (+ 4.0 (* -4.0 (/ z y))) (+ 4.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -116000.0) || !(z <= 4.3e+88)) {
tmp = 4.0 + (-4.0 * (z / y));
} else {
tmp = 4.0 + (4.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 <= (-116000.0d0)) .or. (.not. (z <= 4.3d+88))) then
tmp = 4.0d0 + ((-4.0d0) * (z / y))
else
tmp = 4.0d0 + (4.0d0 * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -116000.0) || !(z <= 4.3e+88)) {
tmp = 4.0 + (-4.0 * (z / y));
} else {
tmp = 4.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -116000.0) or not (z <= 4.3e+88): tmp = 4.0 + (-4.0 * (z / y)) else: tmp = 4.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -116000.0) || !(z <= 4.3e+88)) tmp = Float64(4.0 + Float64(-4.0 * Float64(z / y))); else tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -116000.0) || ~((z <= 4.3e+88))) tmp = 4.0 + (-4.0 * (z / y)); else tmp = 4.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -116000.0], N[Not[LessEqual[z, 4.3e+88]], $MachinePrecision]], N[(4.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -116000 \lor \neg \left(z \leq 4.3 \cdot 10^{+88}\right):\\
\;\;\;\;4 + -4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -116000 or 4.29999999999999974e88 < z Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
sub-neg99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around 0 86.9%
if -116000 < z < 4.29999999999999974e88Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
sub-neg99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around inf 92.7%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.56e-17) (not (<= z 1.8e+14))) (* -4.0 (/ z y)) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.56e-17) || !(z <= 1.8e+14)) {
tmp = -4.0 * (z / y);
} else {
tmp = 4.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 <= (-1.56d-17)) .or. (.not. (z <= 1.8d+14))) then
tmp = (-4.0d0) * (z / y)
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.56e-17) || !(z <= 1.8e+14)) {
tmp = -4.0 * (z / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.56e-17) or not (z <= 1.8e+14): tmp = -4.0 * (z / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.56e-17) || !(z <= 1.8e+14)) tmp = Float64(-4.0 * Float64(z / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.56e-17) || ~((z <= 1.8e+14))) tmp = -4.0 * (z / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.56e-17], N[Not[LessEqual[z, 1.8e+14]], $MachinePrecision]], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.56 \cdot 10^{-17} \lor \neg \left(z \leq 1.8 \cdot 10^{+14}\right):\\
\;\;\;\;-4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if z < -1.56000000000000002e-17 or 1.8e14 < z Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
sub-neg99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around 0 81.9%
Taylor expanded in z around inf 66.1%
if -1.56000000000000002e-17 < z < 1.8e14Initial program 99.9%
associate-*l/99.7%
sub-neg99.7%
sub-neg99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around inf 53.8%
Final simplification60.2%
(FPCore (x y z) :precision binary64 4.0)
double code(double x, double y, double z) {
return 4.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 4.0d0
end function
public static double code(double x, double y, double z) {
return 4.0;
}
def code(x, y, z): return 4.0
function code(x, y, z) return 4.0 end
function tmp = code(x, y, z) tmp = 4.0; end
code[x_, y_, z_] := 4.0
\begin{array}{l}
\\
4
\end{array}
Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
sub-neg99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around inf 34.7%
Final simplification34.7%
herbie shell --seed 2024031
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, A"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))