| Alternative 1 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 26560 |
\[e^{0.3333333333333333 \cdot \left(3 \cdot \log \left(0.3333333333333333 \cdot \cos^{-1} \left(0.05555555555555555 \cdot \frac{\sqrt{t}}{z \cdot \frac{y}{x}}\right)\right)\right)}
\]

(FPCore (x y z t) :precision binary64 (* (/ 1.0 3.0) (acos (* (/ (* 3.0 (/ x (* y 27.0))) (* z 2.0)) (sqrt t)))))
NOTE: y and z should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(exp
(*
0.3333333333333333
(*
3.0
(log
(*
0.3333333333333333
(acos (* 0.05555555555555555 (/ (sqrt t) (* z (/ y x)))))))))))double code(double x, double y, double z, double t) {
return (1.0 / 3.0) * acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * sqrt(t)));
}
assert(y < z);
double code(double x, double y, double z, double t) {
return exp((0.3333333333333333 * (3.0 * log((0.3333333333333333 * acos((0.05555555555555555 * (sqrt(t) / (z * (y / x))))))))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (1.0d0 / 3.0d0) * acos((((3.0d0 * (x / (y * 27.0d0))) / (z * 2.0d0)) * sqrt(t)))
end function
NOTE: y and z should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = exp((0.3333333333333333d0 * (3.0d0 * log((0.3333333333333333d0 * acos((0.05555555555555555d0 * (sqrt(t) / (z * (y / x))))))))))
end function
public static double code(double x, double y, double z, double t) {
return (1.0 / 3.0) * Math.acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * Math.sqrt(t)));
}
assert y < z;
public static double code(double x, double y, double z, double t) {
return Math.exp((0.3333333333333333 * (3.0 * Math.log((0.3333333333333333 * Math.acos((0.05555555555555555 * (Math.sqrt(t) / (z * (y / x))))))))));
}
def code(x, y, z, t): return (1.0 / 3.0) * math.acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * math.sqrt(t)))
[y, z] = sort([y, z]) def code(x, y, z, t): return math.exp((0.3333333333333333 * (3.0 * math.log((0.3333333333333333 * math.acos((0.05555555555555555 * (math.sqrt(t) / (z * (y / x))))))))))
function code(x, y, z, t) return Float64(Float64(1.0 / 3.0) * acos(Float64(Float64(Float64(3.0 * Float64(x / Float64(y * 27.0))) / Float64(z * 2.0)) * sqrt(t)))) end
y, z = sort([y, z]) function code(x, y, z, t) return exp(Float64(0.3333333333333333 * Float64(3.0 * log(Float64(0.3333333333333333 * acos(Float64(0.05555555555555555 * Float64(sqrt(t) / Float64(z * Float64(y / x)))))))))) end
function tmp = code(x, y, z, t) tmp = (1.0 / 3.0) * acos((((3.0 * (x / (y * 27.0))) / (z * 2.0)) * sqrt(t))); end
y, z = num2cell(sort([y, z])){:}
function tmp = code(x, y, z, t)
tmp = exp((0.3333333333333333 * (3.0 * log((0.3333333333333333 * acos((0.05555555555555555 * (sqrt(t) / (z * (y / x))))))))));
end
code[x_, y_, z_, t_] := N[(N[(1.0 / 3.0), $MachinePrecision] * N[ArcCos[N[(N[(N[(3.0 * N[(x / N[(y * 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(z * 2.0), $MachinePrecision]), $MachinePrecision] * N[Sqrt[t], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
NOTE: y and z should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[Exp[N[(0.3333333333333333 * N[(3.0 * N[Log[N[(0.3333333333333333 * N[ArcCos[N[(0.05555555555555555 * N[(N[Sqrt[t], $MachinePrecision] / N[(z * N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right)
\begin{array}{l}
[y, z] = \mathsf{sort}([y, z])\\
\\
e^{0.3333333333333333 \cdot \left(3 \cdot \log \left(0.3333333333333333 \cdot \cos^{-1} \left(0.05555555555555555 \cdot \frac{\sqrt{t}}{z \cdot \frac{y}{x}}\right)\right)\right)}
\end{array}
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
| Original | 97.9% |
|---|---|
| Target | 98.2% |
| Herbie | 99.5% |
Initial program 98.1%
Simplified98.1%
[Start]98.1% | \[ \frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right)
\] |
|---|---|
metadata-eval [=>]98.1% | \[ \color{blue}{0.3333333333333333} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right)
\] |
associate-*r/ [=>]98.1% | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{3 \cdot x}{y \cdot 27}}}{z \cdot 2} \cdot \sqrt{t}\right)
\] |
*-commutative [=>]98.1% | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{\frac{3 \cdot x}{\color{blue}{27 \cdot y}}}{z \cdot 2} \cdot \sqrt{t}\right)
\] |
times-frac [=>]98.1% | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{3}{27} \cdot \frac{x}{y}}}{z \cdot 2} \cdot \sqrt{t}\right)
\] |
*-commutative [=>]98.1% | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{\frac{3}{27} \cdot \frac{x}{y}}{\color{blue}{2 \cdot z}} \cdot \sqrt{t}\right)
\] |
times-frac [=>]98.1% | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\color{blue}{\left(\frac{\frac{3}{27}}{2} \cdot \frac{\frac{x}{y}}{z}\right)} \cdot \sqrt{t}\right)
\] |
metadata-eval [=>]98.1% | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\left(\frac{\color{blue}{0.1111111111111111}}{2} \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)
\] |
metadata-eval [=>]98.1% | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\left(\color{blue}{0.05555555555555555} \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)
\] |
Applied egg-rr99.6%
[Start]98.1% | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\left(0.05555555555555555 \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)
\] |
|---|---|
add-cbrt-cube [=>]98.1% | \[ \color{blue}{\sqrt[3]{\left(\left(0.3333333333333333 \cdot \cos^{-1} \left(\left(0.05555555555555555 \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)\right) \cdot \left(0.3333333333333333 \cdot \cos^{-1} \left(\left(0.05555555555555555 \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)\right)\right) \cdot \left(0.3333333333333333 \cdot \cos^{-1} \left(\left(0.05555555555555555 \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)\right)}}
\] |
pow1/3 [=>]98.1% | \[ \color{blue}{{\left(\left(\left(0.3333333333333333 \cdot \cos^{-1} \left(\left(0.05555555555555555 \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)\right) \cdot \left(0.3333333333333333 \cdot \cos^{-1} \left(\left(0.05555555555555555 \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)\right)\right) \cdot \left(0.3333333333333333 \cdot \cos^{-1} \left(\left(0.05555555555555555 \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)\right)\right)}^{0.3333333333333333}}
\] |
add-exp-log [=>]98.1% | \[ {\color{blue}{\left(e^{\log \left(\left(\left(0.3333333333333333 \cdot \cos^{-1} \left(\left(0.05555555555555555 \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)\right) \cdot \left(0.3333333333333333 \cdot \cos^{-1} \left(\left(0.05555555555555555 \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)\right)\right) \cdot \left(0.3333333333333333 \cdot \cos^{-1} \left(\left(0.05555555555555555 \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)\right)\right)}\right)}}^{0.3333333333333333}
\] |
pow-exp [=>]98.1% | \[ \color{blue}{e^{\log \left(\left(\left(0.3333333333333333 \cdot \cos^{-1} \left(\left(0.05555555555555555 \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)\right) \cdot \left(0.3333333333333333 \cdot \cos^{-1} \left(\left(0.05555555555555555 \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)\right)\right) \cdot \left(0.3333333333333333 \cdot \cos^{-1} \left(\left(0.05555555555555555 \cdot \frac{\frac{x}{y}}{z}\right) \cdot \sqrt{t}\right)\right)\right) \cdot 0.3333333333333333}}
\] |
Final simplification99.6%
| Alternative 1 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 26560 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.4% |
| Cost | 26432 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.0% |
| Cost | 26368 |
| Alternative 4 | |
|---|---|
| Accuracy | 97.9% |
| Cost | 13504 |
herbie shell --seed 2023167
(FPCore (x y z t)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, D"
:precision binary64
:herbie-target
(/ (acos (* (/ (/ x 27.0) (* y z)) (/ (sqrt t) (/ 2.0 3.0)))) 3.0)
(* (/ 1.0 3.0) (acos (* (/ (* 3.0 (/ x (* y 27.0))) (* z 2.0)) (sqrt t)))))