Alternative 1 | |
---|---|
Error | 5.9 |
Cost | 52160 |
\[\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}
\]
(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}
Initial program 6.0
Simplified5.9
[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)
\] |
Applied egg-rr6.0
Simplified5.9
[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)}}}
\] |
Final simplification5.9
Alternative 1 | |
---|---|
Error | 5.9 |
Cost | 52160 |
Alternative 2 | |
---|---|
Error | 6.0 |
Cost | 45824 |
Alternative 3 | |
---|---|
Error | 6.0 |
Cost | 39488 |
Alternative 4 | |
---|---|
Error | 6.0 |
Cost | 32832 |
Alternative 5 | |
---|---|
Error | 5.9 |
Cost | 25920 |
Alternative 6 | |
---|---|
Error | 6.1 |
Cost | 19776 |
Alternative 7 | |
---|---|
Error | 6.0 |
Cost | 19648 |
Alternative 8 | |
---|---|
Error | 56.6 |
Cost | 12928 |
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)))))