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

Percentage Accurate: 70.0% → 76.6%
Time: 17.9s
Alternatives: 5
Speedup: TODO×

Specification

?
\[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]

Your Program's Arguments

Results

Enter valid numbers for all inputs

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.

Accuracy vs Speed?

Herbie found 5 alternatives:

AlternativeAccuracySpeedup
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.

Target

Original70.0%
Target74.3%
Herbie76.6%
\[\begin{array}{l} \mathbf{if}\;z < -1.3793337487235141 \cdot 10^{+129}:\\ \;\;\;\;\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(\frac{1}{y} - \frac{\frac{0.3333333333333333}{z}}{t}\right) - \frac{\frac{a}{3}}{b}\\ \mathbf{elif}\;z < 3.516290613555987 \cdot 10^{+106}:\\ \;\;\;\;\left(\sqrt{x} \cdot 2\right) \cdot \cos \left(y - \frac{t}{3} \cdot z\right) - \frac{\frac{a}{3}}{b}\\ \mathbf{else}:\\ \;\;\;\;\cos \left(y - \frac{\frac{0.3333333333333333}{z}}{t}\right) \cdot \left(2 \cdot \sqrt{x}\right) - \frac{\frac{a}{b}}{3}\\ \end{array} \]

Alternative 1?

\[\left(2 \cdot \sqrt{x}\right) \cdot \cos y - \frac{a}{b \cdot 3} \]
Derivation
  1. Initial program 70.7%

    \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
  2. Taylor expanded in z around 0 79.6%

    \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\cos y} - \frac{a}{b \cdot 3} \]
  3. Final simplification79.6%

    \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \cos y - \frac{a}{b \cdot 3} \]

Alternative 2?

\[\begin{array}{l} t_1 := \frac{a}{b \cdot 3}\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{-94} \lor \neg \left(t_1 \leq 2 \cdot 10^{-96}\right):\\ \;\;\;\;2 \cdot \sqrt{x} - t_1\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot \left(2 \cdot \cos y\right)\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 a (*.f64 b 3)) < -9.9999999999999996e-95 or 1.9999999999999998e-96 < (/.f64 a (*.f64 b 3))

    1. Initial program 79.6%

      \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
    2. Taylor expanded in z around 0 92.9%

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\cos y} - \frac{a}{b \cdot 3} \]
    3. Taylor expanded in y around 0 88.5%

      \[\leadsto \color{blue}{2 \cdot \sqrt{x}} - \frac{a}{b \cdot 3} \]

    if -9.9999999999999996e-95 < (/.f64 a (*.f64 b 3)) < 1.9999999999999998e-96

    1. Initial program 55.7%

      \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
    2. Taylor expanded in z around 0 57.2%

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\cos y} - \frac{a}{b \cdot 3} \]
    3. Step-by-step derivation
      1. *-un-lft-identity57.2%

        \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \cos y - \frac{\color{blue}{1 \cdot a}}{b \cdot 3} \]
      2. times-frac57.2%

        \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \cos y - \color{blue}{\frac{1}{b} \cdot \frac{a}{3}} \]
      3. inv-pow57.2%

        \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \cos y - \color{blue}{{b}^{-1}} \cdot \frac{a}{3} \]
    4. Applied egg-rr57.2%

      \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \cos y - \color{blue}{{b}^{-1} \cdot \frac{a}{3}} \]
    5. Taylor expanded in b around inf 56.9%

      \[\leadsto \color{blue}{2 \cdot \left(\cos y \cdot \sqrt{x}\right)} \]
    6. Step-by-step derivation
      1. associate-*r*56.9%

        \[\leadsto \color{blue}{\left(2 \cdot \cos y\right) \cdot \sqrt{x}} \]
      2. *-commutative56.9%

        \[\leadsto \color{blue}{\sqrt{x} \cdot \left(2 \cdot \cos y\right)} \]
    7. Simplified56.9%

      \[\leadsto \color{blue}{\sqrt{x} \cdot \left(2 \cdot \cos y\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification76.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a}{b \cdot 3} \leq -1 \cdot 10^{-94} \lor \neg \left(\frac{a}{b \cdot 3} \leq 2 \cdot 10^{-96}\right):\\ \;\;\;\;2 \cdot \sqrt{x} - \frac{a}{b \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot \left(2 \cdot \cos y\right)\\ \end{array} \]

Alternative 3?

\[2 \cdot \sqrt{x} - \frac{a}{b \cdot 3} \]
Derivation
  1. Initial program 70.7%

    \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
  2. Taylor expanded in z around 0 79.6%

    \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\cos y} - \frac{a}{b \cdot 3} \]
  3. Taylor expanded in y around 0 69.5%

    \[\leadsto \color{blue}{2 \cdot \sqrt{x}} - \frac{a}{b \cdot 3} \]
  4. Final simplification69.5%

    \[\leadsto 2 \cdot \sqrt{x} - \frac{a}{b \cdot 3} \]

Alternative 4?

\[-0.3333333333333333 \cdot \frac{a}{b} \]
Derivation
  1. Initial program 70.7%

    \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
  2. Taylor expanded in z around 0 79.6%

    \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\cos y} - \frac{a}{b \cdot 3} \]
  3. Taylor expanded in x around 0 53.3%

    \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{a}{b}} \]
  4. Final simplification53.3%

    \[\leadsto -0.3333333333333333 \cdot \frac{a}{b} \]

Alternative 5?

\[\frac{a \cdot -0.3333333333333333}{b} \]
Derivation
  1. Initial program 70.7%

    \[\left(2 \cdot \sqrt{x}\right) \cdot \cos \left(y - \frac{z \cdot t}{3}\right) - \frac{a}{b \cdot 3} \]
  2. Taylor expanded in z around 0 79.6%

    \[\leadsto \left(2 \cdot \sqrt{x}\right) \cdot \color{blue}{\cos y} - \frac{a}{b \cdot 3} \]
  3. Taylor expanded in x around 0 53.3%

    \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{a}{b}} \]
  4. Step-by-step derivation
    1. associate-*r/53.3%

      \[\leadsto \color{blue}{\frac{-0.3333333333333333 \cdot a}{b}} \]
  5. Applied egg-rr53.3%

    \[\leadsto \color{blue}{\frac{-0.3333333333333333 \cdot a}{b}} \]
  6. Final simplification53.3%

    \[\leadsto \frac{a \cdot -0.3333333333333333}{b} \]

Reproduce

?
herbie shell --seed 2023166 
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, K"
  :precision binary64

  :herbie-target
  (if (< z -1.3793337487235141e+129) (- (* (* 2.0 (sqrt x)) (cos (- (/ 1.0 y) (/ (/ 0.3333333333333333 z) t)))) (/ (/ a 3.0) b)) (if (< z 3.516290613555987e+106) (- (* (* (sqrt x) 2.0) (cos (- y (* (/ t 3.0) z)))) (/ (/ a 3.0) b)) (- (* (cos (- y (/ (/ 0.3333333333333333 z) t))) (* 2.0 (sqrt x))) (/ (/ a b) 3.0))))

  (- (* (* 2.0 (sqrt x)) (cos (- y (/ (* z t) 3.0)))) (/ a (* b 3.0))))