
(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 -1.6e+66)
t_0
(if (<= x 1.02e-103) (* (/ z y) -4.0) (if (<= x 1.65e+105) 2.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = (4.0 * x) / y;
double tmp;
if (x <= -1.6e+66) {
tmp = t_0;
} else if (x <= 1.02e-103) {
tmp = (z / y) * -4.0;
} else if (x <= 1.65e+105) {
tmp = 2.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 <= (-1.6d+66)) then
tmp = t_0
else if (x <= 1.02d-103) then
tmp = (z / y) * (-4.0d0)
else if (x <= 1.65d+105) then
tmp = 2.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 <= -1.6e+66) {
tmp = t_0;
} else if (x <= 1.02e-103) {
tmp = (z / y) * -4.0;
} else if (x <= 1.65e+105) {
tmp = 2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (4.0 * x) / y tmp = 0 if x <= -1.6e+66: tmp = t_0 elif x <= 1.02e-103: tmp = (z / y) * -4.0 elif x <= 1.65e+105: tmp = 2.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 <= -1.6e+66) tmp = t_0; elseif (x <= 1.02e-103) tmp = Float64(Float64(z / y) * -4.0); elseif (x <= 1.65e+105) tmp = 2.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 <= -1.6e+66) tmp = t_0; elseif (x <= 1.02e-103) tmp = (z / y) * -4.0; elseif (x <= 1.65e+105) tmp = 2.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, -1.6e+66], t$95$0, If[LessEqual[x, 1.02e-103], N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision], If[LessEqual[x, 1.65e+105], 2.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{4 \cdot x}{y}\\
\mathbf{if}\;x \leq -1.6 \cdot 10^{+66}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.02 \cdot 10^{-103}:\\
\;\;\;\;\frac{z}{y} \cdot -4\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{+105}:\\
\;\;\;\;2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.6e66 or 1.64999999999999999e105 < x Initial program 100.0%
Taylor expanded in x around inf 72.9%
associate-*r/72.9%
Simplified72.9%
if -1.6e66 < x < 1.01999999999999998e-103Initial program 100.0%
Taylor expanded in z around inf 51.1%
*-commutative51.1%
Simplified51.1%
if 1.01999999999999998e-103 < x < 1.64999999999999999e105Initial program 100.0%
Taylor expanded in y around inf 66.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ 4.0 y))))
(if (<= x -2e+64)
t_0
(if (<= x 1.36e-102) (* (/ z y) -4.0) (if (<= x 3.35e+105) 2.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = x * (4.0 / y);
double tmp;
if (x <= -2e+64) {
tmp = t_0;
} else if (x <= 1.36e-102) {
tmp = (z / y) * -4.0;
} else if (x <= 3.35e+105) {
tmp = 2.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 <= (-2d+64)) then
tmp = t_0
else if (x <= 1.36d-102) then
tmp = (z / y) * (-4.0d0)
else if (x <= 3.35d+105) then
tmp = 2.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 <= -2e+64) {
tmp = t_0;
} else if (x <= 1.36e-102) {
tmp = (z / y) * -4.0;
} else if (x <= 3.35e+105) {
tmp = 2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (4.0 / y) tmp = 0 if x <= -2e+64: tmp = t_0 elif x <= 1.36e-102: tmp = (z / y) * -4.0 elif x <= 3.35e+105: tmp = 2.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 <= -2e+64) tmp = t_0; elseif (x <= 1.36e-102) tmp = Float64(Float64(z / y) * -4.0); elseif (x <= 3.35e+105) tmp = 2.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 <= -2e+64) tmp = t_0; elseif (x <= 1.36e-102) tmp = (z / y) * -4.0; elseif (x <= 3.35e+105) tmp = 2.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, -2e+64], t$95$0, If[LessEqual[x, 1.36e-102], N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision], If[LessEqual[x, 3.35e+105], 2.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -2 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.36 \cdot 10^{-102}:\\
\;\;\;\;\frac{z}{y} \cdot -4\\
\mathbf{elif}\;x \leq 3.35 \cdot 10^{+105}:\\
\;\;\;\;2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -2.00000000000000004e64 or 3.3500000000000002e105 < x Initial program 100.0%
Taylor expanded in x around inf 72.9%
associate-*r/72.9%
associate-*l/72.7%
*-commutative72.7%
Simplified72.7%
if -2.00000000000000004e64 < x < 1.36000000000000001e-102Initial program 100.0%
Taylor expanded in z around inf 51.1%
*-commutative51.1%
Simplified51.1%
if 1.36000000000000001e-102 < x < 3.3500000000000002e105Initial program 100.0%
Taylor expanded in y around inf 66.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ 4.0 y))))
(if (<= x -1.75e+65)
t_0
(if (<= x 8e-102) (* z (/ -4.0 y)) (if (<= x 1.45e+105) 2.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = x * (4.0 / y);
double tmp;
if (x <= -1.75e+65) {
tmp = t_0;
} else if (x <= 8e-102) {
tmp = z * (-4.0 / y);
} else if (x <= 1.45e+105) {
tmp = 2.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.75d+65)) then
tmp = t_0
else if (x <= 8d-102) then
tmp = z * ((-4.0d0) / y)
else if (x <= 1.45d+105) then
tmp = 2.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.75e+65) {
tmp = t_0;
} else if (x <= 8e-102) {
tmp = z * (-4.0 / y);
} else if (x <= 1.45e+105) {
tmp = 2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (4.0 / y) tmp = 0 if x <= -1.75e+65: tmp = t_0 elif x <= 8e-102: tmp = z * (-4.0 / y) elif x <= 1.45e+105: tmp = 2.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.75e+65) tmp = t_0; elseif (x <= 8e-102) tmp = Float64(z * Float64(-4.0 / y)); elseif (x <= 1.45e+105) tmp = 2.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.75e+65) tmp = t_0; elseif (x <= 8e-102) tmp = z * (-4.0 / y); elseif (x <= 1.45e+105) tmp = 2.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.75e+65], t$95$0, If[LessEqual[x, 8e-102], N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.45e+105], 2.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -1.75 \cdot 10^{+65}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-102}:\\
\;\;\;\;z \cdot \frac{-4}{y}\\
\mathbf{elif}\;x \leq 1.45 \cdot 10^{+105}:\\
\;\;\;\;2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.75e65 or 1.45000000000000005e105 < x Initial program 100.0%
Taylor expanded in x around inf 72.9%
associate-*r/72.9%
associate-*l/72.7%
*-commutative72.7%
Simplified72.7%
if -1.75e65 < x < 7.99999999999999946e-102Initial program 100.0%
Taylor expanded in z around inf 51.1%
associate-*r/51.1%
*-commutative51.1%
associate-/l*50.9%
Simplified50.9%
if 7.99999999999999946e-102 < x < 1.45000000000000005e105Initial program 100.0%
Taylor expanded in y around inf 66.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -6.2e+21) (not (<= x 1.11e+105))) (* 4.0 (/ (- x z) y)) (+ 2.0 (* (/ z y) -4.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -6.2e+21) || !(x <= 1.11e+105)) {
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 <= (-6.2d+21)) .or. (.not. (x <= 1.11d+105))) 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 <= -6.2e+21) || !(x <= 1.11e+105)) {
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 <= -6.2e+21) or not (x <= 1.11e+105): 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 <= -6.2e+21) || !(x <= 1.11e+105)) 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 <= -6.2e+21) || ~((x <= 1.11e+105))) 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, -6.2e+21], N[Not[LessEqual[x, 1.11e+105]], $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 -6.2 \cdot 10^{+21} \lor \neg \left(x \leq 1.11 \cdot 10^{+105}\right):\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\end{array}
\end{array}
if x < -6.2e21 or 1.11e105 < x Initial program 100.0%
Taylor expanded in y around 0 84.3%
if -6.2e21 < x < 1.11e105Initial 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-*r*99.8%
metadata-eval99.8%
*-lft-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 90.4%
*-commutative90.4%
Simplified90.4%
Final simplification87.7%
(FPCore (x y z) :precision binary64 (if (<= x -9e+20) (* 4.0 (/ (- x z) y)) (if (<= x 6.2e+37) (+ 2.0 (* (/ z y) -4.0)) (+ 2.0 (* x (/ 4.0 y))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -9e+20) {
tmp = 4.0 * ((x - z) / y);
} else if (x <= 6.2e+37) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = 2.0 + (x * (4.0 / 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+20)) then
tmp = 4.0d0 * ((x - z) / y)
else if (x <= 6.2d+37) then
tmp = 2.0d0 + ((z / y) * (-4.0d0))
else
tmp = 2.0d0 + (x * (4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -9e+20) {
tmp = 4.0 * ((x - z) / y);
} else if (x <= 6.2e+37) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = 2.0 + (x * (4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -9e+20: tmp = 4.0 * ((x - z) / y) elif x <= 6.2e+37: tmp = 2.0 + ((z / y) * -4.0) else: tmp = 2.0 + (x * (4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -9e+20) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); elseif (x <= 6.2e+37) tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); else tmp = Float64(2.0 + Float64(x * Float64(4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -9e+20) tmp = 4.0 * ((x - z) / y); elseif (x <= 6.2e+37) tmp = 2.0 + ((z / y) * -4.0); else tmp = 2.0 + (x * (4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -9e+20], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6.2e+37], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9 \cdot 10^{+20}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{+37}:\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;2 + x \cdot \frac{4}{y}\\
\end{array}
\end{array}
if x < -9e20Initial program 100.0%
Taylor expanded in y around 0 83.3%
if -9e20 < x < 6.2000000000000004e37Initial 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-*r*99.8%
metadata-eval99.8%
*-lft-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 92.3%
*-commutative92.3%
Simplified92.3%
if 6.2000000000000004e37 < 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-*r*99.8%
metadata-eval99.8%
*-lft-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf 93.1%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (<= y -3.1e+144) 2.0 (if (<= y 1.3e+99) (* 4.0 (/ (- x z) y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.1e+144) {
tmp = 2.0;
} else if (y <= 1.3e+99) {
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 <= (-3.1d+144)) then
tmp = 2.0d0
else if (y <= 1.3d+99) 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 <= -3.1e+144) {
tmp = 2.0;
} else if (y <= 1.3e+99) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.1e+144: tmp = 2.0 elif y <= 1.3e+99: tmp = 4.0 * ((x - z) / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.1e+144) tmp = 2.0; elseif (y <= 1.3e+99) 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 <= -3.1e+144) tmp = 2.0; elseif (y <= 1.3e+99) tmp = 4.0 * ((x - z) / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.1e+144], 2.0, If[LessEqual[y, 1.3e+99], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{+144}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 1.3 \cdot 10^{+99}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -3.1000000000000002e144 or 1.3e99 < y Initial program 100.0%
Taylor expanded in y around inf 75.9%
if -3.1000000000000002e144 < y < 1.3e99Initial program 100.0%
Taylor expanded in y around 0 85.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.7e+26) (not (<= x 1.12e+105))) (* x (/ 4.0 y)) 2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.7e+26) || !(x <= 1.12e+105)) {
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 <= (-2.7d+26)) .or. (.not. (x <= 1.12d+105))) 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 <= -2.7e+26) || !(x <= 1.12e+105)) {
tmp = x * (4.0 / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.7e+26) or not (x <= 1.12e+105): tmp = x * (4.0 / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.7e+26) || !(x <= 1.12e+105)) 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 <= -2.7e+26) || ~((x <= 1.12e+105))) tmp = x * (4.0 / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.7e+26], N[Not[LessEqual[x, 1.12e+105]], $MachinePrecision]], N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{+26} \lor \neg \left(x \leq 1.12 \cdot 10^{+105}\right):\\
\;\;\;\;x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if x < -2.7e26 or 1.12e105 < x Initial program 100.0%
Taylor expanded in x around inf 69.5%
associate-*r/69.5%
associate-*l/69.3%
*-commutative69.3%
Simplified69.3%
if -2.7e26 < x < 1.12e105Initial program 100.0%
Taylor expanded in y around inf 48.4%
Final simplification57.4%
(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.7%
+-commutative99.7%
associate--l+99.7%
+-commutative99.7%
distribute-lft-in99.7%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*r*99.8%
metadata-eval99.8%
*-lft-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 34.8%
herbie shell --seed 2024165
(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)))