Given's Rotation SVD example, simplified

?

Percentage Accurate: 75.9% → 99.9%
Time: 11.7s
Precision: binary64
Cost: 40516

?

\[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
\[\begin{array}{l} t_0 := 0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\ \mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.0002:\\ \;\;\;\;{x}^{4} \cdot -0.0859375 + x \cdot \left(x \cdot 0.125\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0.25}{t_0} - \frac{\frac{0.25}{\mathsf{fma}\left(x, x, 1\right)}}{t_0}}{1 + \sqrt{t_0}}\\ \end{array} \]
(FPCore (x)
 :precision binary64
 (- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (+ 0.5 (/ 0.5 (hypot 1.0 x)))))
   (if (<= (hypot 1.0 x) 1.0002)
     (+ (* (pow x 4.0) -0.0859375) (* x (* x 0.125)))
     (/ (- (/ 0.25 t_0) (/ (/ 0.25 (fma x x 1.0)) t_0)) (+ 1.0 (sqrt t_0))))))
double code(double x) {
	return 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))));
}
double code(double x) {
	double t_0 = 0.5 + (0.5 / hypot(1.0, x));
	double tmp;
	if (hypot(1.0, x) <= 1.0002) {
		tmp = (pow(x, 4.0) * -0.0859375) + (x * (x * 0.125));
	} else {
		tmp = ((0.25 / t_0) - ((0.25 / fma(x, x, 1.0)) / t_0)) / (1.0 + sqrt(t_0));
	}
	return tmp;
}
function code(x)
	return Float64(1.0 - sqrt(Float64(0.5 * Float64(1.0 + Float64(1.0 / hypot(1.0, x))))))
end
function code(x)
	t_0 = Float64(0.5 + Float64(0.5 / hypot(1.0, x)))
	tmp = 0.0
	if (hypot(1.0, x) <= 1.0002)
		tmp = Float64(Float64((x ^ 4.0) * -0.0859375) + Float64(x * Float64(x * 0.125)));
	else
		tmp = Float64(Float64(Float64(0.25 / t_0) - Float64(Float64(0.25 / fma(x, x, 1.0)) / t_0)) / Float64(1.0 + sqrt(t_0)));
	end
	return tmp
