Average Error: 10.3 → 0.6
Time: 15.7s
Precision: 64
\[\frac{x + y \cdot \left(z - x\right)}{z}\]
\[\begin{array}{l} \mathbf{if}\;z \le -4.177791845767281238430526051246965901231 \cdot 10^{128} \lor \neg \left(z \le 5.886233405157470302139961757302968182258 \cdot 10^{-89}\right):\\ \;\;\;\;y - \frac{x}{\frac{z}{y - 1}}\\ \mathbf{else}:\\ \;\;\;\;y - \frac{1}{\frac{z}{y \cdot x - x}}\\ \end{array}\]
\frac{x + y \cdot \left(z - x\right)}{z}
\begin{array}{l}
\mathbf{if}\;z \le -4.177791845767281238430526051246965901231 \cdot 10^{128} \lor \neg \left(z \le 5.886233405157470302139961757302968182258 \cdot 10^{-89}\right):\\
\;\;\;\;y - \frac{x}{\frac{z}{y - 1}}\\

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

\end{array}
double f(double x, double y, double z) {
        double r500910 = x;
        double r500911 = y;
        double r500912 = z;
        double r500913 = r500912 - r500910;
        double r500914 = r500911 * r500913;
        double r500915 = r500910 + r500914;
        double r500916 = r500915 / r500912;
        return r500916;
}

double f(double x, double y, double z) {
        double r500917 = z;
        double r500918 = -4.177791845767281e+128;
        bool r500919 = r500917 <= r500918;
        double r500920 = 5.88623340515747e-89;
        bool r500921 = r500917 <= r500920;
        double r500922 = !r500921;
        bool r500923 = r500919 || r500922;
        double r500924 = y;
        double r500925 = x;
        double r500926 = 1.0;
        double r500927 = r500924 - r500926;
        double r500928 = r500917 / r500927;
        double r500929 = r500925 / r500928;
        double r500930 = r500924 - r500929;
        double r500931 = r500924 * r500925;
        double r500932 = r500931 - r500925;
        double r500933 = r500917 / r500932;
        double r500934 = r500926 / r500933;
        double r500935 = r500924 - r500934;
        double r500936 = r500923 ? r500930 : r500935;
        return r500936;
}

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

Original10.3
Target0.0
Herbie0.6
\[\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}}\]

Derivation

  1. Split input into 2 regimes
  2. if z < -4.177791845767281e+128 or 5.88623340515747e-89 < z

    1. Initial program 16.9

      \[\frac{x + y \cdot \left(z - x\right)}{z}\]
    2. Taylor expanded around 0 5.3

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

      \[\leadsto \color{blue}{y - \frac{y \cdot x - x}{z}}\]
    4. Using strategy rm
    5. Applied *-un-lft-identity5.3

      \[\leadsto y - \frac{y \cdot x - \color{blue}{1 \cdot x}}{z}\]
    6. Applied distribute-rgt-out--5.3

      \[\leadsto y - \frac{\color{blue}{x \cdot \left(y - 1\right)}}{z}\]
    7. Applied associate-/l*0.2

      \[\leadsto y - \color{blue}{\frac{x}{\frac{z}{y - 1}}}\]

    if -4.177791845767281e+128 < z < 5.88623340515747e-89

    1. Initial program 2.0

      \[\frac{x + y \cdot \left(z - x\right)}{z}\]
    2. Taylor expanded around 0 1.0

      \[\leadsto \color{blue}{\left(\frac{x}{z} + y\right) - \frac{x \cdot y}{z}}\]
    3. Simplified1.0

      \[\leadsto \color{blue}{y - \frac{y \cdot x - x}{z}}\]
    4. Using strategy rm
    5. Applied clear-num1.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -4.177791845767281238430526051246965901231 \cdot 10^{128} \lor \neg \left(z \le 5.886233405157470302139961757302968182258 \cdot 10^{-89}\right):\\ \;\;\;\;y - \frac{x}{\frac{z}{y - 1}}\\ \mathbf{else}:\\ \;\;\;\;y - \frac{1}{\frac{z}{y \cdot x - x}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019322 
(FPCore (x y z)
  :name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
  :precision binary64

  :herbie-target
  (- (+ y (/ x z)) (/ y (/ z x)))

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