Average Error: 7.6 → 6.1
Time: 16.2s
Precision: binary64
Cost: 2564
\[\frac{x + y}{1 - \frac{y}{z}}\]
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \leq -7.571671828713221 \cdot 10^{-294} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \leq 0\right):\\ \;\;\;\;-\frac{x + y}{\frac{y}{z} - 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x + y}{1 + \frac{\sqrt{y}}{\sqrt{z}}}}{1 - \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]
\frac{x + y}{1 - \frac{y}{z}}
\begin{array}{l}
\mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \leq -7.571671828713221 \cdot 10^{-294} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \leq 0\right):\\
\;\;\;\;-\frac{x + y}{\frac{y}{z} - 1}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x + y}{1 + \frac{\sqrt{y}}{\sqrt{z}}}}{1 - \frac{\sqrt{y}}{\sqrt{z}}}\\

\end{array}
(FPCore (x y z) :precision binary64 (/ (+ x y) (- 1.0 (/ y z))))
(FPCore (x y z)
 :precision binary64
 (if (or (<= (/ (+ x y) (- 1.0 (/ y z))) -7.571671828713221e-294)
         (not (<= (/ (+ x y) (- 1.0 (/ y z))) 0.0)))
   (- (/ (+ x y) (- (/ y z) 1.0)))
   (/
    (/ (+ x y) (+ 1.0 (/ (sqrt y) (sqrt z))))
    (- 1.0 (/ (sqrt y) (sqrt z))))))
