Average Error: 3.2 → 1.1
Time: 35.8s
Precision: 64
$\sqrt{\frac{-4}{3} \cdot p} \cdot \cos \left(\frac{1}{3} \cdot \cos^{-1} \left(\frac{-q}{2} \cdot \sqrt{\frac{-27}{{p}^{3}}}\right)\right) - \frac{b}{3} \cdot a$
$\sqrt{\frac{-4}{3} \cdot p} \cdot \cos \left(\frac{1}{3} \cdot \cos^{-1} \left(\frac{-q}{2} \cdot \left(\sqrt{\frac{1}{{\left(\sqrt[3]{p} \cdot \sqrt[3]{p}\right)}^{3}}} \cdot \sqrt{\frac{-27}{{\left(\sqrt[3]{p}\right)}^{3}}}\right)\right)\right) - \frac{b}{3} \cdot a$
\sqrt{\frac{-4}{3} \cdot p} \cdot \cos \left(\frac{1}{3} \cdot \cos^{-1} \left(\frac{-q}{2} \cdot \sqrt{\frac{-27}{{p}^{3}}}\right)\right) - \frac{b}{3} \cdot a
\sqrt{\frac{-4}{3} \cdot p} \cdot \cos \left(\frac{1}{3} \cdot \cos^{-1} \left(\frac{-q}{2} \cdot \left(\sqrt{\frac{1}{{\left(\sqrt[3]{p} \cdot \sqrt[3]{p}\right)}^{3}}} \cdot \sqrt{\frac{-27}{{\left(\sqrt[3]{p}\right)}^{3}}}\right)\right)\right) - \frac{b}{3} \cdot a
double f(double p, double q, double b, double a) {
double r2735120 = 4.0;
double r2735121 = -r2735120;
double r2735122 = 3.0;
double r2735123 = r2735121 / r2735122;
double r2735124 = p;
double r2735125 = r2735123 * r2735124;
double r2735126 = sqrt(r2735125);
double r2735127 = 1.0;
double r2735128 = r2735127 / r2735122;
double r2735129 = q;
double r2735130 = -r2735129;
double r2735131 = 2.0;
double r2735132 = r2735130 / r2735131;
double r2735133 = 27.0;
double r2735134 = -r2735133;
double r2735135 = pow(r2735124, r2735122);
double r2735136 = r2735134 / r2735135;
double r2735137 = sqrt(r2735136);
double r2735138 = r2735132 * r2735137;
double r2735139 = acos(r2735138);
double r2735140 = r2735128 * r2735139;
double r2735141 = cos(r2735140);
double r2735142 = r2735126 * r2735141;
double r2735143 = b;
double r2735144 = r2735143 / r2735122;
double r2735145 = a;
double r2735146 = r2735144 * r2735145;
double r2735147 = r2735142 - r2735146;
return r2735147;
}


double f(double p, double q, double b, double a) {
double r2735148 = 4.0;
double r2735149 = -r2735148;
double r2735150 = 3.0;
double r2735151 = r2735149 / r2735150;
double r2735152 = p;
double r2735153 = r2735151 * r2735152;
double r2735154 = sqrt(r2735153);
double r2735155 = 1.0;
double r2735156 = r2735155 / r2735150;
double r2735157 = q;
double r2735158 = -r2735157;
double r2735159 = 2.0;
double r2735160 = r2735158 / r2735159;
double r2735161 = 1.0;
double r2735162 = cbrt(r2735152);
double r2735163 = r2735162 * r2735162;
double r2735164 = pow(r2735163, r2735150);
double r2735165 = r2735161 / r2735164;
double r2735166 = sqrt(r2735165);
double r2735167 = 27.0;
double r2735168 = -r2735167;
double r2735169 = pow(r2735162, r2735150);
double r2735170 = r2735168 / r2735169;
double r2735171 = sqrt(r2735170);
double r2735172 = r2735166 * r2735171;
double r2735173 = r2735160 * r2735172;
double r2735174 = acos(r2735173);
double r2735175 = r2735156 * r2735174;
double r2735176 = cos(r2735175);
double r2735177 = r2735154 * r2735176;
double r2735178 = b;
double r2735179 = r2735178 / r2735150;
double r2735180 = a;
double r2735181 = r2735179 * r2735180;
double r2735182 = r2735177 - r2735181;
return r2735182;
}



