
(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 2.6e+149) (fma z (* y_m (- (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 <= 2.6e+149) {
tmp = fma(z, (y_m * (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 <= 2.6e+149) tmp = fma(z, Float64(y_m * 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, 2.6e+149], N[(z * N[(y$95$m * 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 2.6 \cdot 10^{+149}:\\
\;\;\;\;\mathsf{fma}\left(z, y_m \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 < 2.59999999999999979e149Initial program 92.3%
+-commutative92.3%
*-commutative92.3%
associate-*l*97.7%
fma-def97.7%
Simplified97.7%
if 2.59999999999999979e149 < y Initial program 72.3%
+-commutative72.3%
*-commutative72.3%
associate-*l*87.8%
fma-def87.8%
Simplified87.8%
Taylor expanded in y around inf 93.8%
Final simplification97.2%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1e+113) (+ x (* (- (tanh (/ t y_m)) (tanh (/ x 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 <= 1e+113) {
tmp = x + ((tanh((t / y_m)) - tanh((x / 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 <= 1e+113) tmp = Float64(x + Float64(Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / 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, 1e+113], 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[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y_m \leq 10^{+113}:\\
\;\;\;\;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}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 1e113Initial program 92.6%
if 1e113 < y Initial program 72.2%
+-commutative72.2%
*-commutative72.2%
associate-*l*88.9%
fma-def88.9%
Simplified88.9%
Taylor expanded in y around inf 94.3%
Final simplification92.8%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (tanh (/ t y_m))))
(if (<= y_m 2.7e+53)
(+ x (* y_m (* z t_1)))
(+ 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 <= 2.7e+53) {
tmp = x + (y_m * (z * t_1));
} 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 <= 2.7d+53) then
tmp = x + (y_m * (z * t_1))
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 <= 2.7e+53) {
tmp = x + (y_m * (z * t_1));
} 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 <= 2.7e+53: tmp = x + (y_m * (z * t_1)) 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 <= 2.7e+53) tmp = Float64(x + Float64(y_m * Float64(z * t_1))); 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 <= 2.7e+53) tmp = x + (y_m * (z * t_1)); 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, 2.7e+53], N[(x + N[(y$95$m * N[(z * t$95$1), $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 2.7 \cdot 10^{+53}:\\
\;\;\;\;x + y_m \cdot \left(z \cdot t_1\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y_m \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < 2.70000000000000019e53Initial program 92.9%
Taylor expanded in x around 0 20.2%
associate-/r*20.2%
div-sub20.2%
rec-exp20.3%
rec-exp20.3%
tanh-def-a81.4%
Simplified81.4%
if 2.70000000000000019e53 < y Initial program 76.5%
Taylor expanded in x around 0 62.9%
+-commutative62.9%
Simplified95.4%
Final simplification84.1%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 3.4e+56) (+ 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 <= 3.4e+56) {
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 <= 3.4e+56) 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, 3.4e+56], 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 3.4 \cdot 10^{+56}:\\
\;\;\;\;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 < 3.40000000000000001e56Initial program 92.9%
Taylor expanded in x around 0 20.2%
associate-/r*20.2%
div-sub20.2%
rec-exp20.3%
rec-exp20.3%
tanh-def-a81.4%
Simplified81.4%
if 3.40000000000000001e56 < y Initial program 76.5%
+-commutative76.5%
*-commutative76.5%
associate-*l*92.1%
fma-def92.1%
Simplified92.1%
Taylor expanded in y around inf 93.5%
Final simplification83.7%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.15e+47) 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.15e+47) {
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.15e+47) 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.15e+47], 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.15 \cdot 10^{+47}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 1.1499999999999999e47Initial program 92.9%
+-commutative92.9%
*-commutative92.9%
associate-*l*97.5%
fma-def97.5%
Simplified97.5%
Taylor expanded in z around 0 63.2%
if 1.1499999999999999e47 < y Initial program 76.5%
+-commutative76.5%
*-commutative76.5%
associate-*l*92.1%
fma-def92.1%
Simplified92.1%
Taylor expanded in y around inf 93.5%
Final simplification68.9%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 9.8e+45)
x
(if (or (<= y_m 3.7e+198) (not (<= y_m 1.6e+235)))
(+ 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 <= 9.8e+45) {
tmp = x;
} else if ((y_m <= 3.7e+198) || !(y_m <= 1.6e+235)) {
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 <= 9.8d+45) then
tmp = x
else if ((y_m <= 3.7d+198) .or. (.not. (y_m <= 1.6d+235))) 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 <= 9.8e+45) {
tmp = x;
} else if ((y_m <= 3.7e+198) || !(y_m <= 1.6e+235)) {
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 <= 9.8e+45: tmp = x elif (y_m <= 3.7e+198) or not (y_m <= 1.6e+235): 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 <= 9.8e+45) tmp = x; elseif ((y_m <= 3.7e+198) || !(y_m <= 1.6e+235)) 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 <= 9.8e+45) tmp = x; elseif ((y_m <= 3.7e+198) || ~((y_m <= 1.6e+235))) 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, 9.8e+45], x, If[Or[LessEqual[y$95$m, 3.7e+198], N[Not[LessEqual[y$95$m, 1.6e+235]], $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 9.8 \cdot 10^{+45}:\\
\;\;\;\;x\\
\mathbf{elif}\;y_m \leq 3.7 \cdot 10^{+198} \lor \neg \left(y_m \leq 1.6 \cdot 10^{+235}\right):\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 9.8000000000000004e45Initial program 92.9%
+-commutative92.9%
*-commutative92.9%
associate-*l*97.5%
fma-def97.5%
Simplified97.5%
Taylor expanded in z around 0 63.2%
if 9.8000000000000004e45 < y < 3.6999999999999998e198 or 1.60000000000000003e235 < y Initial program 77.8%
Taylor expanded in x around 0 41.5%
associate-*r*40.6%
associate-/r*40.5%
div-sub40.6%
rec-exp40.6%
rec-exp40.6%
tanh-def-a68.9%
Simplified68.9%
Taylor expanded in y around inf 73.2%
*-commutative73.2%
Simplified73.2%
if 3.6999999999999998e198 < y < 1.60000000000000003e235Initial program 67.1%
Taylor expanded in y around inf 84.3%
Taylor expanded in x around inf 72.4%
mul-1-neg72.4%
unsub-neg72.4%
Simplified72.4%
Final simplification65.1%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.5e+47) 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+47) {
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.5d+47) 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.5e+47) {
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.5e+47: 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.5e+47) 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.5e+47) 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.5e+47], 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.5 \cdot 10^{+47}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.5000000000000001e47Initial program 92.9%
+-commutative92.9%
*-commutative92.9%
associate-*l*97.5%
fma-def97.5%
Simplified97.5%
Taylor expanded in z around 0 63.2%
if 1.5000000000000001e47 < y Initial program 76.5%
Taylor expanded in y around inf 93.5%
Final simplification68.9%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= x -5e-213) x (if (<= x 5.5e-128) (* z t) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (x <= -5e-213) {
tmp = x;
} else if (x <= 5.5e-128) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (x <= (-5d-213)) then
tmp = x
else if (x <= 5.5d-128) then
tmp = z * t
else
tmp = x
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if (x <= -5e-213) {
tmp = x;
} else if (x <= 5.5e-128) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if x <= -5e-213: tmp = x elif x <= 5.5e-128: tmp = z * t else: tmp = x return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (x <= -5e-213) tmp = x; elseif (x <= 5.5e-128) tmp = Float64(z * t); else tmp = x; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (x <= -5e-213) tmp = x; elseif (x <= 5.5e-128) tmp = z * t; else tmp = x; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[x, -5e-213], x, If[LessEqual[x, 5.5e-128], N[(z * t), $MachinePrecision], x]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{-213}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq 5.5 \cdot 10^{-128}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -4.99999999999999977e-213 or 5.5000000000000004e-128 < x Initial program 93.2%
+-commutative93.2%
*-commutative93.2%
associate-*l*98.5%
fma-def98.5%
Simplified98.5%
Taylor expanded in z around 0 71.8%
if -4.99999999999999977e-213 < x < 5.5000000000000004e-128Initial program 79.4%
+-commutative79.4%
*-commutative79.4%
associate-*l*90.3%
fma-def90.3%
Simplified90.3%
Taylor expanded in t around 0 61.4%
Taylor expanded in t around inf 55.0%
Final simplification67.7%
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 89.9%
+-commutative89.9%
*-commutative89.9%
associate-*l*96.5%
fma-def96.5%
Simplified96.5%
Taylor expanded in z around 0 58.7%
Final simplification58.7%
(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 2023337
(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))))))