
(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 12 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 100.0%
+-commutative100.0%
associate-*l/99.4%
+-commutative99.4%
associate--l+99.4%
+-commutative99.4%
distribute-lft-in99.4%
associate-+l+99.4%
associate-*l/99.4%
*-commutative99.4%
associate-*l*99.4%
metadata-eval99.4%
*-rgt-identity99.4%
*-inverses99.4%
metadata-eval99.4%
Simplified99.4%
clear-num99.4%
div-inv99.4%
metadata-eval99.4%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
(FPCore (x y z)
:precision binary64
(if (<= y -3.4e+119)
2.0
(if (<= y 2.3e-184)
(+ (* -4.0 (/ z y)) 1.0)
(if (<= y 1.35e+91) (+ 1.0 (/ (* x 4.0) y)) 2.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.4e+119) {
tmp = 2.0;
} else if (y <= 2.3e-184) {
tmp = (-4.0 * (z / y)) + 1.0;
} else if (y <= 1.35e+91) {
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 (y <= (-3.4d+119)) then
tmp = 2.0d0
else if (y <= 2.3d-184) then
tmp = ((-4.0d0) * (z / y)) + 1.0d0
else if (y <= 1.35d+91) 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 (y <= -3.4e+119) {
tmp = 2.0;
} else if (y <= 2.3e-184) {
tmp = (-4.0 * (z / y)) + 1.0;
} else if (y <= 1.35e+91) {
tmp = 1.0 + ((x * 4.0) / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.4e+119: tmp = 2.0 elif y <= 2.3e-184: tmp = (-4.0 * (z / y)) + 1.0 elif y <= 1.35e+91: tmp = 1.0 + ((x * 4.0) / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.4e+119) tmp = 2.0; elseif (y <= 2.3e-184) tmp = Float64(Float64(-4.0 * Float64(z / y)) + 1.0); elseif (y <= 1.35e+91) tmp = Float64(1.0 + Float64(Float64(x * 4.0) / y)); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.4e+119) tmp = 2.0; elseif (y <= 2.3e-184) tmp = (-4.0 * (z / y)) + 1.0; elseif (y <= 1.35e+91) tmp = 1.0 + ((x * 4.0) / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.4e+119], 2.0, If[LessEqual[y, 2.3e-184], N[(N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[y, 1.35e+91], N[(1.0 + N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 2.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+119}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-184}:\\
\;\;\;\;-4 \cdot \frac{z}{y} + 1\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+91}:\\
\;\;\;\;1 + \frac{x \cdot 4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -3.40000000000000013e119 or 1.35e91 < y Initial program 100.0%
Taylor expanded in y around inf 78.9%
if -3.40000000000000013e119 < y < 2.2999999999999999e-184Initial program 100.0%
Taylor expanded in z around inf 53.5%
*-commutative53.5%
Simplified53.5%
if 2.2999999999999999e-184 < y < 1.35e91Initial program 100.0%
Taylor expanded in x around inf 59.3%
*-commutative59.3%
associate-*l/59.3%
Simplified59.3%
Final simplification63.7%
(FPCore (x y z)
:precision binary64
(if (<= y -8e+124)
2.0
(if (<= y 1.9e-187)
(+ (* -4.0 (/ z y)) 1.0)
(if (<= y 1.45e+91) (+ 1.0 (* x (/ 4.0 y))) 2.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -8e+124) {
tmp = 2.0;
} else if (y <= 1.9e-187) {
tmp = (-4.0 * (z / y)) + 1.0;
} else if (y <= 1.45e+91) {
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 (y <= (-8d+124)) then
tmp = 2.0d0
else if (y <= 1.9d-187) then
tmp = ((-4.0d0) * (z / y)) + 1.0d0
else if (y <= 1.45d+91) 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 (y <= -8e+124) {
tmp = 2.0;
} else if (y <= 1.9e-187) {
tmp = (-4.0 * (z / y)) + 1.0;
} else if (y <= 1.45e+91) {
tmp = 1.0 + (x * (4.0 / y));
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8e+124: tmp = 2.0 elif y <= 1.9e-187: tmp = (-4.0 * (z / y)) + 1.0 elif y <= 1.45e+91: tmp = 1.0 + (x * (4.0 / y)) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8e+124) tmp = 2.0; elseif (y <= 1.9e-187) tmp = Float64(Float64(-4.0 * Float64(z / y)) + 1.0); elseif (y <= 1.45e+91) 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 (y <= -8e+124) tmp = 2.0; elseif (y <= 1.9e-187) tmp = (-4.0 * (z / y)) + 1.0; elseif (y <= 1.45e+91) tmp = 1.0 + (x * (4.0 / y)); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8e+124], 2.0, If[LessEqual[y, 1.9e-187], N[(N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], If[LessEqual[y, 1.45e+91], N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8 \cdot 10^{+124}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-187}:\\
\;\;\;\;-4 \cdot \frac{z}{y} + 1\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{+91}:\\
\;\;\;\;1 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -7.99999999999999959e124 or 1.45000000000000007e91 < y Initial program 100.0%
Taylor expanded in y around inf 78.9%
if -7.99999999999999959e124 < y < 1.90000000000000013e-187Initial program 100.0%
Taylor expanded in z around inf 53.5%
*-commutative53.5%
Simplified53.5%
if 1.90000000000000013e-187 < y < 1.45000000000000007e91Initial program 100.0%
Taylor expanded in x around inf 59.3%
associate-*r/59.3%
associate-*l/59.1%
*-commutative59.1%
Simplified59.1%
Final simplification63.7%
(FPCore (x y z)
:precision binary64
(if (<= y -1.2e+118)
2.0
(if (<= y 2e-190)
(+ 1.0 (* z (/ -4.0 y)))
(if (<= y 4.5e+91) (+ 1.0 (* x (/ 4.0 y))) 2.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.2e+118) {
tmp = 2.0;
} else if (y <= 2e-190) {
tmp = 1.0 + (z * (-4.0 / y));
} else if (y <= 4.5e+91) {
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 (y <= (-1.2d+118)) then
tmp = 2.0d0
else if (y <= 2d-190) then
tmp = 1.0d0 + (z * ((-4.0d0) / y))
else if (y <= 4.5d+91) 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 (y <= -1.2e+118) {
tmp = 2.0;
} else if (y <= 2e-190) {
tmp = 1.0 + (z * (-4.0 / y));
} else if (y <= 4.5e+91) {
tmp = 1.0 + (x * (4.0 / y));
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.2e+118: tmp = 2.0 elif y <= 2e-190: tmp = 1.0 + (z * (-4.0 / y)) elif y <= 4.5e+91: tmp = 1.0 + (x * (4.0 / y)) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.2e+118) tmp = 2.0; elseif (y <= 2e-190) tmp = Float64(1.0 + Float64(z * Float64(-4.0 / y))); elseif (y <= 4.5e+91) 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 (y <= -1.2e+118) tmp = 2.0; elseif (y <= 2e-190) tmp = 1.0 + (z * (-4.0 / y)); elseif (y <= 4.5e+91) tmp = 1.0 + (x * (4.0 / y)); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.2e+118], 2.0, If[LessEqual[y, 2e-190], N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.5e+91], N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.2 \cdot 10^{+118}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-190}:\\
\;\;\;\;1 + z \cdot \frac{-4}{y}\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{+91}:\\
\;\;\;\;1 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -1.2e118 or 4.5e91 < y Initial program 100.0%
Taylor expanded in y around inf 78.9%
if -1.2e118 < y < 2e-190Initial program 100.0%
Taylor expanded in z around inf 53.5%
associate-*r/53.5%
metadata-eval53.5%
associate-*r*53.5%
neg-mul-153.5%
*-commutative53.5%
associate-*r/53.4%
distribute-lft-neg-out53.4%
distribute-rgt-neg-in53.4%
distribute-neg-frac53.4%
metadata-eval53.4%
Simplified53.4%
if 2e-190 < y < 4.5e91Initial program 100.0%
Taylor expanded in x around inf 59.3%
associate-*r/59.3%
associate-*l/59.1%
*-commutative59.1%
Simplified59.1%
(FPCore (x y z)
:precision binary64
(if (<= y -6.9e+74)
2.0
(if (<= y 9.5e-190)
(* -4.0 (/ z y))
(if (<= y 1.5e+91) (+ 1.0 (* x (/ 4.0 y))) 2.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.9e+74) {
tmp = 2.0;
} else if (y <= 9.5e-190) {
tmp = -4.0 * (z / y);
} else if (y <= 1.5e+91) {
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 (y <= (-6.9d+74)) then
tmp = 2.0d0
else if (y <= 9.5d-190) then
tmp = (-4.0d0) * (z / y)
else if (y <= 1.5d+91) 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 (y <= -6.9e+74) {
tmp = 2.0;
} else if (y <= 9.5e-190) {
tmp = -4.0 * (z / y);
} else if (y <= 1.5e+91) {
tmp = 1.0 + (x * (4.0 / y));
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.9e+74: tmp = 2.0 elif y <= 9.5e-190: tmp = -4.0 * (z / y) elif y <= 1.5e+91: tmp = 1.0 + (x * (4.0 / y)) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.9e+74) tmp = 2.0; elseif (y <= 9.5e-190) tmp = Float64(-4.0 * Float64(z / y)); elseif (y <= 1.5e+91) 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 (y <= -6.9e+74) tmp = 2.0; elseif (y <= 9.5e-190) tmp = -4.0 * (z / y); elseif (y <= 1.5e+91) tmp = 1.0 + (x * (4.0 / y)); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.9e+74], 2.0, If[LessEqual[y, 9.5e-190], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.5e+91], N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.9 \cdot 10^{+74}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 9.5 \cdot 10^{-190}:\\
\;\;\;\;-4 \cdot \frac{z}{y}\\
\mathbf{elif}\;y \leq 1.5 \cdot 10^{+91}:\\
\;\;\;\;1 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -6.8999999999999996e74 or 1.50000000000000003e91 < y Initial program 100.0%
Taylor expanded in y around inf 75.7%
if -6.8999999999999996e74 < y < 9.50000000000000055e-190Initial program 100.0%
Taylor expanded in z around -inf 86.2%
mul-1-neg86.2%
*-commutative86.2%
distribute-rgt-neg-in86.2%
Simplified86.2%
Taylor expanded in z around inf 52.9%
if 9.50000000000000055e-190 < y < 1.50000000000000003e91Initial program 100.0%
Taylor expanded in x around inf 59.3%
associate-*r/59.3%
associate-*l/59.1%
*-commutative59.1%
Simplified59.1%
(FPCore (x y z)
:precision binary64
(if (<= y -1.12e+78)
2.0
(if (<= y 5.6e-184)
(* -4.0 (/ z y))
(if (<= y 8.6e+91) (* 4.0 (/ x y)) 2.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.12e+78) {
tmp = 2.0;
} else if (y <= 5.6e-184) {
tmp = -4.0 * (z / y);
} else if (y <= 8.6e+91) {
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 <= (-1.12d+78)) then
tmp = 2.0d0
else if (y <= 5.6d-184) then
tmp = (-4.0d0) * (z / y)
else if (y <= 8.6d+91) 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 <= -1.12e+78) {
tmp = 2.0;
} else if (y <= 5.6e-184) {
tmp = -4.0 * (z / y);
} else if (y <= 8.6e+91) {
tmp = 4.0 * (x / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.12e+78: tmp = 2.0 elif y <= 5.6e-184: tmp = -4.0 * (z / y) elif y <= 8.6e+91: tmp = 4.0 * (x / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.12e+78) tmp = 2.0; elseif (y <= 5.6e-184) tmp = Float64(-4.0 * Float64(z / y)); elseif (y <= 8.6e+91) 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 <= -1.12e+78) tmp = 2.0; elseif (y <= 5.6e-184) tmp = -4.0 * (z / y); elseif (y <= 8.6e+91) tmp = 4.0 * (x / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.12e+78], 2.0, If[LessEqual[y, 5.6e-184], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.6e+91], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 2.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.12 \cdot 10^{+78}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{-184}:\\
\;\;\;\;-4 \cdot \frac{z}{y}\\
\mathbf{elif}\;y \leq 8.6 \cdot 10^{+91}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -1.12e78 or 8.6000000000000001e91 < y Initial program 100.0%
Taylor expanded in y around inf 75.7%
if -1.12e78 < y < 5.5999999999999997e-184Initial program 100.0%
Taylor expanded in z around -inf 86.2%
mul-1-neg86.2%
*-commutative86.2%
distribute-rgt-neg-in86.2%
Simplified86.2%
Taylor expanded in z around inf 52.9%
if 5.5999999999999997e-184 < y < 8.6000000000000001e91Initial program 100.0%
Taylor expanded in z around -inf 88.9%
mul-1-neg88.9%
*-commutative88.9%
distribute-rgt-neg-in88.9%
Simplified88.8%
Taylor expanded in x around inf 57.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -7.5e+46) (not (<= x 1.75e-106))) (+ 2.0 (* 4.0 (/ x y))) (+ 2.0 (* -4.0 (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -7.5e+46) || !(x <= 1.75e-106)) {
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 <= (-7.5d+46)) .or. (.not. (x <= 1.75d-106))) 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 <= -7.5e+46) || !(x <= 1.75e-106)) {
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 <= -7.5e+46) or not (x <= 1.75e-106): 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 <= -7.5e+46) || !(x <= 1.75e-106)) 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 <= -7.5e+46) || ~((x <= 1.75e-106))) 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, -7.5e+46], N[Not[LessEqual[x, 1.75e-106]], $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 -7.5 \cdot 10^{+46} \lor \neg \left(x \leq 1.75 \cdot 10^{-106}\right):\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < -7.5000000000000003e46 or 1.75e-106 < x Initial 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 84.2%
if -7.5000000000000003e46 < x < 1.75e-106Initial program 100.0%
+-commutative100.0%
associate-*l/99.0%
+-commutative99.0%
associate--l+99.0%
+-commutative99.0%
distribute-lft-in99.0%
associate-+l+99.0%
associate-*l/99.0%
*-commutative99.0%
associate-*l*99.0%
metadata-eval99.0%
*-rgt-identity99.0%
*-inverses99.0%
metadata-eval99.0%
Simplified99.0%
clear-num99.0%
div-inv99.0%
metadata-eval99.0%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 94.5%
Final simplification89.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.45e+100) (not (<= x 1.26e+61))) (+ 1.0 (/ (* x 4.0) y)) (+ 2.0 (* -4.0 (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.45e+100) || !(x <= 1.26e+61)) {
tmp = 1.0 + ((x * 4.0) / 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 <= (-1.45d+100)) .or. (.not. (x <= 1.26d+61))) then
tmp = 1.0d0 + ((x * 4.0d0) / 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 <= -1.45e+100) || !(x <= 1.26e+61)) {
tmp = 1.0 + ((x * 4.0) / y);
} else {
tmp = 2.0 + (-4.0 * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.45e+100) or not (x <= 1.26e+61): tmp = 1.0 + ((x * 4.0) / y) else: tmp = 2.0 + (-4.0 * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.45e+100) || !(x <= 1.26e+61)) tmp = Float64(1.0 + Float64(Float64(x * 4.0) / 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 <= -1.45e+100) || ~((x <= 1.26e+61))) tmp = 1.0 + ((x * 4.0) / y); else tmp = 2.0 + (-4.0 * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.45e+100], N[Not[LessEqual[x, 1.26e+61]], $MachinePrecision]], N[(1.0 + N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.45 \cdot 10^{+100} \lor \neg \left(x \leq 1.26 \cdot 10^{+61}\right):\\
\;\;\;\;1 + \frac{x \cdot 4}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if x < -1.45e100 or 1.2600000000000001e61 < x Initial program 100.0%
Taylor expanded in x around inf 77.7%
*-commutative77.7%
associate-*l/77.7%
Simplified77.7%
if -1.45e100 < x < 1.2600000000000001e61Initial program 100.0%
+-commutative100.0%
associate-*l/99.2%
+-commutative99.2%
associate--l+99.2%
+-commutative99.2%
distribute-lft-in99.2%
associate-+l+99.2%
associate-*l/99.2%
*-commutative99.2%
associate-*l*99.2%
metadata-eval99.2%
*-rgt-identity99.2%
*-inverses99.2%
metadata-eval99.2%
Simplified99.2%
clear-num99.2%
div-inv99.2%
metadata-eval99.2%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 86.6%
Final simplification83.8%
(FPCore (x y z) :precision binary64 (if (<= y -4e+75) 2.0 (if (<= y 1550000000000.0) (* -4.0 (/ z y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -4e+75) {
tmp = 2.0;
} else if (y <= 1550000000000.0) {
tmp = -4.0 * (z / 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 <= (-4d+75)) then
tmp = 2.0d0
else if (y <= 1550000000000.0d0) then
tmp = (-4.0d0) * (z / 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 <= -4e+75) {
tmp = 2.0;
} else if (y <= 1550000000000.0) {
tmp = -4.0 * (z / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4e+75: tmp = 2.0 elif y <= 1550000000000.0: tmp = -4.0 * (z / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4e+75) tmp = 2.0; elseif (y <= 1550000000000.0) tmp = Float64(-4.0 * Float64(z / y)); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4e+75) tmp = 2.0; elseif (y <= 1550000000000.0) tmp = -4.0 * (z / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4e+75], 2.0, If[LessEqual[y, 1550000000000.0], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{+75}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 1550000000000:\\
\;\;\;\;-4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -3.99999999999999971e75 or 1.55e12 < y Initial program 100.0%
Taylor expanded in y around inf 70.4%
if -3.99999999999999971e75 < y < 1.55e12Initial program 100.0%
Taylor expanded in z around -inf 87.1%
mul-1-neg87.1%
*-commutative87.1%
distribute-rgt-neg-in87.1%
Simplified87.0%
Taylor expanded in z around inf 49.1%
(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 100.0%
+-commutative100.0%
associate-*l/99.4%
+-commutative99.4%
associate--l+99.4%
+-commutative99.4%
distribute-lft-in99.4%
associate-+l+99.4%
associate-*l/99.4%
*-commutative99.4%
associate-*l*99.4%
metadata-eval99.4%
*-rgt-identity99.4%
*-inverses99.4%
metadata-eval99.4%
Simplified99.4%
Final simplification99.4%
(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 36.8%
(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%
Taylor expanded in z around inf 39.4%
associate-*r/39.4%
metadata-eval39.4%
associate-*r*39.4%
neg-mul-139.4%
*-commutative39.4%
associate-*r/39.3%
distribute-lft-neg-out39.3%
distribute-rgt-neg-in39.3%
distribute-neg-frac39.3%
metadata-eval39.3%
Simplified39.3%
Taylor expanded in z around 0 8.6%
herbie shell --seed 2024106
(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)))