
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - 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.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\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.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - 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.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - 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.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (* z -4.0) y))) (t_1 (+ 1.0 (* x (/ 4.0 y)))))
(if (<= x -0.48)
t_1
(if (<= x -1.5e-137)
t_0
(if (<= x -1.55e-303)
2.0
(if (<= x 7e-56)
t_0
(if (<= x 1.2e+21) 2.0 (if (<= x 1e+108) t_0 t_1))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + ((z * -4.0) / y);
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -0.48) {
tmp = t_1;
} else if (x <= -1.5e-137) {
tmp = t_0;
} else if (x <= -1.55e-303) {
tmp = 2.0;
} else if (x <= 7e-56) {
tmp = t_0;
} else if (x <= 1.2e+21) {
tmp = 2.0;
} else if (x <= 1e+108) {
tmp = t_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 + ((z * (-4.0d0)) / y)
t_1 = 1.0d0 + (x * (4.0d0 / y))
if (x <= (-0.48d0)) then
tmp = t_1
else if (x <= (-1.5d-137)) then
tmp = t_0
else if (x <= (-1.55d-303)) then
tmp = 2.0d0
else if (x <= 7d-56) then
tmp = t_0
else if (x <= 1.2d+21) then
tmp = 2.0d0
else if (x <= 1d+108) then
tmp = t_0
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 + ((z * -4.0) / y);
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -0.48) {
tmp = t_1;
} else if (x <= -1.5e-137) {
tmp = t_0;
} else if (x <= -1.55e-303) {
tmp = 2.0;
} else if (x <= 7e-56) {
tmp = t_0;
} else if (x <= 1.2e+21) {
tmp = 2.0;
} else if (x <= 1e+108) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((z * -4.0) / y) t_1 = 1.0 + (x * (4.0 / y)) tmp = 0 if x <= -0.48: tmp = t_1 elif x <= -1.5e-137: tmp = t_0 elif x <= -1.55e-303: tmp = 2.0 elif x <= 7e-56: tmp = t_0 elif x <= 1.2e+21: tmp = 2.0 elif x <= 1e+108: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(Float64(z * -4.0) / y)) t_1 = Float64(1.0 + Float64(x * Float64(4.0 / y))) tmp = 0.0 if (x <= -0.48) tmp = t_1; elseif (x <= -1.5e-137) tmp = t_0; elseif (x <= -1.55e-303) tmp = 2.0; elseif (x <= 7e-56) tmp = t_0; elseif (x <= 1.2e+21) tmp = 2.0; elseif (x <= 1e+108) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + ((z * -4.0) / y); t_1 = 1.0 + (x * (4.0 / y)); tmp = 0.0; if (x <= -0.48) tmp = t_1; elseif (x <= -1.5e-137) tmp = t_0; elseif (x <= -1.55e-303) tmp = 2.0; elseif (x <= 7e-56) tmp = t_0; elseif (x <= 1.2e+21) tmp = 2.0; elseif (x <= 1e+108) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -0.48], t$95$1, If[LessEqual[x, -1.5e-137], t$95$0, If[LessEqual[x, -1.55e-303], 2.0, If[LessEqual[x, 7e-56], t$95$0, If[LessEqual[x, 1.2e+21], 2.0, If[LessEqual[x, 1e+108], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{z \cdot -4}{y}\\
t_1 := 1 + x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -0.48:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.5 \cdot 10^{-137}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-303}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 7 \cdot 10^{-56}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{+21}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 10^{+108}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -0.47999999999999998 or 1e108 < x Initial program 100.0%
Taylor expanded in x around inf 78.2%
associate-*r/78.2%
associate-*l/78.1%
*-commutative78.1%
Simplified78.1%
if -0.47999999999999998 < x < -1.4999999999999999e-137 or -1.55e-303 < x < 6.9999999999999996e-56 or 1.2e21 < x < 1e108Initial program 100.0%
Taylor expanded in z around inf 58.6%
associate-*r/58.6%
Simplified58.6%
if -1.4999999999999999e-137 < x < -1.55e-303 or 6.9999999999999996e-56 < x < 1.2e21Initial program 100.0%
Taylor expanded in y around inf 62.3%
Final simplification66.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (* z -4.0) y))) (t_1 (+ 1.0 (/ (* 4.0 x) y))))
(if (<= x -118000000.0)
t_1
(if (<= x -1.25e-135)
t_0
(if (<= x -1.65e-303)
2.0
(if (<= x 3.3e-56)
t_0
(if (<= x 2.35e+22) 2.0 (if (<= x 9e+107) t_0 t_1))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + ((z * -4.0) / y);
double t_1 = 1.0 + ((4.0 * x) / y);
double tmp;
if (x <= -118000000.0) {
tmp = t_1;
} else if (x <= -1.25e-135) {
tmp = t_0;
} else if (x <= -1.65e-303) {
tmp = 2.0;
} else if (x <= 3.3e-56) {
tmp = t_0;
} else if (x <= 2.35e+22) {
tmp = 2.0;
} else if (x <= 9e+107) {
tmp = t_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 + ((z * (-4.0d0)) / y)
t_1 = 1.0d0 + ((4.0d0 * x) / y)
if (x <= (-118000000.0d0)) then
tmp = t_1
else if (x <= (-1.25d-135)) then
tmp = t_0
else if (x <= (-1.65d-303)) then
tmp = 2.0d0
else if (x <= 3.3d-56) then
tmp = t_0
else if (x <= 2.35d+22) then
tmp = 2.0d0
else if (x <= 9d+107) then
tmp = t_0
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 + ((z * -4.0) / y);
double t_1 = 1.0 + ((4.0 * x) / y);
double tmp;
if (x <= -118000000.0) {
tmp = t_1;
} else if (x <= -1.25e-135) {
tmp = t_0;
} else if (x <= -1.65e-303) {
tmp = 2.0;
} else if (x <= 3.3e-56) {
tmp = t_0;
} else if (x <= 2.35e+22) {
tmp = 2.0;
} else if (x <= 9e+107) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((z * -4.0) / y) t_1 = 1.0 + ((4.0 * x) / y) tmp = 0 if x <= -118000000.0: tmp = t_1 elif x <= -1.25e-135: tmp = t_0 elif x <= -1.65e-303: tmp = 2.0 elif x <= 3.3e-56: tmp = t_0 elif x <= 2.35e+22: tmp = 2.0 elif x <= 9e+107: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(Float64(z * -4.0) / y)) t_1 = Float64(1.0 + Float64(Float64(4.0 * x) / y)) tmp = 0.0 if (x <= -118000000.0) tmp = t_1; elseif (x <= -1.25e-135) tmp = t_0; elseif (x <= -1.65e-303) tmp = 2.0; elseif (x <= 3.3e-56) tmp = t_0; elseif (x <= 2.35e+22) tmp = 2.0; elseif (x <= 9e+107) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + ((z * -4.0) / y); t_1 = 1.0 + ((4.0 * x) / y); tmp = 0.0; if (x <= -118000000.0) tmp = t_1; elseif (x <= -1.25e-135) tmp = t_0; elseif (x <= -1.65e-303) tmp = 2.0; elseif (x <= 3.3e-56) tmp = t_0; elseif (x <= 2.35e+22) tmp = 2.0; elseif (x <= 9e+107) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -118000000.0], t$95$1, If[LessEqual[x, -1.25e-135], t$95$0, If[LessEqual[x, -1.65e-303], 2.0, If[LessEqual[x, 3.3e-56], t$95$0, If[LessEqual[x, 2.35e+22], 2.0, If[LessEqual[x, 9e+107], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{z \cdot -4}{y}\\
t_1 := 1 + \frac{4 \cdot x}{y}\\
\mathbf{if}\;x \leq -118000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -1.25 \cdot 10^{-135}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.65 \cdot 10^{-303}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-56}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.35 \cdot 10^{+22}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+107}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -1.18e8 or 9e107 < x Initial program 100.0%
Taylor expanded in x around inf 78.2%
associate-*r/78.2%
*-commutative78.2%
Simplified78.2%
if -1.18e8 < x < -1.25000000000000005e-135 or -1.6499999999999999e-303 < x < 3.29999999999999984e-56 or 2.3500000000000001e22 < x < 9e107Initial program 100.0%
Taylor expanded in z around inf 58.6%
associate-*r/58.6%
Simplified58.6%
if -1.25000000000000005e-135 < x < -1.6499999999999999e-303 or 3.29999999999999984e-56 < x < 2.3500000000000001e22Initial program 100.0%
Taylor expanded in y around inf 62.3%
Final simplification66.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -9.5e-23) (not (<= x 1.35e+58))) (+ 1.0 (* x (/ 4.0 y))) 2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.5e-23) || !(x <= 1.35e+58)) {
tmp = 1.0 + (x * (4.0 / y));
} else {
tmp = 2.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 ((x <= (-9.5d-23)) .or. (.not. (x <= 1.35d+58))) then
tmp = 1.0d0 + (x * (4.0d0 / y))
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -9.5e-23) || !(x <= 1.35e+58)) {
tmp = 1.0 + (x * (4.0 / y));
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9.5e-23) or not (x <= 1.35e+58): tmp = 1.0 + (x * (4.0 / y)) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9.5e-23) || !(x <= 1.35e+58)) tmp = Float64(1.0 + Float64(x * Float64(4.0 / y))); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -9.5e-23) || ~((x <= 1.35e+58))) tmp = 1.0 + (x * (4.0 / y)); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.5e-23], N[Not[LessEqual[x, 1.35e+58]], $MachinePrecision]], N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{-23} \lor \neg \left(x \leq 1.35 \cdot 10^{+58}\right):\\
\;\;\;\;1 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if x < -9.50000000000000058e-23 or 1.3500000000000001e58 < x Initial program 100.0%
Taylor expanded in x around inf 71.1%
associate-*r/71.1%
associate-*l/71.0%
*-commutative71.0%
Simplified71.0%
if -9.50000000000000058e-23 < x < 1.3500000000000001e58Initial program 100.0%
Taylor expanded in y around inf 49.0%
Final simplification59.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.8e+135) (not (<= z 5.8e+130))) (+ 1.0 (/ (* z -4.0) y)) (+ 2.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.8e+135) || !(z <= 5.8e+130)) {
tmp = 1.0 + ((z * -4.0) / y);
} else {
tmp = 2.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 <= (-5.8d+135)) .or. (.not. (z <= 5.8d+130))) then
tmp = 1.0d0 + ((z * (-4.0d0)) / y)
else
tmp = 2.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 <= -5.8e+135) || !(z <= 5.8e+130)) {
tmp = 1.0 + ((z * -4.0) / y);
} else {
tmp = 2.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.8e+135) or not (z <= 5.8e+130): tmp = 1.0 + ((z * -4.0) / y) else: tmp = 2.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5.8e+135) || !(z <= 5.8e+130)) tmp = Float64(1.0 + Float64(Float64(z * -4.0) / y)); else tmp = Float64(2.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.8e+135) || ~((z <= 5.8e+130))) tmp = 1.0 + ((z * -4.0) / y); else tmp = 2.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.8e+135], N[Not[LessEqual[z, 5.8e+130]], $MachinePrecision]], N[(1.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.8 \cdot 10^{+135} \lor \neg \left(z \leq 5.8 \cdot 10^{+130}\right):\\
\;\;\;\;1 + \frac{z \cdot -4}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -5.7999999999999997e135 or 5.7999999999999998e130 < z Initial program 100.0%
Taylor expanded in z around inf 81.8%
associate-*r/81.8%
Simplified81.8%
if -5.7999999999999997e135 < z < 5.7999999999999998e130Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.9%
associate-*l/99.9%
*-commutative99.9%
associate-/l*99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-/l*99.9%
distribute-rgt-neg-in99.9%
distribute-lft-neg-out99.9%
associate-/l*99.9%
*-commutative99.9%
neg-mul-199.9%
distribute-lft-neg-out99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
associate-*l/100.0%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 87.0%
Final simplification85.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.1e+28) (not (<= z 1.02e+121))) (+ 2.0 (/ z (* y -0.25))) (+ 2.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.1e+28) || !(z <= 1.02e+121)) {
tmp = 2.0 + (z / (y * -0.25));
} else {
tmp = 2.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 <= (-3.1d+28)) .or. (.not. (z <= 1.02d+121))) then
tmp = 2.0d0 + (z / (y * (-0.25d0)))
else
tmp = 2.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 <= -3.1e+28) || !(z <= 1.02e+121)) {
tmp = 2.0 + (z / (y * -0.25));
} else {
tmp = 2.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.1e+28) or not (z <= 1.02e+121): tmp = 2.0 + (z / (y * -0.25)) else: tmp = 2.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.1e+28) || !(z <= 1.02e+121)) tmp = Float64(2.0 + Float64(z / Float64(y * -0.25))); else tmp = Float64(2.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -3.1e+28) || ~((z <= 1.02e+121))) tmp = 2.0 + (z / (y * -0.25)); else tmp = 2.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.1e+28], N[Not[LessEqual[z, 1.02e+121]], $MachinePrecision]], N[(2.0 + N[(z / N[(y * -0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.1 \cdot 10^{+28} \lor \neg \left(z \leq 1.02 \cdot 10^{+121}\right):\\
\;\;\;\;2 + \frac{z}{y \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -3.1000000000000001e28 or 1.02000000000000005e121 < z Initial program 100.0%
associate-*l/99.9%
+-commutative99.9%
associate--l+99.9%
distribute-lft-in99.9%
associate-+r+99.9%
associate-*l/99.9%
*-commutative99.9%
associate-/l*99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-/l*99.9%
distribute-rgt-neg-in99.9%
distribute-lft-neg-out99.9%
associate-/l*99.9%
*-commutative99.9%
neg-mul-199.9%
distribute-lft-neg-out99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
associate-*l/100.0%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 88.0%
associate-*r/88.0%
*-commutative88.0%
/-rgt-identity88.0%
associate-/l*88.0%
associate-/l/88.0%
metadata-eval88.0%
Simplified88.0%
if -3.1000000000000001e28 < z < 1.02000000000000005e121Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-/l*99.8%
metadata-eval99.8%
metadata-eval99.8%
associate-/l*99.8%
distribute-rgt-neg-in99.8%
distribute-lft-neg-out99.8%
associate-/l*99.8%
*-commutative99.8%
neg-mul-199.8%
distribute-lft-neg-out99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
associate-*l/100.0%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 90.2%
Final simplification89.3%
(FPCore (x y z) :precision binary64 (+ 2.0 (* (/ 4.0 y) (- x z))))
double code(double x, double y, double z) {
return 2.0 + ((4.0 / y) * (x - z));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0 + ((4.0d0 / y) * (x - z))
end function
public static double code(double x, double y, double z) {
return 2.0 + ((4.0 / y) * (x - z));
}
def code(x, y, z): return 2.0 + ((4.0 / y) * (x - z))
function code(x, y, z) return Float64(2.0 + Float64(Float64(4.0 / y) * Float64(x - z))) end
function tmp = code(x, y, z) tmp = 2.0 + ((4.0 / y) * (x - z)); end
code[x_, y_, z_] := N[(2.0 + N[(N[(4.0 / y), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 + \frac{4}{y} \cdot \left(x - z\right)
\end{array}
Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.9%
associate-*l/99.9%
*-commutative99.9%
associate-/l*99.9%
metadata-eval99.9%
metadata-eval99.9%
associate-/l*99.9%
distribute-rgt-neg-in99.9%
distribute-lft-neg-out99.9%
associate-/l*99.9%
*-commutative99.9%
neg-mul-199.9%
distribute-lft-neg-out99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 2.0)
double code(double x, double y, double z) {
return 2.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 2.0d0
end function
public static double code(double x, double y, double z) {
return 2.0;
}
def code(x, y, z): return 2.0
function code(x, y, z) return 2.0 end
function tmp = code(x, y, z) tmp = 2.0; end
code[x_, y_, z_] := 2.0
\begin{array}{l}
\\
2
\end{array}
Initial program 100.0%
Taylor expanded in y around inf 33.1%
Final simplification33.1%
herbie shell --seed 2023318
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, C"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))