# Try it out

Results

 In Out
Enter valid numbers for all inputs

# Derivation

1. Initial program 3.2

$\sqrt{\frac{-4}{3} \cdot p} \cdot \cos \left(\frac{1}{3} \cdot \cos^{-1} \left(\frac{-q}{2} \cdot \sqrt{\frac{-27}{{p}^{3}}}\right)\right) - \frac{b}{3} \cdot a$
2. Using strategy rm

$\leadsto \sqrt{\frac{-4}{3} \cdot p} \cdot \cos \left(\frac{1}{3} \cdot \cos^{-1} \left(\frac{-q}{2} \cdot \sqrt{\frac{-27}{{\color{blue}{\left(\left(\sqrt[3]{p} \cdot \sqrt[3]{p}\right) \cdot \sqrt[3]{p}\right)}}^{3}}}\right)\right) - \frac{b}{3} \cdot a$
4. Applied unpow-prod-down3.2

$\leadsto \sqrt{\frac{-4}{3} \cdot p} \cdot \cos \left(\frac{1}{3} \cdot \cos^{-1} \left(\frac{-q}{2} \cdot \sqrt{\frac{-27}{\color{blue}{{\left(\sqrt[3]{p} \cdot \sqrt[3]{p}\right)}^{3} \cdot {\left(\sqrt[3]{p}\right)}^{3}}}}\right)\right) - \frac{b}{3} \cdot a$
5. Applied *-un-lft-identity3.2

$\leadsto \sqrt{\frac{-4}{3} \cdot p} \cdot \cos \left(\frac{1}{3} \cdot \cos^{-1} \left(\frac{-q}{2} \cdot \sqrt{\frac{\color{blue}{1 \cdot \left(-27\right)}}{{\left(\sqrt[3]{p} \cdot \sqrt[3]{p}\right)}^{3} \cdot {\left(\sqrt[3]{p}\right)}^{3}}}\right)\right) - \frac{b}{3} \cdot a$
6. Applied times-frac3.2

$\leadsto \sqrt{\frac{-4}{3} \cdot p} \cdot \cos \left(\frac{1}{3} \cdot \cos^{-1} \left(\frac{-q}{2} \cdot \sqrt{\color{blue}{\frac{1}{{\left(\sqrt[3]{p} \cdot \sqrt[3]{p}\right)}^{3}} \cdot \frac{-27}{{\left(\sqrt[3]{p}\right)}^{3}}}}\right)\right) - \frac{b}{3} \cdot a$
7. Applied sqrt-prod1.1

$\leadsto \sqrt{\frac{-4}{3} \cdot p} \cdot \cos \left(\frac{1}{3} \cdot \cos^{-1} \left(\frac{-q}{2} \cdot \color{blue}{\left(\sqrt{\frac{1}{{\left(\sqrt[3]{p} \cdot \sqrt[3]{p}\right)}^{3}}} \cdot \sqrt{\frac{-27}{{\left(\sqrt[3]{p}\right)}^{3}}}\right)}\right)\right) - \frac{b}{3} \cdot a$
8. Final simplification1.1

$\leadsto \sqrt{\frac{-4}{3} \cdot p} \cdot \cos \left(\frac{1}{3} \cdot \cos^{-1} \left(\frac{-q}{2} \cdot \left(\sqrt{\frac{1}{{\left(\sqrt[3]{p} \cdot \sqrt[3]{p}\right)}^{3}}} \cdot \sqrt{\frac{-27}{{\left(\sqrt[3]{p}\right)}^{3}}}\right)\right)\right) - \frac{b}{3} \cdot a$

# Reproduce

herbie shell --seed 1
(FPCore (p q b a)
:name "sqrt(-4/3*p)*cos(1/3*acos(-q/2*sqrt(-27/p^3)))-b/3a"
:precision binary64
(- (* (sqrt (* (/ (- 4) 3) p)) (cos (* (/ 1 3) (acos (* (/ (- q) 2) (sqrt (/ (- 27) (pow p 3)))))))) (* (/ b 3) a)))