?

Average Error: 6.0 → 5.9
Time: 17.3s
Precision: binary64
Cost: 169152

?

\[1 \leq x \land x \leq 1000\]
\[\cos \left(\frac{\pi}{4} - \frac{2}{3} \cdot {x}^{1.5}\right) \]
\[\begin{array}{l} t_0 := -0.6666666666666666 \cdot {x}^{1.5}\\ t_1 := \cos t_0\\ t_2 := \cos \left(0.25 \cdot \pi\right)\\ t_3 := \sin t_0 \cdot \sin \left(0.25 \cdot \pi\right)\\ t_4 := \mathsf{fma}\left(t_1, t_2, t_3\right)\\ \frac{t_4}{\frac{t_4}{t_2 \cdot t_1 - t_3}} \end{array} \]
(FPCore (x)
 :precision binary64
 (cos (- (/ PI 4.0) (* (/ 2.0 3.0) (pow x 1.5)))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* -0.6666666666666666 (pow x 1.5)))
        (t_1 (cos t_0))
        (t_2 (cos (* 0.25 PI)))
        (t_3 (* (sin t_0) (sin (* 0.25 PI))))
        (t_4 (fma t_1 t_2 t_3)))
   (/ t_4 (/ t_4 (- (* t_2 t_1) t_3)))))
double code(double x) {
	return cos(((((double) M_PI) / 4.0) - ((2.0 / 3.0) * pow(x, 1.5))));
}
double code(double x) {
	double t_0 = -0.6666666666666666 * pow(x, 1.5);
	double t_1 = cos(t_0);
	double t_2 = cos((0.25 * ((double) M_PI)));
	double t_3 = sin(t_0) * sin((0.25 * ((double) M_PI)));
	double t_4 = fma(t_1, t_2, t_3);
	return t_4 / (t_4 / ((t_2 * t_1) - t_3));
}
function code(x)
	return cos(Float64(Float64(pi / 4.0) - Float64(Float64(2.0 / 3.0) * (x ^ 1.5))))
end
function code(x)
	t_0 = Float64(-0.6666666666666666 * (x ^ 1.5))
	t_1 = cos(t_0)
	t_2 = cos(Float64(0.25 * pi))
	t_3 = Float64(sin(t_0) * sin(Float64(0.25 * pi)))
	t_4 = fma(t_1, t_2, t_3)
	return Float64(t_4 / Float64(t_4 / Float64(Float64(t_2 * t_1) - t_3)))
