?

Average Error: 4.6 → 1.1
Time: 51.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 := \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\\ \mathbf{if}\;x + \left(y \cdot z\right) \cdot t_1 \leq 2 \cdot 10^{+299}:\\ \;\;\;\;x + z \cdot \left(y \cdot t_1\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot t + x \cdot \left(1 - z\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 (- (tanh (/ t y)) (tanh (/ x y)))))
   (if (<= (+ x (* (* y z) t_1)) 2e+299)
     (+ x (* z (* y t_1)))
     (+ (* z t) (* x (- 1.0 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)) <= 2e+299) {
		tmp = x + (z * (y * t_1));
	} else {
		tmp = (z * t) + (x * (1.0 - 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)) <= 2d+299) then
        tmp = x + (z * (y * t_1))
    else
        tmp = (z * t) + (x * (1.0d0 - 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)) <= 2e+299) {
		tmp = x + (z * (y * t_1));
	} else {
		tmp = (z * t) + (x * (1.0 - 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)) <= 2e+299:
		tmp = x + (z * (y * t_1))
	else:
		tmp = (z * t) + (x * (1.0 - 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)) <= 2e+299)
		tmp = Float64(x + Float64(z * Float64(y * t_1)));
	else
		tmp = Float64(Float64(z * t) + Float64(x * Float64(1.0 - 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)) <= 2e+299)
		tmp = x + (z * (y * t_1));
	else
		tmp = (z * t) + (x * (1.0 - 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], 2e+299], N[(x + N[(z * N[(y * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * t), $MachinePrecision] + N[(x * N[(1.0 - z), $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 := \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\\
\mathbf{if}\;x + \left(y \cdot z\right) \cdot t_1 \leq 2 \cdot 10^{+299}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.6
Target2.1
Herbie1.1
\[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))))) < 2.0000000000000001e299

    1. Initial program 2.3

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

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

      [Start]2.3

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

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

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

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

    if 2.0000000000000001e299 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 52.2

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

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

      [Start]52.2

      \[ 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 [=>]52.2

      \[ 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 [=>]52.2

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

      \[ x + \color{blue}{z \cdot \left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)} \]
    3. Taylor expanded in y around inf 8.5

      \[\leadsto x + \color{blue}{z \cdot \left(t - x\right)} \]
    4. Simplified8.5

      \[\leadsto x + \color{blue}{\left(t - x\right) \cdot z} \]
      Proof

      [Start]8.5

      \[ x + z \cdot \left(t - x\right) \]

      rational.json-simplify-2 [=>]8.5

      \[ x + \color{blue}{\left(t - x\right) \cdot z} \]
    5. Taylor expanded in x around 0 8.5

      \[\leadsto \color{blue}{\left(-1 \cdot z + 1\right) \cdot x + t \cdot z} \]
    6. Simplified8.5

      \[\leadsto \color{blue}{z \cdot t + x \cdot \left(1 - z\right)} \]
      Proof

      [Start]8.5

      \[ \left(-1 \cdot z + 1\right) \cdot x + t \cdot z \]

      rational.json-simplify-1 [=>]8.5

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

      rational.json-simplify-2 [=>]8.5

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

      rational.json-simplify-2 [=>]8.5

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

      rational.json-simplify-2 [=>]8.5

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

      rational.json-simplify-9 [=>]8.5

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

      rational.json-simplify-12 [=>]8.5

      \[ z \cdot t + x \cdot \left(\color{blue}{\left(0 - z\right)} + 1\right) \]

      metadata-eval [<=]8.5

      \[ z \cdot t + x \cdot \left(\left(0 - z\right) + \color{blue}{\left(1 - 0\right)}\right) \]

      rational.json-simplify-27 [=>]8.5

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

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

Alternatives

Alternative 1
Error1.6
Cost13764
\[\begin{array}{l} \mathbf{if}\;y \leq -2.6 \cdot 10^{+199}:\\ \;\;\;\;x + \left(t - x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\ \end{array} \]
Alternative 2
Error14.6
Cost7496
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-33}:\\ \;\;\;\;z \cdot t + x \cdot \left(1 - z\right)\\ \mathbf{elif}\;y \leq 3.9 \cdot 10^{-31}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(y \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\right)\\ \end{array} \]
Alternative 3
Error23.0
Cost1376
\[\begin{array}{l} t_1 := x \cdot \left(1 - z\right)\\ t_2 := \left(t - x\right) \cdot z\\ \mathbf{if}\;y \leq -5.5 \cdot 10^{+206}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -3.2 \cdot 10^{+129}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -4.45 \cdot 10^{+114}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -7.9 \cdot 10^{-25}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.5 \cdot 10^{+105}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.26 \cdot 10^{+171}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{+270}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+294}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error15.0
Cost712
\[\begin{array}{l} t_1 := x + \left(t - x\right) \cdot z\\ \mathbf{if}\;y \leq -2.05 \cdot 10^{-30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.3 \cdot 10^{+104}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error15.0
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{-28}:\\ \;\;\;\;z \cdot t + x \cdot \left(1 - z\right)\\ \mathbf{elif}\;y \leq 2.55 \cdot 10^{+104}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + \left(t - x\right) \cdot z\\ \end{array} \]
Alternative 6
Error23.4
Cost588
\[\begin{array}{l} \mathbf{if}\;y \leq -2.2 \cdot 10^{+205}:\\ \;\;\;\;t \cdot z\\ \mathbf{elif}\;y \leq 6.2 \cdot 10^{+282}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.1 \cdot 10^{+293}:\\ \;\;\;\;t \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error17.6
Cost584
\[\begin{array}{l} t_1 := x + z \cdot t\\ \mathbf{if}\;y \leq -2.6 \cdot 10^{-29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.55 \cdot 10^{+104}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error22.6
Cost64
\[x \]

Error

Reproduce?

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