
(FPCore (x) :precision binary64 (* (* x x) x))
double code(double x) {
return (x * x) * x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * x) * x
end function
public static double code(double x) {
return (x * x) * x;
}
def code(x): return (x * x) * x
function code(x) return Float64(Float64(x * x) * x) end
function tmp = code(x) tmp = (x * x) * x; end
code[x_] := N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot x
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (* (* x x) x))
double code(double x) {
return (x * x) * x;
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * x) * x
end function
public static double code(double x) {
return (x * x) * x;
}
def code(x): return (x * x) * x
function code(x) return Float64(Float64(x * x) * x) end
function tmp = code(x) tmp = (x * x) * x; end
code[x_] := N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot x
\end{array}
NOTE: x should be positive before calling this function
(FPCore (x)
:precision binary64
(let* ((t_0 (- (pow x 3.0))))
(if (<= x 1.46e-15)
t_0
(if (<= x 5.3e+97) (pow x 3.0) (if (<= x 2.55e+225) t_0 (* x (* x x)))))))x = abs(x);
double code(double x) {
double t_0 = -pow(x, 3.0);
double tmp;
if (x <= 1.46e-15) {
tmp = t_0;
} else if (x <= 5.3e+97) {
tmp = pow(x, 3.0);
} else if (x <= 2.55e+225) {
tmp = t_0;
} else {
tmp = x * (x * x);
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: t_0
real(8) :: tmp
t_0 = -(x ** 3.0d0)
if (x <= 1.46d-15) then
tmp = t_0
else if (x <= 5.3d+97) then
tmp = x ** 3.0d0
else if (x <= 2.55d+225) then
tmp = t_0
else
tmp = x * (x * x)
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double t_0 = -Math.pow(x, 3.0);
double tmp;
if (x <= 1.46e-15) {
tmp = t_0;
} else if (x <= 5.3e+97) {
tmp = Math.pow(x, 3.0);
} else if (x <= 2.55e+225) {
tmp = t_0;
} else {
tmp = x * (x * x);
}
return tmp;
}
x = abs(x) def code(x): t_0 = -math.pow(x, 3.0) tmp = 0 if x <= 1.46e-15: tmp = t_0 elif x <= 5.3e+97: tmp = math.pow(x, 3.0) elif x <= 2.55e+225: tmp = t_0 else: tmp = x * (x * x) return tmp
x = abs(x) function code(x) t_0 = Float64(-(x ^ 3.0)) tmp = 0.0 if (x <= 1.46e-15) tmp = t_0; elseif (x <= 5.3e+97) tmp = x ^ 3.0; elseif (x <= 2.55e+225) tmp = t_0; else tmp = Float64(x * Float64(x * x)); end return tmp end
x = abs(x) function tmp_2 = code(x) t_0 = -(x ^ 3.0); tmp = 0.0; if (x <= 1.46e-15) tmp = t_0; elseif (x <= 5.3e+97) tmp = x ^ 3.0; elseif (x <= 2.55e+225) tmp = t_0; else tmp = x * (x * x); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
code[x_] := Block[{t$95$0 = (-N[Power[x, 3.0], $MachinePrecision])}, If[LessEqual[x, 1.46e-15], t$95$0, If[LessEqual[x, 5.3e+97], N[Power[x, 3.0], $MachinePrecision], If[LessEqual[x, 2.55e+225], t$95$0, N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := -{x}^{3}\\
\mathbf{if}\;x \leq 1.46 \cdot 10^{-15}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 5.3 \cdot 10^{+97}:\\
\;\;\;\;{x}^{3}\\
\mathbf{elif}\;x \leq 2.55 \cdot 10^{+225}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot x\right)\\
\end{array}
\end{array}
if x < 1.4600000000000001e-15 or 5.3000000000000003e97 < x < 2.55e225Initial program 99.9%
add-cbrt-cube_binary6489.4%
Applied rewrite-once89.4%
pow389.3%
rem-cbrt-cube99.9%
pow3100.0%
sqr-pow35.8%
pow-prod-down60.1%
metadata-eval60.1%
Applied egg-rr60.1%
Taylor expanded in x around -inf 46.0%
Simplified46.0%
if 1.4600000000000001e-15 < x < 5.3000000000000003e97Initial program 99.7%
unpow3100.0%
Simplified100.0%
if 2.55e225 < x Initial program 100.0%
Final simplification57.6%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (pow x 3.0))
x = abs(x);
double code(double x) {
return pow(x, 3.0);
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
code = x ** 3.0d0
end function
x = Math.abs(x);
public static double code(double x) {
return Math.pow(x, 3.0);
}
x = abs(x) def code(x): return math.pow(x, 3.0)
x = abs(x) function code(x) return x ^ 3.0 end
x = abs(x) function tmp = code(x) tmp = x ^ 3.0; end
NOTE: x should be positive before calling this function code[x_] := N[Power[x, 3.0], $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
{x}^{3}
\end{array}
Initial program 99.9%
unpow3100.0%
Simplified100.0%
Final simplification100.0%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (if (<= x 8.8e-48) 0.0 (* x x)))
x = abs(x);
double code(double x) {
double tmp;
if (x <= 8.8e-48) {
tmp = 0.0;
} else {
tmp = x * x;
}
return tmp;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
real(8) :: tmp
if (x <= 8.8d-48) then
tmp = 0.0d0
else
tmp = x * x
end if
code = tmp
end function
x = Math.abs(x);
public static double code(double x) {
double tmp;
if (x <= 8.8e-48) {
tmp = 0.0;
} else {
tmp = x * x;
}
return tmp;
}
x = abs(x) def code(x): tmp = 0 if x <= 8.8e-48: tmp = 0.0 else: tmp = x * x return tmp
x = abs(x) function code(x) tmp = 0.0 if (x <= 8.8e-48) tmp = 0.0; else tmp = Float64(x * x); end return tmp end
x = abs(x) function tmp_2 = code(x) tmp = 0.0; if (x <= 8.8e-48) tmp = 0.0; else tmp = x * x; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function code[x_] := If[LessEqual[x, 8.8e-48], 0.0, N[(x * x), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.8 \cdot 10^{-48}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;x \cdot x\\
\end{array}
\end{array}
if x < 8.8000000000000005e-48Initial program 99.9%
add-cbrt-cube_binary6488.5%
Applied rewrite-once88.5%
pow388.5%
rem-cbrt-cube99.9%
pow3100.0%
sqr-pow27.1%
pow-prod-down54.7%
metadata-eval54.7%
Applied egg-rr54.7%
pow-to-exp54.4%
pow254.4%
log-pow26.9%
associate-*l*26.9%
exp-prod26.9%
metadata-eval26.9%
metadata-eval26.9%
associate-*l*26.9%
*-commutative26.9%
count-226.9%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
associate-*l/0.0%
+-inverses0.0%
metadata-eval0.0%
metadata-eval0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified52.9%
if 8.8000000000000005e-48 < x Initial program 99.8%
add-cbrt-cube_binary6481.7%
Applied rewrite-once81.7%
pow381.8%
rem-cbrt-cube99.8%
pow3100.0%
sqr-pow99.6%
pow-prod-down99.7%
metadata-eval99.7%
Applied egg-rr99.7%
Applied egg-rr50.3%
Final simplification52.1%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 (* x (* x x)))
x = abs(x);
double code(double x) {
return x * (x * x);
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
code = x * (x * x)
end function
x = Math.abs(x);
public static double code(double x) {
return x * (x * x);
}
x = abs(x) def code(x): return x * (x * x)
x = abs(x) function code(x) return Float64(x * Float64(x * x)) end
x = abs(x) function tmp = code(x) tmp = x * (x * x); end
NOTE: x should be positive before calling this function code[x_] := N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
\\
x \cdot \left(x \cdot x\right)
\end{array}
Initial program 99.9%
Final simplification99.9%
NOTE: x should be positive before calling this function (FPCore (x) :precision binary64 0.0)
x = abs(x);
double code(double x) {
return 0.0;
}
NOTE: x should be positive before calling this function
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
x = Math.abs(x);
public static double code(double x) {
return 0.0;
}
x = abs(x) def code(x): return 0.0
x = abs(x) function code(x) return 0.0 end
x = abs(x) function tmp = code(x) tmp = 0.0; end
NOTE: x should be positive before calling this function code[x_] := 0.0
\begin{array}{l}
x = |x|\\
\\
0
\end{array}
Initial program 99.9%
add-cbrt-cube_binary6486.4%
Applied rewrite-once86.4%
pow386.4%
rem-cbrt-cube99.9%
pow3100.0%
sqr-pow49.5%
pow-prod-down68.6%
metadata-eval68.6%
Applied egg-rr68.6%
pow-to-exp67.2%
pow267.2%
log-pow48.1%
associate-*l*48.1%
exp-prod48.2%
metadata-eval48.2%
metadata-eval48.2%
associate-*l*48.2%
*-commutative48.2%
count-248.2%
flip-+0.0%
+-inverses0.0%
+-inverses0.0%
associate-*l/0.0%
+-inverses0.0%
metadata-eval0.0%
metadata-eval0.0%
+-inverses0.0%
Applied egg-rr0.0%
Simplified37.2%
Final simplification37.2%
(FPCore (x) :precision binary64 (pow x 3.0))
double code(double x) {
return pow(x, 3.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x ** 3.0d0
end function
public static double code(double x) {
return Math.pow(x, 3.0);
}
def code(x): return math.pow(x, 3.0)
function code(x) return x ^ 3.0 end
function tmp = code(x) tmp = x ^ 3.0; end
code[x_] := N[Power[x, 3.0], $MachinePrecision]
\begin{array}{l}
\\
{x}^{3}
\end{array}
herbie shell --seed 2023297
(FPCore (x)
:name "math.cube on real"
:precision binary64
:herbie-target
(pow x 3.0)
(* (* x x) x))