SynthBasics:moogVCF from YampaSynth-0.2

?

Percentage Accurate: 93.3% → 97.7%
Time: 17.7s
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?

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 12 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each of Herbie's proposed alternatives. Up and to the right is better. Each dot represents an alternative program; the red square represents the initial program.

Target

Original93.3%
Target96.9%
Herbie97.7%
\[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 94.6%

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

    \[\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]94.6

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

    +-commutative [=>]94.6

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

    *-commutative [=>]94.6

    \[ \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.0

    \[ \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.0

    \[ \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.0%

    \[\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
Accuracy96.9%
Cost13632
\[x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) \]
Alternative 2
Accuracy87.8%
Cost13513
\[\begin{array}{l} \mathbf{if}\;t \leq -4.15 \cdot 10^{-57} \lor \neg \left(t \leq 7.6 \cdot 10^{-46}\right):\\ \;\;\;\;\mathsf{fma}\left(z, y \cdot \tanh \left(\frac{t}{y}\right), x\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(z \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\right)\\ \end{array} \]
Alternative 3
Accuracy85.6%
Cost7892
\[\begin{array}{l} t_1 := \tanh \left(\frac{t}{y}\right)\\ t_2 := x + t_1 \cdot \left(z \cdot y\right)\\ t_3 := z \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -5 \cdot 10^{+141}:\\ \;\;\;\;x + t_3\\ \mathbf{elif}\;y \leq -2.2 \cdot 10^{-202}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-168}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 31000000000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 8.6 \cdot 10^{+214}:\\ \;\;\;\;x + \left(z \cdot y\right) \cdot \left(t_1 - \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(y \cdot \frac{1}{y}\right) \cdot t_3\\ \end{array} \]
Alternative 4
Accuracy84.9%
Cost7504
\[\begin{array}{l} t_1 := x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ t_2 := z \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -1.02 \cdot 10^{+142}:\\ \;\;\;\;x + t_2\\ \mathbf{elif}\;y \leq -2.8 \cdot 10^{-203}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.6 \cdot 10^{-165}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+191}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + \left(y \cdot \frac{1}{y}\right) \cdot t_2\\ \end{array} \]
Alternative 5
Accuracy86.5%
Cost7497
\[\begin{array}{l} \mathbf{if}\;t \leq -1.3 \cdot 10^{-56} \lor \neg \left(t \leq 1.85 \cdot 10^{-33}\right):\\ \;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(z \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\right)\\ \end{array} \]
Alternative 6
Accuracy59.6%
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq 2.1 \cdot 10^{-284}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-210}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \leq 5.9 \cdot 10^{-52}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-19}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Accuracy78.7%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{+30} \lor \neg \left(y \leq 2.4\right):\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Accuracy57.9%
Cost588
\[\begin{array}{l} \mathbf{if}\;z \leq 3.1 \cdot 10^{+19}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 4 \cdot 10^{+221}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+279}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 9
Accuracy64.8%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -2.3 \cdot 10^{+107} \lor \neg \left(z \leq 3.35 \cdot 10^{+16}\right):\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Accuracy70.8%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{+28} \lor \neg \left(y \leq 2.4 \cdot 10^{-51}\right):\\ \;\;\;\;x + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Accuracy60.4%
Cost64
\[x \]

Reproduce?

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