double code(double x, double y, double z) {
	return (x + y) / (1.0 - (y / z));
}
double code(double x, double y, double z) {
	double tmp;
	if ((((x + y) / (1.0 - (y / z))) <= -7.571671828713221e-294) || !(((x + y) / (1.0 - (y / z))) <= 0.0)) {
		tmp = -((x + y) / ((y / z) - 1.0));
	} else {
		tmp = ((x + y) / (1.0 + (sqrt(y) / sqrt(z)))) / (1.0 - (sqrt(y) / sqrt(z)));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.6
Target4.0
Herbie6.1
\[\begin{array}{l} \mathbf{if}\;y < -3.7429310762689856 \cdot 10^{+171}:\\ \;\;\;\;\frac{y + x}{-y} \cdot z\\ \mathbf{elif}\;y < 3.5534662456086734 \cdot 10^{+168}:\\ \;\;\;\;\frac{x + y}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{y + x}{-y} \cdot z\\ \end{array}\]

Alternatives

Alternative 1
Accuracy6.1
Cost2692
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \leq -7.571671828713221 \cdot 10^{-294} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \leq 0\right):\\ \;\;\;\;-\frac{x + y}{\frac{y}{z} - 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + y}{\frac{\sqrt{y}}{\sqrt{z}} - 1} \cdot \frac{-1}{1 + \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]
Alternative 2
Accuracy6.1
Cost3268
\[\begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \leq -7.571671828713221 \cdot 10^{-294} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \leq 0\right):\\ \;\;\;\;-\frac{x + y}{\frac{y}{z} - 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}{1 + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt[3]{x + y}}{1 - \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]
Alternative 3
Accuracy7.6
Cost640
\[-\frac{x + y}{\frac{y}{z} - 1}\]
Alternative 4
Accuracy8.7
Cost1280
\[\left(\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}\right) \cdot \frac{\sqrt[3]{x + y}}{1 - \frac{y}{z}}\]
Alternative 5
Accuracy28.0
Cost3078
\[\begin{array}{l} \mathbf{if}\;y \leq -1.0272793344604454 \cdot 10^{+65}:\\ \;\;\;\;\frac{\sqrt[3]{y + x} \cdot \sqrt[3]{y + x}}{1 + \sqrt{\frac{y}{z}}} \cdot \frac{\sqrt[3]{y + x}}{1 - \sqrt{\frac{y}{z}}}\\ \mathbf{elif}\;y \leq -6.710582596235068 \cdot 10^{-160}:\\ \;\;\;\;\frac{-\left({x}^{3} + {y}^{3}\right)}{\left(\frac{y}{z} - 1\right) \cdot \left(x \cdot x + y \cdot \left(y - x\right)\right)}\\ \mathbf{elif}\;y \leq -1.2546136822733546 \cdot 10^{-304}:\\ \;\;\;\;\frac{\sqrt[3]{y + x} \cdot \sqrt[3]{y + x}}{1 + \sqrt{\frac{y}{z}}} \cdot \frac{\sqrt[3]{y + x}}{1 - \sqrt{\frac{y}{z}}}\\ \mathbf{elif}\;y \leq 2.8653198895621734 \cdot 10^{-76}:\\ \;\;\;\;\sqrt{y + x} \cdot \frac{\sqrt{y + x}}{1 - \frac{y}{z}}\\ \mathbf{elif}\;y \leq 2.061110669294841 \cdot 10^{-18}:\\ \;\;\;\;\frac{-\left({x}^{3} + {y}^{3}\right)}{\left(\frac{y}{z} - 1\right) \cdot \left(x \cdot x + y \cdot \left(y - x\right)\right)}\\ \mathbf{elif}\;y \leq 3.583161077537527 \cdot 10^{+264}:\\ \;\;\;\;\sqrt{y + x} \cdot \frac{\sqrt{y + x}}{1 - \frac{y}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{y + x} \cdot \sqrt[3]{y + x}}{1 + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt[3]{y + x}}{1 - \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]
Alternative 6
Accuracy30.0
Cost2113
\[\begin{array}{l} \mathbf{if}\;x \leq -3.6442018354467086 \cdot 10^{+120}:\\ \;\;\;\;\frac{\sqrt[3]{x + y} \cdot \sqrt[3]{x + y}}{1 + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt[3]{x + y}}{1 - \frac{\sqrt{y}}{\sqrt{z}}}\\ \mathbf{elif}\;x \leq -1.6568013336058352 \cdot 10^{-147}:\\ \;\;\;\;\frac{-\left({x}^{3} + {y}^{3}\right)}{\left(\frac{y}{z} - 1\right) \cdot \left(x \cdot x + y \cdot \left(y - x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x + y} \cdot \frac{\sqrt{x + y}}{1 - \frac{y}{z}}\\ \end{array}\]
Alternative 7
Accuracy32.3
Cost1729
\[\begin{array}{l} \mathbf{if}\;x \leq -1.633228493482142 \cdot 10^{-138}:\\ \;\;\;\;\frac{-\left({x}^{3} + {y}^{3}\right)}{\left(\frac{y}{z} - 1\right) \cdot \left(x \cdot x + y \cdot \left(y - x\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x + y} \cdot \frac{\sqrt{x + y}}{1 - \frac{y}{z}}\\ \end{array}\]
Alternative 8
Accuracy36.6
Cost1793
\[\begin{array}{l} \mathbf{if}\;x \leq -6.948620035425153 \cdot 10^{+22}:\\ \;\;\;\;\frac{\sqrt{x + y}}{1 + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt{x + y}}{1 - \frac{\sqrt{y}}{\sqrt{z}}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x + y} \cdot \frac{\sqrt{x + y}}{1 - \frac{y}{z}}\\ \end{array}\]
Alternative 9
Accuracy47.1
Cost1793
\[\begin{array}{l} \mathbf{if}\;y \leq 8.207175237586665 \cdot 10^{+147}:\\ \;\;\;\;\frac{\sqrt{y + x}}{1 + \sqrt{\frac{y}{z}}} \cdot \frac{\sqrt{y + x}}{1 - \sqrt{\frac{y}{z}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{y + x}}{1 + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt{y + x}}{1 - \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]
Alternative 10
Accuracy52.3
Cost1600
\[\frac{\sqrt{x + y}}{1 + \frac{\sqrt{y}}{\sqrt{z}}} \cdot \frac{\sqrt{x + y}}{1 - \frac{\sqrt{y}}{\sqrt{z}}}\]

Derivation

  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -7.5716718287132213e-294 or -0.0 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z)))

    1. Initial program 0.1

      \[\frac{x + y}{1 - \frac{y}{z}}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity_binary64_236070.1

      \[\leadsto \frac{x + y}{\color{blue}{1 \cdot \left(1 - \frac{y}{z}\right)}}\]
    4. Applied *-un-lft-identity_binary64_236070.1

      \[\leadsto \frac{\color{blue}{1 \cdot \left(x + y\right)}}{1 \cdot \left(1 - \frac{y}{z}\right)}\]
    5. Applied times-frac_binary64_236130.1

      \[\leadsto \color{blue}{\frac{1}{1} \cdot \frac{x + y}{1 - \frac{y}{z}}}\]
    6. Simplified0.1

      \[\leadsto \color{blue}{1} \cdot \frac{x + y}{1 - \frac{y}{z}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity_binary64_236070.1

      \[\leadsto 1 \cdot \frac{x + y}{\color{blue}{1 \cdot \left(1 - \frac{y}{z}\right)}}\]
    9. Applied *-un-lft-identity_binary64_236070.1

      \[\leadsto 1 \cdot \frac{\color{blue}{1 \cdot \left(x + y\right)}}{1 \cdot \left(1 - \frac{y}{z}\right)}\]
    10. Applied times-frac_binary64_236130.1

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{1}{1} \cdot \frac{x + y}{1 - \frac{y}{z}}\right)}\]
    11. Simplified0.1

      \[\leadsto 1 \cdot \left(\color{blue}{1} \cdot \frac{x + y}{1 - \frac{y}{z}}\right)\]
    12. Using strategy rm
    13. Applied frac-2neg_binary64_236180.1

      \[\leadsto 1 \cdot \left(1 \cdot \color{blue}{\frac{-\left(x + y\right)}{-\left(1 - \frac{y}{z}\right)}}\right)\]
    14. Simplified0.1

      \[\leadsto 1 \cdot \left(1 \cdot \frac{-\left(x + y\right)}{\color{blue}{\frac{y}{z} - 1}}\right)\]
    15. Using strategy rm
    16. Applied distribute-frac-neg_binary64_235700.1

      \[\leadsto 1 \cdot \left(1 \cdot \color{blue}{\left(-\frac{x + y}{\frac{y}{z} - 1}\right)}\right)\]

    if -7.5716718287132213e-294 < (/.f64 (+.f64 x y) (-.f64 1 (/.f64 y z))) < -0.0

    1. Initial program 59.1

      \[\frac{x + y}{1 - \frac{y}{z}}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt_binary64_2362960.9

      \[\leadsto \frac{x + y}{1 - \frac{y}{\color{blue}{\sqrt{z} \cdot \sqrt{z}}}}\]
    4. Applied add-sqr-sqrt_binary64_2362962.6

      \[\leadsto \frac{x + y}{1 - \frac{\color{blue}{\sqrt{y} \cdot \sqrt{y}}}{\sqrt{z} \cdot \sqrt{z}}}\]
    5. Applied times-frac_binary64_2361362.6

      \[\leadsto \frac{x + y}{1 - \color{blue}{\frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}}\]
    6. Applied *-un-lft-identity_binary64_2360762.6

      \[\leadsto \frac{x + y}{\color{blue}{1 \cdot 1} - \frac{\sqrt{y}}{\sqrt{z}} \cdot \frac{\sqrt{y}}{\sqrt{z}}}\]
    7. Applied difference-of-squares_binary64_2357662.6

      \[\leadsto \frac{x + y}{\color{blue}{\left(1 + \frac{\sqrt{y}}{\sqrt{z}}\right) \cdot \left(1 - \frac{\sqrt{y}}{\sqrt{z}}\right)}}\]
    8. Applied associate-/r*_binary64_2355147.2

      \[\leadsto \color{blue}{\frac{\frac{x + y}{1 + \frac{\sqrt{y}}{\sqrt{z}}}}{1 - \frac{\sqrt{y}}{\sqrt{z}}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification6.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{x + y}{1 - \frac{y}{z}} \leq -7.571671828713221 \cdot 10^{-294} \lor \neg \left(\frac{x + y}{1 - \frac{y}{z}} \leq 0\right):\\ \;\;\;\;-\frac{x + y}{\frac{y}{z} - 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x + y}{1 + \frac{\sqrt{y}}{\sqrt{z}}}}{1 - \frac{\sqrt{y}}{\sqrt{z}}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020338 
(FPCore (x y z)
  :name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, A"
  :precision binary64

  :herbie-target
  (if (< y -3.7429310762689856e+171) (* (/ (+ y x) (- y)) z) (if (< y 3.5534662456086734e+168) (/ (+ x y) (- 1.0 (/ y z))) (* (/ (+ y x) (- y)) z)))

  (/ (+ x y) (- 1.0 (/ y z))))