| Alternative 1 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 32832 |
\[e^{\log \left(\mathsf{fma}\left(0.3333333333333333, \cos^{-1} \left(\sqrt{t} \cdot \left(\frac{x}{z} \cdot \frac{0.05555555555555555}{y}\right)\right), 1\right)\right)} + -1
\]
(FPCore (x y z t) :precision binary64 (* (/ 1.0 3.0) (acos (* (/ (* 3.0 (/ x (* y 27.0))) (* z 2.0)) (sqrt t)))))
(FPCore (x y z t)
:precision binary64
(+
(pow
(sqrt
(*
0.5
(*
0.3333333333333333
(acos (* (sqrt t) (* (/ x z) (/ 0.05555555555555555 y)))))))
2.0)
(log
(sqrt
(pow
(exp 0.3333333333333333)
(acos (* (/ 0.05555555555555555 y) (* (sqrt t) (/ x z)))))))))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)));
}
double code(double x, double y, double z, double t) {
return pow(sqrt((0.5 * (0.3333333333333333 * acos((sqrt(t) * ((x / z) * (0.05555555555555555 / y))))))), 2.0) + log(sqrt(pow(exp(0.3333333333333333), acos(((0.05555555555555555 / y) * (sqrt(t) * (x / z)))))));
}
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
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 = (sqrt((0.5d0 * (0.3333333333333333d0 * acos((sqrt(t) * ((x / z) * (0.05555555555555555d0 / y))))))) ** 2.0d0) + log(sqrt((exp(0.3333333333333333d0) ** acos(((0.05555555555555555d0 / y) * (sqrt(t) * (x / z)))))))
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)));
}
public static double code(double x, double y, double z, double t) {
return Math.pow(Math.sqrt((0.5 * (0.3333333333333333 * Math.acos((Math.sqrt(t) * ((x / z) * (0.05555555555555555 / y))))))), 2.0) + Math.log(Math.sqrt(Math.pow(Math.exp(0.3333333333333333), Math.acos(((0.05555555555555555 / y) * (Math.sqrt(t) * (x / z)))))));
}
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)))
def code(x, y, z, t): return math.pow(math.sqrt((0.5 * (0.3333333333333333 * math.acos((math.sqrt(t) * ((x / z) * (0.05555555555555555 / y))))))), 2.0) + math.log(math.sqrt(math.pow(math.exp(0.3333333333333333), math.acos(((0.05555555555555555 / y) * (math.sqrt(t) * (x / z)))))))
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
function code(x, y, z, t) return Float64((sqrt(Float64(0.5 * Float64(0.3333333333333333 * acos(Float64(sqrt(t) * Float64(Float64(x / z) * Float64(0.05555555555555555 / y))))))) ^ 2.0) + log(sqrt((exp(0.3333333333333333) ^ acos(Float64(Float64(0.05555555555555555 / y) * Float64(sqrt(t) * Float64(x / z)))))))) 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
function tmp = code(x, y, z, t) tmp = (sqrt((0.5 * (0.3333333333333333 * acos((sqrt(t) * ((x / z) * (0.05555555555555555 / y))))))) ^ 2.0) + log(sqrt((exp(0.3333333333333333) ^ acos(((0.05555555555555555 / y) * (sqrt(t) * (x / z))))))); 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]
code[x_, y_, z_, t_] := N[(N[Power[N[Sqrt[N[(0.5 * N[(0.3333333333333333 * N[ArcCos[N[(N[Sqrt[t], $MachinePrecision] * N[(N[(x / z), $MachinePrecision] * N[(0.05555555555555555 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[Log[N[Sqrt[N[Power[N[Exp[0.3333333333333333], $MachinePrecision], N[ArcCos[N[(N[(0.05555555555555555 / y), $MachinePrecision] * N[(N[Sqrt[t], $MachinePrecision] * N[(x / z), $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)
{\left(\sqrt{0.5 \cdot \left(0.3333333333333333 \cdot \cos^{-1} \left(\sqrt{t} \cdot \left(\frac{x}{z} \cdot \frac{0.05555555555555555}{y}\right)\right)\right)}\right)}^{2} + \log \left(\sqrt{{\left(e^{0.3333333333333333}\right)}^{\cos^{-1} \left(\frac{0.05555555555555555}{y} \cdot \left(\sqrt{t} \cdot \frac{x}{z}\right)\right)}}\right)
Results
| Original | 98.0% |
|---|---|
| Target | 98.1% |
| Herbie | 99.5% |
Initial program 97.7%
Simplified98.1%
[Start]97.7 | \[ \frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right)
\] |
|---|---|
metadata-eval [=>]97.7 | \[ \color{blue}{0.3333333333333333} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right)
\] |
times-frac [=>]97.7 | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\color{blue}{\left(\frac{3}{z} \cdot \frac{\frac{x}{y \cdot 27}}{2}\right)} \cdot \sqrt{t}\right)
\] |
associate-*r/ [=>]97.7 | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\color{blue}{\frac{\frac{3}{z} \cdot \frac{x}{y \cdot 27}}{2}} \cdot \sqrt{t}\right)
\] |
times-frac [<=]97.7 | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{3 \cdot x}{z \cdot \left(y \cdot 27\right)}}}{2} \cdot \sqrt{t}\right)
\] |
*-commutative [=>]97.7 | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{\frac{\color{blue}{x \cdot 3}}{z \cdot \left(y \cdot 27\right)}}{2} \cdot \sqrt{t}\right)
\] |
times-frac [=>]98.5 | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{x}{z} \cdot \frac{3}{y \cdot 27}}}{2} \cdot \sqrt{t}\right)
\] |
associate-/l* [=>]98.5 | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\color{blue}{\frac{\frac{x}{z}}{\frac{2}{\frac{3}{y \cdot 27}}}} \cdot \sqrt{t}\right)
\] |
associate-*l/ [=>]98.5 | \[ 0.3333333333333333 \cdot \cos^{-1} \color{blue}{\left(\frac{\frac{x}{z} \cdot \sqrt{t}}{\frac{2}{\frac{3}{y \cdot 27}}}\right)}
\] |
associate-*r/ [<=]98.1 | \[ 0.3333333333333333 \cdot \cos^{-1} \color{blue}{\left(\frac{x}{z} \cdot \frac{\sqrt{t}}{\frac{2}{\frac{3}{y \cdot 27}}}\right)}
\] |
associate-/r/ [=>]98.1 | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{\color{blue}{\frac{2}{3} \cdot \left(y \cdot 27\right)}}\right)
\] |
*-commutative [=>]98.1 | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{\frac{2}{3} \cdot \color{blue}{\left(27 \cdot y\right)}}\right)
\] |
associate-*r* [=>]98.1 | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{\color{blue}{\left(\frac{2}{3} \cdot 27\right) \cdot y}}\right)
\] |
metadata-eval [=>]98.1 | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{\left(\color{blue}{0.6666666666666666} \cdot 27\right) \cdot y}\right)
\] |
metadata-eval [=>]98.1 | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{\color{blue}{18} \cdot y}\right)
\] |
Applied egg-rr98.5%
[Start]98.1 | \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{18 \cdot y}\right)
\] |
|---|---|
add-log-exp [=>]98.1 | \[ \color{blue}{\log \left(e^{0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{18 \cdot y}\right)}\right)}
\] |
add-sqr-sqrt [=>]98.1 | \[ \log \color{blue}{\left(\sqrt{e^{0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{18 \cdot y}\right)}} \cdot \sqrt{e^{0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{18 \cdot y}\right)}}\right)}
\] |
log-prod [=>]98.1 | \[ \color{blue}{\log \left(\sqrt{e^{0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{18 \cdot y}\right)}}\right) + \log \left(\sqrt{e^{0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{18 \cdot y}\right)}}\right)}
\] |
exp-prod [=>]98.1 | \[ \log \left(\sqrt{\color{blue}{{\left(e^{0.3333333333333333}\right)}^{\cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{18 \cdot y}\right)}}}\right) + \log \left(\sqrt{e^{0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{18 \cdot y}\right)}}\right)
\] |
associate-*r/ [=>]98.1 | \[ \log \left(\sqrt{{\left(e^{0.3333333333333333}\right)}^{\cos^{-1} \color{blue}{\left(\frac{\frac{x}{z} \cdot \sqrt{t}}{18 \cdot y}\right)}}}\right) + \log \left(\sqrt{e^{0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{18 \cdot y}\right)}}\right)
\] |
div-inv [=>]98.1 | \[ \log \left(\sqrt{{\left(e^{0.3333333333333333}\right)}^{\cos^{-1} \color{blue}{\left(\left(\frac{x}{z} \cdot \sqrt{t}\right) \cdot \frac{1}{18 \cdot y}\right)}}}\right) + \log \left(\sqrt{e^{0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{18 \cdot y}\right)}}\right)
\] |
associate-/r* [=>]98.1 | \[ \log \left(\sqrt{{\left(e^{0.3333333333333333}\right)}^{\cos^{-1} \left(\left(\frac{x}{z} \cdot \sqrt{t}\right) \cdot \color{blue}{\frac{\frac{1}{18}}{y}}\right)}}\right) + \log \left(\sqrt{e^{0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{18 \cdot y}\right)}}\right)
\] |
metadata-eval [=>]98.1 | \[ \log \left(\sqrt{{\left(e^{0.3333333333333333}\right)}^{\cos^{-1} \left(\left(\frac{x}{z} \cdot \sqrt{t}\right) \cdot \frac{\color{blue}{0.05555555555555555}}{y}\right)}}\right) + \log \left(\sqrt{e^{0.3333333333333333 \cdot \cos^{-1} \left(\frac{x}{z} \cdot \frac{\sqrt{t}}{18 \cdot y}\right)}}\right)
\] |
Applied egg-rr100.0%
[Start]98.5 | \[ \log \left(\sqrt{{\left(e^{0.3333333333333333}\right)}^{\cos^{-1} \left(\left(\frac{x}{z} \cdot \sqrt{t}\right) \cdot \frac{0.05555555555555555}{y}\right)}}\right) + \log \left(\sqrt{{\left(e^{0.3333333333333333}\right)}^{\cos^{-1} \left(\left(\frac{x}{z} \cdot \sqrt{t}\right) \cdot \frac{0.05555555555555555}{y}\right)}}\right)
\] |
|---|---|
add-sqr-sqrt [=>]100.0 | \[ \color{blue}{\sqrt{\log \left(\sqrt{{\left(e^{0.3333333333333333}\right)}^{\cos^{-1} \left(\left(\frac{x}{z} \cdot \sqrt{t}\right) \cdot \frac{0.05555555555555555}{y}\right)}}\right)} \cdot \sqrt{\log \left(\sqrt{{\left(e^{0.3333333333333333}\right)}^{\cos^{-1} \left(\left(\frac{x}{z} \cdot \sqrt{t}\right) \cdot \frac{0.05555555555555555}{y}\right)}}\right)}} + \log \left(\sqrt{{\left(e^{0.3333333333333333}\right)}^{\cos^{-1} \left(\left(\frac{x}{z} \cdot \sqrt{t}\right) \cdot \frac{0.05555555555555555}{y}\right)}}\right)
\] |
pow2 [=>]100.0 | \[ \color{blue}{{\left(\sqrt{\log \left(\sqrt{{\left(e^{0.3333333333333333}\right)}^{\cos^{-1} \left(\left(\frac{x}{z} \cdot \sqrt{t}\right) \cdot \frac{0.05555555555555555}{y}\right)}}\right)}\right)}^{2}} + \log \left(\sqrt{{\left(e^{0.3333333333333333}\right)}^{\cos^{-1} \left(\left(\frac{x}{z} \cdot \sqrt{t}\right) \cdot \frac{0.05555555555555555}{y}\right)}}\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 32832 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.5% |
| Cost | 26432 |
| Alternative 3 | |
|---|---|
| Accuracy | 97.0% |
| Cost | 13504 |
herbie shell --seed 2023157
(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)))))