
(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 9 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 y) -4.0))) (t_1 (+ 1.0 (/ x (/ y 4.0)))))
(if (<= x -1e+15)
t_1
(if (<= x -2.15e-259)
2.0
(if (<= x 3.4e-292)
t_0
(if (<= x 2.7e-208)
2.0
(if (<= x 7.8e-59) t_0 (if (<= x 1.85e+27) 2.0 t_1))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + ((z / y) * -4.0);
double t_1 = 1.0 + (x / (y / 4.0));
double tmp;
if (x <= -1e+15) {
tmp = t_1;
} else if (x <= -2.15e-259) {
tmp = 2.0;
} else if (x <= 3.4e-292) {
tmp = t_0;
} else if (x <= 2.7e-208) {
tmp = 2.0;
} else if (x <= 7.8e-59) {
tmp = t_0;
} else if (x <= 1.85e+27) {
tmp = 2.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 / y) * (-4.0d0))
t_1 = 1.0d0 + (x / (y / 4.0d0))
if (x <= (-1d+15)) then
tmp = t_1
else if (x <= (-2.15d-259)) then
tmp = 2.0d0
else if (x <= 3.4d-292) then
tmp = t_0
else if (x <= 2.7d-208) then
tmp = 2.0d0
else if (x <= 7.8d-59) then
tmp = t_0
else if (x <= 1.85d+27) then
tmp = 2.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 + ((z / y) * -4.0);
double t_1 = 1.0 + (x / (y / 4.0));
double tmp;
if (x <= -1e+15) {
tmp = t_1;
} else if (x <= -2.15e-259) {
tmp = 2.0;
} else if (x <= 3.4e-292) {
tmp = t_0;
} else if (x <= 2.7e-208) {
tmp = 2.0;
} else if (x <= 7.8e-59) {
tmp = t_0;
} else if (x <= 1.85e+27) {
tmp = 2.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((z / y) * -4.0) t_1 = 1.0 + (x / (y / 4.0)) tmp = 0 if x <= -1e+15: tmp = t_1 elif x <= -2.15e-259: tmp = 2.0 elif x <= 3.4e-292: tmp = t_0 elif x <= 2.7e-208: tmp = 2.0 elif x <= 7.8e-59: tmp = t_0 elif x <= 1.85e+27: tmp = 2.0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(Float64(z / y) * -4.0)) t_1 = Float64(1.0 + Float64(x / Float64(y / 4.0))) tmp = 0.0 if (x <= -1e+15) tmp = t_1; elseif (x <= -2.15e-259) tmp = 2.0; elseif (x <= 3.4e-292) tmp = t_0; elseif (x <= 2.7e-208) tmp = 2.0; elseif (x <= 7.8e-59) tmp = t_0; elseif (x <= 1.85e+27) tmp = 2.0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + ((z / y) * -4.0); t_1 = 1.0 + (x / (y / 4.0)); tmp = 0.0; if (x <= -1e+15) tmp = t_1; elseif (x <= -2.15e-259) tmp = 2.0; elseif (x <= 3.4e-292) tmp = t_0; elseif (x <= 2.7e-208) tmp = 2.0; elseif (x <= 7.8e-59) tmp = t_0; elseif (x <= 1.85e+27) tmp = 2.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(x / N[(y / 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1e+15], t$95$1, If[LessEqual[x, -2.15e-259], 2.0, If[LessEqual[x, 3.4e-292], t$95$0, If[LessEqual[x, 2.7e-208], 2.0, If[LessEqual[x, 7.8e-59], t$95$0, If[LessEqual[x, 1.85e+27], 2.0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{z}{y} \cdot -4\\
t_1 := 1 + \frac{x}{\frac{y}{4}}\\
\mathbf{if}\;x \leq -1 \cdot 10^{+15}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -2.15 \cdot 10^{-259}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{-292}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-208}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 7.8 \cdot 10^{-59}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.85 \cdot 10^{+27}:\\
\;\;\;\;2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -1e15 or 1.85000000000000001e27 < x Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around inf 68.8%
associate-*r/68.8%
*-commutative68.8%
associate-/l*68.8%
Simplified68.8%
if -1e15 < x < -2.15e-259 or 3.40000000000000017e-292 < x < 2.7e-208 or 7.80000000000000038e-59 < x < 1.85000000000000001e27Initial 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.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 70.8%
Taylor expanded in y around inf 61.4%
if -2.15e-259 < x < 3.40000000000000017e-292 or 2.7e-208 < x < 7.80000000000000038e-59Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in z around inf 63.1%
*-commutative63.1%
Simplified63.1%
Final simplification65.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))) (t_1 (+ 1.0 (* (/ z y) -4.0))))
(if (<= y -2.3e+63)
2.0
(if (<= y -1.05e-204)
t_1
(if (<= y 1.2e-158)
t_0
(if (<= y 4e-35) t_1 (if (<= y 1.4e+45) t_0 2.0)))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double t_1 = 1.0 + ((z / y) * -4.0);
double tmp;
if (y <= -2.3e+63) {
tmp = 2.0;
} else if (y <= -1.05e-204) {
tmp = t_1;
} else if (y <= 1.2e-158) {
tmp = t_0;
} else if (y <= 4e-35) {
tmp = t_1;
} else if (y <= 1.4e+45) {
tmp = t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 4.0d0 * (x / y)
t_1 = 1.0d0 + ((z / y) * (-4.0d0))
if (y <= (-2.3d+63)) then
tmp = 2.0d0
else if (y <= (-1.05d-204)) then
tmp = t_1
else if (y <= 1.2d-158) then
tmp = t_0
else if (y <= 4d-35) then
tmp = t_1
else if (y <= 1.4d+45) then
tmp = t_0
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double t_1 = 1.0 + ((z / y) * -4.0);
double tmp;
if (y <= -2.3e+63) {
tmp = 2.0;
} else if (y <= -1.05e-204) {
tmp = t_1;
} else if (y <= 1.2e-158) {
tmp = t_0;
} else if (y <= 4e-35) {
tmp = t_1;
} else if (y <= 1.4e+45) {
tmp = t_0;
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) t_1 = 1.0 + ((z / y) * -4.0) tmp = 0 if y <= -2.3e+63: tmp = 2.0 elif y <= -1.05e-204: tmp = t_1 elif y <= 1.2e-158: tmp = t_0 elif y <= 4e-35: tmp = t_1 elif y <= 1.4e+45: tmp = t_0 else: tmp = 2.0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / y)) t_1 = Float64(1.0 + Float64(Float64(z / y) * -4.0)) tmp = 0.0 if (y <= -2.3e+63) tmp = 2.0; elseif (y <= -1.05e-204) tmp = t_1; elseif (y <= 1.2e-158) tmp = t_0; elseif (y <= 4e-35) tmp = t_1; elseif (y <= 1.4e+45) tmp = t_0; else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / y); t_1 = 1.0 + ((z / y) * -4.0); tmp = 0.0; if (y <= -2.3e+63) tmp = 2.0; elseif (y <= -1.05e-204) tmp = t_1; elseif (y <= 1.2e-158) tmp = t_0; elseif (y <= 4e-35) tmp = t_1; elseif (y <= 1.4e+45) tmp = t_0; else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.3e+63], 2.0, If[LessEqual[y, -1.05e-204], t$95$1, If[LessEqual[y, 1.2e-158], t$95$0, If[LessEqual[y, 4e-35], t$95$1, If[LessEqual[y, 1.4e+45], t$95$0, 2.0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
t_1 := 1 + \frac{z}{y} \cdot -4\\
\mathbf{if}\;y \leq -2.3 \cdot 10^{+63}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq -1.05 \cdot 10^{-204}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{-158}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 4 \cdot 10^{-35}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+45}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -2.29999999999999993e63 or 1.4e45 < y 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.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 87.9%
Taylor expanded in y around inf 67.3%
if -2.29999999999999993e63 < y < -1.05000000000000005e-204 or 1.20000000000000004e-158 < y < 4.00000000000000003e-35Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around inf 49.8%
*-commutative49.8%
Simplified49.8%
if -1.05000000000000005e-204 < y < 1.20000000000000004e-158 or 4.00000000000000003e-35 < y < 1.4e45Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around inf 65.8%
associate-*r/65.8%
*-commutative65.8%
associate-/l*65.8%
Simplified65.8%
Taylor expanded in x around inf 64.4%
Final simplification60.9%
(FPCore (x y z)
:precision binary64
(if (or (<= z -4e+82)
(not
(or (<= z 2.2e+96) (and (not (<= z 4.5e+177)) (<= z 2.35e+201)))))
(+ 1.0 (* (/ z y) -4.0))
(+ 2.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -4e+82) || !((z <= 2.2e+96) || (!(z <= 4.5e+177) && (z <= 2.35e+201)))) {
tmp = 1.0 + ((z / y) * -4.0);
} 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 <= (-4d+82)) .or. (.not. (z <= 2.2d+96) .or. (.not. (z <= 4.5d+177)) .and. (z <= 2.35d+201))) then
tmp = 1.0d0 + ((z / y) * (-4.0d0))
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 <= -4e+82) || !((z <= 2.2e+96) || (!(z <= 4.5e+177) && (z <= 2.35e+201)))) {
tmp = 1.0 + ((z / y) * -4.0);
} else {
tmp = 2.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -4e+82) or not ((z <= 2.2e+96) or (not (z <= 4.5e+177) and (z <= 2.35e+201))): tmp = 1.0 + ((z / y) * -4.0) else: tmp = 2.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -4e+82) || !((z <= 2.2e+96) || (!(z <= 4.5e+177) && (z <= 2.35e+201)))) tmp = Float64(1.0 + Float64(Float64(z / y) * -4.0)); 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 <= -4e+82) || ~(((z <= 2.2e+96) || (~((z <= 4.5e+177)) && (z <= 2.35e+201))))) tmp = 1.0 + ((z / y) * -4.0); else tmp = 2.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -4e+82], N[Not[Or[LessEqual[z, 2.2e+96], And[N[Not[LessEqual[z, 4.5e+177]], $MachinePrecision], LessEqual[z, 2.35e+201]]]], $MachinePrecision]], N[(1.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4 \cdot 10^{+82} \lor \neg \left(z \leq 2.2 \cdot 10^{+96} \lor \neg \left(z \leq 4.5 \cdot 10^{+177}\right) \land z \leq 2.35 \cdot 10^{+201}\right):\\
\;\;\;\;1 + \frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -3.9999999999999999e82 or 2.1999999999999999e96 < z < 4.4999999999999997e177 or 2.3499999999999999e201 < z Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around inf 76.2%
*-commutative76.2%
Simplified76.2%
if -3.9999999999999999e82 < z < 2.1999999999999999e96 or 4.4999999999999997e177 < z < 2.3499999999999999e201Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
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 inf 88.4%
div-inv88.4%
clear-num88.5%
*-commutative88.5%
Applied egg-rr88.5%
Final simplification85.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -9e-9) (not (<= x 4.8e+25))) (+ 2.0 (* 4.0 (/ x y))) (- 2.0 (* 4.0 (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9e-9) || !(x <= 4.8e+25)) {
tmp = 2.0 + (4.0 * (x / y));
} else {
tmp = 2.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 <= (-9d-9)) .or. (.not. (x <= 4.8d+25))) then
tmp = 2.0d0 + (4.0d0 * (x / y))
else
tmp = 2.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 <= -9e-9) || !(x <= 4.8e+25)) {
tmp = 2.0 + (4.0 * (x / y));
} else {
tmp = 2.0 - (4.0 * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9e-9) or not (x <= 4.8e+25): tmp = 2.0 + (4.0 * (x / y)) else: tmp = 2.0 - (4.0 * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9e-9) || !(x <= 4.8e+25)) tmp = Float64(2.0 + Float64(4.0 * Float64(x / y))); else tmp = Float64(2.0 - Float64(4.0 * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -9e-9) || ~((x <= 4.8e+25))) tmp = 2.0 + (4.0 * (x / y)); else tmp = 2.0 - (4.0 * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9e-9], N[Not[LessEqual[x, 4.8e+25]], $MachinePrecision]], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 - N[(4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{-9} \lor \neg \left(x \leq 4.8 \cdot 10^{+25}\right):\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;2 - 4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < -8.99999999999999953e-9 or 4.79999999999999992e25 < x Initial 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 83.0%
div-inv83.0%
clear-num83.2%
*-commutative83.2%
Applied egg-rr83.2%
if -8.99999999999999953e-9 < x < 4.79999999999999992e25Initial 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.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 92.3%
associate-*r/92.3%
neg-mul-192.3%
Simplified92.3%
frac-2neg92.3%
div-inv92.3%
distribute-neg-frac92.3%
remove-double-neg92.3%
add-sqr-sqrt46.5%
sqrt-unprod65.8%
sqr-neg65.8%
sqrt-unprod23.0%
add-sqr-sqrt52.5%
clear-num52.5%
cancel-sign-sub-inv52.5%
clear-num52.5%
div-inv52.5%
div-inv52.5%
clear-num52.5%
add-sqr-sqrt23.0%
sqrt-unprod65.8%
sqr-neg65.8%
sqrt-unprod46.5%
add-sqr-sqrt92.3%
Applied egg-rr92.3%
Final simplification87.6%
(FPCore (x y z) :precision binary64 (if (<= y -5.5e+71) 2.0 (if (<= y 3.4e+46) (* 4.0 (/ x y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e+71) {
tmp = 2.0;
} else if (y <= 3.4e+46) {
tmp = 4.0 * (x / 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 (y <= (-5.5d+71)) then
tmp = 2.0d0
else if (y <= 3.4d+46) then
tmp = 4.0d0 * (x / y)
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e+71) {
tmp = 2.0;
} else if (y <= 3.4e+46) {
tmp = 4.0 * (x / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.5e+71: tmp = 2.0 elif y <= 3.4e+46: tmp = 4.0 * (x / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.5e+71) tmp = 2.0; elseif (y <= 3.4e+46) tmp = Float64(4.0 * Float64(x / y)); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -5.5e+71) tmp = 2.0; elseif (y <= 3.4e+46) tmp = 4.0 * (x / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.5e+71], 2.0, If[LessEqual[y, 3.4e+46], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+71}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+46}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -5.5e71 or 3.3999999999999998e46 < y 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.9%
Applied egg-rr99.9%
Taylor expanded in x around inf 87.9%
Taylor expanded in y around inf 67.3%
if -5.5e71 < y < 3.3999999999999998e46Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around inf 51.0%
associate-*r/51.0%
*-commutative51.0%
associate-/l*51.0%
Simplified51.0%
Taylor expanded in x around inf 48.7%
Final simplification55.9%
(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 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%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around inf 36.8%
*-commutative36.8%
Simplified36.8%
Taylor expanded in z around 0 8.3%
Final simplification8.3%
(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%
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 72.3%
Taylor expanded in y around inf 35.7%
Final simplification35.7%
herbie shell --seed 2023311
(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)))