
(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 3 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%
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
associate-*l*N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6499.8%
Simplified99.8%
associate-*r*N/A
unswap-sqrN/A
pow2N/A
pow2N/A
unpow-prod-downN/A
cube-unmultN/A
pow2N/A
pow-prod-upN/A
pow-powN/A
pow-lowering-pow.f64N/A
metadata-evalN/A
metadata-eval100.0%
Applied egg-rr100.0%
(FPCore (d1) :precision binary64 (let* ((t_0 (* d1 (* d1 d1)))) (* d1 (* d1 (* t_0 (* d1 (* d1 t_0)))))))
double code(double d1) {
double t_0 = d1 * (d1 * d1);
return d1 * (d1 * (t_0 * (d1 * (d1 * t_0))));
}
real(8) function code(d1)
real(8), intent (in) :: d1
real(8) :: t_0
t_0 = d1 * (d1 * d1)
code = d1 * (d1 * (t_0 * (d1 * (d1 * t_0))))
end function
public static double code(double d1) {
double t_0 = d1 * (d1 * d1);
return d1 * (d1 * (t_0 * (d1 * (d1 * t_0))));
}
def code(d1): t_0 = d1 * (d1 * d1) return d1 * (d1 * (t_0 * (d1 * (d1 * t_0))))
function code(d1) t_0 = Float64(d1 * Float64(d1 * d1)) return Float64(d1 * Float64(d1 * Float64(t_0 * Float64(d1 * Float64(d1 * t_0))))) end
function tmp = code(d1) t_0 = d1 * (d1 * d1); tmp = d1 * (d1 * (t_0 * (d1 * (d1 * t_0)))); end
code[d1_] := Block[{t$95$0 = N[(d1 * N[(d1 * d1), $MachinePrecision]), $MachinePrecision]}, N[(d1 * N[(d1 * N[(t$95$0 * N[(d1 * N[(d1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := d1 \cdot \left(d1 \cdot d1\right)\\
d1 \cdot \left(d1 \cdot \left(t\_0 \cdot \left(d1 \cdot \left(d1 \cdot t\_0\right)\right)\right)\right)
\end{array}
\end{array}
Initial program 99.9%
associate-*l*N/A
associate-*l*N/A
cube-unmultN/A
sqr-powN/A
associate-*l*N/A
associate-*l*N/A
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
associate-*l*N/A
sqr-powN/A
cube-unmultN/A
Applied egg-rr99.9%
Final simplification99.9%
(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 * d1) * Float64(d1 * Float64(d1 * Float64(Float64(d1 * 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[(N[(d1 * d1), $MachinePrecision] * N[(d1 * N[(d1 * N[(N[(d1 * d1), $MachinePrecision] * N[(d1 * N[(d1 * N[(d1 * d1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(d1 \cdot d1\right) \cdot \left(d1 \cdot \left(d1 \cdot \left(\left(d1 \cdot d1\right) \cdot \left(d1 \cdot \left(d1 \cdot \left(d1 \cdot d1\right)\right)\right)\right)\right)\right)
\end{array}
Initial program 99.9%
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
associate-*l*N/A
associate-*l*N/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-commutativeN/A
associate-*r*N/A
*-lowering-*.f64N/A
*-lowering-*.f64N/A
*-lowering-*.f6499.8%
Simplified99.8%
associate-*r*N/A
associate-*r*N/A
associate-*r*N/A
associate-*l*N/A
associate-*r*N/A
associate-*r*N/A
*-lowering-*.f64N/A
Applied egg-rr99.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 2024141
(FPCore (d1)
:name "FastMath test5"
:precision binary64
:alt
(! :herbie-platform default (pow d1 10))
(* (* d1 (* (* (* (* (* d1 (* d1 d1)) d1) d1) (* d1 d1)) d1)) d1))