
(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 (/ (+ (* 2.0 y) (* 4.0 (- x z))) y))
double code(double x, double y, double z) {
return ((2.0 * y) + (4.0 * (x - 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 = ((2.0d0 * y) + (4.0d0 * (x - z))) / y
end function
public static double code(double x, double y, double z) {
return ((2.0 * y) + (4.0 * (x - z))) / y;
}
def code(x, y, z): return ((2.0 * y) + (4.0 * (x - z))) / y
function code(x, y, z) return Float64(Float64(Float64(2.0 * y) + Float64(4.0 * Float64(x - z))) / y) end
function tmp = code(x, y, z) tmp = ((2.0 * y) + (4.0 * (x - z))) / y; end
code[x_, y_, z_] := N[(N[(N[(2.0 * y), $MachinePrecision] + N[(4.0 * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 \cdot y + 4 \cdot \left(x - z\right)}{y}
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ 4.0 y))) (t_1 (* (/ z y) -4.0)))
(if (<= x -1.95e-16)
t_0
(if (<= x -5.2e-160)
t_1
(if (<= x -9.5e-200)
2.0
(if (<= x 3.3e-242)
t_1
(if (<= x 1.46e-173) 2.0 (if (<= x 8.4e-17) t_1 t_0))))))))
double code(double x, double y, double z) {
double t_0 = x * (4.0 / y);
double t_1 = (z / y) * -4.0;
double tmp;
if (x <= -1.95e-16) {
tmp = t_0;
} else if (x <= -5.2e-160) {
tmp = t_1;
} else if (x <= -9.5e-200) {
tmp = 2.0;
} else if (x <= 3.3e-242) {
tmp = t_1;
} else if (x <= 1.46e-173) {
tmp = 2.0;
} else if (x <= 8.4e-17) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = x * (4.0d0 / y)
t_1 = (z / y) * (-4.0d0)
if (x <= (-1.95d-16)) then
tmp = t_0
else if (x <= (-5.2d-160)) then
tmp = t_1
else if (x <= (-9.5d-200)) then
tmp = 2.0d0
else if (x <= 3.3d-242) then
tmp = t_1
else if (x <= 1.46d-173) then
tmp = 2.0d0
else if (x <= 8.4d-17) then
tmp = t_1
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 t_1 = (z / y) * -4.0;
double tmp;
if (x <= -1.95e-16) {
tmp = t_0;
} else if (x <= -5.2e-160) {
tmp = t_1;
} else if (x <= -9.5e-200) {
tmp = 2.0;
} else if (x <= 3.3e-242) {
tmp = t_1;
} else if (x <= 1.46e-173) {
tmp = 2.0;
} else if (x <= 8.4e-17) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (4.0 / y) t_1 = (z / y) * -4.0 tmp = 0 if x <= -1.95e-16: tmp = t_0 elif x <= -5.2e-160: tmp = t_1 elif x <= -9.5e-200: tmp = 2.0 elif x <= 3.3e-242: tmp = t_1 elif x <= 1.46e-173: tmp = 2.0 elif x <= 8.4e-17: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(4.0 / y)) t_1 = Float64(Float64(z / y) * -4.0) tmp = 0.0 if (x <= -1.95e-16) tmp = t_0; elseif (x <= -5.2e-160) tmp = t_1; elseif (x <= -9.5e-200) tmp = 2.0; elseif (x <= 3.3e-242) tmp = t_1; elseif (x <= 1.46e-173) tmp = 2.0; elseif (x <= 8.4e-17) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (4.0 / y); t_1 = (z / y) * -4.0; tmp = 0.0; if (x <= -1.95e-16) tmp = t_0; elseif (x <= -5.2e-160) tmp = t_1; elseif (x <= -9.5e-200) tmp = 2.0; elseif (x <= 3.3e-242) tmp = t_1; elseif (x <= 1.46e-173) tmp = 2.0; elseif (x <= 8.4e-17) tmp = t_1; 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]}, Block[{t$95$1 = N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]}, If[LessEqual[x, -1.95e-16], t$95$0, If[LessEqual[x, -5.2e-160], t$95$1, If[LessEqual[x, -9.5e-200], 2.0, If[LessEqual[x, 3.3e-242], t$95$1, If[LessEqual[x, 1.46e-173], 2.0, If[LessEqual[x, 8.4e-17], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{y}\\
t_1 := \frac{z}{y} \cdot -4\\
\mathbf{if}\;x \leq -1.95 \cdot 10^{-16}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5.2 \cdot 10^{-160}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -9.5 \cdot 10^{-200}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 3.3 \cdot 10^{-242}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.46 \cdot 10^{-173}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 8.4 \cdot 10^{-17}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.94999999999999989e-16 or 8.39999999999999968e-17 < x Initial program 99.9%
Taylor expanded in y around 0 99.9%
Taylor expanded in x around inf 57.5%
*-commutative57.5%
associate-*l/57.5%
associate-*r/57.3%
Simplified57.3%
if -1.94999999999999989e-16 < x < -5.20000000000000007e-160 or -9.4999999999999995e-200 < x < 3.29999999999999982e-242 or 1.46e-173 < x < 8.39999999999999968e-17Initial program 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in z around inf 62.7%
if -5.20000000000000007e-160 < x < -9.4999999999999995e-200 or 3.29999999999999982e-242 < x < 1.46e-173Initial program 100.0%
Taylor expanded in y around inf 82.2%
Final simplification61.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* 4.0 x) y)) (t_1 (* (/ z y) -4.0)))
(if (<= x -5e-8)
t_0
(if (<= x -5.7e-160)
t_1
(if (<= x -4.5e-200)
2.0
(if (<= x 2.7e-244)
t_1
(if (<= x 1.4e-170) 2.0 (if (<= x 5.6e-17) t_1 t_0))))))))
double code(double x, double y, double z) {
double t_0 = (4.0 * x) / y;
double t_1 = (z / y) * -4.0;
double tmp;
if (x <= -5e-8) {
tmp = t_0;
} else if (x <= -5.7e-160) {
tmp = t_1;
} else if (x <= -4.5e-200) {
tmp = 2.0;
} else if (x <= 2.7e-244) {
tmp = t_1;
} else if (x <= 1.4e-170) {
tmp = 2.0;
} else if (x <= 5.6e-17) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = (4.0d0 * x) / y
t_1 = (z / y) * (-4.0d0)
if (x <= (-5d-8)) then
tmp = t_0
else if (x <= (-5.7d-160)) then
tmp = t_1
else if (x <= (-4.5d-200)) then
tmp = 2.0d0
else if (x <= 2.7d-244) then
tmp = t_1
else if (x <= 1.4d-170) then
tmp = 2.0d0
else if (x <= 5.6d-17) then
tmp = t_1
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 t_1 = (z / y) * -4.0;
double tmp;
if (x <= -5e-8) {
tmp = t_0;
} else if (x <= -5.7e-160) {
tmp = t_1;
} else if (x <= -4.5e-200) {
tmp = 2.0;
} else if (x <= 2.7e-244) {
tmp = t_1;
} else if (x <= 1.4e-170) {
tmp = 2.0;
} else if (x <= 5.6e-17) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (4.0 * x) / y t_1 = (z / y) * -4.0 tmp = 0 if x <= -5e-8: tmp = t_0 elif x <= -5.7e-160: tmp = t_1 elif x <= -4.5e-200: tmp = 2.0 elif x <= 2.7e-244: tmp = t_1 elif x <= 1.4e-170: tmp = 2.0 elif x <= 5.6e-17: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(4.0 * x) / y) t_1 = Float64(Float64(z / y) * -4.0) tmp = 0.0 if (x <= -5e-8) tmp = t_0; elseif (x <= -5.7e-160) tmp = t_1; elseif (x <= -4.5e-200) tmp = 2.0; elseif (x <= 2.7e-244) tmp = t_1; elseif (x <= 1.4e-170) tmp = 2.0; elseif (x <= 5.6e-17) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (4.0 * x) / y; t_1 = (z / y) * -4.0; tmp = 0.0; if (x <= -5e-8) tmp = t_0; elseif (x <= -5.7e-160) tmp = t_1; elseif (x <= -4.5e-200) tmp = 2.0; elseif (x <= 2.7e-244) tmp = t_1; elseif (x <= 1.4e-170) tmp = 2.0; elseif (x <= 5.6e-17) tmp = t_1; 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]}, Block[{t$95$1 = N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]}, If[LessEqual[x, -5e-8], t$95$0, If[LessEqual[x, -5.7e-160], t$95$1, If[LessEqual[x, -4.5e-200], 2.0, If[LessEqual[x, 2.7e-244], t$95$1, If[LessEqual[x, 1.4e-170], 2.0, If[LessEqual[x, 5.6e-17], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{4 \cdot x}{y}\\
t_1 := \frac{z}{y} \cdot -4\\
\mathbf{if}\;x \leq -5 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -5.7 \cdot 10^{-160}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -4.5 \cdot 10^{-200}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 2.7 \cdot 10^{-244}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-170}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 5.6 \cdot 10^{-17}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -4.9999999999999998e-8 or 5.5999999999999998e-17 < x Initial program 99.9%
Taylor expanded in y around 0 99.9%
Taylor expanded in x around inf 57.5%
associate-*r/57.5%
Simplified57.5%
if -4.9999999999999998e-8 < x < -5.70000000000000038e-160 or -4.5000000000000002e-200 < x < 2.7e-244 or 1.39999999999999998e-170 < x < 5.5999999999999998e-17Initial program 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in z around inf 62.7%
if -5.70000000000000038e-160 < x < -4.5000000000000002e-200 or 2.7e-244 < x < 1.39999999999999998e-170Initial program 100.0%
Taylor expanded in y around inf 82.2%
Final simplification61.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.1e-32) (not (<= y 30500.0))) (+ 2.0 (* (/ z y) -4.0)) (* (- x z) (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.1e-32) || !(y <= 30500.0)) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = (x - z) * (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 ((y <= (-3.1d-32)) .or. (.not. (y <= 30500.0d0))) then
tmp = 2.0d0 + ((z / y) * (-4.0d0))
else
tmp = (x - z) * (4.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3.1e-32) || !(y <= 30500.0)) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = (x - z) * (4.0 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.1e-32) or not (y <= 30500.0): tmp = 2.0 + ((z / y) * -4.0) else: tmp = (x - z) * (4.0 / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.1e-32) || !(y <= 30500.0)) tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); else tmp = Float64(Float64(x - z) * Float64(4.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.1e-32) || ~((y <= 30500.0))) tmp = 2.0 + ((z / y) * -4.0); else tmp = (x - z) * (4.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.1e-32], N[Not[LessEqual[y, 30500.0]], $MachinePrecision]], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{-32} \lor \neg \left(y \leq 30500\right):\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\end{array}
\end{array}
if y < -3.10000000000000011e-32 or 30500 < 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.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 83.5%
+-commutative83.5%
*-commutative83.5%
Simplified83.5%
if -3.10000000000000011e-32 < y < 30500Initial program 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around 0 94.4%
associate-*r/94.4%
*-commutative94.4%
associate-/l*94.2%
Simplified94.2%
Final simplification89.2%
(FPCore (x y z) :precision binary64 (if (<= y -1.1e+93) 2.0 (if (<= y 1.8e+180) (* (- x z) (/ 4.0 y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.1e+93) {
tmp = 2.0;
} else if (y <= 1.8e+180) {
tmp = (x - z) * (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.1d+93)) then
tmp = 2.0d0
else if (y <= 1.8d+180) then
tmp = (x - z) * (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.1e+93) {
tmp = 2.0;
} else if (y <= 1.8e+180) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.1e+93: tmp = 2.0 elif y <= 1.8e+180: tmp = (x - z) * (4.0 / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.1e+93) tmp = 2.0; elseif (y <= 1.8e+180) tmp = Float64(Float64(x - z) * 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.1e+93) tmp = 2.0; elseif (y <= 1.8e+180) tmp = (x - z) * (4.0 / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.1e+93], 2.0, If[LessEqual[y, 1.8e+180], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.1 \cdot 10^{+93}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+180}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -1.10000000000000011e93 or 1.8000000000000001e180 < y Initial program 99.9%
Taylor expanded in y around inf 73.3%
if -1.10000000000000011e93 < y < 1.8000000000000001e180Initial program 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around 0 83.9%
associate-*r/83.9%
*-commutative83.9%
associate-/l*83.7%
Simplified83.7%
Final simplification81.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.3e+54) (not (<= z 1.34e+48))) (* (/ z y) -4.0) 2.0))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.3e+54) || !(z <= 1.34e+48)) {
tmp = (z / y) * -4.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 ((z <= (-1.3d+54)) .or. (.not. (z <= 1.34d+48))) then
tmp = (z / y) * (-4.0d0)
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.3e+54) || !(z <= 1.34e+48)) {
tmp = (z / y) * -4.0;
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.3e+54) or not (z <= 1.34e+48): tmp = (z / y) * -4.0 else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.3e+54) || !(z <= 1.34e+48)) tmp = Float64(Float64(z / y) * -4.0); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.3e+54) || ~((z <= 1.34e+48))) tmp = (z / y) * -4.0; else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.3e+54], N[Not[LessEqual[z, 1.34e+48]], $MachinePrecision]], N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision], 2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.3 \cdot 10^{+54} \lor \neg \left(z \leq 1.34 \cdot 10^{+48}\right):\\
\;\;\;\;\frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if z < -1.30000000000000003e54 or 1.33999999999999995e48 < z Initial program 99.9%
Taylor expanded in y around 0 99.9%
Taylor expanded in z around inf 71.2%
if -1.30000000000000003e54 < z < 1.33999999999999995e48Initial program 100.0%
Taylor expanded in y around inf 43.6%
Final simplification55.3%
(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.9%
+-commutative99.9%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
+-commutative99.7%
distribute-lft-in99.7%
associate-+l+99.7%
associate-*l/99.7%
*-commutative99.7%
associate-*l*99.7%
metadata-eval99.7%
*-rgt-identity99.7%
*-inverses99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(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.9%
Taylor expanded in y around inf 31.4%
Final simplification31.4%
herbie shell --seed 2024096
(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)))