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