Diagrams.ThreeD.Transform:aboutY from diagrams-lib-1.3.0.3

Percentage Accurate: 99.8% → 99.8%
Time: 6.2s
Alternatives: 8
Speedup: TODO×

Specification

?
\[x \cdot \cos y + z \cdot \sin y \]

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

Alternative 1?

\[x \cdot \cos y + z \cdot \sin y \]
Derivation
  1. Initial program 99.9%

    \[x \cdot \cos y + z \cdot \sin y \]
  2. Final simplification99.9%

    \[\leadsto x \cdot \cos y + z \cdot \sin y \]

Alternative 2?

\[\begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{+69} \lor \neg \left(x \leq 1.16 \cdot 10^{+76}\right):\\ \;\;\;\;x \cdot \cos y + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\sin y, z, x\right)\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if x < -3.49999999999999987e69 or 1.1599999999999999e76 < x

    1. Initial program 99.8%

      \[x \cdot \cos y + z \cdot \sin y \]
    2. Taylor expanded in y around 0 83.0%

      \[\leadsto x \cdot \cos y + \color{blue}{y \cdot z} \]

    if -3.49999999999999987e69 < x < 1.1599999999999999e76

    1. Initial program 99.9%

      \[x \cdot \cos y + z \cdot \sin y \]
    2. Taylor expanded in y around 0 87.0%

      \[\leadsto \color{blue}{x} + z \cdot \sin y \]
    3. Step-by-step derivation
      1. +-commutative87.0%

        \[\leadsto \color{blue}{z \cdot \sin y + x} \]
      2. *-commutative87.0%

        \[\leadsto \color{blue}{\sin y \cdot z} + x \]
      3. fma-def87.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sin y, z, x\right)} \]
    4. Applied egg-rr87.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sin y, z, x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -3.5 \cdot 10^{+69} \lor \neg \left(x \leq 1.16 \cdot 10^{+76}\right):\\ \;\;\;\;x \cdot \cos y + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\sin y, z, x\right)\\ \end{array} \]

Alternative 3?

\[\begin{array}{l} \mathbf{if}\;x \leq -6.6 \cdot 10^{+68} \lor \neg \left(x \leq 6.2 \cdot 10^{+74}\right):\\ \;\;\;\;x \cdot \cos y + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \sin y\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if x < -6.6000000000000001e68 or 6.20000000000000043e74 < x

    1. Initial program 99.8%

      \[x \cdot \cos y + z \cdot \sin y \]
    2. Taylor expanded in y around 0 83.0%

      \[\leadsto x \cdot \cos y + \color{blue}{y \cdot z} \]

    if -6.6000000000000001e68 < x < 6.20000000000000043e74

    1. Initial program 99.9%

      \[x \cdot \cos y + z \cdot \sin y \]
    2. Taylor expanded in y around 0 87.0%

      \[\leadsto \color{blue}{x} + z \cdot \sin y \]
  3. Recombined 2 regimes into one program.
  4. Final simplification85.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -6.6 \cdot 10^{+68} \lor \neg \left(x \leq 6.2 \cdot 10^{+74}\right):\\ \;\;\;\;x \cdot \cos y + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \sin y\\ \end{array} \]

Alternative 4?

