| Alternative 1 | |
|---|---|
| Error | 2.0 |
| Cost | 13632 |
\[x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)
\]
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (- (tanh (/ t y)) (tanh (/ x y)))))
(if (<= (+ x (* (* y z) t_1)) 1e+296)
(+ x (* z (* y t_1)))
(+ x (* (- t x) z)))))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) {
double t_1 = tanh((t / y)) - tanh((x / y));
double tmp;
if ((x + ((y * z) * t_1)) <= 1e+296) {
tmp = x + (z * (y * t_1));
} else {
tmp = x + ((t - x) * z);
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = tanh((t / y)) - tanh((x / y))
if ((x + ((y * z) * t_1)) <= 1d+296) then
tmp = x + (z * (y * t_1))
else
tmp = x + ((t - x) * z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y)) - Math.tanh((x / y));
double tmp;
if ((x + ((y * z) * t_1)) <= 1e+296) {
tmp = x + (z * (y * t_1));
} else {
tmp = x + ((t - x) * z);
}
return tmp;
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
def code(x, y, z, t): t_1 = math.tanh((t / y)) - math.tanh((x / y)) tmp = 0 if (x + ((y * z) * t_1)) <= 1e+296: tmp = x + (z * (y * t_1)) else: tmp = x + ((t - x) * z) return tmp
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) t_1 = Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) tmp = 0.0 if (Float64(x + Float64(Float64(y * z) * t_1)) <= 1e+296) tmp = Float64(x + Float64(z * Float64(y * t_1))); else tmp = Float64(x + Float64(Float64(t - x) * z)); end return tmp end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)) - tanh((x / y)); tmp = 0.0; if ((x + ((y * z) * t_1)) <= 1e+296) tmp = x + (z * (y * t_1)); else tmp = x + ((t - x) * z); end tmp_2 = tmp; 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_] := Block[{t$95$1 = N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x + N[(N[(y * z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 1e+296], N[(x + N[(z * N[(y * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(t - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\\
\mathbf{if}\;x + \left(y \cdot z\right) \cdot t_1 \leq 10^{+296}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(t - x\right) \cdot z\\
\end{array}
Results
| Original | 4.9 |
|---|---|
| Target | 2.0 |
| Herbie | 1.2 |
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 9.99999999999999981e295Initial program 2.4
Simplified0.6
[Start]2.4 | \[ x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\] |
|---|---|
rational.json-simplify-2 [=>]2.4 | \[ x + \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)}
\] |
rational.json-simplify-2 [=>]2.4 | \[ x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \color{blue}{\left(z \cdot y\right)}
\] |
rational.json-simplify-43 [=>]0.6 | \[ x + \color{blue}{z \cdot \left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)}
\] |
if 9.99999999999999981e295 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 49.9
Simplified18.1
[Start]49.9 | \[ x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\] |
|---|---|
rational.json-simplify-2 [=>]49.9 | \[ x + \color{blue}{\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)}
\] |
rational.json-simplify-2 [=>]49.9 | \[ x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \color{blue}{\left(z \cdot y\right)}
\] |
rational.json-simplify-43 [=>]18.1 | \[ x + \color{blue}{z \cdot \left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)}
\] |
Taylor expanded in y around inf 11.5
Simplified11.5
[Start]11.5 | \[ x + z \cdot \left(t - x\right)
\] |
|---|---|
rational.json-simplify-2 [=>]11.5 | \[ x + \color{blue}{\left(t - x\right) \cdot z}
\] |
Final simplification1.2
| Alternative 1 | |
|---|---|
| Error | 2.0 |
| Cost | 13632 |
| Alternative 2 | |
|---|---|
| Error | 15.2 |
| Cost | 7628 |
| Alternative 3 | |
|---|---|
| Error | 22.8 |
| Cost | 1244 |
| Alternative 4 | |
|---|---|
| Error | 18.4 |
| Cost | 848 |
| Alternative 5 | |
|---|---|
| Error | 15.2 |
| Cost | 712 |
| Alternative 6 | |
|---|---|
| Error | 20.6 |
| Cost | 584 |
| Alternative 7 | |
|---|---|
| Error | 23.6 |
| Cost | 520 |
| Alternative 8 | |
|---|---|
| Error | 22.4 |
| Cost | 456 |
| Alternative 9 | |
|---|---|
| Error | 22.7 |
| Cost | 64 |
herbie shell --seed 2023075
(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))))))