
(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 11 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 7e+246) (fma y_m (- (* (tanh (/ t y_m)) z) (* z (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 <= 7e+246) {
tmp = fma(y_m, ((tanh((t / y_m)) * z) - (z * 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 <= 7e+246) tmp = fma(y_m, Float64(Float64(tanh(Float64(t / y_m)) * z) - Float64(z * 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, 7e+246], N[(y$95$m * N[(N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] * z), $MachinePrecision] - N[(z * 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 7 \cdot 10^{+246}:\\
\;\;\;\;\mathsf{fma}\left(y\_m, \tanh \left(\frac{t}{y\_m}\right) \cdot z - z \cdot \tanh \left(\frac{x}{y\_m}\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 6.99999999999999951e246Initial program 95.8%
+-commutative95.8%
associate-*l*97.9%
fma-define97.9%
Simplified97.9%
sub-neg97.9%
distribute-rgt-in97.9%
Applied egg-rr97.9%
distribute-rgt-out97.9%
unsub-neg97.9%
add-sqr-sqrt51.8%
sqrt-unprod85.3%
sqr-neg85.3%
sqrt-unprod40.1%
add-sqr-sqrt76.1%
distribute-rgt-out--76.1%
*-commutative76.1%
add-sqr-sqrt40.1%
sqrt-unprod85.3%
sqr-neg85.3%
sqrt-unprod51.7%
add-sqr-sqrt97.9%
Applied egg-rr97.9%
if 6.99999999999999951e246 < y Initial program 72.5%
Taylor expanded in y around inf 95.2%
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+306) 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+306) {
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+306) 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+306) {
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+306: 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+306) 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+306) 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+306], 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^{+306}:\\
\;\;\;\;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))))) < 1.00000000000000002e306Initial program 98.7%
if 1.00000000000000002e306 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 43.7%
Taylor expanded in y around inf 95.3%
Final simplification98.4%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 7e+246) (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 <= 7e+246) {
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 <= 7e+246) 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, 7e+246], 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 7 \cdot 10^{+246}:\\
\;\;\;\;\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.99999999999999951e246Initial program 95.8%
+-commutative95.8%
associate-*l*97.9%
fma-define97.9%
Simplified97.9%
if 6.99999999999999951e246 < y Initial program 72.5%
Taylor expanded in y around inf 95.2%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 2.4e+246) (+ x (* y_m (- (* (tanh (/ t y_m)) z) (* z (tanh (/ x 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 <= 2.4e+246) {
tmp = x + (y_m * ((tanh((t / y_m)) * z) - (z * tanh((x / 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 <= 2.4d+246) then
tmp = x + (y_m * ((tanh((t / y_m)) * z) - (z * tanh((x / 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 <= 2.4e+246) {
tmp = x + (y_m * ((Math.tanh((t / y_m)) * z) - (z * Math.tanh((x / 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 <= 2.4e+246: tmp = x + (y_m * ((math.tanh((t / y_m)) * z) - (z * math.tanh((x / 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 <= 2.4e+246) tmp = Float64(x + Float64(y_m * Float64(Float64(tanh(Float64(t / y_m)) * z) - Float64(z * tanh(Float64(x / 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 <= 2.4e+246) tmp = x + (y_m * ((tanh((t / y_m)) * z) - (z * tanh((x / 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, 2.4e+246], N[(x + N[(y$95$m * N[(N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] * z), $MachinePrecision] - N[(z * N[Tanh[N[(x / y$95$m), $MachinePrecision]], $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 2.4 \cdot 10^{+246}:\\
\;\;\;\;x + y\_m \cdot \left(\tanh \left(\frac{t}{y\_m}\right) \cdot z - z \cdot \tanh \left(\frac{x}{y\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.4e246Initial program 95.8%
+-commutative95.8%
associate-*l*97.9%
fma-define97.9%
Simplified97.9%
sub-neg97.9%
distribute-rgt-in97.9%
Applied egg-rr97.9%
distribute-rgt-out97.9%
unsub-neg97.9%
add-sqr-sqrt51.8%
sqrt-unprod85.3%
sqr-neg85.3%
sqrt-unprod40.1%
add-sqr-sqrt76.1%
distribute-rgt-out--76.1%
*-commutative76.1%
add-sqr-sqrt40.1%
sqrt-unprod85.3%
sqr-neg85.3%
sqrt-unprod51.7%
add-sqr-sqrt97.9%
Applied egg-rr97.9%
Taylor expanded in y around 0 13.6%
associate-/l*13.6%
rec-exp13.6%
rec-exp13.6%
tanh-def-a38.0%
Simplified97.9%
if 2.4e246 < y Initial program 72.5%
Taylor expanded in y around inf 95.2%
Final simplification97.7%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (tanh (/ t y_m))))
(if (<= y_m 9.8e-210)
x
(if (<= y_m 4e+116)
(+ x (* t_1 (* y_m z)))
(+ x (* z (- (* y_m t_1) x)))))))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 (y_m <= 9.8e-210) {
tmp = x;
} else if (y_m <= 4e+116) {
tmp = x + (t_1 * (y_m * z));
} else {
tmp = x + (z * ((y_m * 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 = tanh((t / y_m))
if (y_m <= 9.8d-210) then
tmp = x
else if (y_m <= 4d+116) then
tmp = x + (t_1 * (y_m * z))
else
tmp = x + (z * ((y_m * 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 = Math.tanh((t / y_m));
double tmp;
if (y_m <= 9.8e-210) {
tmp = x;
} else if (y_m <= 4e+116) {
tmp = x + (t_1 * (y_m * z));
} else {
tmp = x + (z * ((y_m * t_1) - x));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): t_1 = math.tanh((t / y_m)) tmp = 0 if y_m <= 9.8e-210: tmp = x elif y_m <= 4e+116: tmp = x + (t_1 * (y_m * z)) else: tmp = x + (z * ((y_m * t_1) - x)) return tmp
y_m = abs(y) function code(x, y_m, z, t) t_1 = tanh(Float64(t / y_m)) tmp = 0.0 if (y_m <= 9.8e-210) tmp = x; elseif (y_m <= 4e+116) tmp = Float64(x + Float64(t_1 * Float64(y_m * z))); else tmp = Float64(x + Float64(z * Float64(Float64(y_m * t_1) - x))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) t_1 = tanh((t / y_m)); tmp = 0.0; if (y_m <= 9.8e-210) tmp = x; elseif (y_m <= 4e+116) tmp = x + (t_1 * (y_m * z)); else tmp = x + (z * ((y_m * 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[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y$95$m, 9.8e-210], x, If[LessEqual[y$95$m, 4e+116], N[(x + N[(t$95$1 * N[(y$95$m * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y$95$m * t$95$1), $MachinePrecision] - x), $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}\;y\_m \leq 9.8 \cdot 10^{-210}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 4 \cdot 10^{+116}:\\
\;\;\;\;x + t\_1 \cdot \left(y\_m \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y\_m \cdot t\_1 - x\right)\\
\end{array}
\end{array}
if y < 9.7999999999999996e-210Initial program 97.1%
+-commutative97.1%
associate-*l*97.9%
fma-define97.9%
Simplified97.9%
Taylor expanded in y around 0 66.4%
if 9.7999999999999996e-210 < y < 4.00000000000000006e116Initial program 98.4%
Taylor expanded in x around 0 18.3%
associate-*r*18.3%
associate-/r*18.3%
div-sub18.3%
rec-exp18.3%
rec-exp18.3%
tanh-def-a84.0%
Simplified84.0%
if 4.00000000000000006e116 < y Initial program 78.4%
Taylor expanded in x around 0 56.4%
+-commutative56.4%
Simplified95.5%
Final simplification76.6%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 5.5e-209)
x
(if (<= y_m 1.52e+122)
(+ 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 <= 5.5e-209) {
tmp = x;
} else if (y_m <= 1.52e+122) {
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 <= 5.5d-209) then
tmp = x
else if (y_m <= 1.52d+122) 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 <= 5.5e-209) {
tmp = x;
} else if (y_m <= 1.52e+122) {
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 <= 5.5e-209: tmp = x elif y_m <= 1.52e+122: 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 <= 5.5e-209) tmp = x; elseif (y_m <= 1.52e+122) 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 <= 5.5e-209) tmp = x; elseif (y_m <= 1.52e+122) 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, 5.5e-209], x, If[LessEqual[y$95$m, 1.52e+122], 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 5.5 \cdot 10^{-209}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 1.52 \cdot 10^{+122}:\\
\;\;\;\;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 < 5.5000000000000001e-209Initial program 97.1%
+-commutative97.1%
associate-*l*97.9%
fma-define97.9%
Simplified97.9%
Taylor expanded in y around 0 66.4%
if 5.5000000000000001e-209 < y < 1.52e122Initial program 98.4%
Taylor expanded in x around 0 19.4%
associate-*r*19.4%
associate-/r*19.4%
div-sub19.4%
rec-exp19.4%
rec-exp19.4%
tanh-def-a84.2%
Simplified84.2%
if 1.52e122 < y Initial program 77.9%
Taylor expanded in y around inf 91.5%
Final simplification75.9%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 9000.0)
x
(if (or (<= y_m 3.2e+201) (not (<= y_m 4.7e+281)))
(+ x (* t z))
(- x (* z x)))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 9000.0) {
tmp = x;
} else if ((y_m <= 3.2e+201) || !(y_m <= 4.7e+281)) {
tmp = x + (t * z);
} else {
tmp = x - (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 (y_m <= 9000.0d0) then
tmp = x
else if ((y_m <= 3.2d+201) .or. (.not. (y_m <= 4.7d+281))) then
tmp = x + (t * z)
else
tmp = x - (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 (y_m <= 9000.0) {
tmp = x;
} else if ((y_m <= 3.2e+201) || !(y_m <= 4.7e+281)) {
tmp = x + (t * z);
} else {
tmp = x - (z * x);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 9000.0: tmp = x elif (y_m <= 3.2e+201) or not (y_m <= 4.7e+281): tmp = x + (t * z) else: tmp = x - (z * x) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 9000.0) tmp = x; elseif ((y_m <= 3.2e+201) || !(y_m <= 4.7e+281)) tmp = Float64(x + Float64(t * z)); else tmp = Float64(x - Float64(z * x)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 9000.0) tmp = x; elseif ((y_m <= 3.2e+201) || ~((y_m <= 4.7e+281))) tmp = x + (t * z); else tmp = x - (z * x); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 9000.0], x, If[Or[LessEqual[y$95$m, 3.2e+201], N[Not[LessEqual[y$95$m, 4.7e+281]], $MachinePrecision]], N[(x + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 9000:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 3.2 \cdot 10^{+201} \lor \neg \left(y\_m \leq 4.7 \cdot 10^{+281}\right):\\
\;\;\;\;x + t \cdot z\\
\mathbf{else}:\\
\;\;\;\;x - z \cdot x\\
\end{array}
\end{array}
if y < 9e3Initial program 97.9%
+-commutative97.9%
associate-*l*98.4%
fma-define98.4%
Simplified98.4%
Taylor expanded in y around 0 70.1%
if 9e3 < y < 3.1999999999999999e201 or 4.6999999999999998e281 < y Initial program 85.5%
Taylor expanded in y around inf 60.5%
Taylor expanded in t around inf 54.0%
if 3.1999999999999999e201 < y < 4.6999999999999998e281Initial program 79.3%
+-commutative79.3%
associate-*l*84.7%
fma-define84.7%
Simplified84.7%
sub-neg84.7%
distribute-rgt-in84.7%
Applied egg-rr84.7%
Taylor expanded in t around 0 38.7%
mul-1-neg38.7%
unsub-neg38.7%
associate-/l*38.7%
associate-/l*38.7%
rec-exp38.7%
rec-exp38.7%
tanh-def-a59.0%
Simplified59.0%
Taylor expanded in y around inf 68.5%
*-commutative68.5%
Simplified68.5%
Final simplification67.0%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 11500.0)
x
(if (or (<= y_m 2.45e+201) (not (<= y_m 4.8e+281)))
(+ x (* t z))
(* x (- 1.0 z)))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 11500.0) {
tmp = x;
} else if ((y_m <= 2.45e+201) || !(y_m <= 4.8e+281)) {
tmp = x + (t * z);
} 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 <= 11500.0d0) then
tmp = x
else if ((y_m <= 2.45d+201) .or. (.not. (y_m <= 4.8d+281))) then
tmp = x + (t * z)
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 <= 11500.0) {
tmp = x;
} else if ((y_m <= 2.45e+201) || !(y_m <= 4.8e+281)) {
tmp = x + (t * z);
} 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 <= 11500.0: tmp = x elif (y_m <= 2.45e+201) or not (y_m <= 4.8e+281): tmp = x + (t * z) 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 <= 11500.0) tmp = x; elseif ((y_m <= 2.45e+201) || !(y_m <= 4.8e+281)) tmp = Float64(x + Float64(t * z)); 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 <= 11500.0) tmp = x; elseif ((y_m <= 2.45e+201) || ~((y_m <= 4.8e+281))) tmp = x + (t * z); 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, 11500.0], x, If[Or[LessEqual[y$95$m, 2.45e+201], N[Not[LessEqual[y$95$m, 4.8e+281]], $MachinePrecision]], N[(x + N[(t * z), $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 11500:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 2.45 \cdot 10^{+201} \lor \neg \left(y\_m \leq 4.8 \cdot 10^{+281}\right):\\
\;\;\;\;x + t \cdot z\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 11500Initial program 97.9%
+-commutative97.9%
associate-*l*98.4%
fma-define98.4%
Simplified98.4%
Taylor expanded in y around 0 70.1%
if 11500 < y < 2.44999999999999998e201 or 4.8000000000000002e281 < y Initial program 85.5%
Taylor expanded in y around inf 60.5%
Taylor expanded in t around inf 54.0%
if 2.44999999999999998e201 < y < 4.8000000000000002e281Initial program 79.3%
+-commutative79.3%
associate-*l*84.7%
fma-define84.7%
Simplified84.7%
Taylor expanded in y around inf 75.2%
Taylor expanded in t around 0 68.5%
mul-1-neg68.5%
*-rgt-identity68.5%
distribute-rgt-neg-in68.5%
mul-1-neg68.5%
distribute-lft-in68.5%
mul-1-neg68.5%
unsub-neg68.5%
Simplified68.5%
Final simplification67.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 4300.0) 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 <= 4300.0) {
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 <= 4300.0d0) 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 <= 4300.0) {
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 <= 4300.0: 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 <= 4300.0) 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 <= 4300.0) 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, 4300.0], 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 4300:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 4300Initial program 97.9%
+-commutative97.9%
associate-*l*98.4%
fma-define98.4%
Simplified98.4%
Taylor expanded in y around 0 70.1%
if 4300 < y Initial program 83.8%
Taylor expanded in y around inf 77.7%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 5.3e+126) 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 <= 5.3e+126) {
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 <= 5.3d+126) 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 <= 5.3e+126) {
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 <= 5.3e+126: 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 <= 5.3e+126) 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 <= 5.3e+126) 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, 5.3e+126], 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 5.3 \cdot 10^{+126}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 5.30000000000000028e126Initial program 97.1%
+-commutative97.1%
associate-*l*98.1%
fma-define98.1%
Simplified98.1%
Taylor expanded in y around 0 66.7%
if 5.30000000000000028e126 < y Initial program 79.7%
+-commutative79.7%
associate-*l*88.7%
fma-define88.8%
Simplified88.8%
Taylor expanded in y around inf 82.4%
Taylor expanded in t around 0 57.1%
mul-1-neg57.1%
*-rgt-identity57.1%
distribute-rgt-neg-in57.1%
mul-1-neg57.1%
distribute-lft-in57.0%
mul-1-neg57.0%
unsub-neg57.0%
Simplified57.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 94.2%
+-commutative94.2%
associate-*l*96.5%
fma-define96.5%
Simplified96.5%
Taylor expanded in y around 0 60.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 2024100
(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))))))