Average Error: 4.4 → 1.6
Time: 12.2s
Precision: binary64
Cost: 13764
\[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
\[\begin{array}{l} \mathbf{if}\;y \leq 3.5 \cdot 10^{+188}:\\ \;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot t + \left(x - x \cdot 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
 (if (<= y 3.5e+188)
   (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
   (+ (* z t) (- x (* 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 tmp;
	if (y <= 3.5e+188) {
		tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
	} else {
		tmp = (z * t) + (x - (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) :: tmp
    if (y <= 3.5d+188) then
        tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
    else
        tmp = (z * t) + (x - (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 tmp;
	if (y <= 3.5e+188) {
		tmp = x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
	} else {
		tmp = (z * t) + (x - (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):
	tmp = 0
	if y <= 3.5e+188:
		tmp = x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y)))))
	else:
		tmp = (z * t) + (x - (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)
	tmp = 0.0
	if (y <= 3.5e+188)
		tmp = Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))));
	else
		tmp = Float64(Float64(z * t) + Float64(x - Float64(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)
	tmp = 0.0;
	if (y <= 3.5e+188)
		tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
	else
		tmp = (z * t) + (x - (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_] := If[LessEqual[y, 3.5e+188], N[(x + N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * t), $MachinePrecision] + N[(x - N[(x * 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}
\mathbf{if}\;y \leq 3.5 \cdot 10^{+188}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.4
Target2.0
Herbie1.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 y < 3.50000000000000008e188

    1. Initial program 3.1

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

      \[\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)))))): 18 points increase in error, 7 points decrease in error

    if 3.50000000000000008e188 < y

    1. Initial program 18.7

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

      \[\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)))))): 18 points increase in error, 7 points decrease in error
    3. Taylor expanded in y around inf 11.2

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

      \[\leadsto x + y \cdot \color{blue}{\frac{t - x}{\frac{y}{z}}} \]
      Proof
      (/.f64 (-.f64 t x) (/.f64 y z)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 (-.f64 t x) z) y)): 43 points increase in error, 33 points decrease in error
    5. Applied egg-rr11.4

      \[\leadsto x + y \cdot \color{blue}{\left(\frac{1}{y} \cdot \frac{t - x}{\frac{1}{z}}\right)} \]
    6. Applied egg-rr5.8

      \[\leadsto x + \color{blue}{\frac{t - x}{\frac{1}{z}}} \]
    7. Applied egg-rr5.6

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

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

Alternatives

Alternative 1
Error10.0
Cost7240
\[\begin{array}{l} \mathbf{if}\;y \leq -4.2 \cdot 10^{+133}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+108}:\\ \;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;z \cdot t + \left(x - x \cdot z\right)\\ \end{array} \]
Alternative 2
Error21.0
Cost848
\[\begin{array}{l} t_1 := x + z \cdot t\\ \mathbf{if}\;x \leq -9.5 \cdot 10^{-151}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{-197}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.1 \cdot 10^{-132}:\\ \;\;\;\;x - x \cdot z\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-79}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error15.4
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -3.1 \cdot 10^{-20}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+57}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot t + \left(x - x \cdot z\right)\\ \end{array} \]
Alternative 4
Error16.1
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -9.2 \cdot 10^{-20}:\\ \;\;\;\;x + y \cdot \left(\left(t - x\right) \cdot \frac{z}{y}\right)\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{+58}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot t + \left(x - x \cdot z\right)\\ \end{array} \]
Alternative 5
Error16.2
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -1.22 \cdot 10^{-20}:\\ \;\;\;\;x + y \cdot \frac{t - x}{\frac{y}{z}}\\ \mathbf{elif}\;y \leq 6.5 \cdot 10^{+59}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot t + \left(x - x \cdot z\right)\\ \end{array} \]
Alternative 6
Error15.4
Cost712
\[\begin{array}{l} t_1 := x + z \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -3.9 \cdot 10^{-20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.45 \cdot 10^{+58}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error18.4
Cost584
\[\begin{array}{l} t_1 := x + z \cdot t\\ \mathbf{if}\;y \leq -2.7 \cdot 10^{-33}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6 \cdot 10^{+57}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error22.7
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -7.5 \cdot 10^{-177}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.7 \cdot 10^{-238}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error23.3
Cost64
\[x \]

Error

Reproduce

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