
(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 12 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}
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.55e+180) (fma y_m (* z (- (tanh (/ t y_m)) (tanh (/ x y_m)))) x) (+ x (* z (- t x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 1.55e+180) {
tmp = fma(y_m, (z * (tanh((t / y_m)) - tanh((x / y_m)))), x);
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 1.55e+180) tmp = fma(y_m, Float64(z * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))), x); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 1.55e+180], N[(y$95$m * N[(z * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.55 \cdot 10^{+180}:\\
\;\;\;\;\mathsf{fma}\left(y\_m, z \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.54999999999999999e180Initial program 96.5%
+-commutative96.5%
associate-*l*98.5%
fma-define98.5%
Simplified98.5%
if 1.54999999999999999e180 < y Initial program 86.2%
Taylor expanded in y around inf 100.0%
Final simplification98.6%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (let* ((t_1 (+ x (* (- (tanh (/ t y_m)) (tanh (/ x y_m))) (* y_m z))))) (if (<= t_1 1e+308) t_1 (+ x (* z (- t x))))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double t_1 = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (y_m * z));
double tmp;
if (t_1 <= 1e+308) {
tmp = t_1;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (y_m * z))
if (t_1 <= 1d+308) then
tmp = t_1
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double t_1 = x + ((Math.tanh((t / y_m)) - Math.tanh((x / y_m))) * (y_m * z));
double tmp;
if (t_1 <= 1e+308) {
tmp = t_1;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): t_1 = x + ((math.tanh((t / y_m)) - math.tanh((x / y_m))) * (y_m * z)) tmp = 0 if t_1 <= 1e+308: tmp = t_1 else: tmp = x + (z * (t - x)) return tmp
y_m = abs(y) function code(x, y_m, z, t) t_1 = Float64(x + Float64(Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m))) * Float64(y_m * z))) tmp = 0.0 if (t_1 <= 1e+308) tmp = t_1; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) t_1 = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (y_m * z)); tmp = 0.0; if (t_1 <= 1e+308) tmp = t_1; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[(x + N[(N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(y$95$m * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 1e+308], t$95$1, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_1 := x + \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right) \cdot \left(y\_m \cdot z\right)\\
\mathbf{if}\;t\_1 \leq 10^{+308}:\\
\;\;\;\;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))))) < 1e308Initial program 98.1%
if 1e308 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 52.1%
Taylor expanded in y around inf 86.0%
Final simplification97.5%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (+ x (* z (- t x)))))
(if (<= y_m 4.8e-16)
x
(if (<= y_m 9.2e+36)
t_1
(if (<= y_m 8e+129)
x
(if (<= y_m 2.5e+146)
(* z (- (* y_m (tanh (/ t y_m))) x))
(if (<= y_m 2.1e+162) (+ x (* z t)) t_1)))))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double t_1 = x + (z * (t - x));
double tmp;
if (y_m <= 4.8e-16) {
tmp = x;
} else if (y_m <= 9.2e+36) {
tmp = t_1;
} else if (y_m <= 8e+129) {
tmp = x;
} else if (y_m <= 2.5e+146) {
tmp = z * ((y_m * tanh((t / y_m))) - x);
} else if (y_m <= 2.1e+162) {
tmp = x + (z * t);
} else {
tmp = t_1;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
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_m <= 4.8d-16) then
tmp = x
else if (y_m <= 9.2d+36) then
tmp = t_1
else if (y_m <= 8d+129) then
tmp = x
else if (y_m <= 2.5d+146) then
tmp = z * ((y_m * tanh((t / y_m))) - x)
else if (y_m <= 2.1d+162) then
tmp = x + (z * t)
else
tmp = t_1
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double t_1 = x + (z * (t - x));
double tmp;
if (y_m <= 4.8e-16) {
tmp = x;
} else if (y_m <= 9.2e+36) {
tmp = t_1;
} else if (y_m <= 8e+129) {
tmp = x;
} else if (y_m <= 2.5e+146) {
tmp = z * ((y_m * Math.tanh((t / y_m))) - x);
} else if (y_m <= 2.1e+162) {
tmp = x + (z * t);
} else {
tmp = t_1;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): t_1 = x + (z * (t - x)) tmp = 0 if y_m <= 4.8e-16: tmp = x elif y_m <= 9.2e+36: tmp = t_1 elif y_m <= 8e+129: tmp = x elif y_m <= 2.5e+146: tmp = z * ((y_m * math.tanh((t / y_m))) - x) elif y_m <= 2.1e+162: tmp = x + (z * t) else: tmp = t_1 return tmp
y_m = abs(y) function code(x, y_m, z, t) t_1 = Float64(x + Float64(z * Float64(t - x))) tmp = 0.0 if (y_m <= 4.8e-16) tmp = x; elseif (y_m <= 9.2e+36) tmp = t_1; elseif (y_m <= 8e+129) tmp = x; elseif (y_m <= 2.5e+146) tmp = Float64(z * Float64(Float64(y_m * tanh(Float64(t / y_m))) - x)); elseif (y_m <= 2.1e+162) tmp = Float64(x + Float64(z * t)); else tmp = t_1; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) t_1 = x + (z * (t - x)); tmp = 0.0; if (y_m <= 4.8e-16) tmp = x; elseif (y_m <= 9.2e+36) tmp = t_1; elseif (y_m <= 8e+129) tmp = x; elseif (y_m <= 2.5e+146) tmp = z * ((y_m * tanh((t / y_m))) - x); elseif (y_m <= 2.1e+162) tmp = x + (z * t); else tmp = t_1; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y$95$m, 4.8e-16], x, If[LessEqual[y$95$m, 9.2e+36], t$95$1, If[LessEqual[y$95$m, 8e+129], x, If[LessEqual[y$95$m, 2.5e+146], N[(z * N[(N[(y$95$m * N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 2.1e+162], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_1 := x + z \cdot \left(t - x\right)\\
\mathbf{if}\;y\_m \leq 4.8 \cdot 10^{-16}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 9.2 \cdot 10^{+36}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y\_m \leq 8 \cdot 10^{+129}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 2.5 \cdot 10^{+146}:\\
\;\;\;\;z \cdot \left(y\_m \cdot \tanh \left(\frac{t}{y\_m}\right) - x\right)\\
\mathbf{elif}\;y\_m \leq 2.1 \cdot 10^{+162}:\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < 4.8000000000000001e-16 or 9.19999999999999986e36 < y < 8e129Initial program 96.0%
+-commutative96.0%
associate-*l*98.3%
fma-define98.3%
Simplified98.3%
Taylor expanded in y around 0 71.4%
if 4.8000000000000001e-16 < y < 9.19999999999999986e36 or 2.1e162 < y Initial program 91.9%
Taylor expanded in y around inf 85.0%
if 8e129 < y < 2.4999999999999999e146Initial program 100.0%
Taylor expanded in x around 0 3.0%
+-commutative3.0%
Simplified83.0%
Taylor expanded in z around inf 3.0%
associate-/l*3.0%
rec-exp3.0%
rec-exp3.0%
tanh-def-a63.2%
Simplified63.2%
if 2.4999999999999999e146 < y < 2.1e162Initial program 100.0%
+-commutative100.0%
associate-*l*100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in x around 0 67.6%
associate-/r*67.6%
div-sub67.6%
rec-exp67.6%
rec-exp67.6%
tanh-def-a84.3%
Simplified84.3%
Taylor expanded in y around inf 84.3%
+-commutative84.3%
*-commutative84.3%
Simplified84.3%
Final simplification73.4%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (or (<= t -1.05e-83) (not (<= t 3.1e-158))) (+ x (* z (* y_m (tanh (/ t y_m))))) (+ x (* (* y_m z) (- (/ t y_m) (tanh (/ x y_m)))))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if ((t <= -1.05e-83) || !(t <= 3.1e-158)) {
tmp = x + (z * (y_m * tanh((t / y_m))));
} else {
tmp = x + ((y_m * z) * ((t / y_m) - tanh((x / y_m))));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((t <= (-1.05d-83)) .or. (.not. (t <= 3.1d-158))) then
tmp = x + (z * (y_m * tanh((t / y_m))))
else
tmp = x + ((y_m * z) * ((t / y_m) - tanh((x / y_m))))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if ((t <= -1.05e-83) || !(t <= 3.1e-158)) {
tmp = x + (z * (y_m * Math.tanh((t / y_m))));
} else {
tmp = x + ((y_m * z) * ((t / y_m) - Math.tanh((x / y_m))));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if (t <= -1.05e-83) or not (t <= 3.1e-158): tmp = x + (z * (y_m * math.tanh((t / y_m)))) else: tmp = x + ((y_m * z) * ((t / y_m) - math.tanh((x / y_m)))) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if ((t <= -1.05e-83) || !(t <= 3.1e-158)) tmp = Float64(x + Float64(z * Float64(y_m * tanh(Float64(t / y_m))))); else tmp = Float64(x + Float64(Float64(y_m * z) * Float64(Float64(t / y_m) - tanh(Float64(x / y_m))))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if ((t <= -1.05e-83) || ~((t <= 3.1e-158))) tmp = x + (z * (y_m * tanh((t / y_m)))); else tmp = x + ((y_m * z) * ((t / y_m) - tanh((x / y_m)))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[Or[LessEqual[t, -1.05e-83], N[Not[LessEqual[t, 3.1e-158]], $MachinePrecision]], N[(x + N[(z * N[(y$95$m * N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y$95$m * z), $MachinePrecision] * N[(N[(t / y$95$m), $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.05 \cdot 10^{-83} \lor \neg \left(t \leq 3.1 \cdot 10^{-158}\right):\\
\;\;\;\;x + z \cdot \left(y\_m \cdot \tanh \left(\frac{t}{y\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(y\_m \cdot z\right) \cdot \left(\frac{t}{y\_m} - \tanh \left(\frac{x}{y\_m}\right)\right)\\
\end{array}
\end{array}
if t < -1.0499999999999999e-83 or 3.10000000000000018e-158 < t Initial program 96.0%
+-commutative96.0%
associate-*l*98.5%
fma-define98.5%
Simplified98.5%
Taylor expanded in x around 0 15.0%
associate-/r*15.0%
div-sub15.0%
rec-exp15.0%
rec-exp15.0%
tanh-def-a87.7%
Simplified87.7%
fma-undefine87.7%
associate-*r*86.8%
*-commutative86.8%
associate-*r*88.9%
Applied egg-rr88.9%
if -1.0499999999999999e-83 < t < 3.10000000000000018e-158Initial program 94.6%
Taylor expanded in t around 0 93.4%
Final simplification90.2%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (let* ((t_1 (* y_m (tanh (/ t y_m))))) (if (<= z 6e+200) (+ x (* z t_1)) (+ x (* z (- t_1 x))))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double t_1 = y_m * tanh((t / y_m));
double tmp;
if (z <= 6e+200) {
tmp = x + (z * t_1);
} else {
tmp = x + (z * (t_1 - x));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = y_m * tanh((t / y_m))
if (z <= 6d+200) then
tmp = x + (z * t_1)
else
tmp = x + (z * (t_1 - x))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double t_1 = y_m * Math.tanh((t / y_m));
double tmp;
if (z <= 6e+200) {
tmp = x + (z * t_1);
} else {
tmp = x + (z * (t_1 - x));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): t_1 = y_m * math.tanh((t / y_m)) tmp = 0 if z <= 6e+200: tmp = x + (z * t_1) else: tmp = x + (z * (t_1 - x)) return tmp
y_m = abs(y) function code(x, y_m, z, t) t_1 = Float64(y_m * tanh(Float64(t / y_m))) tmp = 0.0 if (z <= 6e+200) tmp = Float64(x + Float64(z * t_1)); else tmp = Float64(x + Float64(z * Float64(t_1 - x))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) t_1 = y_m * tanh((t / y_m)); tmp = 0.0; if (z <= 6e+200) tmp = x + (z * t_1); else tmp = x + (z * (t_1 - x)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[(y$95$m * N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 6e+200], N[(x + N[(z * t$95$1), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t$95$1 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_1 := y\_m \cdot \tanh \left(\frac{t}{y\_m}\right)\\
\mathbf{if}\;z \leq 6 \cdot 10^{+200}:\\
\;\;\;\;x + z \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t\_1 - x\right)\\
\end{array}
\end{array}
if z < 5.99999999999999982e200Initial program 96.0%
+-commutative96.0%
associate-*l*98.0%
fma-define98.0%
Simplified98.0%
Taylor expanded in x around 0 28.8%
associate-/r*28.8%
div-sub28.8%
rec-exp28.8%
rec-exp28.8%
tanh-def-a87.2%
Simplified87.2%
fma-undefine87.2%
associate-*r*86.8%
*-commutative86.8%
associate-*r*88.1%
Applied egg-rr88.1%
if 5.99999999999999982e200 < z Initial program 91.8%
Taylor expanded in x around 0 39.9%
+-commutative39.9%
Simplified66.7%
Final simplification86.2%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 9.5e+162) (+ x (* (tanh (/ t y_m)) (* y_m z))) (+ x (* z (- t x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 9.5e+162) {
tmp = x + (tanh((t / y_m)) * (y_m * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y_m <= 9.5d+162) then
tmp = x + (tanh((t / y_m)) * (y_m * z))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 9.5e+162) {
tmp = x + (Math.tanh((t / y_m)) * (y_m * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 9.5e+162: tmp = x + (math.tanh((t / y_m)) * (y_m * z)) else: tmp = x + (z * (t - x)) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 9.5e+162) tmp = Float64(x + Float64(tanh(Float64(t / y_m)) * Float64(y_m * z))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 9.5e+162) tmp = x + (tanh((t / y_m)) * (y_m * z)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 9.5e+162], N[(x + N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] * N[(y$95$m * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 9.5 \cdot 10^{+162}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y\_m}\right) \cdot \left(y\_m \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 9.50000000000000021e162Initial program 96.4%
Taylor expanded in x around 0 25.6%
associate-*r*25.5%
associate-/r*25.5%
div-sub25.5%
rec-exp25.5%
rec-exp25.5%
tanh-def-a82.8%
Simplified82.8%
if 9.50000000000000021e162 < y Initial program 86.8%
Taylor expanded in y around inf 100.0%
Final simplification84.3%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (let* ((t_1 (* y_m (tanh (/ t y_m))))) (if (<= z 5e+194) (+ x (* z t_1)) (* z (- t_1 x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double t_1 = y_m * tanh((t / y_m));
double tmp;
if (z <= 5e+194) {
tmp = x + (z * t_1);
} else {
tmp = z * (t_1 - x);
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = y_m * tanh((t / y_m))
if (z <= 5d+194) then
tmp = x + (z * t_1)
else
tmp = z * (t_1 - x)
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double t_1 = y_m * Math.tanh((t / y_m));
double tmp;
if (z <= 5e+194) {
tmp = x + (z * t_1);
} else {
tmp = z * (t_1 - x);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): t_1 = y_m * math.tanh((t / y_m)) tmp = 0 if z <= 5e+194: tmp = x + (z * t_1) else: tmp = z * (t_1 - x) return tmp
y_m = abs(y) function code(x, y_m, z, t) t_1 = Float64(y_m * tanh(Float64(t / y_m))) tmp = 0.0 if (z <= 5e+194) tmp = Float64(x + Float64(z * t_1)); else tmp = Float64(z * Float64(t_1 - x)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) t_1 = y_m * tanh((t / y_m)); tmp = 0.0; if (z <= 5e+194) tmp = x + (z * t_1); else tmp = z * (t_1 - x); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[(y$95$m * N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, 5e+194], N[(x + N[(z * t$95$1), $MachinePrecision]), $MachinePrecision], N[(z * N[(t$95$1 - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_1 := y\_m \cdot \tanh \left(\frac{t}{y\_m}\right)\\
\mathbf{if}\;z \leq 5 \cdot 10^{+194}:\\
\;\;\;\;x + z \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t\_1 - x\right)\\
\end{array}
\end{array}
if z < 4.99999999999999989e194Initial program 96.0%
+-commutative96.0%
associate-*l*98.0%
fma-define98.0%
Simplified98.0%
Taylor expanded in x around 0 28.8%
associate-/r*28.8%
div-sub28.8%
rec-exp28.8%
rec-exp28.8%
tanh-def-a87.2%
Simplified87.2%
fma-undefine87.2%
associate-*r*86.8%
*-commutative86.8%
associate-*r*88.1%
Applied egg-rr88.1%
if 4.99999999999999989e194 < z Initial program 91.8%
Taylor expanded in x around 0 39.9%
+-commutative39.9%
Simplified66.7%
Taylor expanded in z around inf 39.9%
associate-/l*39.9%
rec-exp39.9%
rec-exp39.9%
tanh-def-a66.7%
Simplified66.7%
Final simplification86.2%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (or (<= y_m 4.8e-16) (and (not (<= y_m 5.5e+34)) (<= y_m 1.05e+122))) x (+ x (* z (- t x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if ((y_m <= 4.8e-16) || (!(y_m <= 5.5e+34) && (y_m <= 1.05e+122))) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if ((y_m <= 4.8d-16) .or. (.not. (y_m <= 5.5d+34)) .and. (y_m <= 1.05d+122)) then
tmp = x
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if ((y_m <= 4.8e-16) || (!(y_m <= 5.5e+34) && (y_m <= 1.05e+122))) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if (y_m <= 4.8e-16) or (not (y_m <= 5.5e+34) and (y_m <= 1.05e+122)): tmp = x else: tmp = x + (z * (t - x)) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if ((y_m <= 4.8e-16) || (!(y_m <= 5.5e+34) && (y_m <= 1.05e+122))) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if ((y_m <= 4.8e-16) || (~((y_m <= 5.5e+34)) && (y_m <= 1.05e+122))) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[Or[LessEqual[y$95$m, 4.8e-16], And[N[Not[LessEqual[y$95$m, 5.5e+34]], $MachinePrecision], LessEqual[y$95$m, 1.05e+122]]], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 4.8 \cdot 10^{-16} \lor \neg \left(y\_m \leq 5.5 \cdot 10^{+34}\right) \land y\_m \leq 1.05 \cdot 10^{+122}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 4.8000000000000001e-16 or 5.4999999999999996e34 < y < 1.05000000000000008e122Initial program 96.0%
+-commutative96.0%
associate-*l*98.3%
fma-define98.3%
Simplified98.3%
Taylor expanded in y around 0 71.1%
if 4.8000000000000001e-16 < y < 5.4999999999999996e34 or 1.05000000000000008e122 < y Initial program 94.0%
Taylor expanded in y around inf 75.9%
Final simplification72.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= z 5e+214) x (* x (- 1.0 z))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (z <= 5e+214) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= 5d+214) then
tmp = x
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if (z <= 5e+214) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if z <= 5e+214: tmp = x else: tmp = x * (1.0 - z) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (z <= 5e+214) tmp = x; else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (z <= 5e+214) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[z, 5e+214], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 5 \cdot 10^{+214}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if z < 4.99999999999999953e214Initial program 95.6%
+-commutative95.6%
associate-*l*97.6%
fma-define97.6%
Simplified97.6%
Taylor expanded in y around 0 70.3%
if 4.99999999999999953e214 < z Initial program 95.6%
Taylor expanded in y around inf 58.0%
Taylor expanded in x around inf 37.8%
mul-1-neg37.8%
unsub-neg37.8%
Simplified37.8%
Final simplification67.7%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 4.8e-16) x (+ x (* z t))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 4.8e-16) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y_m <= 4.8d-16) then
tmp = x
else
tmp = x + (z * t)
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 4.8e-16) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 4.8e-16: tmp = x else: tmp = x + (z * t) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 4.8e-16) tmp = x; else tmp = Float64(x + Float64(z * t)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 4.8e-16) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 4.8e-16], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 4.8 \cdot 10^{-16}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 4.8000000000000001e-16Initial program 97.0%
+-commutative97.0%
associate-*l*98.0%
fma-define98.0%
Simplified98.0%
Taylor expanded in y around 0 73.9%
if 4.8000000000000001e-16 < y Initial program 92.0%
+-commutative92.0%
associate-*l*97.0%
fma-define97.0%
Simplified97.0%
Taylor expanded in x around 0 30.4%
associate-/r*30.4%
div-sub30.4%
rec-exp30.4%
rec-exp30.4%
tanh-def-a71.4%
Simplified71.4%
Taylor expanded in y around inf 56.6%
+-commutative56.6%
*-commutative56.6%
Simplified56.6%
Final simplification69.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= z 1.9e+218) x (* z (- x))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (z <= 1.9e+218) {
tmp = x;
} else {
tmp = z * -x;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (z <= 1.9d+218) then
tmp = x
else
tmp = z * -x
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if (z <= 1.9e+218) {
tmp = x;
} else {
tmp = z * -x;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if z <= 1.9e+218: tmp = x else: tmp = z * -x return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (z <= 1.9e+218) tmp = x; else tmp = Float64(z * Float64(-x)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (z <= 1.9e+218) tmp = x; else tmp = z * -x; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[z, 1.9e+218], x, N[(z * (-x)), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.9 \cdot 10^{+218}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\end{array}
\end{array}
if z < 1.90000000000000006e218Initial program 95.6%
+-commutative95.6%
associate-*l*97.6%
fma-define97.6%
Simplified97.6%
Taylor expanded in y around 0 70.3%
if 1.90000000000000006e218 < z Initial program 95.6%
Taylor expanded in y around inf 58.0%
Taylor expanded in x around inf 37.8%
mul-1-neg37.8%
unsub-neg37.8%
Simplified37.8%
Taylor expanded in z around inf 37.8%
associate-*r*37.8%
mul-1-neg37.8%
Simplified37.8%
Final simplification67.7%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 x)
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
return x;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
return x;
}
y_m = math.fabs(y) def code(x, y_m, z, t): return x
y_m = abs(y) function code(x, y_m, z, t) return x end
y_m = abs(y); function tmp = code(x, y_m, z, t) tmp = x; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := x
\begin{array}{l}
y_m = \left|y\right|
\\
x
\end{array}
Initial program 95.6%
+-commutative95.6%
associate-*l*97.7%
fma-define97.7%
Simplified97.7%
Taylor expanded in y around 0 65.6%
Final simplification65.6%
(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 2024115
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))