
(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 10 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 6.4e+217) (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 <= 6.4e+217) {
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 <= 6.4e+217) 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, 6.4e+217], 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 6.4 \cdot 10^{+217}:\\
\;\;\;\;\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 < 6.4000000000000001e217Initial program 94.1%
+-commutative94.1%
associate-*l*97.5%
fma-define97.5%
Simplified97.5%
if 6.4000000000000001e217 < y Initial program 74.9%
Taylor expanded in y around inf 95.4%
Final simplification97.3%
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 (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+302)))
(+ x (* z (- t x)))
t_1)))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 <= -((double) INFINITY)) || !(t_1 <= 2e+302)) {
tmp = x + (z * (t - x));
} else {
tmp = t_1;
}
return tmp;
}
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 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 2e+302)) {
tmp = x + (z * (t - x));
} else {
tmp = t_1;
}
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 <= -math.inf) or not (t_1 <= 2e+302): tmp = x + (z * (t - x)) else: tmp = t_1 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 <= Float64(-Inf)) || !(t_1 <= 2e+302)) tmp = Float64(x + Float64(z * Float64(t - x))); else tmp = t_1; 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 <= -Inf) || ~((t_1 <= 2e+302))) tmp = x + (z * (t - x)); 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[(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[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+302]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]
\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 -\infty \lor \neg \left(t\_1 \leq 2 \cdot 10^{+302}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0 or 2.0000000000000002e302 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 54.2%
Taylor expanded in y around inf 100.0%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 2.0000000000000002e302Initial program 98.4%
Final simplification98.6%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 1.4e+27)
x
(if (or (<= y_m 1.7e+80) (not (<= y_m 8.2e+104)))
(+ x (* z (- t x)))
(* (tanh (/ t y_m)) (* y_m z)))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 1.4e+27) {
tmp = x;
} else if ((y_m <= 1.7e+80) || !(y_m <= 8.2e+104)) {
tmp = x + (z * (t - x));
} else {
tmp = tanh((t / y_m)) * (y_m * 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 (y_m <= 1.4d+27) then
tmp = x
else if ((y_m <= 1.7d+80) .or. (.not. (y_m <= 8.2d+104))) then
tmp = x + (z * (t - x))
else
tmp = tanh((t / y_m)) * (y_m * 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 (y_m <= 1.4e+27) {
tmp = x;
} else if ((y_m <= 1.7e+80) || !(y_m <= 8.2e+104)) {
tmp = x + (z * (t - x));
} else {
tmp = Math.tanh((t / y_m)) * (y_m * z);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 1.4e+27: tmp = x elif (y_m <= 1.7e+80) or not (y_m <= 8.2e+104): tmp = x + (z * (t - x)) else: tmp = math.tanh((t / y_m)) * (y_m * z) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 1.4e+27) tmp = x; elseif ((y_m <= 1.7e+80) || !(y_m <= 8.2e+104)) tmp = Float64(x + Float64(z * Float64(t - x))); else tmp = Float64(tanh(Float64(t / y_m)) * Float64(y_m * z)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 1.4e+27) tmp = x; elseif ((y_m <= 1.7e+80) || ~((y_m <= 8.2e+104))) tmp = x + (z * (t - x)); else tmp = tanh((t / y_m)) * (y_m * z); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 1.4e+27], x, If[Or[LessEqual[y$95$m, 1.7e+80], N[Not[LessEqual[y$95$m, 8.2e+104]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] * N[(y$95$m * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.4 \cdot 10^{+27}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 1.7 \cdot 10^{+80} \lor \neg \left(y\_m \leq 8.2 \cdot 10^{+104}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;\tanh \left(\frac{t}{y\_m}\right) \cdot \left(y\_m \cdot z\right)\\
\end{array}
\end{array}
if y < 1.4e27Initial program 94.3%
+-commutative94.3%
associate-*l*97.3%
fma-define97.3%
Simplified97.3%
Taylor expanded in y around 0 66.4%
if 1.4e27 < y < 1.69999999999999996e80 or 8.1999999999999997e104 < y Initial program 86.0%
Taylor expanded in y around inf 82.2%
if 1.69999999999999996e80 < y < 8.1999999999999997e104Initial program 100.0%
+-commutative100.0%
associate-*l*99.7%
fma-define99.7%
Simplified99.7%
Taylor expanded in x around 0 0.8%
associate-/r*0.8%
div-sub0.8%
rec-exp0.8%
rec-exp0.8%
tanh-def-a88.7%
Simplified88.7%
Taylor expanded in z around inf 0.8%
associate-/l*0.8%
associate-/l*0.8%
rec-exp0.8%
rec-exp0.8%
tanh-def-a88.7%
tanh-def-a0.8%
rec-exp0.8%
rec-exp0.8%
Simplified88.7%
Final simplification70.0%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (* y_m (tanh (/ t y_m)))))
(if (<= y_m 1.55e-258)
x
(if (<= y_m 1.45e+26) (+ 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 (y_m <= 1.55e-258) {
tmp = x;
} else if (y_m <= 1.45e+26) {
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 (y_m <= 1.55d-258) then
tmp = x
else if (y_m <= 1.45d+26) 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 (y_m <= 1.55e-258) {
tmp = x;
} else if (y_m <= 1.45e+26) {
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 y_m <= 1.55e-258: tmp = x elif y_m <= 1.45e+26: 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 (y_m <= 1.55e-258) tmp = x; elseif (y_m <= 1.45e+26) 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 (y_m <= 1.55e-258) tmp = x; elseif (y_m <= 1.45e+26) 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[y$95$m, 1.55e-258], x, If[LessEqual[y$95$m, 1.45e+26], 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}\;y\_m \leq 1.55 \cdot 10^{-258}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 1.45 \cdot 10^{+26}:\\
\;\;\;\;x + z \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t\_1 - x\right)\\
\end{array}
\end{array}
if y < 1.54999999999999999e-258Initial program 92.1%
+-commutative92.1%
associate-*l*96.3%
fma-define96.3%
Simplified96.3%
Taylor expanded in y around 0 59.3%
if 1.54999999999999999e-258 < y < 1.45e26Initial program 100.0%
+-commutative100.0%
associate-*l*100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in x around 0 28.6%
associate-/r*28.6%
div-sub28.6%
rec-exp28.6%
rec-exp28.6%
tanh-def-a90.2%
Simplified90.2%
fma-undefine90.2%
associate-*r*90.2%
*-commutative90.2%
associate-*r*90.2%
Applied egg-rr90.2%
if 1.45e26 < y Initial program 87.2%
Taylor expanded in x around 0 44.0%
+-commutative44.0%
Simplified94.6%
Taylor expanded in z around 0 44.0%
associate-/l*44.0%
rec-exp44.0%
rec-exp44.0%
tanh-def-a94.6%
Simplified94.6%
Final simplification73.7%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 1.95e-258)
x
(if (<= y_m 2.15e+132)
(+ 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 <= 1.95e-258) {
tmp = x;
} else if (y_m <= 2.15e+132) {
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 <= 1.95d-258) then
tmp = x
else if (y_m <= 2.15d+132) 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 <= 1.95e-258) {
tmp = x;
} else if (y_m <= 2.15e+132) {
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 <= 1.95e-258: tmp = x elif y_m <= 2.15e+132: 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 <= 1.95e-258) tmp = x; elseif (y_m <= 2.15e+132) 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 <= 1.95e-258) tmp = x; elseif (y_m <= 2.15e+132) 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, 1.95e-258], x, If[LessEqual[y$95$m, 2.15e+132], 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 1.95 \cdot 10^{-258}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 2.15 \cdot 10^{+132}:\\
\;\;\;\;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 < 1.95000000000000002e-258Initial program 92.1%
+-commutative92.1%
associate-*l*96.3%
fma-define96.3%
Simplified96.3%
Taylor expanded in y around 0 59.3%
if 1.95000000000000002e-258 < y < 2.14999999999999991e132Initial program 98.0%
Taylor expanded in x around 0 26.7%
associate-*r*26.7%
associate-/r*26.7%
div-sub26.7%
rec-exp26.7%
rec-exp26.7%
tanh-def-a88.4%
Simplified88.4%
if 2.14999999999999991e132 < y Initial program 84.2%
Taylor expanded in y around inf 86.9%
Final simplification71.7%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 1.7e-257)
x
(if (<= y_m 1.6e+176)
(+ x (* z (* y_m (tanh (/ t y_m)))))
(+ 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.7e-257) {
tmp = x;
} else if (y_m <= 1.6e+176) {
tmp = x + (z * (y_m * tanh((t / y_m))));
} 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 <= 1.7d-257) then
tmp = x
else if (y_m <= 1.6d+176) then
tmp = x + (z * (y_m * tanh((t / y_m))))
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 <= 1.7e-257) {
tmp = x;
} else if (y_m <= 1.6e+176) {
tmp = x + (z * (y_m * Math.tanh((t / y_m))));
} 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 <= 1.7e-257: tmp = x elif y_m <= 1.6e+176: tmp = x + (z * (y_m * math.tanh((t / y_m)))) 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.7e-257) tmp = x; elseif (y_m <= 1.6e+176) tmp = Float64(x + Float64(z * Float64(y_m * tanh(Float64(t / y_m))))); 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 <= 1.7e-257) tmp = x; elseif (y_m <= 1.6e+176) tmp = x + (z * (y_m * tanh((t / y_m)))); 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, 1.7e-257], x, If[LessEqual[y$95$m, 1.6e+176], N[(x + N[(z * N[(y$95$m * N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]), $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 1.7 \cdot 10^{-257}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 1.6 \cdot 10^{+176}:\\
\;\;\;\;x + z \cdot \left(y\_m \cdot \tanh \left(\frac{t}{y\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.6999999999999999e-257Initial program 92.1%
+-commutative92.1%
associate-*l*96.3%
fma-define96.3%
Simplified96.3%
Taylor expanded in y around 0 59.3%
if 1.6999999999999999e-257 < y < 1.5999999999999999e176Initial program 98.3%
+-commutative98.3%
associate-*l*99.2%
fma-define99.2%
Simplified99.2%
Taylor expanded in x around 0 26.2%
associate-/r*26.2%
div-sub26.2%
rec-exp26.2%
rec-exp26.2%
tanh-def-a87.5%
Simplified87.5%
fma-undefine87.5%
associate-*r*87.4%
*-commutative87.4%
associate-*r*87.5%
Applied egg-rr87.5%
if 1.5999999999999999e176 < y Initial program 78.1%
Taylor expanded in y around inf 89.1%
Final simplification71.7%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= x -6.1e-179) x (if (<= x 1.15e-213) (* z t) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (x <= -6.1e-179) {
tmp = x;
} else if (x <= 1.15e-213) {
tmp = z * t;
} else {
tmp = 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 (x <= (-6.1d-179)) then
tmp = x
else if (x <= 1.15d-213) then
tmp = z * t
else
tmp = 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 (x <= -6.1e-179) {
tmp = x;
} else if (x <= 1.15e-213) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if x <= -6.1e-179: tmp = x elif x <= 1.15e-213: tmp = z * t else: tmp = x return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (x <= -6.1e-179) tmp = x; elseif (x <= 1.15e-213) tmp = Float64(z * t); else tmp = x; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (x <= -6.1e-179) tmp = x; elseif (x <= 1.15e-213) tmp = z * t; else tmp = x; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[x, -6.1e-179], x, If[LessEqual[x, 1.15e-213], N[(z * t), $MachinePrecision], x]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.1 \cdot 10^{-179}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{-213}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -6.09999999999999995e-179 or 1.15000000000000001e-213 < x Initial program 94.5%
+-commutative94.5%
associate-*l*98.5%
fma-define98.5%
Simplified98.5%
Taylor expanded in y around 0 66.6%
if -6.09999999999999995e-179 < x < 1.15000000000000001e-213Initial program 82.7%
+-commutative82.7%
associate-*l*90.1%
fma-define90.1%
Simplified90.1%
Taylor expanded in x around 0 3.3%
associate-/r*3.3%
div-sub3.3%
rec-exp3.3%
rec-exp3.3%
tanh-def-a76.4%
Simplified76.4%
Taylor expanded in y around inf 49.1%
+-commutative49.1%
*-commutative49.1%
Simplified49.1%
Taylor expanded in z around inf 46.7%
Final simplification63.5%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.2e+26) 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.2e+26) {
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 <= 1.2d+26) 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 <= 1.2e+26) {
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 <= 1.2e+26: 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 <= 1.2e+26) 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 <= 1.2e+26) 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[LessEqual[y$95$m, 1.2e+26], 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 1.2 \cdot 10^{+26}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.20000000000000002e26Initial program 94.3%
+-commutative94.3%
associate-*l*97.3%
fma-define97.3%
Simplified97.3%
Taylor expanded in y around 0 66.4%
if 1.20000000000000002e26 < y Initial program 87.2%
Taylor expanded in y around inf 77.1%
Final simplification68.8%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 8e+24) x (+ x (* z t))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 8e+24) {
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 <= 8d+24) 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 <= 8e+24) {
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 <= 8e+24: 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 <= 8e+24) 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 <= 8e+24) 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, 8e+24], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 8 \cdot 10^{+24}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 7.9999999999999999e24Initial program 94.3%
+-commutative94.3%
associate-*l*97.3%
fma-define97.3%
Simplified97.3%
Taylor expanded in y around 0 66.4%
if 7.9999999999999999e24 < y Initial program 87.2%
+-commutative87.2%
associate-*l*97.0%
fma-define97.0%
Simplified97.0%
Taylor expanded in x around 0 31.9%
associate-/r*31.9%
div-sub31.9%
rec-exp31.9%
rec-exp31.9%
tanh-def-a83.6%
Simplified83.6%
Taylor expanded in y around inf 67.1%
+-commutative67.1%
*-commutative67.1%
Simplified67.1%
Final simplification66.6%
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 92.7%
+-commutative92.7%
associate-*l*97.3%
fma-define97.3%
Simplified97.3%
Taylor expanded in y around 0 59.4%
Final simplification59.4%
(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 2024041
(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))))))