UniformSampleCone, z

Percentage Accurate: 99.9% → 99.9%
Time: 4.5s
Alternatives: 4
Speedup: 7.0×

Specification

?
\[\left(1 - ux\right) + ux \cdot maxCos \]

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 4 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: 99.9% accurate, 1.0× speedup?

\[1 + ux \cdot \left(maxCos + -1\right) \]
Derivation
  1. Initial program 99.9%

    \[\left(1 - ux\right) + ux \cdot maxCos \]
  2. Step-by-step derivation
    1. associate-+l-100.0%

      \[\leadsto \color{blue}{1 - \left(ux - ux \cdot maxCos\right)} \]
    2. *-un-lft-identity100.0%

      \[\leadsto 1 - \left(\color{blue}{1 \cdot ux} - ux \cdot maxCos\right) \]
    3. *-commutative100.0%

      \[\leadsto 1 - \left(1 \cdot ux - \color{blue}{maxCos \cdot ux}\right) \]
    4. distribute-rgt-out--100.0%

      \[\leadsto 1 - \color{blue}{ux \cdot \left(1 - maxCos\right)} \]
  3. Applied egg-rr100.0%

    \[\leadsto \color{blue}{1 - ux \cdot \left(1 - maxCos\right)} \]
  4. Final simplification100.0%

    \[\leadsto 1 + ux \cdot \left(maxCos + -1\right) \]

Alternative 2: 99.9% accurate, 1.0× speedup?

\[\left(1 - ux\right) + ux \cdot maxCos \]
Derivation
  1. Initial program 99.9%

    \[\left(1 - ux\right) + ux \cdot maxCos \]
  2. Final simplification99.9%

    \[\leadsto \left(1 - ux\right) + ux \cdot maxCos \]

Alternative 3: 98.2% accurate, 2.3× speedup?

\[1 - ux \]
Derivation
  1. Initial program 99.9%

    \[\left(1 - ux\right) + ux \cdot maxCos \]
  2. Taylor expanded in maxCos around 0 98.7%

    \[\leadsto \color{blue}{1 - ux} \]
  3. Final simplification98.7%

    \[\leadsto 1 - ux \]

Alternative 4: 71.4% accurate, 7.0× speedup?

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

    \[\left(1 - ux\right) + ux \cdot maxCos \]
  2. Taylor expanded in ux around 0 72.7%

    \[\leadsto \color{blue}{1} \]
  3. Final simplification72.7%

    \[\leadsto 1 \]

Reproduce

?
herbie shell --seed 2023167 
(FPCore (ux uy maxCos)
  :name "UniformSampleCone, z"
  :precision binary32
  :pre (and (and (and (<= 2.328306437e-10 ux) (<= ux 1.0)) (and (<= 2.328306437e-10 uy) (<= uy 1.0))) (and (<= 0.0 maxCos) (<= maxCos 1.0)))
  (+ (- 1.0 ux) (* ux maxCos)))