end
code[x_] := N[(1.0 - N[Sqrt[N[(0.5 * N[(1.0 + N[(1.0 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision], 1.0002], N[(N[(N[Power[x, 4.0], $MachinePrecision] * -0.0859375), $MachinePrecision] + N[(x * N[(x * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.25 / t$95$0), $MachinePrecision] - N[(N[(0.25 / N[(x * x + 1.0), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\begin{array}{l}
t_0 := 0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.0002:\\
\;\;\;\;{x}^{4} \cdot -0.0859375 + x \cdot \left(x \cdot 0.125\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.25}{t_0} - \frac{\frac{0.25}{\mathsf{fma}\left(x, x, 1\right)}}{t_0}}{1 + \sqrt{t_0}}\\


\end{array}

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 13 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

Derivation?

  1. Split input into 2 regimes
  2. if (hypot.f64 1 x) < 1.0002

    1. Initial program 48.0%

      \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
    2. Simplified48.0%

      \[\leadsto \color{blue}{1 - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
      Step-by-step derivation

      [Start]48.0%

      \[ 1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]

      distribute-lft-in [=>]48.0%

      \[ 1 - \sqrt{\color{blue}{0.5 \cdot 1 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, x\right)}}} \]

      metadata-eval [=>]48.0%

      \[ 1 - \sqrt{\color{blue}{0.5} + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, x\right)}} \]

      associate-*r/ [=>]48.0%

      \[ 1 - \sqrt{0.5 + \color{blue}{\frac{0.5 \cdot 1}{\mathsf{hypot}\left(1, x\right)}}} \]

      metadata-eval [=>]48.0%

      \[ 1 - \sqrt{0.5 + \frac{\color{blue}{0.5}}{\mathsf{hypot}\left(1, x\right)}} \]
    3. Applied egg-rr48.1%

      \[\leadsto \color{blue}{\frac{0.5 - \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}} \]
      Step-by-step derivation

      [Start]48.0%

      \[ 1 - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}} \]

      flip-- [=>]48.0%

      \[ \color{blue}{\frac{1 \cdot 1 - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}} \cdot \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}} \]

      metadata-eval [=>]48.0%

      \[ \frac{\color{blue}{1} - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}} \cdot \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      add-sqr-sqrt [<=]48.1%

      \[ \frac{1 - \color{blue}{\left(0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\right)}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      associate--r+ [=>]48.1%

      \[ \frac{\color{blue}{\left(1 - 0.5\right) - \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      metadata-eval [=>]48.1%

      \[ \frac{\color{blue}{0.5} - \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{0.125 \cdot {x}^{2} + -0.0859375 \cdot {x}^{4}} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{4}, -0.0859375, \left(x \cdot x\right) \cdot 0.125\right)} \]
      Step-by-step derivation

      [Start]100.0%

      \[ 0.125 \cdot {x}^{2} + -0.0859375 \cdot {x}^{4} \]

      +-commutative [=>]100.0%

      \[ \color{blue}{-0.0859375 \cdot {x}^{4} + 0.125 \cdot {x}^{2}} \]

      *-commutative [=>]100.0%

      \[ \color{blue}{{x}^{4} \cdot -0.0859375} + 0.125 \cdot {x}^{2} \]

      fma-def [=>]100.0%

      \[ \color{blue}{\mathsf{fma}\left({x}^{4}, -0.0859375, 0.125 \cdot {x}^{2}\right)} \]

      *-commutative [=>]100.0%

      \[ \mathsf{fma}\left({x}^{4}, -0.0859375, \color{blue}{{x}^{2} \cdot 0.125}\right) \]

      unpow2 [=>]100.0%

      \[ \mathsf{fma}\left({x}^{4}, -0.0859375, \color{blue}{\left(x \cdot x\right)} \cdot 0.125\right) \]
    6. Applied egg-rr100.0%

      \[\leadsto \color{blue}{{x}^{4} \cdot -0.0859375 + x \cdot \left(x \cdot 0.125\right)} \]
      Step-by-step derivation

      [Start]100.0%

      \[ \mathsf{fma}\left({x}^{4}, -0.0859375, \left(x \cdot x\right) \cdot 0.125\right) \]

      fma-udef [=>]100.0%

      \[ \color{blue}{{x}^{4} \cdot -0.0859375 + \left(x \cdot x\right) \cdot 0.125} \]

      associate-*l* [=>]100.0%

      \[ {x}^{4} \cdot -0.0859375 + \color{blue}{x \cdot \left(x \cdot 0.125\right)} \]

    if 1.0002 < (hypot.f64 1 x)

    1. Initial program 98.3%

      \[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]
    2. Simplified98.3%

      \[\leadsto \color{blue}{1 - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
      Step-by-step derivation

      [Start]98.3%

      \[ 1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)} \]

      distribute-lft-in [=>]98.3%

      \[ 1 - \sqrt{\color{blue}{0.5 \cdot 1 + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, x\right)}}} \]

      metadata-eval [=>]98.3%

      \[ 1 - \sqrt{\color{blue}{0.5} + 0.5 \cdot \frac{1}{\mathsf{hypot}\left(1, x\right)}} \]

      associate-*r/ [=>]98.3%

      \[ 1 - \sqrt{0.5 + \color{blue}{\frac{0.5 \cdot 1}{\mathsf{hypot}\left(1, x\right)}}} \]

      metadata-eval [=>]98.3%

      \[ 1 - \sqrt{0.5 + \frac{\color{blue}{0.5}}{\mathsf{hypot}\left(1, x\right)}} \]
    3. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\frac{0.5 - \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}} \]
      Step-by-step derivation

      [Start]98.3%

      \[ 1 - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}} \]

      flip-- [=>]98.4%

      \[ \color{blue}{\frac{1 \cdot 1 - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}} \cdot \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}} \]

      metadata-eval [=>]98.4%

      \[ \frac{\color{blue}{1} - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}} \cdot \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      add-sqr-sqrt [<=]99.8%

      \[ \frac{1 - \color{blue}{\left(0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\right)}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      associate--r+ [=>]99.9%

      \[ \frac{\color{blue}{\left(1 - 0.5\right) - \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      metadata-eval [=>]99.9%

      \[ \frac{\color{blue}{0.5} - \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
    4. Applied egg-rr99.9%

      \[\leadsto \frac{\color{blue}{\left(0.25 - \frac{0.25}{1 + x \cdot x}\right) \cdot \frac{1}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
      Step-by-step derivation

      [Start]99.9%

      \[ \frac{0.5 - \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      flip-- [=>]99.8%

      \[ \frac{\color{blue}{\frac{0.5 \cdot 0.5 - \frac{0.5}{\mathsf{hypot}\left(1, x\right)} \cdot \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      div-inv [=>]99.8%

      \[ \frac{\color{blue}{\left(0.5 \cdot 0.5 - \frac{0.5}{\mathsf{hypot}\left(1, x\right)} \cdot \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\right) \cdot \frac{1}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      metadata-eval [=>]99.8%

      \[ \frac{\left(\color{blue}{0.25} - \frac{0.5}{\mathsf{hypot}\left(1, x\right)} \cdot \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\right) \cdot \frac{1}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      frac-times [=>]99.9%

      \[ \frac{\left(0.25 - \color{blue}{\frac{0.5 \cdot 0.5}{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}}\right) \cdot \frac{1}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      metadata-eval [=>]99.9%

      \[ \frac{\left(0.25 - \frac{\color{blue}{0.25}}{\mathsf{hypot}\left(1, x\right) \cdot \mathsf{hypot}\left(1, x\right)}\right) \cdot \frac{1}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      hypot-udef [=>]99.9%

      \[ \frac{\left(0.25 - \frac{0.25}{\color{blue}{\sqrt{1 \cdot 1 + x \cdot x}} \cdot \mathsf{hypot}\left(1, x\right)}\right) \cdot \frac{1}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      hypot-udef [=>]99.9%

      \[ \frac{\left(0.25 - \frac{0.25}{\sqrt{1 \cdot 1 + x \cdot x} \cdot \color{blue}{\sqrt{1 \cdot 1 + x \cdot x}}}\right) \cdot \frac{1}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      add-sqr-sqrt [<=]99.9%

      \[ \frac{\left(0.25 - \frac{0.25}{\color{blue}{1 \cdot 1 + x \cdot x}}\right) \cdot \frac{1}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      metadata-eval [=>]99.9%

      \[ \frac{\left(0.25 - \frac{0.25}{\color{blue}{1} + x \cdot x}\right) \cdot \frac{1}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
    5. Simplified99.9%

      \[\leadsto \frac{\color{blue}{\frac{0.25 - \frac{0.25}{x \cdot x + 1}}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
      Step-by-step derivation

      [Start]99.9%

      \[ \frac{\left(0.25 - \frac{0.25}{1 + x \cdot x}\right) \cdot \frac{1}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      associate-*r/ [=>]99.9%

      \[ \frac{\color{blue}{\frac{\left(0.25 - \frac{0.25}{1 + x \cdot x}\right) \cdot 1}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      *-rgt-identity [=>]99.9%

      \[ \frac{\frac{\color{blue}{0.25 - \frac{0.25}{1 + x \cdot x}}}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      /-rgt-identity [<=]99.9%

      \[ \frac{\frac{\color{blue}{\frac{0.25 - \frac{0.25}{1 + x \cdot x}}{1}}}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      /-rgt-identity [=>]99.9%

      \[ \frac{\frac{\color{blue}{0.25 - \frac{0.25}{1 + x \cdot x}}}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      unpow2 [<=]99.9%

      \[ \frac{\frac{0.25 - \frac{0.25}{1 + \color{blue}{{x}^{2}}}}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      +-commutative [=>]99.9%

      \[ \frac{\frac{0.25 - \frac{0.25}{\color{blue}{{x}^{2} + 1}}}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      unpow2 [=>]99.9%

      \[ \frac{\frac{0.25 - \frac{0.25}{\color{blue}{x \cdot x} + 1}}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
    6. Applied egg-rr99.9%

      \[\leadsto \frac{\color{blue}{\frac{0.25}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}} - \frac{\frac{0.25}{\mathsf{fma}\left(x, x, 1\right)}}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
      Step-by-step derivation

      [Start]99.9%

      \[ \frac{\frac{0.25 - \frac{0.25}{x \cdot x + 1}}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      div-sub [=>]99.9%

      \[ \frac{\color{blue}{\frac{0.25}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}} - \frac{\frac{0.25}{x \cdot x + 1}}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]

      fma-def [=>]99.9%

      \[ \frac{\frac{0.25}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}} - \frac{\frac{0.25}{\color{blue}{\mathsf{fma}\left(x, x, 1\right)}}}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification100.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.0002:\\ \;\;\;\;{x}^{4} \cdot -0.0859375 + x \cdot \left(x \cdot 0.125\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0.25}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}} - \frac{\frac{0.25}{\mathsf{fma}\left(x, x, 1\right)}}{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy99.9%
Cost40516
\[\begin{array}{l} t_0 := 0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\ \mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.0002:\\ \;\;\;\;{x}^{4} \cdot -0.0859375 + x \cdot \left(x \cdot 0.125\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0.25}{t_0} - \frac{\frac{0.25}{\mathsf{fma}\left(x, x, 1\right)}}{t_0}}{1 + \sqrt{t_0}}\\ \end{array} \]
Alternative 2
Accuracy99.9%
Cost40132
\[\begin{array}{l} t_0 := 1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}\\ \mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.0002:\\ \;\;\;\;{x}^{4} \cdot -0.0859375 + x \cdot \left(x \cdot 0.125\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{t_0} - \frac{0.5}{\mathsf{hypot}\left(1, x\right) \cdot t_0}\\ \end{array} \]
Alternative 3
Accuracy99.9%
Cost26756
\[\begin{array}{l} t_0 := \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\ \mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.0002:\\ \;\;\;\;{x}^{4} \cdot -0.0859375 + x \cdot \left(x \cdot 0.125\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 - t_0}{1 + \sqrt{0.5 + t_0}}\\ \end{array} \]
Alternative 4
Accuracy99.1%
Cost13956
\[\begin{array}{l} t_0 := 0.5 + \frac{-0.5}{x}\\ \mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 2:\\ \;\;\;\;{x}^{4} \cdot -0.0859375 + x \cdot \left(x \cdot 0.125\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1 - t_0}{1 + \sqrt{t_0}}\\ \end{array} \]
Alternative 5
Accuracy99.1%
Cost13828
\[\begin{array}{l} \mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 2:\\ \;\;\;\;{x}^{4} \cdot -0.0859375 + x \cdot \left(x \cdot 0.125\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 + \frac{0.5}{x}}{1 + \sqrt{0.5 + \frac{-0.5}{x}}}\\ \end{array} \]
Alternative 6
Accuracy98.7%
Cost13636
\[\begin{array}{l} \mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 2:\\ \;\;\;\;{x}^{4} \cdot -0.0859375 + x \cdot \left(x \cdot 0.125\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\ \end{array} \]
Alternative 7
Accuracy98.5%
Cost13316
\[\begin{array}{l} \mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 2:\\ \;\;\;\;0.125 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\ \end{array} \]
Alternative 8
Accuracy97.7%
Cost6857
\[\begin{array}{l} \mathbf{if}\;x \leq -1.52 \lor \neg \left(x \leq 1.5\right):\\ \;\;\;\;1 - \sqrt{0.5}\\ \mathbf{else}:\\ \;\;\;\;0.125 \cdot \left(x \cdot x\right)\\ \end{array} \]
Alternative 9
Accuracy60.8%
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -1.42:\\ \;\;\;\;0.25\\ \mathbf{elif}\;x \leq 1.75:\\ \;\;\;\;0.125 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 - \frac{-0.5}{x}}{2}\\ \end{array} \]
Alternative 10
Accuracy60.8%
Cost712
\[\begin{array}{l} \mathbf{if}\;x \leq -1.78:\\ \;\;\;\;\frac{0.5 - \frac{0.5}{x}}{2}\\ \mathbf{elif}\;x \leq 1.75:\\ \;\;\;\;0.125 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5 - \frac{-0.5}{x}}{2}\\ \end{array} \]
Alternative 11
Accuracy60.8%
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.42:\\ \;\;\;\;0.25\\ \mathbf{elif}\;x \leq 1.4:\\ \;\;\;\;0.125 \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;0.25\\ \end{array} \]
Alternative 12
Accuracy37.7%
Cost328
\[\begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{-77}:\\ \;\;\;\;0.25\\ \mathbf{elif}\;x \leq 2.15 \cdot 10^{-77}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;0.25\\ \end{array} \]
Alternative 13
Accuracy27.4%
Cost64
\[0 \]

Reproduce?

herbie shell --seed 2023165 
(FPCore (x)
  :name "Given's Rotation SVD example, simplified"
  :precision binary64
  (- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))