
(FPCore (d1) :precision binary64 (* (* d1 (* (* (* (* (* d1 (* d1 d1)) d1) d1) (* d1 d1)) d1)) d1))
double code(double d1) {
return (d1 * (((((d1 * (d1 * d1)) * d1) * d1) * (d1 * d1)) * d1)) * d1;
}
real(8) function code(d1)
real(8), intent (in) :: d1
code = (d1 * (((((d1 * (d1 * d1)) * d1) * d1) * (d1 * d1)) * d1)) * d1
end function
public static double code(double d1) {
return (d1 * (((((d1 * (d1 * d1)) * d1) * d1) * (d1 * d1)) * d1)) * d1;
}
def code(d1): return (d1 * (((((d1 * (d1 * d1)) * d1) * d1) * (d1 * d1)) * d1)) * d1
function code(d1) return Float64(Float64(d1 * Float64(Float64(Float64(Float64(Float64(d1 * Float64(d1 * d1)) * d1) * d1) * Float64(d1 * d1)) * d1)) * d1) end
function tmp = code(d1) tmp = (d1 * (((((d1 * (d1 * d1)) * d1) * d1) * (d1 * d1)) * d1)) * d1; end
code[d1_] := N[(N[(d1 * N[(N[(N[(N[(N[(d1 * N[(d1 * d1), $MachinePrecision]), $MachinePrecision] * d1), $MachinePrecision] * d1), $MachinePrecision] * N[(d1 * d1), $MachinePrecision]), $MachinePrecision] * d1), $MachinePrecision]), $MachinePrecision] * d1), $MachinePrecision]
\begin{array}{l}
\\
\left(d1 \cdot \left(\left(\left(\left(\left(d1 \cdot \left(d1 \cdot d1\right)\right) \cdot d1\right) \cdot d1\right) \cdot \left(d1 \cdot d1\right)\right) \cdot d1\right)\right) \cdot d1
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (d1) :precision binary64 (* (* d1 (* (* (* (* (* d1 (* d1 d1)) d1) d1) (* d1 d1)) d1)) d1))
double code(double d1) {
return (d1 * (((((d1 * (d1 * d1)) * d1) * d1) * (d1 * d1)) * d1)) * d1;
}
real(8) function code(d1)
real(8), intent (in) :: d1
code = (d1 * (((((d1 * (d1 * d1)) * d1) * d1) * (d1 * d1)) * d1)) * d1
end function
public static double code(double d1) {
return (d1 * (((((d1 * (d1 * d1)) * d1) * d1) * (d1 * d1)) * d1)) * d1;
}
def code(d1): return (d1 * (((((d1 * (d1 * d1)) * d1) * d1) * (d1 * d1)) * d1)) * d1
function code(d1) return Float64(Float64(d1 * Float64(Float64(Float64(Float64(Float64(d1 * Float64(d1 * d1)) * d1) * d1) * Float64(d1 * d1)) * d1)) * d1) end
function tmp = code(d1) tmp = (d1 * (((((d1 * (d1 * d1)) * d1) * d1) * (d1 * d1)) * d1)) * d1; end
code[d1_] := N[(N[(d1 * N[(N[(N[(N[(N[(d1 * N[(d1 * d1), $MachinePrecision]), $MachinePrecision] * d1), $MachinePrecision] * d1), $MachinePrecision] * N[(d1 * d1), $MachinePrecision]), $MachinePrecision] * d1), $MachinePrecision]), $MachinePrecision] * d1), $MachinePrecision]
\begin{array}{l}
\\
\left(d1 \cdot \left(\left(\left(\left(\left(d1 \cdot \left(d1 \cdot d1\right)\right) \cdot d1\right) \cdot d1\right) \cdot \left(d1 \cdot d1\right)\right) \cdot d1\right)\right) \cdot d1
\end{array}
(FPCore (d1) :precision binary64 (pow d1 10.0))
double code(double d1) {
return pow(d1, 10.0);
}
real(8) function code(d1)
real(8), intent (in) :: d1
code = d1 ** 10.0d0
end function
public static double code(double d1) {
return Math.pow(d1, 10.0);
}
def code(d1): return math.pow(d1, 10.0)
function code(d1) return d1 ^ 10.0 end
function tmp = code(d1) tmp = d1 ^ 10.0; end
code[d1_] := N[Power[d1, 10.0], $MachinePrecision]
\begin{array}{l}
\\
{d1}^{10}
\end{array}
Initial program 99.9%
*-commutative99.9%
associate-*l*99.8%
associate-*l*99.8%
associate-*r*99.8%
associate-*l*99.8%
cube-unmult99.9%
pow-plus99.9%
pow-plus99.9%
associate-*l*99.9%
cube-unmult99.9%
pow-plus99.9%
pow-plus99.9%
pow-sqr100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (d1) :precision binary64 (* d1 (* d1 (* d1 (* (* d1 d1) (* d1 (* d1 (* d1 (* d1 d1)))))))))
double code(double d1) {
return d1 * (d1 * (d1 * ((d1 * d1) * (d1 * (d1 * (d1 * (d1 * d1)))))));
}
real(8) function code(d1)
real(8), intent (in) :: d1
code = d1 * (d1 * (d1 * ((d1 * d1) * (d1 * (d1 * (d1 * (d1 * d1)))))))
end function
public static double code(double d1) {
return d1 * (d1 * (d1 * ((d1 * d1) * (d1 * (d1 * (d1 * (d1 * d1)))))));
}
def code(d1): return d1 * (d1 * (d1 * ((d1 * d1) * (d1 * (d1 * (d1 * (d1 * d1)))))))
function code(d1) return Float64(d1 * Float64(d1 * Float64(d1 * Float64(Float64(d1 * d1) * Float64(d1 * Float64(d1 * Float64(d1 * Float64(d1 * d1)))))))) end
function tmp = code(d1) tmp = d1 * (d1 * (d1 * ((d1 * d1) * (d1 * (d1 * (d1 * (d1 * d1))))))); end
code[d1_] := N[(d1 * N[(d1 * N[(d1 * N[(N[(d1 * d1), $MachinePrecision] * N[(d1 * N[(d1 * N[(d1 * N[(d1 * d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
d1 \cdot \left(d1 \cdot \left(d1 \cdot \left(\left(d1 \cdot d1\right) \cdot \left(d1 \cdot \left(d1 \cdot \left(d1 \cdot \left(d1 \cdot d1\right)\right)\right)\right)\right)\right)\right)
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (d1) :precision binary64 (pow d1 10.0))
double code(double d1) {
return pow(d1, 10.0);
}
real(8) function code(d1)
real(8), intent (in) :: d1
code = d1 ** 10.0d0
end function
public static double code(double d1) {
return Math.pow(d1, 10.0);
}
def code(d1): return math.pow(d1, 10.0)
function code(d1) return d1 ^ 10.0 end
function tmp = code(d1) tmp = d1 ^ 10.0; end
code[d1_] := N[Power[d1, 10.0], $MachinePrecision]
\begin{array}{l}
\\
{d1}^{10}
\end{array}
herbie shell --seed 2023201
(FPCore (d1)
:name "FastMath test5"
:precision binary64
:herbie-target
(pow d1 10.0)
(* (* d1 (* (* (* (* (* d1 (* d1 d1)) d1) d1) (* d1 d1)) d1)) d1))