
(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 10 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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* 4.0 x) y)))
(if (<= x -31000000000000.0)
t_0
(if (<= x 3.7e-82) 2.0 (if (<= x 5.6e+38) (* (/ z y) -4.0) t_0)))))
double code(double x, double y, double z) {
double t_0 = (4.0 * x) / y;
double tmp;
if (x <= -31000000000000.0) {
tmp = t_0;
} else if (x <= 3.7e-82) {
tmp = 2.0;
} else if (x <= 5.6e+38) {
tmp = (z / y) * -4.0;
} else {
tmp = t_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) :: tmp
t_0 = (4.0d0 * x) / y
if (x <= (-31000000000000.0d0)) then
tmp = t_0
else if (x <= 3.7d-82) then
tmp = 2.0d0
else if (x <= 5.6d+38) then
tmp = (z / y) * (-4.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (4.0 * x) / y;
double tmp;
if (x <= -31000000000000.0) {
tmp = t_0;
} else if (x <= 3.7e-82) {
tmp = 2.0;
} else if (x <= 5.6e+38) {
tmp = (z / y) * -4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (4.0 * x) / y tmp = 0 if x <= -31000000000000.0: tmp = t_0 elif x <= 3.7e-82: tmp = 2.0 elif x <= 5.6e+38: tmp = (z / y) * -4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(4.0 * x) / y) tmp = 0.0 if (x <= -31000000000000.0) tmp = t_0; elseif (x <= 3.7e-82) tmp = 2.0; elseif (x <= 5.6e+38) tmp = Float64(Float64(z / y) * -4.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (4.0 * x) / y; tmp = 0.0; if (x <= -31000000000000.0) tmp = t_0; elseif (x <= 3.7e-82) tmp = 2.0; elseif (x <= 5.6e+38) tmp = (z / y) * -4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x, -31000000000000.0], t$95$0, If[LessEqual[x, 3.7e-82], 2.0, If[LessEqual[x, 5.6e+38], N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{4 \cdot x}{y}\\
\mathbf{if}\;x \leq -31000000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.7 \cdot 10^{-82}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 5.6 \cdot 10^{+38}:\\
\;\;\;\;\frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.1e13 or 5.6e38 < x Initial program 100.0%
Taylor expanded in x around inf 65.7%
associate-*r/65.7%
Simplified65.7%
if -3.1e13 < x < 3.7000000000000001e-82Initial program 100.0%
Taylor expanded in y around inf 56.4%
if 3.7000000000000001e-82 < x < 5.6e38Initial program 99.9%
Taylor expanded in z around inf 60.4%
*-commutative60.4%
Simplified60.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ 4.0 y))))
(if (<= x -1.02e+14)
t_0
(if (<= x 3.8e-81) 2.0 (if (<= x 5.6e+38) (* (/ z y) -4.0) t_0)))))
double code(double x, double y, double z) {
double t_0 = x * (4.0 / y);
double tmp;
if (x <= -1.02e+14) {
tmp = t_0;
} else if (x <= 3.8e-81) {
tmp = 2.0;
} else if (x <= 5.6e+38) {
tmp = (z / y) * -4.0;
} else {
tmp = t_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) :: tmp
t_0 = x * (4.0d0 / y)
if (x <= (-1.02d+14)) then
tmp = t_0
else if (x <= 3.8d-81) then
tmp = 2.0d0
else if (x <= 5.6d+38) then
tmp = (z / y) * (-4.0d0)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (4.0 / y);
double tmp;
if (x <= -1.02e+14) {
tmp = t_0;
} else if (x <= 3.8e-81) {
tmp = 2.0;
} else if (x <= 5.6e+38) {
tmp = (z / y) * -4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (4.0 / y) tmp = 0 if x <= -1.02e+14: tmp = t_0 elif x <= 3.8e-81: tmp = 2.0 elif x <= 5.6e+38: tmp = (z / y) * -4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(4.0 / y)) tmp = 0.0 if (x <= -1.02e+14) tmp = t_0; elseif (x <= 3.8e-81) tmp = 2.0; elseif (x <= 5.6e+38) tmp = Float64(Float64(z / y) * -4.0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (4.0 / y); tmp = 0.0; if (x <= -1.02e+14) tmp = t_0; elseif (x <= 3.8e-81) tmp = 2.0; elseif (x <= 5.6e+38) tmp = (z / y) * -4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.02e+14], t$95$0, If[LessEqual[x, 3.8e-81], 2.0, If[LessEqual[x, 5.6e+38], N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -1.02 \cdot 10^{+14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-81}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 5.6 \cdot 10^{+38}:\\
\;\;\;\;\frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.02e14 or 5.6e38 < x Initial program 100.0%
Taylor expanded in y around 0 83.4%
div-sub79.9%
Applied egg-rr79.9%
Taylor expanded in x around inf 65.7%
associate-*r/65.7%
*-commutative65.7%
associate-*r/65.6%
Simplified65.6%
if -1.02e14 < x < 3.7999999999999999e-81Initial program 100.0%
Taylor expanded in y around inf 56.4%
if 3.7999999999999999e-81 < x < 5.6e38Initial program 99.9%
Taylor expanded in z around inf 60.4%
*-commutative60.4%
Simplified60.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ 4.0 y))))
(if (<= x -41000000000000.0)
t_0
(if (<= x 3e-82) 2.0 (if (<= x 1e+34) (* z (/ -4.0 y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = x * (4.0 / y);
double tmp;
if (x <= -41000000000000.0) {
tmp = t_0;
} else if (x <= 3e-82) {
tmp = 2.0;
} else if (x <= 1e+34) {
tmp = z * (-4.0 / y);
} else {
tmp = t_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) :: tmp
t_0 = x * (4.0d0 / y)
if (x <= (-41000000000000.0d0)) then
tmp = t_0
else if (x <= 3d-82) then
tmp = 2.0d0
else if (x <= 1d+34) then
tmp = z * ((-4.0d0) / y)
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (4.0 / y);
double tmp;
if (x <= -41000000000000.0) {
tmp = t_0;
} else if (x <= 3e-82) {
tmp = 2.0;
} else if (x <= 1e+34) {
tmp = z * (-4.0 / y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (4.0 / y) tmp = 0 if x <= -41000000000000.0: tmp = t_0 elif x <= 3e-82: tmp = 2.0 elif x <= 1e+34: tmp = z * (-4.0 / y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(4.0 / y)) tmp = 0.0 if (x <= -41000000000000.0) tmp = t_0; elseif (x <= 3e-82) tmp = 2.0; elseif (x <= 1e+34) tmp = Float64(z * Float64(-4.0 / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (4.0 / y); tmp = 0.0; if (x <= -41000000000000.0) tmp = t_0; elseif (x <= 3e-82) tmp = 2.0; elseif (x <= 1e+34) tmp = z * (-4.0 / y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -41000000000000.0], t$95$0, If[LessEqual[x, 3e-82], 2.0, If[LessEqual[x, 1e+34], N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -41000000000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 3 \cdot 10^{-82}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 10^{+34}:\\
\;\;\;\;z \cdot \frac{-4}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.1e13 or 9.99999999999999946e33 < x Initial program 100.0%
Taylor expanded in y around 0 83.6%
div-sub80.3%
Applied egg-rr80.3%
Taylor expanded in x around inf 65.5%
associate-*r/65.5%
*-commutative65.5%
associate-*r/65.3%
Simplified65.3%
if -4.1e13 < x < 2.9999999999999999e-82Initial program 100.0%
Taylor expanded in y around inf 56.4%
if 2.9999999999999999e-82 < x < 9.99999999999999946e33Initial program 99.9%
Taylor expanded in z around inf 61.3%
associate-*r/61.3%
*-commutative61.3%
associate-/l*61.2%
Simplified61.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -0.0145) (not (<= x 20000000000000.0))) (* 4.0 (/ (- x z) y)) (+ 2.0 (* (/ z y) -4.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -0.0145) || !(x <= 20000000000000.0)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0 + ((z / y) * -4.0);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-0.0145d0)) .or. (.not. (x <= 20000000000000.0d0))) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = 2.0d0 + ((z / y) * (-4.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -0.0145) || !(x <= 20000000000000.0)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0 + ((z / y) * -4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -0.0145) or not (x <= 20000000000000.0): tmp = 4.0 * ((x - z) / y) else: tmp = 2.0 + ((z / y) * -4.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -0.0145) || !(x <= 20000000000000.0)) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -0.0145) || ~((x <= 20000000000000.0))) tmp = 4.0 * ((x - z) / y); else tmp = 2.0 + ((z / y) * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -0.0145], N[Not[LessEqual[x, 20000000000000.0]], $MachinePrecision]], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0145 \lor \neg \left(x \leq 20000000000000\right):\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\end{array}
\end{array}
if x < -0.0145000000000000007 or 2e13 < x Initial program 100.0%
Taylor expanded in y around 0 83.9%
if -0.0145000000000000007 < x < 2e13Initial 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%
Taylor expanded in x around 0 94.8%
*-commutative94.8%
Simplified94.8%
Final simplification89.4%
(FPCore (x y z) :precision binary64 (if (<= y -2.7e+48) (+ 2.0 (* (/ z y) -4.0)) (if (<= y 60000000000.0) (* 4.0 (/ (- x z) y)) (+ 2.0 (/ (* 4.0 x) y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+48) {
tmp = 2.0 + ((z / y) * -4.0);
} else if (y <= 60000000000.0) {
tmp = 4.0 * ((x - 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 (y <= (-2.7d+48)) then
tmp = 2.0d0 + ((z / y) * (-4.0d0))
else if (y <= 60000000000.0d0) then
tmp = 4.0d0 * ((x - 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 (y <= -2.7e+48) {
tmp = 2.0 + ((z / y) * -4.0);
} else if (y <= 60000000000.0) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0 + ((4.0 * x) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.7e+48: tmp = 2.0 + ((z / y) * -4.0) elif y <= 60000000000.0: tmp = 4.0 * ((x - z) / y) else: tmp = 2.0 + ((4.0 * x) / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.7e+48) tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); elseif (y <= 60000000000.0) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = Float64(2.0 + Float64(Float64(4.0 * x) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.7e+48) tmp = 2.0 + ((z / y) * -4.0); elseif (y <= 60000000000.0) tmp = 4.0 * ((x - z) / y); else tmp = 2.0 + ((4.0 * x) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.7e+48], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 60000000000.0], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+48}:\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\mathbf{elif}\;y \leq 60000000000:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{4 \cdot x}{y}\\
\end{array}
\end{array}
if y < -2.70000000000000004e48Initial program 99.9%
+-commutative99.9%
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%
Taylor expanded in x around 0 86.7%
*-commutative86.7%
Simplified86.7%
if -2.70000000000000004e48 < y < 6e10Initial program 100.0%
Taylor expanded in y around 0 94.5%
if 6e10 < y Initial program 99.9%
+-commutative99.9%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
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%
Taylor expanded in z around 0 85.2%
+-commutative85.2%
associate-*r/85.2%
Simplified85.2%
Final simplification90.3%
(FPCore (x y z) :precision binary64 (if (<= y -2.5e+53) 2.0 (if (<= y 4.5e+175) (* 4.0 (/ (- x z) y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.5e+53) {
tmp = 2.0;
} else if (y <= 4.5e+175) {
tmp = 4.0 * ((x - 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 <= (-2.5d+53)) then
tmp = 2.0d0
else if (y <= 4.5d+175) then
tmp = 4.0d0 * ((x - 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 <= -2.5e+53) {
tmp = 2.0;
} else if (y <= 4.5e+175) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.5e+53: tmp = 2.0 elif y <= 4.5e+175: tmp = 4.0 * ((x - z) / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.5e+53) tmp = 2.0; elseif (y <= 4.5e+175) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.5e+53) tmp = 2.0; elseif (y <= 4.5e+175) tmp = 4.0 * ((x - z) / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.5e+53], 2.0, If[LessEqual[y, 4.5e+175], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.5 \cdot 10^{+53}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 4.5 \cdot 10^{+175}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -2.5000000000000002e53 or 4.49999999999999989e175 < y Initial program 99.9%
Taylor expanded in y around inf 73.8%
if -2.5000000000000002e53 < y < 4.49999999999999989e175Initial program 100.0%
Taylor expanded in y around 0 84.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -22000000.0) (not (<= x 4.1e+20))) (* x (/ 4.0 y)) 2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -22000000.0) || !(x <= 4.1e+20)) {
tmp = 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 <= (-22000000.0d0)) .or. (.not. (x <= 4.1d+20))) then
tmp = 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 <= -22000000.0) || !(x <= 4.1e+20)) {
tmp = x * (4.0 / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -22000000.0) or not (x <= 4.1e+20): tmp = x * (4.0 / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -22000000.0) || !(x <= 4.1e+20)) tmp = 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 <= -22000000.0) || ~((x <= 4.1e+20))) tmp = x * (4.0 / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -22000000.0], N[Not[LessEqual[x, 4.1e+20]], $MachinePrecision]], N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -22000000 \lor \neg \left(x \leq 4.1 \cdot 10^{+20}\right):\\
\;\;\;\;x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if x < -2.2e7 or 4.1e20 < x Initial program 100.0%
Taylor expanded in y around 0 84.2%
div-sub80.9%
Applied egg-rr80.9%
Taylor expanded in x around inf 63.4%
associate-*r/63.4%
*-commutative63.4%
associate-*r/63.3%
Simplified63.3%
if -2.2e7 < x < 4.1e20Initial program 100.0%
Taylor expanded in y around inf 53.7%
Final simplification58.3%
(FPCore (x y z) :precision binary64 (+ (* (/ 4.0 y) (- x z)) 2.0))
double code(double x, double y, double z) {
return ((4.0 / y) * (x - z)) + 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 = ((4.0d0 / y) * (x - z)) + 2.0d0
end function
public static double code(double x, double y, double z) {
return ((4.0 / y) * (x - z)) + 2.0;
}
def code(x, y, z): return ((4.0 / y) * (x - z)) + 2.0
function code(x, y, z) return Float64(Float64(Float64(4.0 / y) * Float64(x - z)) + 2.0) end
function tmp = code(x, y, z) tmp = ((4.0 / y) * (x - z)) + 2.0; end
code[x_, y_, z_] := N[(N[(N[(4.0 / y), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{4}{y} \cdot \left(x - z\right) + 2
\end{array}
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%
(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 35.3%
herbie shell --seed 2024114
(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)))