
(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 (+ (/ (- x z) (* y 0.25)) 2.0))
double code(double x, double y, double z) {
return ((x - z) / (y * 0.25)) + 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 = ((x - z) / (y * 0.25d0)) + 2.0d0
end function
public static double code(double x, double y, double z) {
return ((x - z) / (y * 0.25)) + 2.0;
}
def code(x, y, z): return ((x - z) / (y * 0.25)) + 2.0
function code(x, y, z) return Float64(Float64(Float64(x - z) / Float64(y * 0.25)) + 2.0) end
function tmp = code(x, y, z) tmp = ((x - z) / (y * 0.25)) + 2.0; end
code[x_, y_, z_] := N[(N[(N[(x - z), $MachinePrecision] / N[(y * 0.25), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - z}{y \cdot 0.25} + 2
\end{array}
Initial program 99.6%
+-commutative99.6%
associate-*l/99.9%
+-commutative99.9%
associate--l+99.9%
+-commutative99.9%
distribute-lft-in99.9%
associate-+l+99.9%
associate-*l/99.9%
*-commutative99.9%
associate-*l*99.9%
metadata-eval99.9%
*-rgt-identity99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
div-inv99.9%
metadata-eval99.9%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (* 4.0 (/ x y)) 1.0)) (t_1 (+ 1.0 (* -4.0 (/ z y)))))
(if (<= z -6.2e+21)
t_1
(if (<= z -1.8e-134)
t_0
(if (<= z -1.15e-256)
2.0
(if (<= z 4.4e-184)
t_0
(if (<= z 2.6e-70) 2.0 (if (<= z 6.5e+66) t_0 t_1))))))))
double code(double x, double y, double z) {
double t_0 = (4.0 * (x / y)) + 1.0;
double t_1 = 1.0 + (-4.0 * (z / y));
double tmp;
if (z <= -6.2e+21) {
tmp = t_1;
} else if (z <= -1.8e-134) {
tmp = t_0;
} else if (z <= -1.15e-256) {
tmp = 2.0;
} else if (z <= 4.4e-184) {
tmp = t_0;
} else if (z <= 2.6e-70) {
tmp = 2.0;
} else if (z <= 6.5e+66) {
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 = (4.0d0 * (x / y)) + 1.0d0
t_1 = 1.0d0 + ((-4.0d0) * (z / y))
if (z <= (-6.2d+21)) then
tmp = t_1
else if (z <= (-1.8d-134)) then
tmp = t_0
else if (z <= (-1.15d-256)) then
tmp = 2.0d0
else if (z <= 4.4d-184) then
tmp = t_0
else if (z <= 2.6d-70) then
tmp = 2.0d0
else if (z <= 6.5d+66) 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 = (4.0 * (x / y)) + 1.0;
double t_1 = 1.0 + (-4.0 * (z / y));
double tmp;
if (z <= -6.2e+21) {
tmp = t_1;
} else if (z <= -1.8e-134) {
tmp = t_0;
} else if (z <= -1.15e-256) {
tmp = 2.0;
} else if (z <= 4.4e-184) {
tmp = t_0;
} else if (z <= 2.6e-70) {
tmp = 2.0;
} else if (z <= 6.5e+66) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (4.0 * (x / y)) + 1.0 t_1 = 1.0 + (-4.0 * (z / y)) tmp = 0 if z <= -6.2e+21: tmp = t_1 elif z <= -1.8e-134: tmp = t_0 elif z <= -1.15e-256: tmp = 2.0 elif z <= 4.4e-184: tmp = t_0 elif z <= 2.6e-70: tmp = 2.0 elif z <= 6.5e+66: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(4.0 * Float64(x / y)) + 1.0) t_1 = Float64(1.0 + Float64(-4.0 * Float64(z / y))) tmp = 0.0 if (z <= -6.2e+21) tmp = t_1; elseif (z <= -1.8e-134) tmp = t_0; elseif (z <= -1.15e-256) tmp = 2.0; elseif (z <= 4.4e-184) tmp = t_0; elseif (z <= 2.6e-70) tmp = 2.0; elseif (z <= 6.5e+66) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (4.0 * (x / y)) + 1.0; t_1 = 1.0 + (-4.0 * (z / y)); tmp = 0.0; if (z <= -6.2e+21) tmp = t_1; elseif (z <= -1.8e-134) tmp = t_0; elseif (z <= -1.15e-256) tmp = 2.0; elseif (z <= 4.4e-184) tmp = t_0; elseif (z <= 2.6e-70) tmp = 2.0; elseif (z <= 6.5e+66) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -6.2e+21], t$95$1, If[LessEqual[z, -1.8e-134], t$95$0, If[LessEqual[z, -1.15e-256], 2.0, If[LessEqual[z, 4.4e-184], t$95$0, If[LessEqual[z, 2.6e-70], 2.0, If[LessEqual[z, 6.5e+66], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y} + 1\\
t_1 := 1 + -4 \cdot \frac{z}{y}\\
\mathbf{if}\;z \leq -6.2 \cdot 10^{+21}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -1.8 \cdot 10^{-134}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -1.15 \cdot 10^{-256}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq 4.4 \cdot 10^{-184}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.6 \cdot 10^{-70}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{+66}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -6.2e21 or 6.5000000000000001e66 < z Initial program 99.2%
Taylor expanded in z around inf 76.5%
*-commutative76.5%
Simplified76.5%
if -6.2e21 < z < -1.79999999999999995e-134 or -1.15e-256 < z < 4.39999999999999984e-184 or 2.60000000000000002e-70 < z < 6.5000000000000001e66Initial program 100.0%
Taylor expanded in x around inf 63.6%
if -1.79999999999999995e-134 < z < -1.15e-256 or 4.39999999999999984e-184 < z < 2.60000000000000002e-70Initial program 100.0%
Taylor expanded in y around inf 69.3%
Final simplification70.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (* 4.0 (/ x y)) 1.0)) (t_1 (+ 1.0 (* z (/ -4.0 y)))))
(if (<= z -1.4e+22)
t_1
(if (<= z -2.1e-134)
t_0
(if (<= z -9.5e-258)
2.0
(if (<= z 1.15e-183)
t_0
(if (<= z 2.75e-70) 2.0 (if (<= z 1.42e+66) t_0 t_1))))))))
double code(double x, double y, double z) {
double t_0 = (4.0 * (x / y)) + 1.0;
double t_1 = 1.0 + (z * (-4.0 / y));
double tmp;
if (z <= -1.4e+22) {
tmp = t_1;
} else if (z <= -2.1e-134) {
tmp = t_0;
} else if (z <= -9.5e-258) {
tmp = 2.0;
} else if (z <= 1.15e-183) {
tmp = t_0;
} else if (z <= 2.75e-70) {
tmp = 2.0;
} else if (z <= 1.42e+66) {
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 = (4.0d0 * (x / y)) + 1.0d0
t_1 = 1.0d0 + (z * ((-4.0d0) / y))
if (z <= (-1.4d+22)) then
tmp = t_1
else if (z <= (-2.1d-134)) then
tmp = t_0
else if (z <= (-9.5d-258)) then
tmp = 2.0d0
else if (z <= 1.15d-183) then
tmp = t_0
else if (z <= 2.75d-70) then
tmp = 2.0d0
else if (z <= 1.42d+66) 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 = (4.0 * (x / y)) + 1.0;
double t_1 = 1.0 + (z * (-4.0 / y));
double tmp;
if (z <= -1.4e+22) {
tmp = t_1;
} else if (z <= -2.1e-134) {
tmp = t_0;
} else if (z <= -9.5e-258) {
tmp = 2.0;
} else if (z <= 1.15e-183) {
tmp = t_0;
} else if (z <= 2.75e-70) {
tmp = 2.0;
} else if (z <= 1.42e+66) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (4.0 * (x / y)) + 1.0 t_1 = 1.0 + (z * (-4.0 / y)) tmp = 0 if z <= -1.4e+22: tmp = t_1 elif z <= -2.1e-134: tmp = t_0 elif z <= -9.5e-258: tmp = 2.0 elif z <= 1.15e-183: tmp = t_0 elif z <= 2.75e-70: tmp = 2.0 elif z <= 1.42e+66: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(4.0 * Float64(x / y)) + 1.0) t_1 = Float64(1.0 + Float64(z * Float64(-4.0 / y))) tmp = 0.0 if (z <= -1.4e+22) tmp = t_1; elseif (z <= -2.1e-134) tmp = t_0; elseif (z <= -9.5e-258) tmp = 2.0; elseif (z <= 1.15e-183) tmp = t_0; elseif (z <= 2.75e-70) tmp = 2.0; elseif (z <= 1.42e+66) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (4.0 * (x / y)) + 1.0; t_1 = 1.0 + (z * (-4.0 / y)); tmp = 0.0; if (z <= -1.4e+22) tmp = t_1; elseif (z <= -2.1e-134) tmp = t_0; elseif (z <= -9.5e-258) tmp = 2.0; elseif (z <= 1.15e-183) tmp = t_0; elseif (z <= 2.75e-70) tmp = 2.0; elseif (z <= 1.42e+66) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.4e+22], t$95$1, If[LessEqual[z, -2.1e-134], t$95$0, If[LessEqual[z, -9.5e-258], 2.0, If[LessEqual[z, 1.15e-183], t$95$0, If[LessEqual[z, 2.75e-70], 2.0, If[LessEqual[z, 1.42e+66], t$95$0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y} + 1\\
t_1 := 1 + z \cdot \frac{-4}{y}\\
\mathbf{if}\;z \leq -1.4 \cdot 10^{+22}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -2.1 \cdot 10^{-134}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -9.5 \cdot 10^{-258}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{-183}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.75 \cdot 10^{-70}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq 1.42 \cdot 10^{+66}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.4e22 or 1.4200000000000001e66 < z Initial program 99.2%
Taylor expanded in z around inf 76.5%
associate-*r/76.5%
metadata-eval76.5%
associate-*r*76.5%
neg-mul-176.5%
*-commutative76.5%
associate-*r/76.3%
distribute-lft-neg-out76.3%
distribute-rgt-neg-in76.3%
distribute-neg-frac76.3%
metadata-eval76.3%
Simplified76.3%
if -1.4e22 < z < -2.0999999999999999e-134 or -9.5000000000000009e-258 < z < 1.15000000000000008e-183 or 2.75e-70 < z < 1.4200000000000001e66Initial program 100.0%
Taylor expanded in x around inf 63.6%
if -2.0999999999999999e-134 < z < -9.5000000000000009e-258 or 1.15000000000000008e-183 < z < 2.75e-70Initial program 100.0%
Taylor expanded in y around inf 69.3%
Final simplification70.5%
(FPCore (x y z) :precision binary64 (if (or (<= z -2e+21) (not (<= z 2e+66))) (+ 2.0 (/ (* z -4.0) y)) (+ 2.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2e+21) || !(z <= 2e+66)) {
tmp = 2.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 <= (-2d+21)) .or. (.not. (z <= 2d+66))) then
tmp = 2.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 <= -2e+21) || !(z <= 2e+66)) {
tmp = 2.0 + ((z * -4.0) / y);
} else {
tmp = 2.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2e+21) or not (z <= 2e+66): tmp = 2.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 <= -2e+21) || !(z <= 2e+66)) tmp = Float64(2.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 <= -2e+21) || ~((z <= 2e+66))) tmp = 2.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, -2e+21], N[Not[LessEqual[z, 2e+66]], $MachinePrecision]], N[(2.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 -2 \cdot 10^{+21} \lor \neg \left(z \leq 2 \cdot 10^{+66}\right):\\
\;\;\;\;2 + \frac{z \cdot -4}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -2e21 or 1.99999999999999989e66 < z Initial program 99.2%
+-commutative99.2%
associate-*l/99.9%
+-commutative99.9%
associate--l+99.9%
+-commutative99.9%
distribute-lft-in99.9%
associate-+l+99.9%
associate-*l/99.9%
*-commutative99.9%
associate-*l*99.9%
metadata-eval99.9%
*-rgt-identity99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
div-inv99.9%
metadata-eval99.9%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 89.9%
associate-*r/89.9%
Simplified89.9%
if -2e21 < z < 1.99999999999999989e66Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 90.6%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.02e+77) (not (<= z 2.6e+72))) (+ 1.0 (* -4.0 (/ z y))) (+ 2.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.02e+77) || !(z <= 2.6e+72)) {
tmp = 1.0 + (-4.0 * (z / 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 <= (-2.02d+77)) .or. (.not. (z <= 2.6d+72))) then
tmp = 1.0d0 + ((-4.0d0) * (z / 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 <= -2.02e+77) || !(z <= 2.6e+72)) {
tmp = 1.0 + (-4.0 * (z / y));
} else {
tmp = 2.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.02e+77) or not (z <= 2.6e+72): tmp = 1.0 + (-4.0 * (z / y)) else: tmp = 2.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.02e+77) || !(z <= 2.6e+72)) tmp = Float64(1.0 + Float64(-4.0 * Float64(z / 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 <= -2.02e+77) || ~((z <= 2.6e+72))) tmp = 1.0 + (-4.0 * (z / y)); else tmp = 2.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.02e+77], N[Not[LessEqual[z, 2.6e+72]], $MachinePrecision]], N[(1.0 + N[(-4.0 * N[(z / y), $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 -2.02 \cdot 10^{+77} \lor \neg \left(z \leq 2.6 \cdot 10^{+72}\right):\\
\;\;\;\;1 + -4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -2.0199999999999999e77 or 2.59999999999999981e72 < z Initial program 99.1%
Taylor expanded in z around inf 80.5%
*-commutative80.5%
Simplified80.5%
if -2.0199999999999999e77 < z < 2.59999999999999981e72Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 89.7%
Final simplification85.9%
(FPCore (x y z) :precision binary64 (if (<= y -1.52e+38) 2.0 (if (<= y 2.5e+69) (+ (* 4.0 (/ x y)) 1.0) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.52e+38) {
tmp = 2.0;
} else if (y <= 2.5e+69) {
tmp = (4.0 * (x / y)) + 1.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) :: tmp
if (y <= (-1.52d+38)) then
tmp = 2.0d0
else if (y <= 2.5d+69) then
tmp = (4.0d0 * (x / y)) + 1.0d0
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.52e+38) {
tmp = 2.0;
} else if (y <= 2.5e+69) {
tmp = (4.0 * (x / y)) + 1.0;
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.52e+38: tmp = 2.0 elif y <= 2.5e+69: tmp = (4.0 * (x / y)) + 1.0 else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.52e+38) tmp = 2.0; elseif (y <= 2.5e+69) tmp = Float64(Float64(4.0 * Float64(x / y)) + 1.0); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.52e+38) tmp = 2.0; elseif (y <= 2.5e+69) tmp = (4.0 * (x / y)) + 1.0; else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.52e+38], 2.0, If[LessEqual[y, 2.5e+69], N[(N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.52 \cdot 10^{+38}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{+69}:\\
\;\;\;\;4 \cdot \frac{x}{y} + 1\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -1.51999999999999996e38 or 2.50000000000000018e69 < y Initial program 99.1%
Taylor expanded in y around inf 60.3%
if -1.51999999999999996e38 < y < 2.50000000000000018e69Initial program 100.0%
Taylor expanded in x around inf 48.9%
Final simplification53.8%
(FPCore (x y z) :precision binary64 (+ 2.0 (* (- x z) (/ 4.0 y))))
double code(double x, double y, double z) {
return 2.0 + ((x - z) * (4.0 / y));
}
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 + ((x - z) * (4.0d0 / y))
end function
public static double code(double x, double y, double z) {
return 2.0 + ((x - z) * (4.0 / y));
}
def code(x, y, z): return 2.0 + ((x - z) * (4.0 / y))
function code(x, y, z) return Float64(2.0 + Float64(Float64(x - z) * Float64(4.0 / y))) end
function tmp = code(x, y, z) tmp = 2.0 + ((x - z) * (4.0 / y)); end
code[x_, y_, z_] := N[(2.0 + N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 + \left(x - z\right) \cdot \frac{4}{y}
\end{array}
Initial program 99.6%
+-commutative99.6%
associate-*l/99.9%
+-commutative99.9%
associate--l+99.9%
+-commutative99.9%
distribute-lft-in99.9%
associate-+l+99.9%
associate-*l/99.9%
*-commutative99.9%
associate-*l*99.9%
metadata-eval99.9%
*-rgt-identity99.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 99.6%
Taylor expanded in y around inf 32.0%
herbie shell --seed 2024093
(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)))