
(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 (+ 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 (* (/ z y) -4.0)) (t_1 (* 4.0 (/ x y))))
(if (<= x -4.8e+41)
t_1
(if (<= x -8.7e-106)
2.0
(if (<= x -3e-244)
t_0
(if (<= x 9e-229)
2.0
(if (<= x 1e-189)
t_0
(if (<= x 1.1e-146)
2.0
(if (<= x 3.2e-113)
t_0
(if (<= x 5.2e-95) 2.0 (if (<= x 6.6e+149) t_0 t_1)))))))))))
double code(double x, double y, double z) {
double t_0 = (z / y) * -4.0;
double t_1 = 4.0 * (x / y);
double tmp;
if (x <= -4.8e+41) {
tmp = t_1;
} else if (x <= -8.7e-106) {
tmp = 2.0;
} else if (x <= -3e-244) {
tmp = t_0;
} else if (x <= 9e-229) {
tmp = 2.0;
} else if (x <= 1e-189) {
tmp = t_0;
} else if (x <= 1.1e-146) {
tmp = 2.0;
} else if (x <= 3.2e-113) {
tmp = t_0;
} else if (x <= 5.2e-95) {
tmp = 2.0;
} else if (x <= 6.6e+149) {
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 = (z / y) * (-4.0d0)
t_1 = 4.0d0 * (x / y)
if (x <= (-4.8d+41)) then
tmp = t_1
else if (x <= (-8.7d-106)) then
tmp = 2.0d0
else if (x <= (-3d-244)) then
tmp = t_0
else if (x <= 9d-229) then
tmp = 2.0d0
else if (x <= 1d-189) then
tmp = t_0
else if (x <= 1.1d-146) then
tmp = 2.0d0
else if (x <= 3.2d-113) then
tmp = t_0
else if (x <= 5.2d-95) then
tmp = 2.0d0
else if (x <= 6.6d+149) 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 = (z / y) * -4.0;
double t_1 = 4.0 * (x / y);
double tmp;
if (x <= -4.8e+41) {
tmp = t_1;
} else if (x <= -8.7e-106) {
tmp = 2.0;
} else if (x <= -3e-244) {
tmp = t_0;
} else if (x <= 9e-229) {
tmp = 2.0;
} else if (x <= 1e-189) {
tmp = t_0;
} else if (x <= 1.1e-146) {
tmp = 2.0;
} else if (x <= 3.2e-113) {
tmp = t_0;
} else if (x <= 5.2e-95) {
tmp = 2.0;
} else if (x <= 6.6e+149) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (z / y) * -4.0 t_1 = 4.0 * (x / y) tmp = 0 if x <= -4.8e+41: tmp = t_1 elif x <= -8.7e-106: tmp = 2.0 elif x <= -3e-244: tmp = t_0 elif x <= 9e-229: tmp = 2.0 elif x <= 1e-189: tmp = t_0 elif x <= 1.1e-146: tmp = 2.0 elif x <= 3.2e-113: tmp = t_0 elif x <= 5.2e-95: tmp = 2.0 elif x <= 6.6e+149: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(z / y) * -4.0) t_1 = Float64(4.0 * Float64(x / y)) tmp = 0.0 if (x <= -4.8e+41) tmp = t_1; elseif (x <= -8.7e-106) tmp = 2.0; elseif (x <= -3e-244) tmp = t_0; elseif (x <= 9e-229) tmp = 2.0; elseif (x <= 1e-189) tmp = t_0; elseif (x <= 1.1e-146) tmp = 2.0; elseif (x <= 3.2e-113) tmp = t_0; elseif (x <= 5.2e-95) tmp = 2.0; elseif (x <= 6.6e+149) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z / y) * -4.0; t_1 = 4.0 * (x / y); tmp = 0.0; if (x <= -4.8e+41) tmp = t_1; elseif (x <= -8.7e-106) tmp = 2.0; elseif (x <= -3e-244) tmp = t_0; elseif (x <= 9e-229) tmp = 2.0; elseif (x <= 1e-189) tmp = t_0; elseif (x <= 1.1e-146) tmp = 2.0; elseif (x <= 3.2e-113) tmp = t_0; elseif (x <= 5.2e-95) tmp = 2.0; elseif (x <= 6.6e+149) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.8e+41], t$95$1, If[LessEqual[x, -8.7e-106], 2.0, If[LessEqual[x, -3e-244], t$95$0, If[LessEqual[x, 9e-229], 2.0, If[LessEqual[x, 1e-189], t$95$0, If[LessEqual[x, 1.1e-146], 2.0, If[LessEqual[x, 3.2e-113], t$95$0, If[LessEqual[x, 5.2e-95], 2.0, If[LessEqual[x, 6.6e+149], t$95$0, t$95$1]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z}{y} \cdot -4\\
t_1 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -4.8 \cdot 10^{+41}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -8.7 \cdot 10^{-106}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq -3 \cdot 10^{-244}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 9 \cdot 10^{-229}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 10^{-189}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.1 \cdot 10^{-146}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-113}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.2 \cdot 10^{-95}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 6.6 \cdot 10^{+149}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -4.8000000000000003e41 or 6.6e149 < x Initial program 100.0%
Taylor expanded in x around inf 78.1%
if -4.8000000000000003e41 < x < -8.7000000000000001e-106 or -3.0000000000000001e-244 < x < 9.0000000000000004e-229 or 1.00000000000000007e-189 < x < 1.1e-146 or 3.2000000000000002e-113 < x < 5.20000000000000001e-95Initial program 100.0%
Taylor expanded in y around inf 64.7%
if -8.7000000000000001e-106 < x < -3.0000000000000001e-244 or 9.0000000000000004e-229 < x < 1.00000000000000007e-189 or 1.1e-146 < x < 3.2000000000000002e-113 or 5.20000000000000001e-95 < x < 6.6e149Initial program 100.0%
Taylor expanded in z around inf 61.3%
*-commutative61.3%
Simplified61.3%
Final simplification68.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -4.2e+41) (not (<= x 680000.0))) (* (/ 4.0 y) (- x z)) (+ 2.0 (* (/ z y) -4.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4.2e+41) || !(x <= 680000.0)) {
tmp = (4.0 / y) * (x - z);
} 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 <= (-4.2d+41)) .or. (.not. (x <= 680000.0d0))) then
tmp = (4.0d0 / y) * (x - z)
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 <= -4.2e+41) || !(x <= 680000.0)) {
tmp = (4.0 / y) * (x - z);
} else {
tmp = 2.0 + ((z / y) * -4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4.2e+41) or not (x <= 680000.0): tmp = (4.0 / y) * (x - z) else: tmp = 2.0 + ((z / y) * -4.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4.2e+41) || !(x <= 680000.0)) tmp = Float64(Float64(4.0 / y) * Float64(x - z)); 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 <= -4.2e+41) || ~((x <= 680000.0))) tmp = (4.0 / y) * (x - z); else tmp = 2.0 + ((z / y) * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4.2e+41], N[Not[LessEqual[x, 680000.0]], $MachinePrecision]], N[(N[(4.0 / y), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{+41} \lor \neg \left(x \leq 680000\right):\\
\;\;\;\;\frac{4}{y} \cdot \left(x - z\right)\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\end{array}
\end{array}
if x < -4.1999999999999999e41 or 6.8e5 < x Initial program 100.0%
Taylor expanded in y around 0 85.4%
associate-*r/85.4%
associate-*l/85.2%
Simplified85.2%
if -4.1999999999999999e41 < x < 6.8e5Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.9%
Simplified99.9%
Taylor expanded in x around 0 93.3%
*-commutative93.3%
Simplified93.3%
Final simplification89.4%
(FPCore (x y z) :precision binary64 (if (<= y -1.7e+225) 2.0 (if (<= y 4.6e+112) (* (/ 4.0 y) (- x z)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.7e+225) {
tmp = 2.0;
} else if (y <= 4.6e+112) {
tmp = (4.0 / y) * (x - z);
} 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.7d+225)) then
tmp = 2.0d0
else if (y <= 4.6d+112) then
tmp = (4.0d0 / y) * (x - z)
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.7e+225) {
tmp = 2.0;
} else if (y <= 4.6e+112) {
tmp = (4.0 / y) * (x - z);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.7e+225: tmp = 2.0 elif y <= 4.6e+112: tmp = (4.0 / y) * (x - z) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.7e+225) tmp = 2.0; elseif (y <= 4.6e+112) tmp = Float64(Float64(4.0 / y) * Float64(x - z)); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.7e+225) tmp = 2.0; elseif (y <= 4.6e+112) tmp = (4.0 / y) * (x - z); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.7e+225], 2.0, If[LessEqual[y, 4.6e+112], N[(N[(4.0 / y), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+225}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{+112}:\\
\;\;\;\;\frac{4}{y} \cdot \left(x - z\right)\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -1.70000000000000009e225 or 4.5999999999999999e112 < y Initial program 100.0%
Taylor expanded in y around inf 80.4%
if -1.70000000000000009e225 < y < 4.5999999999999999e112Initial program 100.0%
Taylor expanded in y around 0 83.6%
associate-*r/83.6%
associate-*l/83.4%
Simplified83.4%
Final simplification82.7%
(FPCore (x y z) :precision binary64 (if (<= x -1.12e+52) (+ 2.0 (* x (/ 4.0 y))) (if (<= x 850.0) (+ 2.0 (* (/ z y) -4.0)) (* (/ 4.0 y) (- x z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.12e+52) {
tmp = 2.0 + (x * (4.0 / y));
} else if (x <= 850.0) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = (4.0 / y) * (x - z);
}
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.12d+52)) then
tmp = 2.0d0 + (x * (4.0d0 / y))
else if (x <= 850.0d0) then
tmp = 2.0d0 + ((z / y) * (-4.0d0))
else
tmp = (4.0d0 / y) * (x - z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.12e+52) {
tmp = 2.0 + (x * (4.0 / y));
} else if (x <= 850.0) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = (4.0 / y) * (x - z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.12e+52: tmp = 2.0 + (x * (4.0 / y)) elif x <= 850.0: tmp = 2.0 + ((z / y) * -4.0) else: tmp = (4.0 / y) * (x - z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.12e+52) tmp = Float64(2.0 + Float64(x * Float64(4.0 / y))); elseif (x <= 850.0) tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); else tmp = Float64(Float64(4.0 / y) * Float64(x - z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.12e+52) tmp = 2.0 + (x * (4.0 / y)); elseif (x <= 850.0) tmp = 2.0 + ((z / y) * -4.0); else tmp = (4.0 / y) * (x - z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.12e+52], N[(2.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 850.0], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(N[(4.0 / y), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.12 \cdot 10^{+52}:\\
\;\;\;\;2 + x \cdot \frac{4}{y}\\
\mathbf{elif}\;x \leq 850:\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\frac{4}{y} \cdot \left(x - z\right)\\
\end{array}
\end{array}
if x < -1.12000000000000002e52Initial program 100.0%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
distribute-lft-in99.7%
associate-+r+99.7%
Simplified99.7%
Taylor expanded in z around 0 93.9%
+-commutative93.9%
associate-*r/93.9%
associate-*l/93.7%
*-commutative93.7%
Simplified93.7%
if -1.12000000000000002e52 < x < 850Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.9%
Simplified99.9%
Taylor expanded in x around 0 92.7%
*-commutative92.7%
Simplified92.7%
if 850 < x Initial program 100.0%
Taylor expanded in y around 0 89.9%
associate-*r/89.9%
associate-*l/89.7%
Simplified89.7%
Final simplification92.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.75e+41) (not (<= x 59000.0))) (* 4.0 (/ x y)) 2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.75e+41) || !(x <= 59000.0)) {
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 ((x <= (-1.75d+41)) .or. (.not. (x <= 59000.0d0))) 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 ((x <= -1.75e+41) || !(x <= 59000.0)) {
tmp = 4.0 * (x / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.75e+41) or not (x <= 59000.0): tmp = 4.0 * (x / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.75e+41) || !(x <= 59000.0)) 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 ((x <= -1.75e+41) || ~((x <= 59000.0))) tmp = 4.0 * (x / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.75e+41], N[Not[LessEqual[x, 59000.0]], $MachinePrecision]], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.75 \cdot 10^{+41} \lor \neg \left(x \leq 59000\right):\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if x < -1.75e41 or 59000 < x Initial program 100.0%
Taylor expanded in x around inf 69.4%
if -1.75e41 < x < 59000Initial program 100.0%
Taylor expanded in y around inf 47.1%
Final simplification57.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.8%
Simplified99.8%
Final simplification99.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 32.4%
Final simplification32.4%
herbie shell --seed 2024011
(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)))