
(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 7e+211) (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+211) {
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+211) 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+211], 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^{+211}:\\
\;\;\;\;\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.99999999999999993e211Initial program 93.4%
+-commutative93.4%
associate-*l*97.6%
fma-define97.6%
Simplified97.6%
if 6.99999999999999993e211 < y Initial program 74.0%
Taylor expanded in y around inf 100.0%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (tanh (/ t y_m))))
(if (<= y_m 2.15e+113)
(+ x (* (- t_1 (tanh (/ x y_m))) (* 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 <= 2.15e+113) {
tmp = x + ((t_1 - tanh((x / y_m))) * (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 <= 2.15d+113) then
tmp = x + ((t_1 - tanh((x / y_m))) * (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 <= 2.15e+113) {
tmp = x + ((t_1 - Math.tanh((x / y_m))) * (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 <= 2.15e+113: tmp = x + ((t_1 - math.tanh((x / y_m))) * (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 <= 2.15e+113) tmp = Float64(x + Float64(Float64(t_1 - tanh(Float64(x / y_m))) * 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 <= 2.15e+113) tmp = x + ((t_1 - tanh((x / y_m))) * (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, 2.15e+113], N[(x + N[(N[(t$95$1 - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 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 2.15 \cdot 10^{+113}:\\
\;\;\;\;x + \left(t\_1 - \tanh \left(\frac{x}{y\_m}\right)\right) \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 < 2.1500000000000002e113Initial program 94.4%
if 2.1500000000000002e113 < y Initial program 77.1%
Taylor expanded in x around 0 57.9%
+-commutative57.9%
Simplified93.0%
Taylor expanded in z around 0 57.9%
associate-/l*57.9%
rec-exp57.9%
rec-exp57.9%
tanh-def-a93.0%
Simplified93.0%
Final simplification94.2%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.65e-89) x (+ x (* z (- (* y_m (tanh (/ t y_m))) x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 1.65e-89) {
tmp = x;
} else {
tmp = x + (z * ((y_m * tanh((t / y_m))) - 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.65d-89) then
tmp = x
else
tmp = x + (z * ((y_m * tanh((t / y_m))) - 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.65e-89) {
tmp = x;
} else {
tmp = x + (z * ((y_m * Math.tanh((t / y_m))) - x));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 1.65e-89: tmp = x else: tmp = x + (z * ((y_m * math.tanh((t / y_m))) - x)) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 1.65e-89) tmp = x; else tmp = Float64(x + Float64(z * Float64(Float64(y_m * tanh(Float64(t / y_m))) - 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.65e-89) tmp = x; else tmp = x + (z * ((y_m * tanh((t / y_m))) - 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.65e-89], x, N[(x + N[(z * N[(N[(y$95$m * N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.65 \cdot 10^{-89}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y\_m \cdot \tanh \left(\frac{t}{y\_m}\right) - x\right)\\
\end{array}
\end{array}
if y < 1.6499999999999998e-89Initial program 93.6%
+-commutative93.6%
associate-*l*97.1%
fma-define97.1%
Simplified97.1%
Taylor expanded in y around 0 64.7%
if 1.6499999999999998e-89 < y Initial program 87.5%
Taylor expanded in x around 0 52.7%
+-commutative52.7%
Simplified90.4%
Taylor expanded in z around 0 52.7%
associate-/l*52.7%
rec-exp52.7%
rec-exp52.7%
tanh-def-a90.4%
Simplified90.4%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 38000.0) (+ 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 <= 38000.0) {
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 <= 38000.0d0) 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 <= 38000.0) {
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 <= 38000.0: 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 <= 38000.0) 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 <= 38000.0) 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, 38000.0], 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 38000:\\
\;\;\;\;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 < 38000Initial program 94.2%
Taylor expanded in x around 0 21.6%
associate-*r*21.4%
associate-/r*21.4%
div-sub21.4%
rec-exp21.4%
rec-exp21.4%
tanh-def-a75.8%
Simplified75.8%
if 38000 < y Initial program 84.4%
Taylor expanded in y around inf 82.2%
Final simplification77.5%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.2e-50) x (if (<= y_m 7e+79) (- x (* z x)) (+ x (* z t)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 1.2e-50) {
tmp = x;
} else if (y_m <= 7e+79) {
tmp = x - (z * x);
} else {
tmp = x + (z * t);
}
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.2d-50) then
tmp = x
else if (y_m <= 7d+79) then
tmp = x - (z * x)
else
tmp = x + (z * t)
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.2e-50) {
tmp = x;
} else if (y_m <= 7e+79) {
tmp = x - (z * x);
} else {
tmp = x + (z * t);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 1.2e-50: tmp = x elif y_m <= 7e+79: tmp = x - (z * x) else: tmp = x + (z * t) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 1.2e-50) tmp = x; elseif (y_m <= 7e+79) tmp = Float64(x - Float64(z * x)); else tmp = Float64(x + Float64(z * t)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 1.2e-50) tmp = x; elseif (y_m <= 7e+79) tmp = x - (z * x); else tmp = x + (z * t); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 1.2e-50], x, If[LessEqual[y$95$m, 7e+79], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.2 \cdot 10^{-50}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 7 \cdot 10^{+79}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.20000000000000001e-50Initial program 93.9%
+-commutative93.9%
associate-*l*97.2%
fma-define97.3%
Simplified97.3%
Taylor expanded in y around 0 64.8%
if 1.20000000000000001e-50 < y < 6.99999999999999961e79Initial program 96.3%
+-commutative96.3%
associate-*l*99.8%
fma-define99.8%
Simplified99.8%
Taylor expanded in y around inf 65.7%
Taylor expanded in t around 0 61.9%
neg-mul-161.9%
distribute-neg-frac61.9%
Simplified61.9%
Taylor expanded in y around 0 62.0%
metadata-eval62.0%
*-commutative62.0%
cancel-sign-sub-inv62.0%
*-lft-identity62.0%
Simplified62.0%
if 6.99999999999999961e79 < y Initial program 80.5%
Taylor expanded in y around inf 63.8%
Taylor expanded in t around inf 67.2%
Final simplification65.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.2e-50) x (if (<= y_m 1.35e+80) (* x (- 1.0 z)) (+ x (* z t)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 1.2e-50) {
tmp = x;
} else if (y_m <= 1.35e+80) {
tmp = x * (1.0 - z);
} else {
tmp = x + (z * t);
}
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.2d-50) then
tmp = x
else if (y_m <= 1.35d+80) then
tmp = x * (1.0d0 - z)
else
tmp = x + (z * t)
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.2e-50) {
tmp = x;
} else if (y_m <= 1.35e+80) {
tmp = x * (1.0 - z);
} else {
tmp = x + (z * t);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 1.2e-50: tmp = x elif y_m <= 1.35e+80: tmp = x * (1.0 - z) else: tmp = x + (z * t) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 1.2e-50) tmp = x; elseif (y_m <= 1.35e+80) tmp = Float64(x * Float64(1.0 - z)); else tmp = Float64(x + Float64(z * t)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 1.2e-50) tmp = x; elseif (y_m <= 1.35e+80) tmp = x * (1.0 - z); else tmp = x + (z * t); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 1.2e-50], x, If[LessEqual[y$95$m, 1.35e+80], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.2 \cdot 10^{-50}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 1.35 \cdot 10^{+80}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.20000000000000001e-50Initial program 93.9%
+-commutative93.9%
associate-*l*97.2%
fma-define97.3%
Simplified97.3%
Taylor expanded in y around 0 64.8%
if 1.20000000000000001e-50 < y < 1.34999999999999991e80Initial program 96.3%
+-commutative96.3%
associate-*l*99.8%
fma-define99.8%
Simplified99.8%
Taylor expanded in y around inf 65.7%
Taylor expanded in t around 0 62.0%
*-rgt-identity62.0%
mul-1-neg62.0%
distribute-rgt-neg-in62.0%
mul-1-neg62.0%
distribute-lft-in62.0%
mul-1-neg62.0%
unsub-neg62.0%
Simplified62.0%
if 1.34999999999999991e80 < y Initial program 80.5%
Taylor expanded in y around inf 63.8%
Taylor expanded in t around inf 67.2%
Final simplification65.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.15e-50) 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.15e-50) {
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.15d-50) 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.15e-50) {
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.15e-50: 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.15e-50) 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.15e-50) 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.15e-50], 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.15 \cdot 10^{-50}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.1500000000000001e-50Initial program 93.9%
+-commutative93.9%
associate-*l*97.2%
fma-define97.3%
Simplified97.3%
Taylor expanded in y around 0 64.8%
if 1.1500000000000001e-50 < y Initial program 86.1%
Taylor expanded in y around inf 75.7%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.2e-50) x (* x (- 1.0 z))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 1.2e-50) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: tmp
if (y_m <= 1.2d-50) then
tmp = x
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 1.2e-50) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 1.2e-50: tmp = x else: tmp = x * (1.0 - z) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 1.2e-50) tmp = x; else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 1.2e-50) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 1.2e-50], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.2 \cdot 10^{-50}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 1.20000000000000001e-50Initial program 93.9%
+-commutative93.9%
associate-*l*97.2%
fma-define97.3%
Simplified97.3%
Taylor expanded in y around 0 64.8%
if 1.20000000000000001e-50 < y Initial program 86.1%
+-commutative86.1%
associate-*l*95.4%
fma-define95.4%
Simplified95.4%
Taylor expanded in y around inf 71.1%
Taylor expanded in t around 0 58.7%
*-rgt-identity58.7%
mul-1-neg58.7%
distribute-rgt-neg-in58.7%
mul-1-neg58.7%
distribute-lft-in58.7%
mul-1-neg58.7%
unsub-neg58.7%
Simplified58.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 91.7%
+-commutative91.7%
associate-*l*96.7%
fma-define96.7%
Simplified96.7%
Taylor expanded in y around 0 59.9%
(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 2024086
(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))))))