Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, D

?

Percentage Accurate: 98.0% → 99.4%
Time: 11.4s
Precision: binary64
Cost: 26432

?

\[ \begin{array}{c}[y, z] = \mathsf{sort}([y, z])\\ \end{array} \]
\[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
\[e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{\sqrt{t} \cdot \frac{x \cdot 0.05555555555555555}{z}}{y}\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
 (+
  (exp
   (log1p
    (*
     0.3333333333333333
     (acos (/ (* (sqrt t) (/ (* x 0.05555555555555555) z)) y)))))
  -1.0))
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 exp(log1p((0.3333333333333333 * acos(((sqrt(t) * ((x * 0.05555555555555555) / z)) / y))))) + -1.0;
}
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.exp(Math.log1p((0.3333333333333333 * Math.acos(((Math.sqrt(t) * ((x * 0.05555555555555555) / z)) / y))))) + -1.0;
}
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.exp(math.log1p((0.3333333333333333 * math.acos(((math.sqrt(t) * ((x * 0.05555555555555555) / z)) / y))))) + -1.0
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(exp(log1p(Float64(0.3333333333333333 * acos(Float64(Float64(sqrt(t) * Float64(Float64(x * 0.05555555555555555) / z)) / y))))) + -1.0)
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[Exp[N[Log[1 + N[(0.3333333333333333 * N[ArcCos[N[(N[(N[Sqrt[t], $MachinePrecision] * N[(N[(x * 0.05555555555555555), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision]
\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right)
e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{\sqrt{t} \cdot \frac{x \cdot 0.05555555555555555}{z}}{y}\right)\right)} + -1

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Herbie found 3 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Bogosity?

Bogosity

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original98.0%
Target98.0%
Herbie99.4%
\[\frac{\cos^{-1} \left(\frac{\frac{x}{27}}{y \cdot z} \cdot \frac{\sqrt{t}}{\frac{2}{3}}\right)}{3} \]

Derivation?

  1. Initial program 97.7%

    \[\frac{1}{3} \cdot \cos^{-1} \left(\frac{3 \cdot \frac{x}{y \cdot 27}}{z \cdot 2} \cdot \sqrt{t}\right) \]
  2. Simplified98.5%

    \[\leadsto \color{blue}{0.3333333333333333 \cdot \cos^{-1} \left(\frac{\sqrt{t}}{y \cdot \left(18 \cdot z\right)} \cdot x\right)} \]
    Step-by-step derivation

    [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) \]

    associate-*l/ [=>]97.7%

    \[ 0.3333333333333333 \cdot \cos^{-1} \color{blue}{\left(\frac{\left(3 \cdot \frac{x}{y \cdot 27}\right) \cdot \sqrt{t}}{z \cdot 2}\right)} \]

    *-commutative [=>]97.7%

    \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{\color{blue}{\left(\frac{x}{y \cdot 27} \cdot 3\right)} \cdot \sqrt{t}}{z \cdot 2}\right) \]

    associate-*l* [=>]97.7%

    \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{\color{blue}{\frac{x}{y \cdot 27} \cdot \left(3 \cdot \sqrt{t}\right)}}{z \cdot 2}\right) \]

    times-frac [=>]97.7%

    \[ 0.3333333333333333 \cdot \cos^{-1} \color{blue}{\left(\frac{\frac{x}{y \cdot 27}}{z} \cdot \frac{3 \cdot \sqrt{t}}{2}\right)} \]

    *-commutative [=>]97.7%

    \[ 0.3333333333333333 \cdot \cos^{-1} \color{blue}{\left(\frac{3 \cdot \sqrt{t}}{2} \cdot \frac{\frac{x}{y \cdot 27}}{z}\right)} \]

    associate-/l/ [=>]98.5%

    \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{3 \cdot \sqrt{t}}{2} \cdot \color{blue}{\frac{x}{z \cdot \left(y \cdot 27\right)}}\right) \]

    associate-*r/ [=>]97.7%

    \[ 0.3333333333333333 \cdot \cos^{-1} \color{blue}{\left(\frac{\frac{3 \cdot \sqrt{t}}{2} \cdot x}{z \cdot \left(y \cdot 27\right)}\right)} \]

    associate-*l/ [<=]98.5%

    \[ 0.3333333333333333 \cdot \cos^{-1} \color{blue}{\left(\frac{\frac{3 \cdot \sqrt{t}}{2}}{z \cdot \left(y \cdot 27\right)} \cdot x\right)} \]
  3. Applied egg-rr98.4%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{\sqrt{t}}{y} \cdot \frac{x}{18 \cdot z}\right)\right)} - 1} \]
    Step-by-step derivation

    [Start]98.5%

    \[ 0.3333333333333333 \cdot \cos^{-1} \left(\frac{\sqrt{t}}{y \cdot \left(18 \cdot z\right)} \cdot x\right) \]

    expm1-log1p-u [=>]98.5%

    \[ \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{\sqrt{t}}{y \cdot \left(18 \cdot z\right)} \cdot x\right)\right)\right)} \]

    expm1-udef [=>]100.0%

    \[ \color{blue}{e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{\sqrt{t}}{y \cdot \left(18 \cdot z\right)} \cdot x\right)\right)} - 1} \]

    associate-*l/ [=>]99.2%

    \[ e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \color{blue}{\left(\frac{\sqrt{t} \cdot x}{y \cdot \left(18 \cdot z\right)}\right)}\right)} - 1 \]

    times-frac [=>]98.4%

    \[ e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \color{blue}{\left(\frac{\sqrt{t}}{y} \cdot \frac{x}{18 \cdot z}\right)}\right)} - 1 \]
  4. Applied egg-rr98.8%

    \[\leadsto e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \color{blue}{\left(\frac{\sqrt{t} \cdot \frac{x \cdot 0.05555555555555555}{z}}{y}\right)}\right)} - 1 \]
    Step-by-step derivation

    [Start]98.4%

    \[ e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{\sqrt{t}}{y} \cdot \frac{x}{18 \cdot z}\right)\right)} - 1 \]

    associate-*l/ [=>]98.8%

    \[ e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \color{blue}{\left(\frac{\sqrt{t} \cdot \frac{x}{18 \cdot z}}{y}\right)}\right)} - 1 \]

    associate-/r* [=>]98.8%

    \[ e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{\sqrt{t} \cdot \color{blue}{\frac{\frac{x}{18}}{z}}}{y}\right)\right)} - 1 \]

    div-inv [=>]98.8%

    \[ e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{\sqrt{t} \cdot \frac{\color{blue}{x \cdot \frac{1}{18}}}{z}}{y}\right)\right)} - 1 \]

    metadata-eval [=>]98.8%

    \[ e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{\sqrt{t} \cdot \frac{x \cdot \color{blue}{0.05555555555555555}}{z}}{y}\right)\right)} - 1 \]
  5. Final simplification98.8%

    \[\leadsto e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{\sqrt{t} \cdot \frac{x \cdot 0.05555555555555555}{z}}{y}\right)\right)} + -1 \]

Alternatives

Alternative 1
Accuracy99.4%
Cost26432
\[e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{\sqrt{t} \cdot \frac{x \cdot 0.05555555555555555}{z}}{y}\right)\right)} + -1 \]
Alternative 2
Accuracy98.5%
Cost26432
\[e^{\mathsf{log1p}\left(0.3333333333333333 \cdot \cos^{-1} \left(\frac{\sqrt{t}}{y} \cdot \frac{x}{z \cdot 18}\right)\right)} + -1 \]
Alternative 3
Accuracy98.0%
Cost13504
\[0.3333333333333333 \cdot \cos^{-1} \left(x \cdot \frac{\sqrt{t}}{y \cdot \left(z \cdot 18\right)}\right) \]

Reproduce?

herbie shell --seed 2023171 
(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)))))