end
code[x_] := N[Cos[N[(N[(Pi / 4.0), $MachinePrecision] - N[(N[(2.0 / 3.0), $MachinePrecision] * N[Power[x, 1.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(-0.6666666666666666 * N[Power[x, 1.5], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(0.25 * Pi), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Sin[t$95$0], $MachinePrecision] * N[Sin[N[(0.25 * Pi), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 * t$95$2 + t$95$3), $MachinePrecision]}, N[(t$95$4 / N[(t$95$4 / N[(N[(t$95$2 * t$95$1), $MachinePrecision] - t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\cos \left(\frac{\pi}{4} - \frac{2}{3} \cdot {x}^{1.5}\right)
\begin{array}{l}
t_0 := -0.6666666666666666 \cdot {x}^{1.5}\\
t_1 := \cos t_0\\
t_2 := \cos \left(0.25 \cdot \pi\right)\\
t_3 := \sin t_0 \cdot \sin \left(0.25 \cdot \pi\right)\\
t_4 := \mathsf{fma}\left(t_1, t_2, t_3\right)\\
\frac{t_4}{\frac{t_4}{t_2 \cdot t_1 - t_3}}
\end{array}

Error?

Derivation?

  1. Initial program 6.0

    \[\cos \left(\frac{\pi}{4} - \frac{2}{3} \cdot {x}^{1.5}\right) \]
  2. Simplified5.9

    \[\leadsto \color{blue}{\cos \left(\mathsf{fma}\left({x}^{1.5}, -0.6666666666666666, \frac{\pi}{4}\right)\right)} \]
    Proof

    [Start]6.0

    \[ \cos \left(\frac{\pi}{4} - \frac{2}{3} \cdot {x}^{1.5}\right) \]

    cancel-sign-sub-inv [=>]6.0

    \[ \cos \color{blue}{\left(\frac{\pi}{4} + \left(-\frac{2}{3}\right) \cdot {x}^{1.5}\right)} \]

    +-commutative [=>]6.0

    \[ \cos \color{blue}{\left(\left(-\frac{2}{3}\right) \cdot {x}^{1.5} + \frac{\pi}{4}\right)} \]

    *-commutative [=>]6.0

    \[ \cos \left(\color{blue}{{x}^{1.5} \cdot \left(-\frac{2}{3}\right)} + \frac{\pi}{4}\right) \]

    fma-def [=>]5.9

    \[ \cos \color{blue}{\left(\mathsf{fma}\left({x}^{1.5}, -\frac{2}{3}, \frac{\pi}{4}\right)\right)} \]

    metadata-eval [=>]5.9

    \[ \cos \left(\mathsf{fma}\left({x}^{1.5}, -\color{blue}{0.6666666666666666}, \frac{\pi}{4}\right)\right) \]

    metadata-eval [=>]5.9

    \[ \cos \left(\mathsf{fma}\left({x}^{1.5}, \color{blue}{-0.6666666666666666}, \frac{\pi}{4}\right)\right) \]
  3. Applied egg-rr6.0

    \[\leadsto \color{blue}{\frac{\left(\cos \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \cos \left(\pi \cdot 0.25\right)\right) \cdot \left(\cos \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \cos \left(\pi \cdot 0.25\right)\right) - \left(\sin \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \sin \left(\pi \cdot 0.25\right)\right) \cdot \left(\sin \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \sin \left(\pi \cdot 0.25\right)\right)}{\cos \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \cos \left(\pi \cdot 0.25\right) + \sin \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \sin \left(\pi \cdot 0.25\right)}} \]
  4. Simplified5.9

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\cos \left(-0.6666666666666666 \cdot {x}^{1.5}\right), \cos \left(0.25 \cdot \pi\right), \sin \left(-0.6666666666666666 \cdot {x}^{1.5}\right) \cdot \sin \left(0.25 \cdot \pi\right)\right)}{\frac{\mathsf{fma}\left(\cos \left(-0.6666666666666666 \cdot {x}^{1.5}\right), \cos \left(0.25 \cdot \pi\right), \sin \left(-0.6666666666666666 \cdot {x}^{1.5}\right) \cdot \sin \left(0.25 \cdot \pi\right)\right)}{\cos \left(-0.6666666666666666 \cdot {x}^{1.5}\right) \cdot \cos \left(0.25 \cdot \pi\right) - \sin \left(-0.6666666666666666 \cdot {x}^{1.5}\right) \cdot \sin \left(0.25 \cdot \pi\right)}}} \]
    Proof

    [Start]6.0

    \[ \frac{\left(\cos \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \cos \left(\pi \cdot 0.25\right)\right) \cdot \left(\cos \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \cos \left(\pi \cdot 0.25\right)\right) - \left(\sin \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \sin \left(\pi \cdot 0.25\right)\right) \cdot \left(\sin \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \sin \left(\pi \cdot 0.25\right)\right)}{\cos \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \cos \left(\pi \cdot 0.25\right) + \sin \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \sin \left(\pi \cdot 0.25\right)} \]

    difference-of-squares [=>]5.9

    \[ \frac{\color{blue}{\left(\cos \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \cos \left(\pi \cdot 0.25\right) + \sin \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \sin \left(\pi \cdot 0.25\right)\right) \cdot \left(\cos \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \cos \left(\pi \cdot 0.25\right) - \sin \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \sin \left(\pi \cdot 0.25\right)\right)}}{\cos \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \cos \left(\pi \cdot 0.25\right) + \sin \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \sin \left(\pi \cdot 0.25\right)} \]

    associate-/l* [=>]5.9

    \[ \color{blue}{\frac{\cos \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \cos \left(\pi \cdot 0.25\right) + \sin \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \sin \left(\pi \cdot 0.25\right)}{\frac{\cos \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \cos \left(\pi \cdot 0.25\right) + \sin \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \sin \left(\pi \cdot 0.25\right)}{\cos \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \cos \left(\pi \cdot 0.25\right) - \sin \left({x}^{1.5} \cdot -0.6666666666666666\right) \cdot \sin \left(\pi \cdot 0.25\right)}}} \]
  5. Final simplification5.9

    \[\leadsto \frac{\mathsf{fma}\left(\cos \left(-0.6666666666666666 \cdot {x}^{1.5}\right), \cos \left(0.25 \cdot \pi\right), \sin \left(-0.6666666666666666 \cdot {x}^{1.5}\right) \cdot \sin \left(0.25 \cdot \pi\right)\right)}{\frac{\mathsf{fma}\left(\cos \left(-0.6666666666666666 \cdot {x}^{1.5}\right), \cos \left(0.25 \cdot \pi\right), \sin \left(-0.6666666666666666 \cdot {x}^{1.5}\right) \cdot \sin \left(0.25 \cdot \pi\right)\right)}{\cos \left(0.25 \cdot \pi\right) \cdot \cos \left(-0.6666666666666666 \cdot {x}^{1.5}\right) - \sin \left(-0.6666666666666666 \cdot {x}^{1.5}\right) \cdot \sin \left(0.25 \cdot \pi\right)}} \]

Alternatives

Alternative 1
Error5.9
Cost52160
\[\begin{array}{l} t_0 := -0.6666666666666666 \cdot {x}^{1.5}\\ \cos \left(0.25 \cdot \pi\right) \cdot \cos t_0 - \sin t_0 \cdot \sin \left(0.25 \cdot \pi\right) \end{array} \]
Alternative 2
Error6.0
Cost45824
\[\begin{array}{l} t_0 := -0.6666666666666666 \cdot {x}^{1.5}\\ \mathsf{fma}\left(\frac{\sqrt{2}}{2}, \cos t_0, \sin t_0 \cdot \frac{-\sqrt{2}}{2}\right) \end{array} \]
Alternative 3
Error6.0
Cost39488
\[\begin{array}{l} t_0 := -0.6666666666666666 \cdot {x}^{1.5}\\ t_1 := \frac{\sqrt{2}}{2}\\ \cos t_0 \cdot t_1 - \sin t_0 \cdot t_1 \end{array} \]
Alternative 4
Error6.0
Cost32832
\[\begin{array}{l} t_0 := -0.6666666666666666 \cdot {x}^{1.5}\\ \frac{\sqrt{2}}{2} \cdot \left(\cos t_0 - \sin t_0\right) \end{array} \]
Alternative 5
Error5.9
Cost25920
\[\cos \left(\mathsf{fma}\left({x}^{1.5}, -0.6666666666666666, \frac{\pi}{4}\right)\right) \]
Alternative 6
Error6.1
Cost19776
\[\cos \left(\frac{\pi}{4} + -0.6666666666666666 \cdot {\left(x \cdot x\right)}^{0.75}\right) \]
Alternative 7
Error6.0
Cost19648
\[\cos \left(-0.6666666666666666 \cdot {x}^{1.5} + \frac{\pi}{4}\right) \]
Alternative 8
Error56.6
Cost12928
\[\cos \left(0.25 \cdot \pi\right) \]

Error

Reproduce?

herbie shell --seed 1 
(FPCore (x)
  :name "cos(PI/4 - 2/3*pow(x, 1.5))"
  :precision binary64
  :pre (and (<= 1.0 x) (<= x 1000.0))
  (cos (- (/ PI 4.0) (* (/ 2.0 3.0) (pow x 1.5)))))