
(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 1.5e+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 <= 1.5e+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 <= 1.5e+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, 1.5e+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 1.5 \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 < 1.49999999999999988e217Initial program 94.3%
+-commutative94.3%
associate-*l*97.1%
fma-def97.1%
Simplified97.1%
if 1.49999999999999988e217 < y Initial program 81.1%
Taylor expanded in y around inf 100.0%
Final simplification97.3%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 8.6e+140) (+ x (* (- (tanh (/ t y_m)) (tanh (/ x 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 <= 8.6e+140) {
tmp = x + ((tanh((t / y_m)) - tanh((x / 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 <= 8.6d+140) then
tmp = x + ((tanh((t / y_m)) - tanh((x / 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 <= 8.6e+140) {
tmp = x + ((Math.tanh((t / y_m)) - Math.tanh((x / 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 <= 8.6e+140: tmp = x + ((math.tanh((t / y_m)) - math.tanh((x / 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 <= 8.6e+140) tmp = Float64(x + Float64(Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / 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 <= 8.6e+140) tmp = x + ((tanh((t / y_m)) - tanh((x / 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, 8.6e+140], 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], 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 8.6 \cdot 10^{+140}:\\
\;\;\;\;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{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 8.60000000000000004e140Initial program 95.6%
if 8.60000000000000004e140 < y Initial program 78.4%
Taylor expanded in y around inf 93.7%
Final simplification95.4%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (tanh (/ t y_m))))
(if (<= t -1.9e-19)
(fma y_m (* z t_1) x)
(if (<= t 6.4e-24)
(+ x (* z (* y_m (- (/ t y_m) (tanh (/ x y_m))))))
(+ x (* t_1 (* y_m z)))))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double t_1 = tanh((t / y_m));
double tmp;
if (t <= -1.9e-19) {
tmp = fma(y_m, (z * t_1), x);
} else if (t <= 6.4e-24) {
tmp = x + (z * (y_m * ((t / y_m) - tanh((x / y_m)))));
} else {
tmp = x + (t_1 * (y_m * z));
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) t_1 = tanh(Float64(t / y_m)) tmp = 0.0 if (t <= -1.9e-19) tmp = fma(y_m, Float64(z * t_1), x); elseif (t <= 6.4e-24) tmp = Float64(x + Float64(z * Float64(y_m * Float64(Float64(t / y_m) - tanh(Float64(x / y_m)))))); else tmp = Float64(x + Float64(t_1 * Float64(y_m * z))); end return tmp end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -1.9e-19], N[(y$95$m * N[(z * t$95$1), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t, 6.4e-24], N[(x + N[(z * N[(y$95$m * N[(N[(t / y$95$m), $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$1 * N[(y$95$m * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y_m}\right)\\
\mathbf{if}\;t \leq -1.9 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(y_m, z \cdot t_1, x\right)\\
\mathbf{elif}\;t \leq 6.4 \cdot 10^{-24}:\\
\;\;\;\;x + z \cdot \left(y_m \cdot \left(\frac{t}{y_m} - \tanh \left(\frac{x}{y_m}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + t_1 \cdot \left(y_m \cdot z\right)\\
\end{array}
\end{array}
if t < -1.9e-19Initial program 98.4%
+-commutative98.4%
associate-*l*98.4%
fma-def98.4%
Simplified98.4%
Taylor expanded in x around 0 5.1%
associate-/r*5.1%
div-sub5.1%
rec-exp5.2%
rec-exp5.2%
tanh-def-a87.8%
Simplified87.8%
if -1.9e-19 < t < 6.40000000000000025e-24Initial program 88.6%
+-commutative88.6%
associate-*l*94.6%
fma-def94.6%
Simplified94.6%
Taylor expanded in t around 0 90.2%
fma-udef90.2%
associate-*l*84.9%
*-commutative84.9%
associate-*l*91.7%
Applied egg-rr91.7%
if 6.40000000000000025e-24 < t Initial program 98.3%
Taylor expanded in x around 0 10.6%
associate-*r*10.5%
associate-/r*10.5%
div-sub10.5%
rec-exp10.5%
rec-exp10.5%
tanh-def-a88.3%
Simplified88.3%
Final simplification89.9%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (or (<= t -1.45e-18) (not (<= t 1.85e-24))) (+ x (* (tanh (/ t y_m)) (* y_m z))) (+ x (* z (* y_m (- (/ 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.45e-18) || !(t <= 1.85e-24)) {
tmp = x + (tanh((t / y_m)) * (y_m * z));
} else {
tmp = x + (z * (y_m * ((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.45d-18)) .or. (.not. (t <= 1.85d-24))) then
tmp = x + (tanh((t / y_m)) * (y_m * z))
else
tmp = x + (z * (y_m * ((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.45e-18) || !(t <= 1.85e-24)) {
tmp = x + (Math.tanh((t / y_m)) * (y_m * z));
} else {
tmp = x + (z * (y_m * ((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.45e-18) or not (t <= 1.85e-24): tmp = x + (math.tanh((t / y_m)) * (y_m * z)) else: tmp = x + (z * (y_m * ((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.45e-18) || !(t <= 1.85e-24)) tmp = Float64(x + Float64(tanh(Float64(t / y_m)) * Float64(y_m * z))); else tmp = Float64(x + Float64(z * Float64(y_m * 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.45e-18) || ~((t <= 1.85e-24))) tmp = x + (tanh((t / y_m)) * (y_m * z)); else tmp = x + (z * (y_m * ((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.45e-18], N[Not[LessEqual[t, 1.85e-24]], $MachinePrecision]], 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[(y$95$m * N[(N[(t / y$95$m), $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.45 \cdot 10^{-18} \lor \neg \left(t \leq 1.85 \cdot 10^{-24}\right):\\
\;\;\;\;x + \tanh \left(\frac{t}{y_m}\right) \cdot \left(y_m \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y_m \cdot \left(\frac{t}{y_m} - \tanh \left(\frac{x}{y_m}\right)\right)\right)\\
\end{array}
\end{array}
if t < -1.45e-18 or 1.8499999999999999e-24 < t Initial program 98.4%
Taylor expanded in x around 0 7.6%
associate-*r*7.5%
associate-/r*7.5%
div-sub7.5%
rec-exp7.6%
rec-exp7.6%
tanh-def-a88.1%
Simplified88.1%
if -1.45e-18 < t < 1.8499999999999999e-24Initial program 88.6%
+-commutative88.6%
associate-*l*94.6%
fma-def94.6%
Simplified94.6%
Taylor expanded in t around 0 90.2%
fma-udef90.2%
associate-*l*84.9%
*-commutative84.9%
associate-*l*91.7%
Applied egg-rr91.7%
Final simplification89.9%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 4e-43)
x
(if (<= y_m 2.1e-15)
(* (tanh (/ t y_m)) (* y_m z))
(if (<= y_m 5.5e+39) 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 <= 4e-43) {
tmp = x;
} else if (y_m <= 2.1e-15) {
tmp = tanh((t / y_m)) * (y_m * z);
} else if (y_m <= 5.5e+39) {
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 <= 4d-43) then
tmp = x
else if (y_m <= 2.1d-15) then
tmp = tanh((t / y_m)) * (y_m * z)
else if (y_m <= 5.5d+39) 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 <= 4e-43) {
tmp = x;
} else if (y_m <= 2.1e-15) {
tmp = Math.tanh((t / y_m)) * (y_m * z);
} else if (y_m <= 5.5e+39) {
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 <= 4e-43: tmp = x elif y_m <= 2.1e-15: tmp = math.tanh((t / y_m)) * (y_m * z) elif y_m <= 5.5e+39: 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 <= 4e-43) tmp = x; elseif (y_m <= 2.1e-15) tmp = Float64(tanh(Float64(t / y_m)) * Float64(y_m * z)); elseif (y_m <= 5.5e+39) 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 <= 4e-43) tmp = x; elseif (y_m <= 2.1e-15) tmp = tanh((t / y_m)) * (y_m * z); elseif (y_m <= 5.5e+39) 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, 4e-43], x, If[LessEqual[y$95$m, 2.1e-15], N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] * N[(y$95$m * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 5.5e+39], 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 \cdot 10^{-43}:\\
\;\;\;\;x\\
\mathbf{elif}\;y_m \leq 2.1 \cdot 10^{-15}:\\
\;\;\;\;\tanh \left(\frac{t}{y_m}\right) \cdot \left(y_m \cdot z\right)\\
\mathbf{elif}\;y_m \leq 5.5 \cdot 10^{+39}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 4.00000000000000031e-43 or 2.09999999999999981e-15 < y < 5.4999999999999997e39Initial program 95.1%
Taylor expanded in x around inf 65.0%
if 4.00000000000000031e-43 < y < 2.09999999999999981e-15Initial program 99.7%
+-commutative99.7%
associate-*l*99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in x around 0 0.6%
associate-/r*0.6%
div-sub0.6%
rec-exp0.6%
rec-exp0.6%
tanh-def-a80.1%
Simplified80.1%
Taylor expanded in z around inf 0.7%
associate-*r*0.7%
*-commutative0.7%
associate-*r/0.7%
rec-exp0.7%
rec-exp0.7%
tanh-def-a59.2%
*-commutative59.2%
Simplified59.2%
if 5.4999999999999997e39 < y Initial program 85.8%
Taylor expanded in y around inf 88.2%
Final simplification69.2%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 9.2e+129) (+ 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.2e+129) {
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.2d+129) 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.2e+129) {
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.2e+129: 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.2e+129) 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.2e+129) 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.2e+129], 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.2 \cdot 10^{+129}:\\
\;\;\;\;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.19999999999999961e129Initial program 95.6%
Taylor expanded in x around 0 27.8%
associate-*r*27.6%
associate-/r*27.6%
div-sub27.6%
rec-exp27.6%
rec-exp27.6%
tanh-def-a79.8%
Simplified79.8%
if 9.19999999999999961e129 < y Initial program 79.0%
Taylor expanded in y around inf 91.2%
Final simplification81.3%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.35e+42) 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.35e+42) {
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.35d+42) 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.35e+42) {
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.35e+42: 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.35e+42) 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.35e+42) 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.35e+42], 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.35 \cdot 10^{+42}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.35e42Initial program 95.3%
Taylor expanded in x around inf 63.3%
if 1.35e42 < y Initial program 85.8%
Taylor expanded in y around inf 88.2%
Final simplification68.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.45e+130) 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.45e+130) {
tmp = x;
} else {
tmp = 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.45d+130) then
tmp = x
else
tmp = 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.45e+130) {
tmp = x;
} else {
tmp = z * (t - x);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 1.45e+130: tmp = x else: tmp = z * (t - x) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 1.45e+130) tmp = x; else tmp = 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.45e+130) tmp = x; else tmp = 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.45e+130], x, N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y_m \leq 1.45 \cdot 10^{+130}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.45e130Initial program 95.6%
Taylor expanded in x around inf 62.2%
if 1.45e130 < y Initial program 79.0%
Taylor expanded in y around inf 91.2%
Taylor expanded in z around inf 70.0%
Final simplification63.2%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 2e+135) x (* z t)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 2e+135) {
tmp = x;
} else {
tmp = 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 <= 2d+135) then
tmp = x
else
tmp = 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 <= 2e+135) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 2e+135: tmp = x else: tmp = z * t return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 2e+135) tmp = x; else tmp = 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 <= 2e+135) tmp = x; else tmp = 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, 2e+135], x, N[(z * t), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y_m \leq 2 \cdot 10^{+135}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < 1.99999999999999992e135Initial program 95.6%
Taylor expanded in x around inf 62.2%
if 1.99999999999999992e135 < y Initial program 79.0%
Taylor expanded in y around inf 91.2%
Taylor expanded in x around 0 48.6%
*-commutative48.6%
Simplified48.6%
Final simplification60.5%
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 93.5%
Taylor expanded in x around inf 57.6%
Final simplification57.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 2023326
(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))))))