?

Average Accuracy: 92.6% → 95.6%
Time: 15.5s
Precision: binary64
Cost: 27332

?

\[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 := x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\right)\\ \mathbf{if}\;t_1 \leq 5 \cdot 10^{+283}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
(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 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* z y)))))
   (if (<= t_1 5e+283) t_1 (+ x (* z (- t 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) {
	double t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (z * y));
	double tmp;
	if (t_1 <= 5e+283) {
		tmp = t_1;
	} else {
		tmp = x + (z * (t - x));
	}
	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 = x + ((tanh((t / y)) - tanh((x / y))) * (z * y))
    if (t_1 <= 5d+283) then
        tmp = t_1
    else
        tmp = x + (z * (t - x))
    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 = x + ((Math.tanh((t / y)) - Math.tanh((x / y))) * (z * y));
	double tmp;
	if (t_1 <= 5e+283) {
		tmp = t_1;
	} else {
		tmp = x + (z * (t - x));
	}
	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 = x + ((math.tanh((t / y)) - math.tanh((x / y))) * (z * y))
	tmp = 0
	if t_1 <= 5e+283:
		tmp = t_1
	else:
		tmp = x + (z * (t - x))
	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(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(z * y)))
	tmp = 0.0
	if (t_1 <= 5e+283)
		tmp = t_1;
	else
		tmp = Float64(x + Float64(z * Float64(t - x)));
	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 = x + ((tanh((t / y)) - tanh((x / y))) * (z * y));
	tmp = 0.0;
	if (t_1 <= 5e+283)
		tmp = t_1;
	else
		tmp = x + (z * (t - x));
	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[(x + N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e+283], t$95$1, N[(x + N[(z * N[(t - x), $MachinePrecision]), $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 := x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\right)\\
\mathbf{if}\;t_1 \leq 5 \cdot 10^{+283}:\\
\;\;\;\;t_1\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original92.6%
Target96.8%
Herbie95.6%
\[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 (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 5.0000000000000004e283

    1. Initial program 96.8%

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

    if 5.0000000000000004e283 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 31.0%

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

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

      [Start]31.0

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

      +-commutative [=>]31.0

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

      fma-def [=>]31.0

      \[ \color{blue}{\mathsf{fma}\left(y \cdot z, \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right), x\right)} \]
    3. Taylor expanded in y around inf 78.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\right) \leq 5 \cdot 10^{+283}:\\ \;\;\;\;x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy97.8%
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
Accuracy83.0%
Cost13644
\[\begin{array}{l} t_1 := \mathsf{fma}\left(y, z \cdot \tanh \left(\frac{t}{y}\right), x\right)\\ \mathbf{if}\;t \leq -3.5 \cdot 10^{-260}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.2 \cdot 10^{-203}:\\ \;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\ \mathbf{elif}\;t \leq 7.5 \cdot 10^{-68}:\\ \;\;\;\;x + \left(z \cdot y\right) \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy81.5%
Cost7628
\[\begin{array}{l} t_1 := x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \mathbf{if}\;t \leq -1.85 \cdot 10^{-254}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 6 \cdot 10^{-203}:\\ \;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\ \mathbf{elif}\;t \leq 1.1 \cdot 10^{-66}:\\ \;\;\;\;x + \left(z \cdot y\right) \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy84.5%
Cost7240
\[\begin{array}{l} \mathbf{if}\;y \leq -9 \cdot 10^{+100}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+120}:\\ \;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\ \end{array} \]
Alternative 5
Accuracy76.9%
Cost6984
\[\begin{array}{l} \mathbf{if}\;y \leq -7.5 \cdot 10^{-17}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq 16500000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\ \end{array} \]
Alternative 6
Accuracy76.9%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -8.4 \cdot 10^{-19} \lor \neg \left(y \leq 12000000\right):\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Accuracy68.2%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -7.8 \cdot 10^{+86} \lor \neg \left(y \leq 7.5 \cdot 10^{+120}\right):\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Accuracy72.3%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{-21} \lor \neg \left(y \leq 4300000\right):\\ \;\;\;\;x + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Accuracy65.2%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{-234}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-200}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Accuracy64.5%
Cost64
\[x \]

Error

Reproduce?

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