x / sqrt(1 + pow(x, 2))

Percentage Accurate: 99.4% → 99.6%
Time: 2.9s
Alternatives: 7
Speedup: 4.5×

Specification

?
\[1 \leq x \land x \leq 1000\]
\[\begin{array}{l} \\ \frac{x}{\sqrt{1 + {x}^{2}}} \end{array} \]
(FPCore (x) :precision binary64 (/ x (sqrt (+ 1.0 (pow x 2.0)))))
double code(double x) {
	return x / sqrt((1.0 + pow(x, 2.0)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = x / sqrt((1.0d0 + (x ** 2.0d0)))
end function
public static double code(double x) {
	return x / Math.sqrt((1.0 + Math.pow(x, 2.0)));
}
def code(x):
	return x / math.sqrt((1.0 + math.pow(x, 2.0)))
function code(x)
	return Float64(x / sqrt(Float64(1.0 + (x ^ 2.0))))
end
function tmp = code(x)
	tmp = x / sqrt((1.0 + (x ^ 2.0)));
end
code[x_] := N[(x / N[Sqrt[N[(1.0 + N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x}{\sqrt{1 + {x}^{2}}}
\end{array}

Sampling outcomes in binary64 precision:

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

Initial Program: 99.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{x}{\sqrt{1 + {x}^{2}}} \end{array} \]
(FPCore (x) :precision binary64 (/ x (sqrt (+ 1.0 (pow x 2.0)))))
double code(double x) {
	return x / sqrt((1.0 + pow(x, 2.0)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = x / sqrt((1.0d0 + (x ** 2.0d0)))
end function
public static double code(double x) {
	return x / Math.sqrt((1.0 + Math.pow(x, 2.0)));
}
def code(x):
	return x / math.sqrt((1.0 + math.pow(x, 2.0)))
function code(x)
	return Float64(x / sqrt(Float64(1.0 + (x ^ 2.0))))
end
function tmp = code(x)
	tmp = x / sqrt((1.0 + (x ^ 2.0)));
end
code[x_] := N[(x / N[Sqrt[N[(1.0 + N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x}{\sqrt{1 + {x}^{2}}}
\end{array}

Alternative 1: 99.6% accurate, 3.8× speedup?

\[\begin{array}{l} \\ \sqrt{\frac{x}{\mathsf{fma}\left(x, x, 1\right)} \cdot x} \end{array} \]
(FPCore (x) :precision binary64 (sqrt (* (/ x (fma x x 1.0)) x)))
double code(double x) {
	return sqrt(((x / fma(x, x, 1.0)) * x));
}
function code(x)
	return sqrt(Float64(Float64(x / fma(x, x, 1.0)) * x))
end
code[x_] := N[Sqrt[N[(N[(x / N[(x * x + 1.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
\sqrt{\frac{x}{\mathsf{fma}\left(x, x, 1\right)} \cdot x}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\frac{x}{\sqrt{1 + {x}^{2}}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \frac{x}{\sqrt{\color{blue}{1 + {x}^{2}}}} \]
    2. +-commutativeN/A

      \[\leadsto \frac{x}{\sqrt{\color{blue}{{x}^{2} + 1}}} \]
    3. lift-pow.f64N/A

      \[\leadsto \frac{x}{\sqrt{\color{blue}{{x}^{2}} + 1}} \]
    4. unpow2N/A

      \[\leadsto \frac{x}{\sqrt{\color{blue}{x \cdot x} + 1}} \]
    5. lower-fma.f6499.5

      \[\leadsto \frac{x}{\sqrt{\color{blue}{\mathsf{fma}\left(x, x, 1\right)}}} \]
  4. Applied rewrites99.5%

    \[\leadsto \frac{x}{\sqrt{\color{blue}{\mathsf{fma}\left(x, x, 1\right)}}} \]
  5. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{x}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}}} \]
    2. rem-square-sqrtN/A

      \[\leadsto \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}} \]
    3. sqrt-unprodN/A

      \[\leadsto \frac{\color{blue}{\sqrt{x \cdot x}}}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{\sqrt{\color{blue}{x \cdot x}}}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}} \]
    5. lift-sqrt.f64N/A

      \[\leadsto \frac{\sqrt{x \cdot x}}{\color{blue}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}}} \]
    6. sqrt-divN/A

      \[\leadsto \color{blue}{\sqrt{\frac{x \cdot x}{\mathsf{fma}\left(x, x, 1\right)}}} \]
    7. lift-*.f64N/A

      \[\leadsto \sqrt{\frac{\color{blue}{x \cdot x}}{\mathsf{fma}\left(x, x, 1\right)}} \]
    8. associate-*r/N/A

      \[\leadsto \sqrt{\color{blue}{x \cdot \frac{x}{\mathsf{fma}\left(x, x, 1\right)}}} \]
    9. lift-/.f64N/A

      \[\leadsto \sqrt{x \cdot \color{blue}{\frac{x}{\mathsf{fma}\left(x, x, 1\right)}}} \]
    10. lower-sqrt.f64N/A

      \[\leadsto \color{blue}{\sqrt{x \cdot \frac{x}{\mathsf{fma}\left(x, x, 1\right)}}} \]
    11. *-commutativeN/A

      \[\leadsto \sqrt{\color{blue}{\frac{x}{\mathsf{fma}\left(x, x, 1\right)} \cdot x}} \]
    12. lower-*.f6499.6

      \[\leadsto \sqrt{\color{blue}{\frac{x}{\mathsf{fma}\left(x, x, 1\right)} \cdot x}} \]
  6. Applied rewrites99.6%

    \[\leadsto \color{blue}{\sqrt{\frac{x}{\mathsf{fma}\left(x, x, 1\right)} \cdot x}} \]
  7. Add Preprocessing

Alternative 2: 99.4% accurate, 4.5× speedup?

\[\begin{array}{l} \\ \frac{x}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}} \end{array} \]
(FPCore (x) :precision binary64 (/ x (sqrt (fma x x 1.0))))
double code(double x) {
	return x / sqrt(fma(x, x, 1.0));
}
function code(x)
	return Float64(x / sqrt(fma(x, x, 1.0)))
end
code[x_] := N[(x / N[Sqrt[N[(x * x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\frac{x}{\sqrt{1 + {x}^{2}}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \frac{x}{\sqrt{\color{blue}{1 + {x}^{2}}}} \]
    2. +-commutativeN/A

      \[\leadsto \frac{x}{\sqrt{\color{blue}{{x}^{2} + 1}}} \]
    3. lift-pow.f64N/A

      \[\leadsto \frac{x}{\sqrt{\color{blue}{{x}^{2}} + 1}} \]
    4. unpow2N/A

      \[\leadsto \frac{x}{\sqrt{\color{blue}{x \cdot x} + 1}} \]
    5. lower-fma.f6499.5

      \[\leadsto \frac{x}{\sqrt{\color{blue}{\mathsf{fma}\left(x, x, 1\right)}}} \]
  4. Applied rewrites99.5%

    \[\leadsto \frac{x}{\sqrt{\color{blue}{\mathsf{fma}\left(x, x, 1\right)}}} \]
  5. Add Preprocessing

Alternative 3: 53.6% accurate, 4.8× speedup?

\[\begin{array}{l} \\ \frac{x}{x - \frac{-0.5}{x}} \end{array} \]
(FPCore (x) :precision binary64 (/ x (- x (/ -0.5 x))))
double code(double x) {
	return x / (x - (-0.5 / x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = x / (x - ((-0.5d0) / x))
end function
public static double code(double x) {
	return x / (x - (-0.5 / x));
}
def code(x):
	return x / (x - (-0.5 / x))
function code(x)
	return Float64(x / Float64(x - Float64(-0.5 / x)))
end
function tmp = code(x)
	tmp = x / (x - (-0.5 / x));
end
code[x_] := N[(x / N[(x - N[(-0.5 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{x}{x - \frac{-0.5}{x}}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\frac{x}{\sqrt{1 + {x}^{2}}} \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf

    \[\leadsto \frac{x}{\color{blue}{x \cdot \left(1 + \frac{1}{2} \cdot \frac{1}{{x}^{2}}\right)}} \]
  4. Step-by-step derivation
    1. distribute-lft-inN/A

      \[\leadsto \frac{x}{\color{blue}{x \cdot 1 + x \cdot \left(\frac{1}{2} \cdot \frac{1}{{x}^{2}}\right)}} \]
    2. *-rgt-identityN/A

      \[\leadsto \frac{x}{\color{blue}{x} + x \cdot \left(\frac{1}{2} \cdot \frac{1}{{x}^{2}}\right)} \]
    3. cancel-sign-subN/A

      \[\leadsto \frac{x}{\color{blue}{x - \left(\mathsf{neg}\left(x\right)\right) \cdot \left(\frac{1}{2} \cdot \frac{1}{{x}^{2}}\right)}} \]
    4. mul-1-negN/A

      \[\leadsto \frac{x}{x - \color{blue}{\left(-1 \cdot x\right)} \cdot \left(\frac{1}{2} \cdot \frac{1}{{x}^{2}}\right)} \]
    5. lower--.f64N/A

      \[\leadsto \frac{x}{\color{blue}{x - \left(-1 \cdot x\right) \cdot \left(\frac{1}{2} \cdot \frac{1}{{x}^{2}}\right)}} \]
    6. associate-*r*N/A

      \[\leadsto \frac{x}{x - \color{blue}{-1 \cdot \left(x \cdot \left(\frac{1}{2} \cdot \frac{1}{{x}^{2}}\right)\right)}} \]
    7. *-commutativeN/A

      \[\leadsto \frac{x}{x - -1 \cdot \color{blue}{\left(\left(\frac{1}{2} \cdot \frac{1}{{x}^{2}}\right) \cdot x\right)}} \]
    8. associate-*l*N/A

      \[\leadsto \frac{x}{x - -1 \cdot \color{blue}{\left(\frac{1}{2} \cdot \left(\frac{1}{{x}^{2}} \cdot x\right)\right)}} \]
    9. associate-*r*N/A

      \[\leadsto \frac{x}{x - \color{blue}{\left(-1 \cdot \frac{1}{2}\right) \cdot \left(\frac{1}{{x}^{2}} \cdot x\right)}} \]
    10. metadata-evalN/A

      \[\leadsto \frac{x}{x - \color{blue}{\frac{-1}{2}} \cdot \left(\frac{1}{{x}^{2}} \cdot x\right)} \]
    11. associate-*l/N/A

      \[\leadsto \frac{x}{x - \frac{-1}{2} \cdot \color{blue}{\frac{1 \cdot x}{{x}^{2}}}} \]
    12. *-lft-identityN/A

      \[\leadsto \frac{x}{x - \frac{-1}{2} \cdot \frac{\color{blue}{x}}{{x}^{2}}} \]
    13. unpow2N/A

      \[\leadsto \frac{x}{x - \frac{-1}{2} \cdot \frac{x}{\color{blue}{x \cdot x}}} \]
    14. associate-/r*N/A

      \[\leadsto \frac{x}{x - \frac{-1}{2} \cdot \color{blue}{\frac{\frac{x}{x}}{x}}} \]
    15. *-inversesN/A

      \[\leadsto \frac{x}{x - \frac{-1}{2} \cdot \frac{\color{blue}{1}}{x}} \]
    16. associate-*r/N/A

      \[\leadsto \frac{x}{x - \color{blue}{\frac{\frac{-1}{2} \cdot 1}{x}}} \]
    17. metadata-evalN/A

      \[\leadsto \frac{x}{x - \frac{\color{blue}{\frac{-1}{2}}}{x}} \]
    18. lower-/.f6453.3

      \[\leadsto \frac{x}{x - \color{blue}{\frac{-0.5}{x}}} \]
  5. Applied rewrites53.3%

    \[\leadsto \frac{x}{\color{blue}{x - \frac{-0.5}{x}}} \]
  6. Add Preprocessing

Alternative 4: 51.0% accurate, 6.3× speedup?

\[\begin{array}{l} \\ 1 - \frac{0.5}{x \cdot x} \end{array} \]
(FPCore (x) :precision binary64 (- 1.0 (/ 0.5 (* x x))))
double code(double x) {
	return 1.0 - (0.5 / (x * x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 1.0d0 - (0.5d0 / (x * x))
end function
public static double code(double x) {
	return 1.0 - (0.5 / (x * x));
}
def code(x):
	return 1.0 - (0.5 / (x * x))
function code(x)
	return Float64(1.0 - Float64(0.5 / Float64(x * x)))
end
function tmp = code(x)
	tmp = 1.0 - (0.5 / (x * x));
end
code[x_] := N[(1.0 - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 - \frac{0.5}{x \cdot x}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\frac{x}{\sqrt{1 + {x}^{2}}} \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf

    \[\leadsto \color{blue}{1 - \frac{1}{2} \cdot \frac{1}{{x}^{2}}} \]
  4. Step-by-step derivation
    1. lower--.f64N/A

      \[\leadsto \color{blue}{1 - \frac{1}{2} \cdot \frac{1}{{x}^{2}}} \]
    2. associate-*r/N/A

      \[\leadsto 1 - \color{blue}{\frac{\frac{1}{2} \cdot 1}{{x}^{2}}} \]
    3. metadata-evalN/A

      \[\leadsto 1 - \frac{\color{blue}{\frac{1}{2}}}{{x}^{2}} \]
    4. lower-/.f64N/A

      \[\leadsto 1 - \color{blue}{\frac{\frac{1}{2}}{{x}^{2}}} \]
    5. unpow2N/A

      \[\leadsto 1 - \frac{\frac{1}{2}}{\color{blue}{x \cdot x}} \]
    6. lower-*.f6450.7

      \[\leadsto 1 - \frac{0.5}{\color{blue}{x \cdot x}} \]
  5. Applied rewrites50.7%

    \[\leadsto \color{blue}{1 - \frac{0.5}{x \cdot x}} \]
  6. Add Preprocessing

Alternative 5: 34.6% accurate, 6.6× speedup?

\[\begin{array}{l} \\ \frac{-1}{x} \cdot \left(-x\right) \end{array} \]
(FPCore (x) :precision binary64 (* (/ -1.0 x) (- x)))
double code(double x) {
	return (-1.0 / x) * -x;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = ((-1.0d0) / x) * -x
end function
public static double code(double x) {
	return (-1.0 / x) * -x;
}
def code(x):
	return (-1.0 / x) * -x
function code(x)
	return Float64(Float64(-1.0 / x) * Float64(-x))
end
function tmp = code(x)
	tmp = (-1.0 / x) * -x;
end
code[x_] := N[(N[(-1.0 / x), $MachinePrecision] * (-x)), $MachinePrecision]
\begin{array}{l}

\\
\frac{-1}{x} \cdot \left(-x\right)
\end{array}
Derivation
  1. Initial program 99.5%

    \[\frac{x}{\sqrt{1 + {x}^{2}}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{x}{\sqrt{1 + {x}^{2}}}} \]
    2. clear-numN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{1 + {x}^{2}}}{x}}} \]
    3. frac-2negN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{neg}\left(\sqrt{1 + {x}^{2}}\right)}{\mathsf{neg}\left(x\right)}}} \]
    4. associate-/r/N/A

      \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left(\sqrt{1 + {x}^{2}}\right)} \cdot \left(\mathsf{neg}\left(x\right)\right)} \]
    5. lower-*.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left(\sqrt{1 + {x}^{2}}\right)} \cdot \left(\mathsf{neg}\left(x\right)\right)} \]
    6. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(-1\right)}}{\mathsf{neg}\left(\sqrt{1 + {x}^{2}}\right)} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    7. frac-2negN/A

      \[\leadsto \color{blue}{\frac{-1}{\sqrt{1 + {x}^{2}}}} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    8. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{-1}{\sqrt{1 + {x}^{2}}}} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    9. lift-+.f64N/A

      \[\leadsto \frac{-1}{\sqrt{\color{blue}{1 + {x}^{2}}}} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    10. +-commutativeN/A

      \[\leadsto \frac{-1}{\sqrt{\color{blue}{{x}^{2} + 1}}} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    11. lift-pow.f64N/A

      \[\leadsto \frac{-1}{\sqrt{\color{blue}{{x}^{2}} + 1}} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    12. unpow2N/A

      \[\leadsto \frac{-1}{\sqrt{\color{blue}{x \cdot x} + 1}} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    13. lower-fma.f64N/A

      \[\leadsto \frac{-1}{\sqrt{\color{blue}{\mathsf{fma}\left(x, x, 1\right)}}} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    14. lower-neg.f6499.3

      \[\leadsto \frac{-1}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}} \cdot \color{blue}{\left(-x\right)} \]
  4. Applied rewrites99.3%

    \[\leadsto \color{blue}{\frac{-1}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}} \cdot \left(-x\right)} \]
  5. Taylor expanded in x around inf

    \[\leadsto \color{blue}{\frac{-1}{x}} \cdot \left(-x\right) \]
  6. Step-by-step derivation
    1. lower-/.f6434.5

      \[\leadsto \color{blue}{\frac{-1}{x}} \cdot \left(-x\right) \]
  7. Applied rewrites34.5%

    \[\leadsto \color{blue}{\frac{-1}{x}} \cdot \left(-x\right) \]
  8. Add Preprocessing

Alternative 6: 15.6% accurate, 15.8× speedup?

\[\begin{array}{l} \\ -1 \cdot \left(-x\right) \end{array} \]
(FPCore (x) :precision binary64 (* -1.0 (- x)))
double code(double x) {
	return -1.0 * -x;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (-1.0d0) * -x
end function
public static double code(double x) {
	return -1.0 * -x;
}
def code(x):
	return -1.0 * -x
function code(x)
	return Float64(-1.0 * Float64(-x))
end
function tmp = code(x)
	tmp = -1.0 * -x;
end
code[x_] := N[(-1.0 * (-x)), $MachinePrecision]
\begin{array}{l}

\\
-1 \cdot \left(-x\right)
\end{array}
Derivation
  1. Initial program 99.5%

    \[\frac{x}{\sqrt{1 + {x}^{2}}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{x}{\sqrt{1 + {x}^{2}}}} \]
    2. clear-numN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{1 + {x}^{2}}}{x}}} \]
    3. frac-2negN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{neg}\left(\sqrt{1 + {x}^{2}}\right)}{\mathsf{neg}\left(x\right)}}} \]
    4. associate-/r/N/A

      \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left(\sqrt{1 + {x}^{2}}\right)} \cdot \left(\mathsf{neg}\left(x\right)\right)} \]
    5. lower-*.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\mathsf{neg}\left(\sqrt{1 + {x}^{2}}\right)} \cdot \left(\mathsf{neg}\left(x\right)\right)} \]
    6. metadata-evalN/A

      \[\leadsto \frac{\color{blue}{\mathsf{neg}\left(-1\right)}}{\mathsf{neg}\left(\sqrt{1 + {x}^{2}}\right)} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    7. frac-2negN/A

      \[\leadsto \color{blue}{\frac{-1}{\sqrt{1 + {x}^{2}}}} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    8. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{-1}{\sqrt{1 + {x}^{2}}}} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    9. lift-+.f64N/A

      \[\leadsto \frac{-1}{\sqrt{\color{blue}{1 + {x}^{2}}}} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    10. +-commutativeN/A

      \[\leadsto \frac{-1}{\sqrt{\color{blue}{{x}^{2} + 1}}} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    11. lift-pow.f64N/A

      \[\leadsto \frac{-1}{\sqrt{\color{blue}{{x}^{2}} + 1}} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    12. unpow2N/A

      \[\leadsto \frac{-1}{\sqrt{\color{blue}{x \cdot x} + 1}} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    13. lower-fma.f64N/A

      \[\leadsto \frac{-1}{\sqrt{\color{blue}{\mathsf{fma}\left(x, x, 1\right)}}} \cdot \left(\mathsf{neg}\left(x\right)\right) \]
    14. lower-neg.f6499.3

      \[\leadsto \frac{-1}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}} \cdot \color{blue}{\left(-x\right)} \]
  4. Applied rewrites99.3%

    \[\leadsto \color{blue}{\frac{-1}{\sqrt{\mathsf{fma}\left(x, x, 1\right)}} \cdot \left(-x\right)} \]
  5. Taylor expanded in x around 0

    \[\leadsto \color{blue}{-1} \cdot \left(-x\right) \]
  6. Step-by-step derivation
    1. Applied rewrites15.6%

      \[\leadsto \color{blue}{-1} \cdot \left(-x\right) \]
    2. Add Preprocessing

    Alternative 7: 1.6% accurate, 126.0× speedup?

    \[\begin{array}{l} \\ -1 \end{array} \]
    (FPCore (x) :precision binary64 -1.0)
    double code(double x) {
    	return -1.0;
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = -1.0d0
    end function
    
    public static double code(double x) {
    	return -1.0;
    }
    
    def code(x):
    	return -1.0
    
    function code(x)
    	return -1.0
    end
    
    function tmp = code(x)
    	tmp = -1.0;
    end
    
    code[x_] := -1.0
    
    \begin{array}{l}
    
    \\
    -1
    \end{array}
    
    Derivation
    1. Initial program 99.5%

      \[\frac{x}{\sqrt{1 + {x}^{2}}} \]
    2. Add Preprocessing
    3. Taylor expanded in x around -inf

      \[\leadsto \color{blue}{-1} \]
    4. Step-by-step derivation
      1. Applied rewrites1.6%

        \[\leadsto \color{blue}{-1} \]
      2. Add Preprocessing

      Reproduce

      ?
      herbie shell --seed 1 
      (FPCore (x)
        :name "x / sqrt(1 + pow(x, 2))"
        :precision binary64
        :pre (and (<= 1.0 x) (<= x 1000.0))
        (/ x (sqrt (+ 1.0 (pow x 2.0)))))