Average Error: 4.9 → 1.4
Time: 11.0s
Precision: binary64
Cost: 27460
\[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{x}{y}\right)\\ t_2 := \tanh \left(\frac{t}{y}\right)\\ \mathbf{if}\;x + \left(y \cdot z\right) \cdot \left(t_2 - t_1\right) \leq 5 \cdot 10^{+305}:\\ \;\;\;\;x + y \cdot \left(z \cdot t_2 - z \cdot t_1\right)\\ \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 (tanh (/ x y))) (t_2 (tanh (/ t y))))
   (if (<= (+ x (* (* y z) (- t_2 t_1))) 5e+305)
     (+ x (* y (- (* z t_2) (* z 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 = tanh((x / y));
	double t_2 = tanh((t / y));
	double tmp;
	if ((x + ((y * z) * (t_2 - t_1))) <= 5e+305) {
		tmp = x + (y * ((z * t_2) - (z * 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) :: t_2
    real(8) :: tmp
    t_1 = tanh((x / y))
    t_2 = tanh((t / y))
    if ((x + ((y * z) * (t_2 - t_1))) <= 5d+305) then
        tmp = x + (y * ((z * t_2) - (z * 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 = Math.tanh((x / y));
	double t_2 = Math.tanh((t / y));
	double tmp;
	if ((x + ((y * z) * (t_2 - t_1))) <= 5e+305) {
		tmp = x + (y * ((z * t_2) - (z * 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 = math.tanh((x / y))
	t_2 = math.tanh((t / y))
	tmp = 0
	if (x + ((y * z) * (t_2 - t_1))) <= 5e+305:
		tmp = x + (y * ((z * t_2) - (z * 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 = tanh(Float64(x / y))
	t_2 = tanh(Float64(t / y))
	tmp = 0.0
	if (Float64(x + Float64(Float64(y * z) * Float64(t_2 - t_1))) <= 5e+305)
		tmp = Float64(x + Float64(y * Float64(Float64(z * t_2) - Float64(z * 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 = tanh((x / y));
	t_2 = tanh((t / y));
	tmp = 0.0;
	if ((x + ((y * z) * (t_2 - t_1))) <= 5e+305)
		tmp = x + (y * ((z * t_2) - (z * 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[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(x + N[(N[(y * z), $MachinePrecision] * N[(t$95$2 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+305], N[(x + N[(y * N[(N[(z * t$95$2), $MachinePrecision] - N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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 := \tanh \left(\frac{x}{y}\right)\\
t_2 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;x + \left(y \cdot z\right) \cdot \left(t_2 - t_1\right) \leq 5 \cdot 10^{+305}:\\
\;\;\;\;x + y \cdot \left(z \cdot t_2 - z \cdot t_1\right)\\

\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

Original4.9
Target2.0
Herbie1.4
\[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.00000000000000009e305

    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. Simplified1.2

      \[\leadsto \color{blue}{x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)} \]
      Proof
      (+.f64 x (*.f64 y (*.f64 z (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))): 25 points increase in error, 11 points decrease in error
    3. Applied egg-rr1.2

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

    if 5.00000000000000009e305 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 60.7

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

      \[\leadsto \color{blue}{x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)} \]
      Proof
      (+.f64 x (*.f64 y (*.f64 z (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))): 25 points increase in error, 11 points decrease in error
    3. Taylor expanded in y around inf 4.9

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

    \[\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 5 \cdot 10^{+305}:\\ \;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right) - z \cdot \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]

Alternatives

Alternative 1
Error1.4
Cost27332
\[\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 5 \cdot 10^{+305}:\\ \;\;\;\;x + y \cdot \left(z \cdot t_1\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 2
Error10.7
Cost7240
\[\begin{array}{l} t_1 := x + z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right)\right)\\ \mathbf{if}\;t \leq -1.2 \cdot 10^{-135}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.3 \cdot 10^{-161}:\\ \;\;\;\;\mathsf{fma}\left(t, z, x \cdot \left(1 - z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error15.0
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{+99}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq 85000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t, z, x \cdot \left(1 - z\right)\right)\\ \end{array} \]
Alternative 4
Error22.9
Cost848
\[\begin{array}{l} t_1 := z \cdot \left(t - x\right)\\ \mathbf{if}\;x \leq -1.55 \cdot 10^{-202}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.7 \cdot 10^{-224}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-268}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-118}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error18.5
Cost848
\[\begin{array}{l} t_1 := x + z \cdot t\\ \mathbf{if}\;y \leq -1.8 \cdot 10^{+100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.85 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 9 \cdot 10^{+175}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+233}:\\ \;\;\;\;x - x \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error22.7
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -1.8 \cdot 10^{-201}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -7 \cdot 10^{-226}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \leq -5.4 \cdot 10^{-269}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8.8 \cdot 10^{-289}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error15.1
Cost712
\[\begin{array}{l} t_1 := x + z \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -1.8 \cdot 10^{+100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1050000000:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error18.2
Cost584
\[\begin{array}{l} t_1 := x + z \cdot t\\ \mathbf{if}\;y \leq -1.28 \cdot 10^{+100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-19}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error23.0
Cost64
\[x \]

Error

Reproduce

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