Average Error: 25.4 → 8.6
Time: 3.1m
Precision: 64
Internal Precision: 384
\[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
\[\begin{array}{l} \mathbf{if}\;\cosh x \cdot \frac{y}{x} \le -4.010803076035026 \cdot 10^{+232}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{y \cdot x}{z} + \frac{y}{z \cdot x}\\ \mathbf{if}\;\cosh x \cdot \frac{y}{x} \le 1.0747284663836783 \cdot 10^{+250}:\\ \;\;\;\;\left(\cosh x \cdot \frac{y}{x}\right) \cdot \frac{1}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt[3]{\cosh x} \cdot \sqrt[3]{e^{x} + e^{-x}}\right) \cdot \left(\sqrt[3]{\cosh x} \cdot y\right)}{z \cdot \left(\sqrt[3]{2} \cdot x\right)}\\ \end{array}\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original25.4
Target20.8
Herbie8.6
\[\begin{array}{l} \mathbf{if}\;y \lt -4.618902267687042 \cdot 10^{-52}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} \cdot \cosh x\\ \mathbf{if}\;y \lt 1.038530535935153 \cdot 10^{-39}:\\ \;\;\;\;\frac{\frac{\cosh x \cdot y}{x}}{z}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{y}{z}}{x} \cdot \cosh x\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if (* (cosh x) (/ y x)) < -4.010803076035026e+232

    1. Initial program 55.0

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Taylor expanded around 0 8.2

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

    if -4.010803076035026e+232 < (* (cosh x) (/ y x)) < 1.0747284663836783e+250

    1. Initial program 0.2

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Using strategy rm
    3. Applied div-inv0.3

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

    if 1.0747284663836783e+250 < (* (cosh x) (/ y x))

    1. Initial program 52.6

      \[\frac{\cosh x \cdot \frac{y}{x}}{z}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt52.6

      \[\leadsto \frac{\color{blue}{\left(\left(\sqrt[3]{\cosh x} \cdot \sqrt[3]{\cosh x}\right) \cdot \sqrt[3]{\cosh x}\right)} \cdot \frac{y}{x}}{z}\]
    4. Applied associate-*l*52.6

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{\cosh x} \cdot \sqrt[3]{\cosh x}\right) \cdot \left(\sqrt[3]{\cosh x} \cdot \frac{y}{x}\right)}}{z}\]
    5. Using strategy rm
    6. Applied associate-*r/52.1

      \[\leadsto \frac{\left(\sqrt[3]{\cosh x} \cdot \sqrt[3]{\cosh x}\right) \cdot \color{blue}{\frac{\sqrt[3]{\cosh x} \cdot y}{x}}}{z}\]
    7. Applied cosh-def52.1

      \[\leadsto \frac{\left(\sqrt[3]{\cosh x} \cdot \sqrt[3]{\color{blue}{\frac{e^{x} + e^{-x}}{2}}}\right) \cdot \frac{\sqrt[3]{\cosh x} \cdot y}{x}}{z}\]
    8. Applied cbrt-div52.1

      \[\leadsto \frac{\left(\sqrt[3]{\cosh x} \cdot \color{blue}{\frac{\sqrt[3]{e^{x} + e^{-x}}}{\sqrt[3]{2}}}\right) \cdot \frac{\sqrt[3]{\cosh x} \cdot y}{x}}{z}\]
    9. Applied associate-*r/52.1

      \[\leadsto \frac{\color{blue}{\frac{\sqrt[3]{\cosh x} \cdot \sqrt[3]{e^{x} + e^{-x}}}{\sqrt[3]{2}}} \cdot \frac{\sqrt[3]{\cosh x} \cdot y}{x}}{z}\]
    10. Applied frac-times52.1

      \[\leadsto \frac{\color{blue}{\frac{\left(\sqrt[3]{\cosh x} \cdot \sqrt[3]{e^{x} + e^{-x}}\right) \cdot \left(\sqrt[3]{\cosh x} \cdot y\right)}{\sqrt[3]{2} \cdot x}}}{z}\]
    11. Applied associate-/l/37.1

      \[\leadsto \color{blue}{\frac{\left(\sqrt[3]{\cosh x} \cdot \sqrt[3]{e^{x} + e^{-x}}\right) \cdot \left(\sqrt[3]{\cosh x} \cdot y\right)}{z \cdot \left(\sqrt[3]{2} \cdot x\right)}}\]
  3. Recombined 3 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 3.1m)Debug log

herbie shell --seed '#(1567391828 2030694642 2833800258 828025724 3004380912 3532991858)' +o setup:early-exit +o reduce:binary-search
(FPCore (x y z)
  :name "Linear.Quaternion:$ctan from linear-1.19.1.3"

  :herbie-target
  (if (< y -4.618902267687042e-52) (* (/ (/ y z) x) (cosh x)) (if (< y 1.038530535935153e-39) (/ (/ (* (cosh x) y) x) z) (* (/ (/ y z) x) (cosh x))))

  (/ (* (cosh x) (/ y x)) z))