Average Error: 2.6 → 0.6
Time: 36.4s
Precision: 64
\[\frac{x \cdot \frac{\sin y}{y}}{z}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.594701495792515057480404720241474555947 \cdot 10^{144} \lor \neg \left(x \le 131028341213362427538349437327769600\right):\\ \;\;\;\;\frac{1}{z} \cdot \left(\frac{\sin y}{y} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\ \end{array}\]
\frac{x \cdot \frac{\sin y}{y}}{z}
\begin{array}{l}
\mathbf{if}\;x \le -2.594701495792515057480404720241474555947 \cdot 10^{144} \lor \neg \left(x \le 131028341213362427538349437327769600\right):\\
\;\;\;\;\frac{1}{z} \cdot \left(\frac{\sin y}{y} \cdot x\right)\\

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

\end{array}
double f(double x, double y, double z) {
        double r323659 = x;
        double r323660 = y;
        double r323661 = sin(r323660);
        double r323662 = r323661 / r323660;
        double r323663 = r323659 * r323662;
        double r323664 = z;
        double r323665 = r323663 / r323664;
        return r323665;
}

double f(double x, double y, double z) {
        double r323666 = x;
        double r323667 = -2.594701495792515e+144;
        bool r323668 = r323666 <= r323667;
        double r323669 = 1.3102834121336243e+35;
        bool r323670 = r323666 <= r323669;
        double r323671 = !r323670;
        bool r323672 = r323668 || r323671;
        double r323673 = 1.0;
        double r323674 = z;
        double r323675 = r323673 / r323674;
        double r323676 = y;
        double r323677 = sin(r323676);
        double r323678 = r323677 / r323676;
        double r323679 = r323678 * r323666;
        double r323680 = r323675 * r323679;
        double r323681 = r323666 / r323674;
        double r323682 = r323678 * r323681;
        double r323683 = r323672 ? r323680 : r323682;
        return r323683;
}

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

Original2.6
Target0.2
Herbie0.6
\[\begin{array}{l} \mathbf{if}\;z \lt -4.217372020342714661850238929213415773451 \cdot 10^{-29}:\\ \;\;\;\;\frac{x \cdot \frac{1}{\frac{y}{\sin y}}}{z}\\ \mathbf{elif}\;z \lt 4.446702369113811028051510715777703865332 \cdot 10^{64}:\\ \;\;\;\;\frac{x}{z \cdot \frac{y}{\sin y}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \frac{1}{\frac{y}{\sin y}}}{z}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -2.594701495792515e+144 or 1.3102834121336243e+35 < x

    1. Initial program 0.2

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Simplified8.0

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

      \[\leadsto x \cdot \color{blue}{\left(\frac{\sin y}{y} \cdot \frac{1}{z}\right)}\]
    5. Applied associate-*r*0.4

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

    if -2.594701495792515e+144 < x < 1.3102834121336243e+35

    1. Initial program 3.6

      \[\frac{x \cdot \frac{\sin y}{y}}{z}\]
    2. Simplified0.7

      \[\leadsto \color{blue}{x \cdot \frac{\frac{\sin y}{y}}{z}}\]
    3. Taylor expanded around inf 11.1

      \[\leadsto \color{blue}{\frac{x \cdot \sin y}{z \cdot y}}\]
    4. Simplified0.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.594701495792515057480404720241474555947 \cdot 10^{144} \lor \neg \left(x \le 131028341213362427538349437327769600\right):\\ \;\;\;\;\frac{1}{z} \cdot \left(\frac{\sin y}{y} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sin y}{y} \cdot \frac{x}{z}\\ \end{array}\]

Reproduce

herbie shell --seed 2019179 +o rules:numerics
(FPCore (x y z)
  :name "Linear.Quaternion:$ctanh from linear-1.19.1.3"

  :herbie-target
  (if (< z -4.2173720203427147e-29) (/ (* x (/ 1.0 (/ y (sin y)))) z) (if (< z 4.446702369113811e+64) (/ x (* z (/ y (sin y)))) (/ (* x (/ 1.0 (/ y (sin y)))) z)))

  (/ (* x (/ (sin y) y)) z))