SynthBasics:moogVCF from YampaSynth-0.2

?

Percentage Accurate: 92.6% → 97.3%
Time: 22.4s
Precision: binary64
Cost: 19904

?

\[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
\[\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right) \]
(FPCore (x y z t)
 :precision binary64
 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
(FPCore (x y z t)
 :precision binary64
 (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x))
double code(double x, double y, double z, double t) {
	return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
double code(double x, double y, double z, double t) {
	return fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
}
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))
end
function code(x, y, z, t)
	return fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x)
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(z * N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Herbie found 13 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Bogosity?

Bogosity

Target

Original92.6%
Target96.4%
Herbie97.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 95.4%

    \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
  2. Simplified98.7%

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)} \]
    Step-by-step derivation

    [Start]95.4%

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

    +-commutative [=>]95.4%

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

    *-commutative [=>]95.4%

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

    associate-*l* [=>]98.7%

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

    fma-def [=>]98.7%

    \[ \color{blue}{\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)} \]
  3. Final simplification98.7%

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

Alternatives

Alternative 1
Accuracy97.3%
Cost19904
\[\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right) \]
Alternative 2
Accuracy96.4%
Cost13632
\[x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) \]
Alternative 3
Accuracy88.9%
Cost13513
\[\begin{array}{l} t_1 := y \cdot \tanh \left(\frac{t}{y}\right)\\ \mathbf{if}\;y \leq -6.2 \cdot 10^{+17} \lor \neg \left(y \leq 61\right):\\ \;\;\;\;x + z \cdot \left(t_1 - x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, t_1, x\right)\\ \end{array} \]
Alternative 4
Accuracy89.0%
Cost7369
\[\begin{array}{l} t_1 := \tanh \left(\frac{t}{y}\right)\\ \mathbf{if}\;y \leq -1.52 \cdot 10^{+16} \lor \neg \left(y \leq 1050\right):\\ \;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + t_1 \cdot \left(z \cdot y\right)\\ \end{array} \]
Alternative 5
Accuracy86.1%
Cost7240
\[\begin{array}{l} \mathbf{if}\;y \leq -6.5 \cdot 10^{+147}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+144}:\\ \;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\ \end{array} \]
Alternative 6
Accuracy75.3%
Cost6984
\[\begin{array}{l} \mathbf{if}\;y \leq -2 \cdot 10^{-38}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq 125:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\ \end{array} \]
Alternative 7
Accuracy65.3%
Cost848
\[\begin{array}{l} t_1 := z \cdot \left(t - x\right)\\ t_2 := x + z \cdot t\\ \mathbf{if}\;z \leq -4.8 \cdot 10^{+38}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.5 \cdot 10^{-68}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 9 \cdot 10^{-192}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.65 \cdot 10^{+199}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Accuracy55.7%
Cost784
\[\begin{array}{l} t_1 := -z \cdot x\\ \mathbf{if}\;z \leq -9.2 \cdot 10^{+153}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{+72}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 2.3 \cdot 10^{+163}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{+201}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Accuracy64.5%
Cost717
\[\begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{+160}:\\ \;\;\;\;x - z \cdot x\\ \mathbf{elif}\;y \leq -1.5 \cdot 10^{-38} \lor \neg \left(y \leq 6.6 \cdot 10^{-74}\right):\\ \;\;\;\;x + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Accuracy75.3%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1.65 \cdot 10^{-38} \lor \neg \left(y \leq 60\right):\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Accuracy64.2%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -4.2 \cdot 10^{+30} \lor \neg \left(z \leq 1.45 \cdot 10^{-21}\right):\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Accuracy55.4%
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -4.8 \cdot 10^{+140}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \leq 2.7 \cdot 10^{+70}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 13
Accuracy53.1%
Cost64
\[x \]

Reproduce?

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