Average Error: 4.7 → 2.3
Time: 4.2s
Precision: binary64
\[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
\[x + \left(y \cdot \left(\tanh \left(\frac{t}{y}\right) \cdot z\right) + y \cdot \left(\left(-\tanh \left(\frac{x}{y}\right)\right) \cdot z\right)\right)\]

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.7
Target2.2
Herbie2.3
\[x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\]

Derivation

  1. Initial program 4.7

    \[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*2.2

    \[\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 sub-neg2.2

    \[\leadsto x + y \cdot \left(z \cdot \color{blue}{\left(\tanh \left(\frac{t}{y}\right) + \left(-\tanh \left(\frac{x}{y}\right)\right)\right)}\right)\]
  6. Applied distribute-lft-in2.2

    \[\leadsto x + y \cdot \color{blue}{\left(z \cdot \tanh \left(\frac{t}{y}\right) + z \cdot \left(-\tanh \left(\frac{x}{y}\right)\right)\right)}\]
  7. Applied distribute-lft-in2.3

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

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

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

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

Reproduce

herbie shell --seed 2020153 
(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))))))