Average Error: 16.4 → 0.2
Time: 16.7s
Precision: 64
$4 \cdot \frac{{x}^{2}}{{pi}^{2}} - \left(\frac{x}{\left|x\right|} \cdot 2\right) \cdot \frac{x}{pi}$
$\left(\left(4 \cdot {x}^{\left(\frac{2}{2}\right)}\right) \cdot \frac{1}{{pi}^{\left(\frac{2}{2}\right)}}\right) \cdot \frac{{x}^{\left(\frac{2}{2}\right)}}{{pi}^{\left(\frac{2}{2}\right)}} - \left(\frac{x}{\left|x\right|} \cdot 2\right) \cdot \frac{x}{pi}$
4 \cdot \frac{{x}^{2}}{{pi}^{2}} - \left(\frac{x}{\left|x\right|} \cdot 2\right) \cdot \frac{x}{pi}
\left(\left(4 \cdot {x}^{\left(\frac{2}{2}\right)}\right) \cdot \frac{1}{{pi}^{\left(\frac{2}{2}\right)}}\right) \cdot \frac{{x}^{\left(\frac{2}{2}\right)}}{{pi}^{\left(\frac{2}{2}\right)}} - \left(\frac{x}{\left|x\right|} \cdot 2\right) \cdot \frac{x}{pi}
double f(double x, double pi) {
double r1400817 = 4.0;
double r1400818 = x;
double r1400819 = 2.0;
double r1400820 = pow(r1400818, r1400819);
double r1400821 = pi;
double r1400822 = pow(r1400821, r1400819);
double r1400823 = r1400820 / r1400822;
double r1400824 = r1400817 * r1400823;
double r1400825 = fabs(r1400818);
double r1400826 = r1400818 / r1400825;
double r1400827 = r1400826 * r1400819;
double r1400828 = r1400818 / r1400821;
double r1400829 = r1400827 * r1400828;
double r1400830 = r1400824 - r1400829;
return r1400830;
}


double f(double x, double pi) {
double r1400831 = 4.0;
double r1400832 = x;
double r1400833 = 2.0;
double r1400834 = 2.0;
double r1400835 = r1400833 / r1400834;
double r1400836 = pow(r1400832, r1400835);
double r1400837 = r1400831 * r1400836;
double r1400838 = 1.0;
double r1400839 = pi;
double r1400840 = pow(r1400839, r1400835);
double r1400841 = r1400838 / r1400840;
double r1400842 = r1400837 * r1400841;
double r1400843 = r1400836 / r1400840;
double r1400844 = r1400842 * r1400843;
double r1400845 = fabs(r1400832);
double r1400846 = r1400832 / r1400845;
double r1400847 = r1400846 * r1400833;
double r1400848 = r1400832 / r1400839;
double r1400849 = r1400847 * r1400848;
double r1400850 = r1400844 - r1400849;
return r1400850;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 16.4

$4 \cdot \frac{{x}^{2}}{{pi}^{2}} - \left(\frac{x}{\left|x\right|} \cdot 2\right) \cdot \frac{x}{pi}$
2. Using strategy rm
3. Applied sqr-pow16.4

$\leadsto 4 \cdot \frac{{x}^{2}}{\color{blue}{{pi}^{\left(\frac{2}{2}\right)} \cdot {pi}^{\left(\frac{2}{2}\right)}}} - \left(\frac{x}{\left|x\right|} \cdot 2\right) \cdot \frac{x}{pi}$
4. Applied sqr-pow16.4

$\leadsto 4 \cdot \frac{\color{blue}{{x}^{\left(\frac{2}{2}\right)} \cdot {x}^{\left(\frac{2}{2}\right)}}}{{pi}^{\left(\frac{2}{2}\right)} \cdot {pi}^{\left(\frac{2}{2}\right)}} - \left(\frac{x}{\left|x\right|} \cdot 2\right) \cdot \frac{x}{pi}$
5. Applied times-frac0.2

$\leadsto 4 \cdot \color{blue}{\left(\frac{{x}^{\left(\frac{2}{2}\right)}}{{pi}^{\left(\frac{2}{2}\right)}} \cdot \frac{{x}^{\left(\frac{2}{2}\right)}}{{pi}^{\left(\frac{2}{2}\right)}}\right)} - \left(\frac{x}{\left|x\right|} \cdot 2\right) \cdot \frac{x}{pi}$
6. Applied associate-*r*0.2

$\leadsto \color{blue}{\left(4 \cdot \frac{{x}^{\left(\frac{2}{2}\right)}}{{pi}^{\left(\frac{2}{2}\right)}}\right) \cdot \frac{{x}^{\left(\frac{2}{2}\right)}}{{pi}^{\left(\frac{2}{2}\right)}}} - \left(\frac{x}{\left|x\right|} \cdot 2\right) \cdot \frac{x}{pi}$
7. Using strategy rm
8. Applied div-inv0.2

$\leadsto \left(4 \cdot \color{blue}{\left({x}^{\left(\frac{2}{2}\right)} \cdot \frac{1}{{pi}^{\left(\frac{2}{2}\right)}}\right)}\right) \cdot \frac{{x}^{\left(\frac{2}{2}\right)}}{{pi}^{\left(\frac{2}{2}\right)}} - \left(\frac{x}{\left|x\right|} \cdot 2\right) \cdot \frac{x}{pi}$
9. Applied associate-*r*0.2

$\leadsto \color{blue}{\left(\left(4 \cdot {x}^{\left(\frac{2}{2}\right)}\right) \cdot \frac{1}{{pi}^{\left(\frac{2}{2}\right)}}\right)} \cdot \frac{{x}^{\left(\frac{2}{2}\right)}}{{pi}^{\left(\frac{2}{2}\right)}} - \left(\frac{x}{\left|x\right|} \cdot 2\right) \cdot \frac{x}{pi}$
10. Final simplification0.2

$\leadsto \left(\left(4 \cdot {x}^{\left(\frac{2}{2}\right)}\right) \cdot \frac{1}{{pi}^{\left(\frac{2}{2}\right)}}\right) \cdot \frac{{x}^{\left(\frac{2}{2}\right)}}{{pi}^{\left(\frac{2}{2}\right)}} - \left(\frac{x}{\left|x\right|} \cdot 2\right) \cdot \frac{x}{pi}$

# Reproduce

herbie shell --seed 1
(FPCore (x pi)
:name "4x^2/pi^2-(x/abs(x))*2x/pi"
:precision binary64
(- (* 4 (/ (pow x 2) (pow pi 2))) (* (* (/ x (fabs x)) 2) (/ x pi))))