
(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.56e+131) (fma y_m (* z (- (tanh (/ t y_m)) (tanh (/ x y_m)))) x) (fma z (- t x) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 1.56e+131) {
tmp = fma(y_m, (z * (tanh((t / y_m)) - tanh((x / y_m)))), x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 1.56e+131) tmp = fma(y_m, Float64(z * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))), x); else tmp = fma(z, Float64(t - x), x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 1.56e+131], 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[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.56 \cdot 10^{+131}:\\
\;\;\;\;\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}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 1.5600000000000001e131Initial program 96.4%
+-commutative96.4%
associate-*l*98.6%
fma-define98.6%
Simplified98.6%
if 1.5600000000000001e131 < y Initial program 76.3%
Taylor expanded in y around inf 97.2%
+-commutative97.2%
fma-define97.2%
Simplified97.2%
Final simplification98.4%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 6.6e+131) (+ x (* y_m (* z (- (tanh (/ t y_m)) (tanh (/ x y_m)))))) (fma z (- t x) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 6.6e+131) {
tmp = x + (y_m * (z * (tanh((t / y_m)) - tanh((x / y_m)))));
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 6.6e+131) tmp = Float64(x + Float64(y_m * Float64(z * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))))); else tmp = fma(z, Float64(t - x), x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 6.6e+131], N[(x + 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]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 6.6 \cdot 10^{+131}:\\
\;\;\;\;x + y\_m \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 6.5999999999999997e131Initial program 96.4%
sub-neg96.4%
distribute-lft-in94.4%
Applied egg-rr94.4%
Taylor expanded in y around 0 17.2%
+-commutative17.2%
Simplified98.6%
if 6.5999999999999997e131 < y Initial program 76.3%
Taylor expanded in y around inf 97.2%
+-commutative97.2%
fma-define97.2%
Simplified97.2%
Final simplification98.4%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 2e-53)
x
(if (<= y_m 2.15e+15)
(+ x (* z t))
(if (<= y_m 6.8e+20) (* (tanh (/ t y_m)) (* y_m z)) (fma z (- t x) x)))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 2e-53) {
tmp = x;
} else if (y_m <= 2.15e+15) {
tmp = x + (z * t);
} else if (y_m <= 6.8e+20) {
tmp = tanh((t / y_m)) * (y_m * z);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 2e-53) tmp = x; elseif (y_m <= 2.15e+15) tmp = Float64(x + Float64(z * t)); elseif (y_m <= 6.8e+20) tmp = Float64(tanh(Float64(t / y_m)) * Float64(y_m * z)); else tmp = fma(z, Float64(t - x), x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 2e-53], x, If[LessEqual[y$95$m, 2.15e+15], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 6.8e+20], N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] * N[(y$95$m * z), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 2 \cdot 10^{-53}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 2.15 \cdot 10^{+15}:\\
\;\;\;\;x + z \cdot t\\
\mathbf{elif}\;y\_m \leq 6.8 \cdot 10^{+20}:\\
\;\;\;\;\tanh \left(\frac{t}{y\_m}\right) \cdot \left(y\_m \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 2.00000000000000006e-53Initial program 95.6%
Taylor expanded in x around inf 72.3%
if 2.00000000000000006e-53 < y < 2.15e15Initial program 99.9%
sub-neg99.9%
distribute-lft-in99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 5.5%
+-commutative5.5%
Simplified99.8%
Taylor expanded in x around 0 41.0%
associate-/r*41.0%
div-sub41.0%
rec-exp41.0%
rec-exp41.0%
tanh-def-a90.4%
Simplified90.4%
Taylor expanded in y around inf 79.9%
+-commutative79.9%
*-commutative79.9%
Simplified79.9%
if 2.15e15 < y < 6.8e20Initial program 100.0%
+-commutative100.0%
associate-*l*100.0%
fma-define100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in z around inf 40.0%
associate-*r*40.0%
associate--r+40.0%
Simplified100.0%
Taylor expanded in x around 0 20.0%
associate-/r*20.0%
div-sub20.0%
rec-exp20.0%
rec-exp20.0%
tanh-def-a100.0%
Simplified100.0%
if 6.8e20 < y Initial program 83.0%
Taylor expanded in y around inf 92.2%
+-commutative92.2%
fma-define92.2%
Simplified92.2%
Final simplification77.8%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 5.5e-206)
x
(if (<= y_m 5.6e+104)
(+ x (* y_m (* z (tanh (/ t y_m)))))
(fma z (- t x) x))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 5.5e-206) {
tmp = x;
} else if (y_m <= 5.6e+104) {
tmp = x + (y_m * (z * tanh((t / y_m))));
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 5.5e-206) tmp = x; elseif (y_m <= 5.6e+104) tmp = Float64(x + Float64(y_m * Float64(z * tanh(Float64(t / y_m))))); else tmp = fma(z, Float64(t - x), x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 5.5e-206], x, If[LessEqual[y$95$m, 5.6e+104], N[(x + N[(y$95$m * N[(z * N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 5.5 \cdot 10^{-206}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 5.6 \cdot 10^{+104}:\\
\;\;\;\;x + y\_m \cdot \left(z \cdot \tanh \left(\frac{t}{y\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 5.50000000000000023e-206Initial program 94.7%
Taylor expanded in x around inf 72.6%
if 5.50000000000000023e-206 < y < 5.6e104Initial program 99.9%
sub-neg99.9%
distribute-lft-in99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 8.4%
+-commutative8.4%
Simplified99.9%
Taylor expanded in x around 0 25.4%
associate-/r*25.4%
div-sub25.3%
rec-exp25.4%
rec-exp25.4%
tanh-def-a85.6%
Simplified85.6%
if 5.6e104 < y Initial program 77.9%
Taylor expanded in y around inf 97.4%
+-commutative97.4%
fma-define97.4%
Simplified97.4%
Final simplification80.2%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 9e-207)
x
(if (<= y_m 1.65e+105)
(+ x (* (tanh (/ t y_m)) (* y_m z)))
(fma z (- t x) x))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 9e-207) {
tmp = x;
} else if (y_m <= 1.65e+105) {
tmp = x + (tanh((t / y_m)) * (y_m * z));
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 9e-207) tmp = x; elseif (y_m <= 1.65e+105) tmp = Float64(x + Float64(tanh(Float64(t / y_m)) * Float64(y_m * z))); else tmp = fma(z, Float64(t - x), x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 9e-207], x, If[LessEqual[y$95$m, 1.65e+105], N[(x + N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] * N[(y$95$m * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 9 \cdot 10^{-207}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 1.65 \cdot 10^{+105}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y\_m}\right) \cdot \left(y\_m \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 8.99999999999999984e-207Initial program 94.7%
Taylor expanded in x around inf 72.6%
if 8.99999999999999984e-207 < y < 1.64999999999999999e105Initial program 99.9%
Taylor expanded in x around 0 25.4%
associate-*r*25.3%
associate-/r*25.3%
div-sub25.3%
rec-exp25.4%
rec-exp25.4%
tanh-def-a88.5%
Simplified88.5%
if 1.64999999999999999e105 < y Initial program 77.9%
Taylor expanded in y around inf 97.4%
+-commutative97.4%
fma-define97.4%
Simplified97.4%
Final simplification81.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.4e-36) x (fma z (- t x) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 1.4e-36) {
tmp = x;
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 1.4e-36) tmp = x; else tmp = fma(z, Float64(t - x), x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 1.4e-36], x, N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.4 \cdot 10^{-36}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 1.4000000000000001e-36Initial program 95.8%
Taylor expanded in x around inf 72.6%
if 1.4000000000000001e-36 < y Initial program 87.4%
Taylor expanded in y around inf 82.9%
+-commutative82.9%
fma-define82.9%
Simplified82.9%
Final simplification75.7%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 5.1e-52)
x
(if (or (<= y_m 3.7e+84) (not (<= y_m 2.2e+176)))
(+ x (* z t))
(* x (- 1.0 z)))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 5.1e-52) {
tmp = x;
} else if ((y_m <= 3.7e+84) || !(y_m <= 2.2e+176)) {
tmp = x + (z * t);
} 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 (y_m <= 5.1d-52) then
tmp = x
else if ((y_m <= 3.7d+84) .or. (.not. (y_m <= 2.2d+176))) then
tmp = x + (z * t)
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 (y_m <= 5.1e-52) {
tmp = x;
} else if ((y_m <= 3.7e+84) || !(y_m <= 2.2e+176)) {
tmp = x + (z * t);
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 5.1e-52: tmp = x elif (y_m <= 3.7e+84) or not (y_m <= 2.2e+176): tmp = x + (z * t) else: tmp = x * (1.0 - z) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 5.1e-52) tmp = x; elseif ((y_m <= 3.7e+84) || !(y_m <= 2.2e+176)) tmp = Float64(x + Float64(z * t)); 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 (y_m <= 5.1e-52) tmp = x; elseif ((y_m <= 3.7e+84) || ~((y_m <= 2.2e+176))) tmp = x + (z * t); 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[y$95$m, 5.1e-52], x, If[Or[LessEqual[y$95$m, 3.7e+84], N[Not[LessEqual[y$95$m, 2.2e+176]], $MachinePrecision]], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 5.1 \cdot 10^{-52}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 3.7 \cdot 10^{+84} \lor \neg \left(y\_m \leq 2.2 \cdot 10^{+176}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 5.09999999999999989e-52Initial program 95.6%
Taylor expanded in x around inf 72.3%
if 5.09999999999999989e-52 < y < 3.7e84 or 2.20000000000000007e176 < y Initial program 84.6%
sub-neg84.6%
distribute-lft-in75.7%
Applied egg-rr75.7%
Taylor expanded in y around 0 26.2%
+-commutative26.2%
Simplified93.6%
Taylor expanded in x around 0 41.1%
associate-/r*41.1%
div-sub41.0%
rec-exp41.1%
rec-exp41.1%
tanh-def-a78.8%
Simplified78.8%
Taylor expanded in y around inf 70.4%
+-commutative70.4%
*-commutative70.4%
Simplified70.4%
if 3.7e84 < y < 2.20000000000000007e176Initial program 99.8%
Taylor expanded in x around 0 80.7%
+-commutative80.7%
Simplified100.0%
Taylor expanded in x around inf 84.4%
mul-1-neg84.4%
unsub-neg84.4%
Simplified84.4%
Final simplification72.8%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 4.2e-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 <= 4.2e-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 <= 4.2d-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 <= 4.2e-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 <= 4.2e-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 <= 4.2e-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 <= 4.2e-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, 4.2e-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.2 \cdot 10^{-39}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 4.19999999999999987e-39Initial program 95.8%
Taylor expanded in x around inf 72.6%
if 4.19999999999999987e-39 < y Initial program 87.4%
Taylor expanded in y around inf 82.9%
Final simplification75.7%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.45e+63) x (* x (- 1.0 z))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 1.45e+63) {
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 (y_m <= 1.45d+63) 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 (y_m <= 1.45e+63) {
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 y_m <= 1.45e+63: 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 (y_m <= 1.45e+63) 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 (y_m <= 1.45e+63) 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[y$95$m, 1.45e+63], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.45 \cdot 10^{+63}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 1.45e63Initial program 96.3%
Taylor expanded in x around inf 69.9%
if 1.45e63 < y Initial program 81.0%
Taylor expanded in x around 0 70.5%
+-commutative70.5%
Simplified96.1%
Taylor expanded in x around inf 70.4%
mul-1-neg70.4%
unsub-neg70.4%
Simplified70.4%
Final simplification70.0%
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.3%
Taylor expanded in x around inf 66.0%
Final simplification66.0%
(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 2024053
(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))))))