
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
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
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); 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]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
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
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); 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]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
(FPCore (x y z t) :precision binary64 (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x))
double code(double x, double y, double z, double t) {
return fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
}
function code(x, y, z, t) return fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
code[x_, y_, z_, t_] := N[(z * N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
\end{array}
Initial program 95.9%
+-commutative95.9%
*-commutative95.9%
associate-*l*98.8%
fma-def98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* z y))))) (if (<= t_1 5e+296) t_1 (+ x (* z (- t x))))))
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+296) {
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
real(8) :: t_1
real(8) :: tmp
t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (z * y))
if (t_1 <= 5d+296) 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) {
double t_1 = x + ((Math.tanh((t / y)) - Math.tanh((x / y))) * (z * y));
double tmp;
if (t_1 <= 5e+296) {
tmp = t_1;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
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+296: tmp = t_1 else: tmp = x + (z * (t - x)) return tmp
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+296) tmp = t_1; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp 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+296) tmp = t_1; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
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+296], t$95$1, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\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^{+296}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 5.0000000000000001e296Initial program 98.0%
if 5.0000000000000001e296 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 64.4%
Taylor expanded in y around inf 100.0%
Final simplification98.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= t -8e-23)
(fma z (* y t_1) x)
(if (<= t 60000.0)
(+ (- x (* y (* z (tanh (/ x y))))) (* z t))
(+ x (* t_1 (* z y)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (t <= -8e-23) {
tmp = fma(z, (y * t_1), x);
} else if (t <= 60000.0) {
tmp = (x - (y * (z * tanh((x / y))))) + (z * t);
} else {
tmp = x + (t_1 * (z * y));
}
return tmp;
}
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (t <= -8e-23) tmp = fma(z, Float64(y * t_1), x); elseif (t <= 60000.0) tmp = Float64(Float64(x - Float64(y * Float64(z * tanh(Float64(x / y))))) + Float64(z * t)); else tmp = Float64(x + Float64(t_1 * Float64(z * y))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -8e-23], N[(z * N[(y * t$95$1), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t, 60000.0], N[(N[(x - N[(y * N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$1 * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;t \leq -8 \cdot 10^{-23}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot t_1, x\right)\\
\mathbf{elif}\;t \leq 60000:\\
\;\;\;\;\left(x - y \cdot \left(z \cdot \tanh \left(\frac{x}{y}\right)\right)\right) + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x + t_1 \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if t < -7.99999999999999968e-23Initial program 97.2%
+-commutative97.2%
*-commutative97.2%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in x around 0 4.0%
associate-/r*4.0%
div-sub4.0%
rec-exp4.0%
rec-exp4.0%
tanh-def-a88.7%
Simplified88.7%
if -7.99999999999999968e-23 < t < 6e4Initial program 93.4%
+-commutative93.4%
*-commutative93.4%
associate-*l*97.7%
fma-def97.7%
Simplified97.7%
Taylor expanded in t around 0 94.1%
Taylor expanded in t around -inf 36.2%
associate-+r+36.2%
Simplified96.0%
if 6e4 < t Initial program 99.9%
Taylor expanded in x around 0 68.5%
Taylor expanded in x around 0 8.8%
associate-/r*8.8%
div-sub8.8%
rec-exp8.8%
rec-exp8.8%
tanh-def-a94.2%
Simplified94.2%
Final simplification93.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= t -8.2e-23)
(+ x (* y (* z t_1)))
(if (<= t 15.5)
(+ x (* (* z y) (- (/ t y) (tanh (/ x y)))))
(+ x (* t_1 (* z y)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (t <= -8.2e-23) {
tmp = x + (y * (z * t_1));
} else if (t <= 15.5) {
tmp = x + ((z * y) * ((t / y) - tanh((x / y))));
} else {
tmp = x + (t_1 * (z * y));
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (t <= (-8.2d-23)) then
tmp = x + (y * (z * t_1))
else if (t <= 15.5d0) then
tmp = x + ((z * y) * ((t / y) - tanh((x / y))))
else
tmp = x + (t_1 * (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (t <= -8.2e-23) {
tmp = x + (y * (z * t_1));
} else if (t <= 15.5) {
tmp = x + ((z * y) * ((t / y) - Math.tanh((x / y))));
} else {
tmp = x + (t_1 * (z * y));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if t <= -8.2e-23: tmp = x + (y * (z * t_1)) elif t <= 15.5: tmp = x + ((z * y) * ((t / y) - math.tanh((x / y)))) else: tmp = x + (t_1 * (z * y)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (t <= -8.2e-23) tmp = Float64(x + Float64(y * Float64(z * t_1))); elseif (t <= 15.5) tmp = Float64(x + Float64(Float64(z * y) * Float64(Float64(t / y) - tanh(Float64(x / y))))); else tmp = Float64(x + Float64(t_1 * Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (t <= -8.2e-23) tmp = x + (y * (z * t_1)); elseif (t <= 15.5) tmp = x + ((z * y) * ((t / y) - tanh((x / y)))); else tmp = x + (t_1 * (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -8.2e-23], N[(x + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 15.5], N[(x + N[(N[(z * y), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$1 * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;t \leq -8.2 \cdot 10^{-23}:\\
\;\;\;\;x + y \cdot \left(z \cdot t_1\right)\\
\mathbf{elif}\;t \leq 15.5:\\
\;\;\;\;x + \left(z \cdot y\right) \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + t_1 \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if t < -8.20000000000000059e-23Initial program 97.2%
Taylor expanded in x around 0 4.0%
associate-/r*4.0%
div-sub4.0%
rec-exp4.0%
rec-exp4.0%
tanh-def-a87.3%
Simplified87.3%
if -8.20000000000000059e-23 < t < 15.5Initial program 93.4%
Taylor expanded in t around 0 89.7%
if 15.5 < t Initial program 99.9%
Taylor expanded in x around 0 68.5%
Taylor expanded in x around 0 8.8%
associate-/r*8.8%
div-sub8.8%
rec-exp8.8%
rec-exp8.8%
tanh-def-a94.2%
Simplified94.2%
Final simplification90.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= t -8e-23)
(+ x (* y (* z t_1)))
(if (<= t 106000000.0)
(+ (- x (* y (* z (tanh (/ x y))))) (* z t))
(+ x (* t_1 (* z y)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (t <= -8e-23) {
tmp = x + (y * (z * t_1));
} else if (t <= 106000000.0) {
tmp = (x - (y * (z * tanh((x / y))))) + (z * t);
} else {
tmp = x + (t_1 * (z * y));
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (t <= (-8d-23)) then
tmp = x + (y * (z * t_1))
else if (t <= 106000000.0d0) then
tmp = (x - (y * (z * tanh((x / y))))) + (z * t)
else
tmp = x + (t_1 * (z * y))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (t <= -8e-23) {
tmp = x + (y * (z * t_1));
} else if (t <= 106000000.0) {
tmp = (x - (y * (z * Math.tanh((x / y))))) + (z * t);
} else {
tmp = x + (t_1 * (z * y));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if t <= -8e-23: tmp = x + (y * (z * t_1)) elif t <= 106000000.0: tmp = (x - (y * (z * math.tanh((x / y))))) + (z * t) else: tmp = x + (t_1 * (z * y)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (t <= -8e-23) tmp = Float64(x + Float64(y * Float64(z * t_1))); elseif (t <= 106000000.0) tmp = Float64(Float64(x - Float64(y * Float64(z * tanh(Float64(x / y))))) + Float64(z * t)); else tmp = Float64(x + Float64(t_1 * Float64(z * y))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (t <= -8e-23) tmp = x + (y * (z * t_1)); elseif (t <= 106000000.0) tmp = (x - (y * (z * tanh((x / y))))) + (z * t); else tmp = x + (t_1 * (z * y)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -8e-23], N[(x + N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 106000000.0], N[(N[(x - N[(y * N[(z * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$1 * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;t \leq -8 \cdot 10^{-23}:\\
\;\;\;\;x + y \cdot \left(z \cdot t_1\right)\\
\mathbf{elif}\;t \leq 106000000:\\
\;\;\;\;\left(x - y \cdot \left(z \cdot \tanh \left(\frac{x}{y}\right)\right)\right) + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x + t_1 \cdot \left(z \cdot y\right)\\
\end{array}
\end{array}
if t < -7.99999999999999968e-23Initial program 97.2%
Taylor expanded in x around 0 4.0%
associate-/r*4.0%
div-sub4.0%
rec-exp4.0%
rec-exp4.0%
tanh-def-a87.3%
Simplified87.3%
if -7.99999999999999968e-23 < t < 1.06e8Initial program 93.4%
+-commutative93.4%
*-commutative93.4%
associate-*l*97.7%
fma-def97.7%
Simplified97.7%
Taylor expanded in t around 0 94.1%
Taylor expanded in t around -inf 36.2%
associate-+r+36.2%
Simplified96.0%
if 1.06e8 < t Initial program 99.9%
Taylor expanded in x around 0 68.5%
Taylor expanded in x around 0 8.8%
associate-/r*8.8%
div-sub8.8%
rec-exp8.8%
rec-exp8.8%
tanh-def-a94.2%
Simplified94.2%
Final simplification93.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* z (- t x)))))
(if (<= y 3.1e-7)
x
(if (<= y 2.7e+100)
t_1
(if (<= y 7e+108)
x
(if (<= y 3.5e+158) (* y (* z (tanh (/ t y)))) t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = x + (z * (t - x));
double tmp;
if (y <= 3.1e-7) {
tmp = x;
} else if (y <= 2.7e+100) {
tmp = t_1;
} else if (y <= 7e+108) {
tmp = x;
} else if (y <= 3.5e+158) {
tmp = y * (z * tanh((t / y)));
} else {
tmp = t_1;
}
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
real(8) :: t_1
real(8) :: tmp
t_1 = x + (z * (t - x))
if (y <= 3.1d-7) then
tmp = x
else if (y <= 2.7d+100) then
tmp = t_1
else if (y <= 7d+108) then
tmp = x
else if (y <= 3.5d+158) then
tmp = y * (z * tanh((t / y)))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x + (z * (t - x));
double tmp;
if (y <= 3.1e-7) {
tmp = x;
} else if (y <= 2.7e+100) {
tmp = t_1;
} else if (y <= 7e+108) {
tmp = x;
} else if (y <= 3.5e+158) {
tmp = y * (z * Math.tanh((t / y)));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + (z * (t - x)) tmp = 0 if y <= 3.1e-7: tmp = x elif y <= 2.7e+100: tmp = t_1 elif y <= 7e+108: tmp = x elif y <= 3.5e+158: tmp = y * (z * math.tanh((t / y))) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(z * Float64(t - x))) tmp = 0.0 if (y <= 3.1e-7) tmp = x; elseif (y <= 2.7e+100) tmp = t_1; elseif (y <= 7e+108) tmp = x; elseif (y <= 3.5e+158) tmp = Float64(y * Float64(z * tanh(Float64(t / y)))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + (z * (t - x)); tmp = 0.0; if (y <= 3.1e-7) tmp = x; elseif (y <= 2.7e+100) tmp = t_1; elseif (y <= 7e+108) tmp = x; elseif (y <= 3.5e+158) tmp = y * (z * tanh((t / y))); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 3.1e-7], x, If[LessEqual[y, 2.7e+100], t$95$1, If[LessEqual[y, 7e+108], x, If[LessEqual[y, 3.5e+158], N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + z \cdot \left(t - x\right)\\
\mathbf{if}\;y \leq 3.1 \cdot 10^{-7}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 2.7 \cdot 10^{+100}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 7 \cdot 10^{+108}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 3.5 \cdot 10^{+158}:\\
\;\;\;\;y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if y < 3.1e-7 or 2.69999999999999998e100 < y < 7.0000000000000005e108Initial program 96.0%
Taylor expanded in x around inf 66.4%
if 3.1e-7 < y < 2.69999999999999998e100 or 3.5000000000000001e158 < y Initial program 94.8%
Taylor expanded in y around inf 82.4%
if 7.0000000000000005e108 < y < 3.5000000000000001e158Initial program 100.0%
Taylor expanded in x around 0 89.9%
Taylor expanded in x around 0 11.8%
associate-/r*11.8%
div-sub11.8%
rec-exp11.8%
rec-exp11.8%
tanh-def-a89.6%
Simplified89.6%
Taylor expanded in x around 0 0.7%
associate-*r*0.5%
associate-*r/0.5%
rec-exp0.5%
rec-exp0.5%
tanh-def-a57.9%
associate-*l*47.5%
Simplified47.5%
Final simplification69.1%
(FPCore (x y z t) :precision binary64 (if (<= y 1.6e+161) (+ x (* y (* z (tanh (/ t y))))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.6e+161) {
tmp = x + (y * (z * tanh((t / y))));
} 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
real(8) :: tmp
if (y <= 1.6d+161) then
tmp = x + (y * (z * tanh((t / y))))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.6e+161) {
tmp = x + (y * (z * Math.tanh((t / y))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.6e+161: tmp = x + (y * (z * math.tanh((t / y)))) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.6e+161) tmp = Float64(x + Float64(y * Float64(z * tanh(Float64(t / y))))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.6e+161) tmp = x + (y * (z * tanh((t / y)))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.6e+161], N[(x + N[(y * N[(z * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{+161}:\\
\;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.60000000000000001e161Initial program 96.0%
Taylor expanded in x around 0 23.1%
associate-/r*23.1%
div-sub23.1%
rec-exp23.1%
rec-exp23.1%
tanh-def-a80.5%
Simplified80.5%
if 1.60000000000000001e161 < y Initial program 95.3%
Taylor expanded in y around inf 88.3%
Final simplification81.7%
(FPCore (x y z t) :precision binary64 (if (or (<= z -6.3e+181) (not (<= z 4e+86))) (* z (- t x)) x))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -6.3e+181) || !(z <= 4e+86)) {
tmp = z * (t - x);
} else {
tmp = 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
real(8) :: tmp
if ((z <= (-6.3d+181)) .or. (.not. (z <= 4d+86))) then
tmp = z * (t - x)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -6.3e+181) || !(z <= 4e+86)) {
tmp = z * (t - x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (z <= -6.3e+181) or not (z <= 4e+86): tmp = z * (t - x) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if ((z <= -6.3e+181) || !(z <= 4e+86)) tmp = Float64(z * Float64(t - x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((z <= -6.3e+181) || ~((z <= 4e+86))) tmp = z * (t - x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -6.3e+181], N[Not[LessEqual[z, 4e+86]], $MachinePrecision]], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -6.3 \cdot 10^{+181} \lor \neg \left(z \leq 4 \cdot 10^{+86}\right):\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -6.3000000000000003e181 or 4.0000000000000001e86 < z Initial program 87.7%
Taylor expanded in y around inf 58.9%
Taylor expanded in z around inf 58.9%
if -6.3000000000000003e181 < z < 4.0000000000000001e86Initial program 98.9%
Taylor expanded in x around inf 75.1%
Final simplification70.8%
(FPCore (x y z t) :precision binary64 (if (<= y 2.9e-5) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.9e-5) {
tmp = x;
} 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
real(8) :: tmp
if (y <= 2.9d-5) then
tmp = x
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.9e-5) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.9e-5: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.9e-5) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.9e-5) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.9e-5], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.9 \cdot 10^{-5}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.9e-5Initial program 96.0%
Taylor expanded in x around inf 66.3%
if 2.9e-5 < y Initial program 95.6%
Taylor expanded in y around inf 76.1%
Final simplification68.7%
(FPCore (x y z t) :precision binary64 (if (<= y 1.25e-5) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.25e-5) {
tmp = x;
} else {
tmp = x + (z * t);
}
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
real(8) :: tmp
if (y <= 1.25d-5) then
tmp = x
else
tmp = x + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.25e-5) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.25e-5: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.25e-5) tmp = x; else tmp = Float64(x + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.25e-5) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.25e-5], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.25 \cdot 10^{-5}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.25000000000000006e-5Initial program 96.0%
Taylor expanded in x around inf 66.3%
if 1.25000000000000006e-5 < y Initial program 95.6%
+-commutative95.6%
*-commutative95.6%
associate-*l*100.0%
fma-def100.0%
Simplified100.0%
Taylor expanded in t around 0 85.2%
Taylor expanded in y around 0 62.6%
+-commutative62.6%
*-commutative62.6%
Simplified62.6%
Final simplification65.4%
(FPCore (x y z t) :precision binary64 (if (<= z -9e+184) (- (* z x)) x))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9e+184) {
tmp = -(z * x);
} else {
tmp = 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
real(8) :: tmp
if (z <= (-9d+184)) then
tmp = -(z * x)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -9e+184) {
tmp = -(z * x);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -9e+184: tmp = -(z * x) else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -9e+184) tmp = Float64(-Float64(z * x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -9e+184) tmp = -(z * x); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -9e+184], (-N[(z * x), $MachinePrecision]), x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+184}:\\
\;\;\;\;-z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -9.00000000000000072e184Initial program 82.6%
Taylor expanded in y around inf 75.6%
Taylor expanded in t around 0 50.4%
mul-1-neg50.4%
unsub-neg50.4%
*-commutative50.4%
Simplified50.4%
Taylor expanded in z around inf 50.4%
mul-1-neg50.4%
distribute-rgt-neg-in50.4%
Simplified50.4%
if -9.00000000000000072e184 < z Initial program 97.5%
Taylor expanded in x around inf 66.3%
Final simplification64.6%
(FPCore (x y z t) :precision binary64 (if (<= z -7.6e+188) (* z t) x))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.6e+188) {
tmp = z * t;
} else {
tmp = 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
real(8) :: tmp
if (z <= (-7.6d+188)) then
tmp = z * t
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -7.6e+188) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -7.6e+188: tmp = z * t else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -7.6e+188) tmp = Float64(z * t); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -7.6e+188) tmp = z * t; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -7.6e+188], N[(z * t), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.6 \cdot 10^{+188}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -7.5999999999999997e188Initial program 82.0%
+-commutative82.0%
*-commutative82.0%
associate-*l*96.2%
fma-def96.2%
Simplified96.2%
Taylor expanded in t around 0 79.2%
Taylor expanded in t around -inf 39.4%
associate-+r+39.4%
Simplified78.9%
Taylor expanded in x around 0 47.4%
*-commutative47.4%
Simplified47.4%
if -7.5999999999999997e188 < z Initial program 97.5%
Taylor expanded in x around inf 66.0%
Final simplification64.2%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
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
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 95.9%
Taylor expanded in x around inf 60.9%
Final simplification60.9%
(FPCore (x y z t) :precision binary64 (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
}
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
public static double code(double x, double y, double z, double t) {
return x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); end
code[x_, y_, z_, t_] := 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]
\begin{array}{l}
\\
x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)
\end{array}
herbie shell --seed 2023322
(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))))))