
(FPCore (x) :precision binary64 (* (* x x) (- 3.0 (* x 2.0))))
double code(double x) {
return (x * x) * (3.0 - (x * 2.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * x) * (3.0d0 - (x * 2.0d0))
end function
public static double code(double x) {
return (x * x) * (3.0 - (x * 2.0));
}
def code(x): return (x * x) * (3.0 - (x * 2.0))
function code(x) return Float64(Float64(x * x) * Float64(3.0 - Float64(x * 2.0))) end
function tmp = code(x) tmp = (x * x) * (3.0 - (x * 2.0)); end
code[x_] := N[(N[(x * x), $MachinePrecision] * N[(3.0 - N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot \left(3 - x \cdot 2\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x) :precision binary64 (* (* x x) (- 3.0 (* x 2.0))))
double code(double x) {
return (x * x) * (3.0 - (x * 2.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * x) * (3.0d0 - (x * 2.0d0))
end function
public static double code(double x) {
return (x * x) * (3.0 - (x * 2.0));
}
def code(x): return (x * x) * (3.0 - (x * 2.0))
function code(x) return Float64(Float64(x * x) * Float64(3.0 - Float64(x * 2.0))) end
function tmp = code(x) tmp = (x * x) * (3.0 - (x * 2.0)); end
code[x_] := N[(N[(x * x), $MachinePrecision] * N[(3.0 - N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot \left(3 - x \cdot 2\right)
\end{array}
(FPCore (x) :precision binary64 (* (* x x) (- 3.0 (* x 2.0))))
double code(double x) {
return (x * x) * (3.0 - (x * 2.0));
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * x) * (3.0d0 - (x * 2.0d0))
end function
public static double code(double x) {
return (x * x) * (3.0 - (x * 2.0));
}
def code(x): return (x * x) * (3.0 - (x * 2.0))
function code(x) return Float64(Float64(x * x) * Float64(3.0 - Float64(x * 2.0))) end
function tmp = code(x) tmp = (x * x) * (3.0 - (x * 2.0)); end
code[x_] := N[(N[(x * x), $MachinePrecision] * N[(3.0 - N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot \left(3 - x \cdot 2\right)
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x) :precision binary64 (* x (* x (- 3.0 (* x 2.0)))))
double code(double x) {
return x * (x * (3.0 - (x * 2.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (x * (3.0d0 - (x * 2.0d0)))
end function
public static double code(double x) {
return x * (x * (3.0 - (x * 2.0)));
}
def code(x): return x * (x * (3.0 - (x * 2.0)))
function code(x) return Float64(x * Float64(x * Float64(3.0 - Float64(x * 2.0)))) end
function tmp = code(x) tmp = x * (x * (3.0 - (x * 2.0))); end
code[x_] := N[(x * N[(x * N[(3.0 - N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(x \cdot \left(3 - x \cdot 2\right)\right)
\end{array}
Initial program 99.8%
associate-*l*99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x) :precision binary64 (* (* x x) (- -3.0)))
double code(double x) {
return (x * x) * -(-3.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (x * x) * -(-3.0d0)
end function
public static double code(double x) {
return (x * x) * -(-3.0);
}
def code(x): return (x * x) * -(-3.0)
function code(x) return Float64(Float64(x * x) * Float64(-(-3.0))) end
function tmp = code(x) tmp = (x * x) * -(-3.0); end
code[x_] := N[(N[(x * x), $MachinePrecision] * (--3.0)), $MachinePrecision]
\begin{array}{l}
\\
\left(x \cdot x\right) \cdot \left(--3\right)
\end{array}
Initial program 99.8%
associate-*l*99.8%
Simplified99.8%
flip--99.8%
clear-num99.7%
associate-*r/99.6%
*-commutative99.6%
*-un-lft-identity99.6%
*-commutative99.6%
metadata-eval99.6%
cancel-sign-sub-inv99.6%
*-commutative99.6%
add-sqr-sqrt49.0%
sqrt-unprod65.0%
swap-sqr65.0%
metadata-eval65.0%
metadata-eval65.0%
swap-sqr65.0%
sqrt-unprod25.3%
add-sqr-sqrt50.5%
*-un-lft-identity50.5%
associate-/l*50.5%
Applied egg-rr99.6%
clear-num99.7%
un-div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 61.0%
clear-num60.3%
frac-2neg60.3%
associate-/l/60.3%
associate-/r/61.1%
metadata-eval61.1%
metadata-eval61.1%
Applied egg-rr61.1%
Final simplification61.1%
(FPCore (x) :precision binary64 (* x (* x 3.0)))
double code(double x) {
return x * (x * 3.0);
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (x * 3.0d0)
end function
public static double code(double x) {
return x * (x * 3.0);
}
def code(x): return x * (x * 3.0)
function code(x) return Float64(x * Float64(x * 3.0)) end
function tmp = code(x) tmp = x * (x * 3.0); end
code[x_] := N[(x * N[(x * 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(x \cdot 3\right)
\end{array}
Initial program 99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in x around 0 61.1%
Final simplification61.1%
(FPCore (x) :precision binary64 (* x -4.5))
double code(double x) {
return x * -4.5;
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (-4.5d0)
end function
public static double code(double x) {
return x * -4.5;
}
def code(x): return x * -4.5
function code(x) return Float64(x * -4.5) end
function tmp = code(x) tmp = x * -4.5; end
code[x_] := N[(x * -4.5), $MachinePrecision]
\begin{array}{l}
\\
x \cdot -4.5
\end{array}
Initial program 99.8%
associate-*l*99.8%
Simplified99.8%
Applied egg-rr95.2%
Taylor expanded in x around 0 74.7%
*-commutative74.7%
Simplified74.7%
Taylor expanded in x around inf 6.0%
*-commutative6.0%
Simplified6.0%
Final simplification6.0%
(FPCore (x) :precision binary64 -6.75)
double code(double x) {
return -6.75;
}
real(8) function code(x)
real(8), intent (in) :: x
code = -6.75d0
end function
public static double code(double x) {
return -6.75;
}
def code(x): return -6.75
function code(x) return -6.75 end
function tmp = code(x) tmp = -6.75; end
code[x_] := -6.75
\begin{array}{l}
\\
-6.75
\end{array}
Initial program 99.8%
associate-*l*99.8%
Simplified99.8%
Applied egg-rr95.2%
Taylor expanded in x around 0 74.7%
*-commutative74.7%
Simplified74.7%
Taylor expanded in x around inf 4.5%
Taylor expanded in x around 0 2.6%
Final simplification2.6%
(FPCore (x) :precision binary64 (* x (* x (- 3.0 (* x 2.0)))))
double code(double x) {
return x * (x * (3.0 - (x * 2.0)));
}
real(8) function code(x)
real(8), intent (in) :: x
code = x * (x * (3.0d0 - (x * 2.0d0)))
end function
public static double code(double x) {
return x * (x * (3.0 - (x * 2.0)));
}
def code(x): return x * (x * (3.0 - (x * 2.0)))
function code(x) return Float64(x * Float64(x * Float64(3.0 - Float64(x * 2.0)))) end
function tmp = code(x) tmp = x * (x * (3.0 - (x * 2.0))); end
code[x_] := N[(x * N[(x * N[(3.0 - N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(x \cdot \left(3 - x \cdot 2\right)\right)
\end{array}
herbie shell --seed 2023301
(FPCore (x)
:name "Data.Spline.Key:interpolateKeys from smoothie-0.4.0.2"
:precision binary64
:herbie-target
(* x (* x (- 3.0 (* x 2.0))))
(* (* x x) (- 3.0 (* x 2.0))))