\[\begin{array}{l} \mathbf{if}\;y \leq -0.015 \lor \neg \left(y \leq 0.061\right):\\ \;\;\;\;z \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;y \cdot z + \left(x + \left(x \cdot y\right) \cdot \left(y \cdot -0.5\right)\right)\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if y < -0.014999999999999999 or 0.060999999999999999 < y

    1. Initial program 99.7%

      \[x \cdot \cos y + z \cdot \sin y \]
    2. Taylor expanded in y around 0 52.4%

      \[\leadsto \color{blue}{x} + z \cdot \sin y \]
    3. Step-by-step derivation
      1. +-commutative52.4%

        \[\leadsto \color{blue}{z \cdot \sin y + x} \]
      2. *-commutative52.4%

        \[\leadsto \color{blue}{\sin y \cdot z} + x \]
      3. fma-def52.4%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sin y, z, x\right)} \]
    4. Applied egg-rr52.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sin y, z, x\right)} \]
    5. Taylor expanded in z around inf 48.3%

      \[\leadsto \color{blue}{z \cdot \sin y} \]

    if -0.014999999999999999 < y < 0.060999999999999999

    1. Initial program 100.0%

      \[x \cdot \cos y + z \cdot \sin y \]
    2. Taylor expanded in y around 0 100.0%

      \[\leadsto x \cdot \cos y + \color{blue}{y \cdot z} \]
    3. Taylor expanded in y around 0 99.7%

      \[\leadsto \color{blue}{\left(-0.5 \cdot \left({y}^{2} \cdot x\right) + x\right)} + y \cdot z \]
    4. Step-by-step derivation
      1. associate-*r*99.7%

        \[\leadsto \left(\color{blue}{\left(-0.5 \cdot {y}^{2}\right) \cdot x} + x\right) + y \cdot z \]
      2. *-commutative99.7%

        \[\leadsto \left(\color{blue}{x \cdot \left(-0.5 \cdot {y}^{2}\right)} + x\right) + y \cdot z \]
      3. fma-def99.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, -0.5 \cdot {y}^{2}, x\right)} + y \cdot z \]
      4. *-commutative99.7%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{{y}^{2} \cdot -0.5}, x\right) + y \cdot z \]
      5. unpow299.7%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(y \cdot y\right)} \cdot -0.5, x\right) + y \cdot z \]
      6. associate-*l*99.7%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{y \cdot \left(y \cdot -0.5\right)}, x\right) + y \cdot z \]
    5. Simplified99.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y \cdot \left(y \cdot -0.5\right), x\right)} + y \cdot z \]
    6. Step-by-step derivation
      1. fma-udef99.7%

        \[\leadsto \color{blue}{\left(x \cdot \left(y \cdot \left(y \cdot -0.5\right)\right) + x\right)} + y \cdot z \]
      2. associate-*r*99.7%

        \[\leadsto \left(\color{blue}{\left(x \cdot y\right) \cdot \left(y \cdot -0.5\right)} + x\right) + y \cdot z \]
    7. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\left(\left(x \cdot y\right) \cdot \left(y \cdot -0.5\right) + x\right)} + y \cdot z \]
  3. Recombined 2 regimes into one program.
  4. Final simplification76.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -0.015 \lor \neg \left(y \leq 0.061\right):\\ \;\;\;\;z \cdot \sin y\\ \mathbf{else}:\\ \;\;\;\;y \cdot z + \left(x + \left(x \cdot y\right) \cdot \left(y \cdot -0.5\right)\right)\\ \end{array} \]

Alternative 5?

\[x + z \cdot \sin y \]
Derivation
  1. Initial program 99.9%

    \[x \cdot \cos y + z \cdot \sin y \]
  2. Taylor expanded in y around 0 77.8%

    \[\leadsto \color{blue}{x} + z \cdot \sin y \]
  3. Final simplification77.8%

    \[\leadsto x + z \cdot \sin y \]

Alternative 6?

\[\begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{+65}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+208}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if z < -7.0000000000000002e65 or 7.20000000000000005e208 < z

    1. Initial program 99.8%

      \[x \cdot \cos y + z \cdot \sin y \]
    2. Taylor expanded in y around 0 88.9%

      \[\leadsto \color{blue}{x} + z \cdot \sin y \]
    3. Taylor expanded in y around 0 51.4%

      \[\leadsto \color{blue}{y \cdot z + x} \]
    4. Taylor expanded in y around inf 43.2%

      \[\leadsto \color{blue}{y \cdot z} \]

    if -7.0000000000000002e65 < z < 7.20000000000000005e208

    1. Initial program 99.9%

      \[x \cdot \cos y + z \cdot \sin y \]
    2. Taylor expanded in y around 0 73.9%

      \[\leadsto \color{blue}{x} + z \cdot \sin y \]
    3. Taylor expanded in x around inf 51.9%

      \[\leadsto \color{blue}{x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification49.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -7 \cdot 10^{+65}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+208}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]

Alternative 7?

\[x + y \cdot z \]
Derivation
  1. Initial program 99.9%

    \[x \cdot \cos y + z \cdot \sin y \]
  2. Taylor expanded in y around 0 77.8%

    \[\leadsto \color{blue}{x} + z \cdot \sin y \]
  3. Taylor expanded in y around 0 57.3%

    \[\leadsto \color{blue}{y \cdot z + x} \]
  4. Final simplification57.3%

    \[\leadsto x + y \cdot z \]

Alternative 8?

\[x \]
Derivation
  1. Initial program 99.9%

    \[x \cdot \cos y + z \cdot \sin y \]
  2. Taylor expanded in y around 0 77.8%

    \[\leadsto \color{blue}{x} + z \cdot \sin y \]
  3. Taylor expanded in x around inf 41.4%

    \[\leadsto \color{blue}{x} \]
  4. Final simplification41.4%

    \[\leadsto x \]

Reproduce

?
herbie shell --seed 2023166 
(FPCore (x y z)
  :name "Diagrams.ThreeD.Transform:aboutY from diagrams-lib-1.3.0.3"
  :precision binary64
  (+ (* x (cos y)) (* z (sin y))))