Average Error: 15.1 → 3.7
Time: 8.8s
Precision: 64
\[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
\[\begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -1.63086994211637596483956921546385031623 \cdot 10^{66}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -6.545487680777495021156682531032583832353 \cdot 10^{-230}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \le 4.814036022956164419199695264571075550494 \cdot 10^{-12}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array}\]
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \le -1.63086994211637596483956921546385031623 \cdot 10^{66}:\\
\;\;\;\;\frac{y \cdot x}{z}\\

\mathbf{elif}\;\frac{y}{z} \le -6.545487680777495021156682531032583832353 \cdot 10^{-230}:\\
\;\;\;\;\frac{y}{z} \cdot x\\

\mathbf{elif}\;\frac{y}{z} \le 4.814036022956164419199695264571075550494 \cdot 10^{-12}:\\
\;\;\;\;\frac{y \cdot x}{z}\\

\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{x}}\\

\end{array}
double f(double x, double y, double z, double t) {
        double r458869 = x;
        double r458870 = y;
        double r458871 = z;
        double r458872 = r458870 / r458871;
        double r458873 = t;
        double r458874 = r458872 * r458873;
        double r458875 = r458874 / r458873;
        double r458876 = r458869 * r458875;
        return r458876;
}

double f(double x, double y, double z, double __attribute__((unused)) t) {
        double r458877 = y;
        double r458878 = z;
        double r458879 = r458877 / r458878;
        double r458880 = -1.630869942116376e+66;
        bool r458881 = r458879 <= r458880;
        double r458882 = x;
        double r458883 = r458877 * r458882;
        double r458884 = r458883 / r458878;
        double r458885 = -6.545487680777495e-230;
        bool r458886 = r458879 <= r458885;
        double r458887 = r458879 * r458882;
        double r458888 = 4.8140360229561644e-12;
        bool r458889 = r458879 <= r458888;
        double r458890 = r458878 / r458882;
        double r458891 = r458877 / r458890;
        double r458892 = r458889 ? r458884 : r458891;
        double r458893 = r458886 ? r458887 : r458892;
        double r458894 = r458881 ? r458884 : r458893;
        return r458894;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original15.1
Target1.6
Herbie3.7
\[\begin{array}{l} \mathbf{if}\;\frac{\frac{y}{z} \cdot t}{t} \lt -1.206722051230450047215521150762600712224 \cdot 10^{245}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} \lt -5.90752223693390632993316700759382836344 \cdot 10^{-275}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} \lt 5.658954423153415216825328199697215652986 \cdot 10^{-65}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \mathbf{elif}\;\frac{\frac{y}{z} \cdot t}{t} \lt 2.008718050240713347941382056648619307142 \cdot 10^{217}:\\ \;\;\;\;x \cdot \frac{y}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ y z) < -1.630869942116376e+66 or -6.545487680777495e-230 < (/ y z) < 4.8140360229561644e-12

    1. Initial program 17.6

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
    2. Simplified3.9

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

    if -1.630869942116376e+66 < (/ y z) < -6.545487680777495e-230

    1. Initial program 6.5

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
    2. Simplified9.8

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}}\]
    3. Using strategy rm
    4. Applied div-inv9.8

      \[\leadsto \color{blue}{\left(y \cdot x\right) \cdot \frac{1}{z}}\]
    5. Using strategy rm
    6. Applied pow19.8

      \[\leadsto \left(y \cdot x\right) \cdot \color{blue}{{\left(\frac{1}{z}\right)}^{1}}\]
    7. Applied pow19.8

      \[\leadsto \left(y \cdot \color{blue}{{x}^{1}}\right) \cdot {\left(\frac{1}{z}\right)}^{1}\]
    8. Applied pow19.8

      \[\leadsto \left(\color{blue}{{y}^{1}} \cdot {x}^{1}\right) \cdot {\left(\frac{1}{z}\right)}^{1}\]
    9. Applied pow-prod-down9.8

      \[\leadsto \color{blue}{{\left(y \cdot x\right)}^{1}} \cdot {\left(\frac{1}{z}\right)}^{1}\]
    10. Applied pow-prod-down9.8

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

      \[\leadsto {\color{blue}{\left(\frac{y}{\frac{z}{x}}\right)}}^{1}\]
    12. Using strategy rm
    13. Applied associate-/r/0.2

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

    if 4.8140360229561644e-12 < (/ y z)

    1. Initial program 18.7

      \[x \cdot \frac{\frac{y}{z} \cdot t}{t}\]
    2. Simplified8.3

      \[\leadsto \color{blue}{\frac{y \cdot x}{z}}\]
    3. Using strategy rm
    4. Applied div-inv8.4

      \[\leadsto \color{blue}{\left(y \cdot x\right) \cdot \frac{1}{z}}\]
    5. Using strategy rm
    6. Applied pow18.4

      \[\leadsto \left(y \cdot x\right) \cdot \color{blue}{{\left(\frac{1}{z}\right)}^{1}}\]
    7. Applied pow18.4

      \[\leadsto \left(y \cdot \color{blue}{{x}^{1}}\right) \cdot {\left(\frac{1}{z}\right)}^{1}\]
    8. Applied pow18.4

      \[\leadsto \left(\color{blue}{{y}^{1}} \cdot {x}^{1}\right) \cdot {\left(\frac{1}{z}\right)}^{1}\]
    9. Applied pow-prod-down8.4

      \[\leadsto \color{blue}{{\left(y \cdot x\right)}^{1}} \cdot {\left(\frac{1}{z}\right)}^{1}\]
    10. Applied pow-prod-down8.4

      \[\leadsto \color{blue}{{\left(\left(y \cdot x\right) \cdot \frac{1}{z}\right)}^{1}}\]
    11. Simplified7.3

      \[\leadsto {\color{blue}{\left(\frac{y}{\frac{z}{x}}\right)}}^{1}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification3.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{y}{z} \le -1.63086994211637596483956921546385031623 \cdot 10^{66}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{elif}\;\frac{y}{z} \le -6.545487680777495021156682531032583832353 \cdot 10^{-230}:\\ \;\;\;\;\frac{y}{z} \cdot x\\ \mathbf{elif}\;\frac{y}{z} \le 4.814036022956164419199695264571075550494 \cdot 10^{-12}:\\ \;\;\;\;\frac{y \cdot x}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{\frac{z}{x}}\\ \end{array}\]

Reproduce

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

  :herbie-target
  (if (< (/ (* (/ y z) t) t) -1.20672205123045005e245) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) -5.90752223693390633e-275) (* x (/ y z)) (if (< (/ (* (/ y z) t) t) 5.65895442315341522e-65) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) 2.0087180502407133e217) (* x (/ y z)) (/ (* y x) z)))))

  (* x (/ (* (/ y z) t) t)))