?

Average Accuracy: 52.4% → 100.0%
Time: 2.3s
Precision: binary64
Cost: 6528

?

\[\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(x, x\right)\right)\right) \]
\[\mathsf{hypot.f64}\left(x, x\right) \]
(FPCore (x) :precision binary64 (sqrt.f64 (*.f64 2 (*.f64 x x))))
(FPCore (x) :precision binary64 (hypot.f64 x x))
\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(x, x\right)\right)\right)
\mathsf{hypot.f64}\left(x, x\right)

Error?

Derivation?

  1. Initial program 52.4%

    \[\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(x, x\right)\right)\right) \]
  2. Taylor expanded in x around 0 51.1%

    \[\leadsto \color{blue}{\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(2\right), x\right)} \]
  3. Simplified100.0%

    \[\leadsto \color{blue}{\mathsf{hypot.f64}\left(x, x\right)} \]
    Proof

    [Start]51.1

    \[ \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(2\right), x\right) \]

    *-commutative [=>]51.1

    \[ \color{blue}{\mathsf{*.f64}\left(x, \mathsf{sqrt.f64}\left(2\right)\right)} \]

    rem-square-sqrt [<=]49.8

    \[ \color{blue}{\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(x, \mathsf{sqrt.f64}\left(2\right)\right)\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(x, \mathsf{sqrt.f64}\left(2\right)\right)\right)\right)} \]

    fabs-sqr [<=]49.8

    \[ \color{blue}{\mathsf{fabs.f64}\left(\mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(x, \mathsf{sqrt.f64}\left(2\right)\right)\right), \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(x, \mathsf{sqrt.f64}\left(2\right)\right)\right)\right)\right)} \]

    rem-square-sqrt [=>]99.3

    \[ \mathsf{fabs.f64}\left(\color{blue}{\mathsf{*.f64}\left(x, \mathsf{sqrt.f64}\left(2\right)\right)}\right) \]

    rem-sqrt-square [<=]52.2

    \[ \color{blue}{\mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, \mathsf{sqrt.f64}\left(2\right)\right), \mathsf{*.f64}\left(x, \mathsf{sqrt.f64}\left(2\right)\right)\right)\right)} \]

    swap-sqr [=>]52.0

    \[ \mathsf{sqrt.f64}\left(\color{blue}{\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(2\right), \mathsf{sqrt.f64}\left(2\right)\right)\right)}\right) \]

    rem-square-sqrt [=>]52.4

    \[ \mathsf{sqrt.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(x, x\right), \color{blue}{2}\right)\right) \]

    *-commutative [<=]52.4

    \[ \mathsf{sqrt.f64}\left(\color{blue}{\mathsf{*.f64}\left(2, \mathsf{*.f64}\left(x, x\right)\right)}\right) \]

    count-2 [<=]52.4

    \[ \mathsf{sqrt.f64}\left(\color{blue}{\mathsf{+.f64}\left(\mathsf{*.f64}\left(x, x\right), \mathsf{*.f64}\left(x, x\right)\right)}\right) \]

    hypot-def [=>]100.0

    \[ \color{blue}{\mathsf{hypot.f64}\left(x, x\right)} \]
  4. Final simplification100.0%

    \[\leadsto \mathsf{hypot.f64}\left(x, x\right) \]

Reproduce?

herbie shell --seed 2023144 
(FPCore (x)
  :name "sqrt C (should all be same)"
  :precision binary64
  (sqrt (* 2.0 (* x x))))