Average Error: 4.5 → 3.4
Time: 1.1m
Precision: 64
\[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
\[\begin{array}{l} \mathbf{if}\;y \le 3.756259882225389882314932700969424341805 \cdot 10^{164}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}\right) \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)} - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(t \cdot z - x \cdot z\right)\\ \end{array}\]
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\begin{array}{l}
\mathbf{if}\;y \le 3.756259882225389882314932700969424341805 \cdot 10^{164}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}\right) \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)} - \tanh \left(\frac{x}{y}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x + \left(t \cdot z - x \cdot z\right)\\

\end{array}
double f(double x, double y, double z, double t) {
        double r583937 = x;
        double r583938 = y;
        double r583939 = z;
        double r583940 = r583938 * r583939;
        double r583941 = t;
        double r583942 = r583941 / r583938;
        double r583943 = tanh(r583942);
        double r583944 = r583937 / r583938;
        double r583945 = tanh(r583944);
        double r583946 = r583943 - r583945;
        double r583947 = r583940 * r583946;
        double r583948 = r583937 + r583947;
        return r583948;
}

double f(double x, double y, double z, double t) {
        double r583949 = y;
        double r583950 = 3.75625988222539e+164;
        bool r583951 = r583949 <= r583950;
        double r583952 = x;
        double r583953 = z;
        double r583954 = r583949 * r583953;
        double r583955 = t;
        double r583956 = r583955 / r583949;
        double r583957 = tanh(r583956);
        double r583958 = cbrt(r583957);
        double r583959 = r583958 * r583958;
        double r583960 = r583959 * r583958;
        double r583961 = r583952 / r583949;
        double r583962 = tanh(r583961);
        double r583963 = r583960 - r583962;
        double r583964 = r583954 * r583963;
        double r583965 = r583952 + r583964;
        double r583966 = r583955 * r583953;
        double r583967 = r583952 * r583953;
        double r583968 = r583966 - r583967;
        double r583969 = r583952 + r583968;
        double r583970 = r583951 ? r583965 : r583969;
        return r583970;
}

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

Original4.5
Target1.9
Herbie3.4
\[x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\]

Derivation

  1. Split input into 2 regimes
  2. if y < 3.75625988222539e+164

    1. Initial program 3.0

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
    2. Using strategy rm
    3. Applied add-cube-cbrt3.1

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

    if 3.75625988222539e+164 < y

    1. Initial program 18.2

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
    2. Using strategy rm
    3. Applied associate-*l*8.9

      \[\leadsto x + \color{blue}{y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)}\]
    4. Using strategy rm
    5. Applied flip3--35.7

      \[\leadsto x + y \cdot \left(z \cdot \color{blue}{\frac{{\left(\tanh \left(\frac{t}{y}\right)\right)}^{3} - {\left(\tanh \left(\frac{x}{y}\right)\right)}^{3}}{\tanh \left(\frac{t}{y}\right) \cdot \tanh \left(\frac{t}{y}\right) + \left(\tanh \left(\frac{x}{y}\right) \cdot \tanh \left(\frac{x}{y}\right) + \tanh \left(\frac{t}{y}\right) \cdot \tanh \left(\frac{x}{y}\right)\right)}}\right)\]
    6. Applied associate-*r/36.3

      \[\leadsto x + y \cdot \color{blue}{\frac{z \cdot \left({\left(\tanh \left(\frac{t}{y}\right)\right)}^{3} - {\left(\tanh \left(\frac{x}{y}\right)\right)}^{3}\right)}{\tanh \left(\frac{t}{y}\right) \cdot \tanh \left(\frac{t}{y}\right) + \left(\tanh \left(\frac{x}{y}\right) \cdot \tanh \left(\frac{x}{y}\right) + \tanh \left(\frac{t}{y}\right) \cdot \tanh \left(\frac{x}{y}\right)\right)}}\]
    7. Applied associate-*r/36.3

      \[\leadsto x + \color{blue}{\frac{y \cdot \left(z \cdot \left({\left(\tanh \left(\frac{t}{y}\right)\right)}^{3} - {\left(\tanh \left(\frac{x}{y}\right)\right)}^{3}\right)\right)}{\tanh \left(\frac{t}{y}\right) \cdot \tanh \left(\frac{t}{y}\right) + \left(\tanh \left(\frac{x}{y}\right) \cdot \tanh \left(\frac{x}{y}\right) + \tanh \left(\frac{t}{y}\right) \cdot \tanh \left(\frac{x}{y}\right)\right)}}\]
    8. Taylor expanded around 0 6.4

      \[\leadsto x + \color{blue}{\left(t \cdot z - x \cdot z\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification3.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le 3.756259882225389882314932700969424341805 \cdot 10^{164}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(\left(\sqrt[3]{\tanh \left(\frac{t}{y}\right)} \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)}\right) \cdot \sqrt[3]{\tanh \left(\frac{t}{y}\right)} - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(t \cdot z - x \cdot z\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019353 
(FPCore (x y z t)
  :name "SynthBasics:moogVCF from YampaSynth-0.2"
  :precision binary64

  :herbie-target
  (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))

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