
(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 8 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 5.2e+149) (fma (- (tanh (/ t y_m)) (tanh (/ x y_m))) (* y_m z) 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 <= 5.2e+149) {
tmp = fma((tanh((t / y_m)) - tanh((x / y_m))), (y_m * z), 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 <= 5.2e+149) tmp = fma(Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m))), Float64(y_m * z), 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, 5.2e+149], 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] + 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 5.2 \cdot 10^{+149}:\\
\;\;\;\;\mathsf{fma}\left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right), y\_m \cdot z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 5.19999999999999957e149Initial program 95.4%
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6495.4
Applied egg-rr95.4%
if 5.19999999999999957e149 < y Initial program 71.1%
Taylor expanded in y around inf
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6490.0
Simplified90.0%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (* z (- t x)))
(t_2 (+ x (* (- (tanh (/ t y_m)) (tanh (/ x y_m))) (* y_m z)))))
(if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 5e+297) x t_1))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double t_1 = z * (t - x);
double t_2 = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (y_m * z));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 5e+297) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double t_1 = z * (t - x);
double t_2 = x + ((Math.tanh((t / y_m)) - Math.tanh((x / y_m))) * (y_m * z));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 5e+297) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): t_1 = z * (t - x) t_2 = x + ((math.tanh((t / y_m)) - math.tanh((x / y_m))) * (y_m * z)) tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 5e+297: tmp = x else: tmp = t_1 return tmp
y_m = abs(y) function code(x, y_m, z, t) t_1 = Float64(z * Float64(t - x)) t_2 = Float64(x + Float64(Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m))) * Float64(y_m * z))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 5e+297) tmp = x; else tmp = t_1; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) t_1 = z * (t - x); t_2 = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (y_m * z)); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= 5e+297) tmp = x; else tmp = t_1; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 5e+297], x, t$95$1]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_1 := z \cdot \left(t - x\right)\\
t_2 := 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\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+297}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0 or 4.9999999999999998e297 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 58.9%
Taylor expanded in y around inf
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6497.5
Simplified97.5%
Taylor expanded in z around inf
*-lowering-*.f64N/A
--lowering--.f6497.5
Simplified97.5%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.9999999999999998e297Initial program 98.8%
Taylor expanded in x around inf
Simplified70.5%
Final simplification74.7%
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 (- INFINITY)) (* t z) (if (<= t_1 5e+297) x (* t z)))))
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 <= -((double) INFINITY)) {
tmp = t * z;
} else if (t_1 <= 5e+297) {
tmp = x;
} else {
tmp = t * z;
}
return tmp;
}
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 <= -Double.POSITIVE_INFINITY) {
tmp = t * z;
} else if (t_1 <= 5e+297) {
tmp = x;
} else {
tmp = t * z;
}
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 <= -math.inf: tmp = t * z elif t_1 <= 5e+297: tmp = x else: tmp = t * z 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 <= Float64(-Inf)) tmp = Float64(t * z); elseif (t_1 <= 5e+297) tmp = x; else tmp = Float64(t * z); 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 <= -Inf) tmp = t * z; elseif (t_1 <= 5e+297) tmp = x; else tmp = t * z; 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, (-Infinity)], N[(t * z), $MachinePrecision], If[LessEqual[t$95$1, 5e+297], x, N[(t * z), $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 -\infty:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+297}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0 or 4.9999999999999998e297 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 58.9%
Taylor expanded in y around inf
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6497.5
Simplified97.5%
Taylor expanded in t around inf
*-commutativeN/A
*-lowering-*.f6453.6
Simplified53.6%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.9999999999999998e297Initial program 98.8%
Taylor expanded in x around inf
Simplified70.5%
Final simplification68.0%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 7.2e-11)
x
(if (<= y_m 7.5e+148)
(fma (- (tanh (/ t y_m)) (/ x y_m)) (* y_m z) 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 <= 7.2e-11) {
tmp = x;
} else if (y_m <= 7.5e+148) {
tmp = fma((tanh((t / y_m)) - (x / y_m)), (y_m * z), 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 <= 7.2e-11) tmp = x; elseif (y_m <= 7.5e+148) tmp = fma(Float64(tanh(Float64(t / y_m)) - Float64(x / y_m)), Float64(y_m * z), 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, 7.2e-11], x, If[LessEqual[y$95$m, 7.5e+148], N[(N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[(x / y$95$m), $MachinePrecision]), $MachinePrecision] * N[(y$95$m * z), $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 7.2 \cdot 10^{-11}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 7.5 \cdot 10^{+148}:\\
\;\;\;\;\mathsf{fma}\left(\tanh \left(\frac{t}{y\_m}\right) - \frac{x}{y\_m}, y\_m \cdot z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 7.19999999999999969e-11Initial program 95.5%
Taylor expanded in x around inf
Simplified65.5%
if 7.19999999999999969e-11 < y < 7.50000000000000008e148Initial program 94.8%
Taylor expanded in x around 0
/-lowering-/.f6472.2
Simplified72.2%
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f6472.2
Applied egg-rr72.2%
if 7.50000000000000008e148 < y Initial program 71.1%
Taylor expanded in y around inf
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6490.0
Simplified90.0%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 7.8e-115)
x
(if (<= y_m 1.3e+147)
(fma z (- x) (fma (* y_m z) (tanh (/ t 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 <= 7.8e-115) {
tmp = x;
} else if (y_m <= 1.3e+147) {
tmp = fma(z, -x, fma((y_m * z), tanh((t / 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 <= 7.8e-115) tmp = x; elseif (y_m <= 1.3e+147) tmp = fma(z, Float64(-x), fma(Float64(y_m * z), tanh(Float64(t / 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, 7.8e-115], x, If[LessEqual[y$95$m, 1.3e+147], N[(z * (-x) + N[(N[(y$95$m * z), $MachinePrecision] * N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] + x), $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 7.8 \cdot 10^{-115}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 1.3 \cdot 10^{+147}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, \mathsf{fma}\left(y\_m \cdot z, \tanh \left(\frac{t}{y\_m}\right), x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 7.7999999999999997e-115Initial program 94.5%
Taylor expanded in x around inf
Simplified64.4%
if 7.7999999999999997e-115 < y < 1.2999999999999999e147Initial program 97.2%
Taylor expanded in x around 0
/-lowering-/.f6474.1
Simplified74.1%
sub-negN/A
+-commutativeN/A
div-invN/A
distribute-lft-neg-inN/A
accelerator-lowering-fma.f64N/A
neg-lowering-neg.f64N/A
/-lowering-/.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6474.1
Applied egg-rr74.1%
+-commutativeN/A
distribute-lft-inN/A
associate-+l+N/A
un-div-invN/A
associate-*r/N/A
*-commutativeN/A
associate-*r*N/A
associate-*l/N/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
div-invN/A
associate-*l*N/A
inv-powN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
accelerator-lowering-fma.f64N/A
Applied egg-rr75.5%
if 1.2999999999999999e147 < y Initial program 71.1%
Taylor expanded in y around inf
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6490.0
Simplified90.0%
Final simplification70.3%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.1e+39) 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.1e+39) {
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.1e+39) 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.1e+39], 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.1 \cdot 10^{+39}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 1.1000000000000001e39Initial program 95.8%
Taylor expanded in x around inf
Simplified64.8%
if 1.1000000000000001e39 < y Initial program 80.6%
Taylor expanded in y around inf
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6477.5
Simplified77.5%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 6.2e+38) x (fma z t x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 6.2e+38) {
tmp = x;
} else {
tmp = fma(z, t, x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 6.2e+38) tmp = x; else tmp = fma(z, t, x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 6.2e+38], x, N[(z * t + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 6.2 \cdot 10^{+38}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t, x\right)\\
\end{array}
\end{array}
if y < 6.20000000000000035e38Initial program 95.8%
Taylor expanded in x around inf
Simplified64.8%
if 6.20000000000000035e38 < y Initial program 80.6%
Taylor expanded in y around inf
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6477.5
Simplified77.5%
Taylor expanded in t around inf
Simplified69.9%
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 92.7%
Taylor expanded in x around inf
Simplified60.6%
(FPCore (x y z t) :precision binary64 (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
end function
public static double code(double x, double y, double z, double t) {
return x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)
\end{array}
herbie shell --seed 2024204
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(! :herbie-platform default (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))