bug333 (missed optimization)

Percentage Accurate: 8.5% → 100.0%
Time: 5.3s
Alternatives: 6
Speedup: N/A×

Specification

?
\[\sqrt{1 + x} - \sqrt{1 - x} \]

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

\[\left(x + x\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{1 - x}} \]
Derivation
  1. Initial program 8.0%

    \[\sqrt{1 + x} - \sqrt{1 - x} \]
  2. Step-by-step derivation
    1. +-commutative8.0%

      \[\leadsto \sqrt{\color{blue}{x + 1}} - \sqrt{1 - x} \]
    2. metadata-eval8.0%

      \[\leadsto \sqrt{x + \color{blue}{\left(--1\right)}} - \sqrt{1 - x} \]
    3. sub-neg8.0%

      \[\leadsto \sqrt{\color{blue}{x - -1}} - \sqrt{1 - x} \]
  3. Simplified8.0%

    \[\leadsto \color{blue}{\sqrt{x - -1} - \sqrt{1 - x}} \]
  4. Step-by-step derivation
    1. flip--8.0%

      \[\leadsto \color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{1 - x} \cdot \sqrt{1 - x}}{\sqrt{x - -1} + \sqrt{1 - x}}} \]
    2. div-inv8.0%

      \[\leadsto \color{blue}{\left(\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{1 - x} \cdot \sqrt{1 - x}\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}}} \]
    3. add-sqr-sqrt8.1%

      \[\leadsto \left(\color{blue}{\left(x - -1\right)} - \sqrt{1 - x} \cdot \sqrt{1 - x}\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    4. add-sqr-sqrt8.1%

      \[\leadsto \left(\left(x - -1\right) - \color{blue}{\left(1 - x\right)}\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    5. associate--r-20.7%

      \[\leadsto \color{blue}{\left(\left(\left(x - -1\right) - 1\right) + x\right)} \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    6. sub-neg20.7%

      \[\leadsto \left(\left(\color{blue}{\left(x + \left(--1\right)\right)} - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    7. metadata-eval20.7%

      \[\leadsto \left(\left(\left(x + \color{blue}{1}\right) - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    8. +-commutative20.7%

      \[\leadsto \left(\left(\color{blue}{\left(1 + x\right)} - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    9. add-exp-log20.7%

      \[\leadsto \left(\left(\color{blue}{e^{\log \left(1 + x\right)}} - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    10. log1p-udef20.7%

      \[\leadsto \left(\left(e^{\color{blue}{\mathsf{log1p}\left(x\right)}} - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    11. expm1-udef100.0%

      \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    12. expm1-log1p-u100.0%

      \[\leadsto \left(\color{blue}{x} + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    13. sub-neg100.0%

      \[\leadsto \left(x + x\right) \cdot \frac{1}{\sqrt{\color{blue}{x + \left(--1\right)}} + \sqrt{1 - x}} \]
    14. metadata-eval100.0%

      \[\leadsto \left(x + x\right) \cdot \frac{1}{\sqrt{x + \color{blue}{1}} + \sqrt{1 - x}} \]
  5. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\left(x + x\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{1 - x}}} \]
  6. Final simplification100.0%

    \[\leadsto \left(x + x\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{1 - x}} \]

Alternative 2: 99.7% accurate, 1.0× speedup?

\[\frac{2}{\frac{\sqrt{x + 1} + \sqrt{1 - x}}{x}} \]
Derivation
  1. Initial program 8.0%

    \[\sqrt{1 + x} - \sqrt{1 - x} \]
  2. Step-by-step derivation
    1. +-commutative8.0%

      \[\leadsto \sqrt{\color{blue}{x + 1}} - \sqrt{1 - x} \]
    2. metadata-eval8.0%

      \[\leadsto \sqrt{x + \color{blue}{\left(--1\right)}} - \sqrt{1 - x} \]
    3. sub-neg8.0%

      \[\leadsto \sqrt{\color{blue}{x - -1}} - \sqrt{1 - x} \]
  3. Simplified8.0%

    \[\leadsto \color{blue}{\sqrt{x - -1} - \sqrt{1 - x}} \]
  4. Step-by-step derivation
    1. flip--8.0%

      \[\leadsto \color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{1 - x} \cdot \sqrt{1 - x}}{\sqrt{x - -1} + \sqrt{1 - x}}} \]
    2. div-inv8.0%

      \[\leadsto \color{blue}{\left(\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{1 - x} \cdot \sqrt{1 - x}\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}}} \]
    3. add-sqr-sqrt8.1%

      \[\leadsto \left(\color{blue}{\left(x - -1\right)} - \sqrt{1 - x} \cdot \sqrt{1 - x}\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    4. add-sqr-sqrt8.1%

      \[\leadsto \left(\left(x - -1\right) - \color{blue}{\left(1 - x\right)}\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    5. associate--r-20.7%

      \[\leadsto \color{blue}{\left(\left(\left(x - -1\right) - 1\right) + x\right)} \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    6. sub-neg20.7%

      \[\leadsto \left(\left(\color{blue}{\left(x + \left(--1\right)\right)} - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    7. metadata-eval20.7%

      \[\leadsto \left(\left(\left(x + \color{blue}{1}\right) - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    8. +-commutative20.7%

      \[\leadsto \left(\left(\color{blue}{\left(1 + x\right)} - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    9. add-exp-log20.7%

      \[\leadsto \left(\left(\color{blue}{e^{\log \left(1 + x\right)}} - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    10. log1p-udef20.7%

      \[\leadsto \left(\left(e^{\color{blue}{\mathsf{log1p}\left(x\right)}} - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    11. expm1-udef100.0%

      \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    12. expm1-log1p-u100.0%

      \[\leadsto \left(\color{blue}{x} + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    13. sub-neg100.0%

      \[\leadsto \left(x + x\right) \cdot \frac{1}{\sqrt{\color{blue}{x + \left(--1\right)}} + \sqrt{1 - x}} \]
    14. metadata-eval100.0%

      \[\leadsto \left(x + x\right) \cdot \frac{1}{\sqrt{x + \color{blue}{1}} + \sqrt{1 - x}} \]
  5. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\left(x + x\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{1 - x}}} \]
  6. Step-by-step derivation
    1. associate-*r/100.0%

      \[\leadsto \color{blue}{\frac{\left(x + x\right) \cdot 1}{\sqrt{x + 1} + \sqrt{1 - x}}} \]
    2. *-rgt-identity100.0%

      \[\leadsto \frac{\color{blue}{x + x}}{\sqrt{x + 1} + \sqrt{1 - x}} \]
    3. count-2100.0%

      \[\leadsto \frac{\color{blue}{2 \cdot x}}{\sqrt{x + 1} + \sqrt{1 - x}} \]
    4. associate-/l*99.8%

      \[\leadsto \color{blue}{\frac{2}{\frac{\sqrt{x + 1} + \sqrt{1 - x}}{x}}} \]
  7. Simplified99.8%

    \[\leadsto \color{blue}{\frac{2}{\frac{\sqrt{x + 1} + \sqrt{1 - x}}{x}}} \]
  8. Final simplification99.8%

    \[\leadsto \frac{2}{\frac{\sqrt{x + 1} + \sqrt{1 - x}}{x}} \]

Alternative 3: 100.0% accurate, 1.0× speedup?

\[\frac{x + x}{\sqrt{x + 1} + \sqrt{1 - x}} \]
Derivation
  1. Initial program 8.0%

    \[\sqrt{1 + x} - \sqrt{1 - x} \]
  2. Step-by-step derivation
    1. +-commutative8.0%

      \[\leadsto \sqrt{\color{blue}{x + 1}} - \sqrt{1 - x} \]
    2. metadata-eval8.0%

      \[\leadsto \sqrt{x + \color{blue}{\left(--1\right)}} - \sqrt{1 - x} \]
    3. sub-neg8.0%

      \[\leadsto \sqrt{\color{blue}{x - -1}} - \sqrt{1 - x} \]
  3. Simplified8.0%

    \[\leadsto \color{blue}{\sqrt{x - -1} - \sqrt{1 - x}} \]
  4. Step-by-step derivation
    1. flip--8.0%

      \[\leadsto \color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{1 - x} \cdot \sqrt{1 - x}}{\sqrt{x - -1} + \sqrt{1 - x}}} \]
    2. add-sqr-sqrt8.1%

      \[\leadsto \frac{\color{blue}{\left(x - -1\right)} - \sqrt{1 - x} \cdot \sqrt{1 - x}}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    3. add-sqr-sqrt8.1%

      \[\leadsto \frac{\left(x - -1\right) - \color{blue}{\left(1 - x\right)}}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    4. associate--r-20.7%

      \[\leadsto \frac{\color{blue}{\left(\left(x - -1\right) - 1\right) + x}}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    5. sub-neg20.7%

      \[\leadsto \frac{\left(\color{blue}{\left(x + \left(--1\right)\right)} - 1\right) + x}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    6. metadata-eval20.7%

      \[\leadsto \frac{\left(\left(x + \color{blue}{1}\right) - 1\right) + x}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    7. +-commutative20.7%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} - 1\right) + x}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    8. add-exp-log20.7%

      \[\leadsto \frac{\left(\color{blue}{e^{\log \left(1 + x\right)}} - 1\right) + x}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    9. log1p-udef20.7%

      \[\leadsto \frac{\left(e^{\color{blue}{\mathsf{log1p}\left(x\right)}} - 1\right) + x}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    10. expm1-udef100.0%

      \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} + x}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    11. expm1-log1p-u100.0%

      \[\leadsto \frac{\color{blue}{x} + x}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    12. sub-neg100.0%

      \[\leadsto \frac{x + x}{\sqrt{\color{blue}{x + \left(--1\right)}} + \sqrt{1 - x}} \]
    13. metadata-eval100.0%

      \[\leadsto \frac{x + x}{\sqrt{x + \color{blue}{1}} + \sqrt{1 - x}} \]
  5. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\frac{x + x}{\sqrt{x + 1} + \sqrt{1 - x}}} \]
  6. Final simplification100.0%

    \[\leadsto \frac{x + x}{\sqrt{x + 1} + \sqrt{1 - x}} \]

Alternative 4: 99.6% accurate, 15.9× speedup?

\[\left(x + x\right) \cdot \frac{1}{2 + x \cdot \left(x \cdot -0.25\right)} \]
Derivation
  1. Initial program 8.0%

    \[\sqrt{1 + x} - \sqrt{1 - x} \]
  2. Step-by-step derivation
    1. +-commutative8.0%

      \[\leadsto \sqrt{\color{blue}{x + 1}} - \sqrt{1 - x} \]
    2. metadata-eval8.0%

      \[\leadsto \sqrt{x + \color{blue}{\left(--1\right)}} - \sqrt{1 - x} \]
    3. sub-neg8.0%

      \[\leadsto \sqrt{\color{blue}{x - -1}} - \sqrt{1 - x} \]
  3. Simplified8.0%

    \[\leadsto \color{blue}{\sqrt{x - -1} - \sqrt{1 - x}} \]
  4. Step-by-step derivation
    1. flip--8.0%

      \[\leadsto \color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{1 - x} \cdot \sqrt{1 - x}}{\sqrt{x - -1} + \sqrt{1 - x}}} \]
    2. div-inv8.0%

      \[\leadsto \color{blue}{\left(\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{1 - x} \cdot \sqrt{1 - x}\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}}} \]
    3. add-sqr-sqrt8.1%

      \[\leadsto \left(\color{blue}{\left(x - -1\right)} - \sqrt{1 - x} \cdot \sqrt{1 - x}\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    4. add-sqr-sqrt8.1%

      \[\leadsto \left(\left(x - -1\right) - \color{blue}{\left(1 - x\right)}\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    5. associate--r-20.7%

      \[\leadsto \color{blue}{\left(\left(\left(x - -1\right) - 1\right) + x\right)} \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    6. sub-neg20.7%

      \[\leadsto \left(\left(\color{blue}{\left(x + \left(--1\right)\right)} - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    7. metadata-eval20.7%

      \[\leadsto \left(\left(\left(x + \color{blue}{1}\right) - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    8. +-commutative20.7%

      \[\leadsto \left(\left(\color{blue}{\left(1 + x\right)} - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    9. add-exp-log20.7%

      \[\leadsto \left(\left(\color{blue}{e^{\log \left(1 + x\right)}} - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    10. log1p-udef20.7%

      \[\leadsto \left(\left(e^{\color{blue}{\mathsf{log1p}\left(x\right)}} - 1\right) + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    11. expm1-udef100.0%

      \[\leadsto \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    12. expm1-log1p-u100.0%

      \[\leadsto \left(\color{blue}{x} + x\right) \cdot \frac{1}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    13. sub-neg100.0%

      \[\leadsto \left(x + x\right) \cdot \frac{1}{\sqrt{\color{blue}{x + \left(--1\right)}} + \sqrt{1 - x}} \]
    14. metadata-eval100.0%

      \[\leadsto \left(x + x\right) \cdot \frac{1}{\sqrt{x + \color{blue}{1}} + \sqrt{1 - x}} \]
  5. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\left(x + x\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{1 - x}}} \]
  6. Taylor expanded in x around 0 99.3%

    \[\leadsto \left(x + x\right) \cdot \frac{1}{\color{blue}{2 + -0.25 \cdot {x}^{2}}} \]
  7. Step-by-step derivation
    1. add-log-exp99.3%

      \[\leadsto \frac{x + x}{2 + \color{blue}{\log \left(e^{-0.25 \cdot {x}^{2}}\right)}} \]
    2. *-un-lft-identity99.3%

      \[\leadsto \frac{x + x}{2 + \log \color{blue}{\left(1 \cdot e^{-0.25 \cdot {x}^{2}}\right)}} \]
    3. log-prod99.3%

      \[\leadsto \frac{x + x}{2 + \color{blue}{\left(\log 1 + \log \left(e^{-0.25 \cdot {x}^{2}}\right)\right)}} \]
    4. metadata-eval99.3%

      \[\leadsto \frac{x + x}{2 + \left(\color{blue}{0} + \log \left(e^{-0.25 \cdot {x}^{2}}\right)\right)} \]
    5. add-log-exp99.3%

      \[\leadsto \frac{x + x}{2 + \left(0 + \color{blue}{-0.25 \cdot {x}^{2}}\right)} \]
    6. *-commutative99.3%

      \[\leadsto \frac{x + x}{2 + \left(0 + \color{blue}{{x}^{2} \cdot -0.25}\right)} \]
    7. unpow299.3%

      \[\leadsto \frac{x + x}{2 + \left(0 + \color{blue}{\left(x \cdot x\right)} \cdot -0.25\right)} \]
    8. associate-*l*99.3%

      \[\leadsto \frac{x + x}{2 + \left(0 + \color{blue}{x \cdot \left(x \cdot -0.25\right)}\right)} \]
  8. Applied egg-rr99.3%

    \[\leadsto \left(x + x\right) \cdot \frac{1}{2 + \color{blue}{\left(0 + x \cdot \left(x \cdot -0.25\right)\right)}} \]
  9. Step-by-step derivation
    1. +-lft-identity99.3%

      \[\leadsto \frac{x + x}{2 + \color{blue}{x \cdot \left(x \cdot -0.25\right)}} \]
  10. Simplified99.3%

    \[\leadsto \left(x + x\right) \cdot \frac{1}{2 + \color{blue}{x \cdot \left(x \cdot -0.25\right)}} \]
  11. Final simplification99.3%

    \[\leadsto \left(x + x\right) \cdot \frac{1}{2 + x \cdot \left(x \cdot -0.25\right)} \]

Alternative 5: 99.6% accurate, 18.8× speedup?

\[\frac{x + x}{2 + x \cdot \left(x \cdot -0.25\right)} \]
Derivation
  1. Initial program 8.0%

    \[\sqrt{1 + x} - \sqrt{1 - x} \]
  2. Step-by-step derivation
    1. +-commutative8.0%

      \[\leadsto \sqrt{\color{blue}{x + 1}} - \sqrt{1 - x} \]
    2. metadata-eval8.0%

      \[\leadsto \sqrt{x + \color{blue}{\left(--1\right)}} - \sqrt{1 - x} \]
    3. sub-neg8.0%

      \[\leadsto \sqrt{\color{blue}{x - -1}} - \sqrt{1 - x} \]
  3. Simplified8.0%

    \[\leadsto \color{blue}{\sqrt{x - -1} - \sqrt{1 - x}} \]
  4. Step-by-step derivation
    1. flip--8.0%

      \[\leadsto \color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{1 - x} \cdot \sqrt{1 - x}}{\sqrt{x - -1} + \sqrt{1 - x}}} \]
    2. add-sqr-sqrt8.1%

      \[\leadsto \frac{\color{blue}{\left(x - -1\right)} - \sqrt{1 - x} \cdot \sqrt{1 - x}}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    3. add-sqr-sqrt8.1%

      \[\leadsto \frac{\left(x - -1\right) - \color{blue}{\left(1 - x\right)}}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    4. associate--r-20.7%

      \[\leadsto \frac{\color{blue}{\left(\left(x - -1\right) - 1\right) + x}}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    5. sub-neg20.7%

      \[\leadsto \frac{\left(\color{blue}{\left(x + \left(--1\right)\right)} - 1\right) + x}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    6. metadata-eval20.7%

      \[\leadsto \frac{\left(\left(x + \color{blue}{1}\right) - 1\right) + x}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    7. +-commutative20.7%

      \[\leadsto \frac{\left(\color{blue}{\left(1 + x\right)} - 1\right) + x}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    8. add-exp-log20.7%

      \[\leadsto \frac{\left(\color{blue}{e^{\log \left(1 + x\right)}} - 1\right) + x}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    9. log1p-udef20.7%

      \[\leadsto \frac{\left(e^{\color{blue}{\mathsf{log1p}\left(x\right)}} - 1\right) + x}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    10. expm1-udef100.0%

      \[\leadsto \frac{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} + x}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    11. expm1-log1p-u100.0%

      \[\leadsto \frac{\color{blue}{x} + x}{\sqrt{x - -1} + \sqrt{1 - x}} \]
    12. sub-neg100.0%

      \[\leadsto \frac{x + x}{\sqrt{\color{blue}{x + \left(--1\right)}} + \sqrt{1 - x}} \]
    13. metadata-eval100.0%

      \[\leadsto \frac{x + x}{\sqrt{x + \color{blue}{1}} + \sqrt{1 - x}} \]
  5. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\frac{x + x}{\sqrt{x + 1} + \sqrt{1 - x}}} \]
  6. Taylor expanded in x around 0 99.3%

    \[\leadsto \frac{x + x}{\color{blue}{2 + -0.25 \cdot {x}^{2}}} \]
  7. Step-by-step derivation
    1. add-log-exp99.3%

      \[\leadsto \frac{x + x}{2 + \color{blue}{\log \left(e^{-0.25 \cdot {x}^{2}}\right)}} \]
    2. *-un-lft-identity99.3%

      \[\leadsto \frac{x + x}{2 + \log \color{blue}{\left(1 \cdot e^{-0.25 \cdot {x}^{2}}\right)}} \]
    3. log-prod99.3%

      \[\leadsto \frac{x + x}{2 + \color{blue}{\left(\log 1 + \log \left(e^{-0.25 \cdot {x}^{2}}\right)\right)}} \]
    4. metadata-eval99.3%

      \[\leadsto \frac{x + x}{2 + \left(\color{blue}{0} + \log \left(e^{-0.25 \cdot {x}^{2}}\right)\right)} \]
    5. add-log-exp99.3%

      \[\leadsto \frac{x + x}{2 + \left(0 + \color{blue}{-0.25 \cdot {x}^{2}}\right)} \]
    6. *-commutative99.3%

      \[\leadsto \frac{x + x}{2 + \left(0 + \color{blue}{{x}^{2} \cdot -0.25}\right)} \]
    7. unpow299.3%

      \[\leadsto \frac{x + x}{2 + \left(0 + \color{blue}{\left(x \cdot x\right)} \cdot -0.25\right)} \]
    8. associate-*l*99.3%

      \[\leadsto \frac{x + x}{2 + \left(0 + \color{blue}{x \cdot \left(x \cdot -0.25\right)}\right)} \]
  8. Applied egg-rr99.3%

    \[\leadsto \frac{x + x}{2 + \color{blue}{\left(0 + x \cdot \left(x \cdot -0.25\right)\right)}} \]
  9. Step-by-step derivation
    1. +-lft-identity99.3%

      \[\leadsto \frac{x + x}{2 + \color{blue}{x \cdot \left(x \cdot -0.25\right)}} \]
  10. Simplified99.3%

    \[\leadsto \frac{x + x}{2 + \color{blue}{x \cdot \left(x \cdot -0.25\right)}} \]
  11. Final simplification99.3%

    \[\leadsto \frac{x + x}{2 + x \cdot \left(x \cdot -0.25\right)} \]

Alternative 6: 99.1% accurate, 207.0× speedup?

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

    \[\sqrt{1 + x} - \sqrt{1 - x} \]
  2. Step-by-step derivation
    1. +-commutative8.0%

      \[\leadsto \sqrt{\color{blue}{x + 1}} - \sqrt{1 - x} \]
    2. metadata-eval8.0%

      \[\leadsto \sqrt{x + \color{blue}{\left(--1\right)}} - \sqrt{1 - x} \]
    3. sub-neg8.0%

      \[\leadsto \sqrt{\color{blue}{x - -1}} - \sqrt{1 - x} \]
  3. Simplified8.0%

    \[\leadsto \color{blue}{\sqrt{x - -1} - \sqrt{1 - x}} \]
  4. Taylor expanded in x around 0 99.1%

    \[\leadsto \color{blue}{x} \]
  5. Final simplification99.1%

    \[\leadsto x \]

Developer target: 100.0% accurate, 1.0× speedup?

\[\frac{2 \cdot x}{\sqrt{1 + x} + \sqrt{1 - x}} \]

Reproduce

?
herbie shell --seed 2023167 
(FPCore (x)
  :name "bug333 (missed optimization)"
  :precision binary64
  :pre (and (<= -1.0 x) (<= x 1.0))

  :herbie-target
  (/ (* 2.0 x) (+ (sqrt (+ 1.0 x)) (sqrt (- 1.0 x))))

  (- (sqrt (+ 1.0 x)) (sqrt (- 1.0 x))))