
(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 9 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 5e+178) (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 <= 5e+178) {
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 <= 5e+178) 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, 5e+178], 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 5 \cdot 10^{+178}:\\
\;\;\;\;\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 < 4.9999999999999999e178Initial program 97.0%
+-commutative97.0%
associate-*l*99.1%
fma-define99.1%
Simplified99.1%
if 4.9999999999999999e178 < y Initial program 79.2%
Taylor expanded in y around inf 98.8%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 4e+197) (+ x (* (* y_m z) (- (tanh (/ t y_m)) (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 <= 4e+197) {
tmp = x + ((y_m * z) * (tanh((t / y_m)) - 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 <= 4d+197) then
tmp = x + ((y_m * z) * (tanh((t / y_m)) - 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 <= 4e+197) {
tmp = x + ((y_m * z) * (Math.tanh((t / y_m)) - 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 <= 4e+197: tmp = x + ((y_m * z) * (math.tanh((t / y_m)) - 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 <= 4e+197) tmp = Float64(x + Float64(Float64(y_m * z) * Float64(tanh(Float64(t / y_m)) - 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 <= 4e+197) tmp = x + ((y_m * z) * (tanh((t / y_m)) - 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, 4e+197], N[(x + N[(N[(y$95$m * z), $MachinePrecision] * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / 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 4 \cdot 10^{+197}:\\
\;\;\;\;x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.9999999999999998e197Initial program 97.1%
if 3.9999999999999998e197 < y Initial program 76.5%
Taylor expanded in y around inf 100.0%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 1.25e-49)
x
(if (<= y_m 4.2e+95)
(+ x (* (* y_m z) (- (tanh (/ t y_m)) (/ 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 <= 1.25e-49) {
tmp = x;
} else if (y_m <= 4.2e+95) {
tmp = x + ((y_m * z) * (tanh((t / y_m)) - (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 <= 1.25d-49) then
tmp = x
else if (y_m <= 4.2d+95) then
tmp = x + ((y_m * z) * (tanh((t / y_m)) - (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 <= 1.25e-49) {
tmp = x;
} else if (y_m <= 4.2e+95) {
tmp = x + ((y_m * z) * (Math.tanh((t / y_m)) - (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 <= 1.25e-49: tmp = x elif y_m <= 4.2e+95: tmp = x + ((y_m * z) * (math.tanh((t / y_m)) - (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 <= 1.25e-49) tmp = x; elseif (y_m <= 4.2e+95) tmp = Float64(x + Float64(Float64(y_m * z) * Float64(tanh(Float64(t / y_m)) - 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 <= 1.25e-49) tmp = x; elseif (y_m <= 4.2e+95) tmp = x + ((y_m * z) * (tanh((t / y_m)) - (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, 1.25e-49], x, If[LessEqual[y$95$m, 4.2e+95], N[(x + N[(N[(y$95$m * z), $MachinePrecision] * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[(x / y$95$m), $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.25 \cdot 10^{-49}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 4.2 \cdot 10^{+95}:\\
\;\;\;\;x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \frac{x}{y\_m}\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.25e-49Initial program 96.8%
+-commutative96.8%
associate-*l*98.8%
fma-define98.8%
Simplified98.8%
Taylor expanded in y around 0 69.4%
if 1.25e-49 < y < 4.2e95Initial program 99.8%
Taylor expanded in x around 0 71.8%
if 4.2e95 < y Initial program 84.8%
Taylor expanded in y around inf 93.1%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 1.35e-49)
x
(if (<= y_m 1.9e+178)
(- (+ x (* y_m (* z (tanh (/ t y_m))))) (* z 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-49) {
tmp = x;
} else if (y_m <= 1.9e+178) {
tmp = (x + (y_m * (z * tanh((t / y_m))))) - (z * 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-49) then
tmp = x
else if (y_m <= 1.9d+178) then
tmp = (x + (y_m * (z * tanh((t / y_m))))) - (z * 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-49) {
tmp = x;
} else if (y_m <= 1.9e+178) {
tmp = (x + (y_m * (z * Math.tanh((t / y_m))))) - (z * 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-49: tmp = x elif y_m <= 1.9e+178: tmp = (x + (y_m * (z * math.tanh((t / y_m))))) - (z * 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-49) tmp = x; elseif (y_m <= 1.9e+178) tmp = Float64(Float64(x + Float64(y_m * Float64(z * tanh(Float64(t / y_m))))) - Float64(z * 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-49) tmp = x; elseif (y_m <= 1.9e+178) tmp = (x + (y_m * (z * tanh((t / y_m))))) - (z * 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-49], x, If[LessEqual[y$95$m, 1.9e+178], N[(N[(x + N[(y$95$m * N[(z * N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z * x), $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.35 \cdot 10^{-49}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 1.9 \cdot 10^{+178}:\\
\;\;\;\;\left(x + y\_m \cdot \left(z \cdot \tanh \left(\frac{t}{y\_m}\right)\right)\right) - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.35e-49Initial program 96.8%
+-commutative96.8%
associate-*l*98.8%
fma-define98.8%
Simplified98.8%
Taylor expanded in y around 0 69.4%
if 1.35e-49 < y < 1.89999999999999999e178Initial program 97.9%
sub-neg97.9%
distribute-lft-in97.9%
Applied egg-rr97.9%
Taylor expanded in y around inf 78.3%
associate-+r+78.3%
mul-1-neg78.3%
unsub-neg78.3%
associate-*l*80.4%
*-commutative80.4%
Applied egg-rr80.4%
if 1.89999999999999999e178 < y Initial program 79.2%
Taylor expanded in y around inf 98.8%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= x -4.4e-173)
x
(if (<= x -2.5e-204)
(* t z)
(if (<= x -2.1e-244) x (if (<= x 2.1e-136) (* z (- t x)) x)))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (x <= -4.4e-173) {
tmp = x;
} else if (x <= -2.5e-204) {
tmp = t * z;
} else if (x <= -2.1e-244) {
tmp = x;
} else if (x <= 2.1e-136) {
tmp = z * (t - x);
} 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 <= (-4.4d-173)) then
tmp = x
else if (x <= (-2.5d-204)) then
tmp = t * z
else if (x <= (-2.1d-244)) then
tmp = x
else if (x <= 2.1d-136) then
tmp = z * (t - x)
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 <= -4.4e-173) {
tmp = x;
} else if (x <= -2.5e-204) {
tmp = t * z;
} else if (x <= -2.1e-244) {
tmp = x;
} else if (x <= 2.1e-136) {
tmp = z * (t - x);
} else {
tmp = x;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if x <= -4.4e-173: tmp = x elif x <= -2.5e-204: tmp = t * z elif x <= -2.1e-244: tmp = x elif x <= 2.1e-136: tmp = z * (t - x) else: tmp = x return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (x <= -4.4e-173) tmp = x; elseif (x <= -2.5e-204) tmp = Float64(t * z); elseif (x <= -2.1e-244) tmp = x; elseif (x <= 2.1e-136) tmp = Float64(z * Float64(t - x)); 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 <= -4.4e-173) tmp = x; elseif (x <= -2.5e-204) tmp = t * z; elseif (x <= -2.1e-244) tmp = x; elseif (x <= 2.1e-136) tmp = z * (t - x); else tmp = x; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[x, -4.4e-173], x, If[LessEqual[x, -2.5e-204], N[(t * z), $MachinePrecision], If[LessEqual[x, -2.1e-244], x, If[LessEqual[x, 2.1e-136], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], x]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.4 \cdot 10^{-173}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -2.5 \cdot 10^{-204}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;x \leq -2.1 \cdot 10^{-244}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-136}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -4.3999999999999999e-173 or -2.5000000000000001e-204 < x < -2.10000000000000002e-244 or 2.0999999999999999e-136 < x Initial program 96.5%
+-commutative96.5%
associate-*l*99.2%
fma-define99.2%
Simplified99.2%
Taylor expanded in y around 0 73.5%
if -4.3999999999999999e-173 < x < -2.5000000000000001e-204Initial program 99.4%
Taylor expanded in y around inf 64.4%
Taylor expanded in x around 0 65.9%
if -2.10000000000000002e-244 < x < 2.0999999999999999e-136Initial program 84.6%
Taylor expanded in y around inf 54.0%
Taylor expanded in z around inf 61.5%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= x -4e-177)
x
(if (<= x -1.9e-204)
(* t z)
(if (<= x -1.4e-244) x (if (<= x 3.2e-136) (* t z) x)))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (x <= -4e-177) {
tmp = x;
} else if (x <= -1.9e-204) {
tmp = t * z;
} else if (x <= -1.4e-244) {
tmp = x;
} else if (x <= 3.2e-136) {
tmp = t * z;
} 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 <= (-4d-177)) then
tmp = x
else if (x <= (-1.9d-204)) then
tmp = t * z
else if (x <= (-1.4d-244)) then
tmp = x
else if (x <= 3.2d-136) then
tmp = t * z
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 <= -4e-177) {
tmp = x;
} else if (x <= -1.9e-204) {
tmp = t * z;
} else if (x <= -1.4e-244) {
tmp = x;
} else if (x <= 3.2e-136) {
tmp = t * z;
} else {
tmp = x;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if x <= -4e-177: tmp = x elif x <= -1.9e-204: tmp = t * z elif x <= -1.4e-244: tmp = x elif x <= 3.2e-136: tmp = t * z else: tmp = x return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (x <= -4e-177) tmp = x; elseif (x <= -1.9e-204) tmp = Float64(t * z); elseif (x <= -1.4e-244) tmp = x; elseif (x <= 3.2e-136) tmp = Float64(t * z); 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 <= -4e-177) tmp = x; elseif (x <= -1.9e-204) tmp = t * z; elseif (x <= -1.4e-244) tmp = x; elseif (x <= 3.2e-136) tmp = t * z; else tmp = x; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[x, -4e-177], x, If[LessEqual[x, -1.9e-204], N[(t * z), $MachinePrecision], If[LessEqual[x, -1.4e-244], x, If[LessEqual[x, 3.2e-136], N[(t * z), $MachinePrecision], x]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-177}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -1.9 \cdot 10^{-204}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;x \leq -1.4 \cdot 10^{-244}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{-136}:\\
\;\;\;\;t \cdot z\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -3.99999999999999981e-177 or -1.89999999999999991e-204 < x < -1.40000000000000007e-244 or 3.19999999999999993e-136 < x Initial program 96.5%
+-commutative96.5%
associate-*l*99.2%
fma-define99.2%
Simplified99.2%
Taylor expanded in y around 0 73.5%
if -3.99999999999999981e-177 < x < -1.89999999999999991e-204 or -1.40000000000000007e-244 < x < 3.19999999999999993e-136Initial program 86.9%
Taylor expanded in y around inf 55.6%
Taylor expanded in x around 0 54.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 620000000000.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 <= 620000000000.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 <= 620000000000.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 <= 620000000000.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 <= 620000000000.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 <= 620000000000.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 <= 620000000000.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, 620000000000.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 620000000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 6.2e11Initial program 96.9%
+-commutative96.9%
associate-*l*98.9%
fma-define98.9%
Simplified98.9%
Taylor expanded in y around 0 67.9%
if 6.2e11 < y Initial program 88.4%
Taylor expanded in y around inf 87.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 155000000.0) x (+ x (* t z))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 155000000.0) {
tmp = x;
} else {
tmp = x + (t * 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 <= 155000000.0d0) then
tmp = x
else
tmp = x + (t * 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 <= 155000000.0) {
tmp = x;
} else {
tmp = x + (t * z);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 155000000.0: tmp = x else: tmp = x + (t * z) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 155000000.0) tmp = x; else tmp = Float64(x + Float64(t * z)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 155000000.0) tmp = x; else tmp = x + (t * z); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 155000000.0], x, N[(x + N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 155000000:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + t \cdot z\\
\end{array}
\end{array}
if y < 1.55e8Initial program 96.9%
+-commutative96.9%
associate-*l*98.9%
fma-define98.9%
Simplified98.9%
Taylor expanded in y around 0 67.7%
if 1.55e8 < y Initial program 88.5%
Taylor expanded in y around inf 74.3%
Taylor expanded in t around inf 78.3%
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.6%
+-commutative94.6%
associate-*l*97.1%
fma-define97.1%
Simplified97.1%
Taylor expanded in y around 0 63.1%
(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 2024076 -o generate:simplify
(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))))))