
(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 10 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 3.6e+114) (+ x (* (* y_m z) (- (tanh (/ t y_m)) (tanh (/ x 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.6e+114) {
tmp = x + ((y_m * z) * (tanh((t / y_m)) - tanh((x / 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.6e+114) tmp = Float64(x + Float64(Float64(y_m * z) * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / 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.6e+114], 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[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 3.6 \cdot 10^{+114}:\\
\;\;\;\;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}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 3.6000000000000001e114Initial program 96.5%
if 3.6000000000000001e114 < y Initial program 80.0%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6497.0
Simplified97.0%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (tanh (/ x y_m)))
(t_2 (+ x (* (* y_m z) (- (tanh (/ t y_m)) t_1))))
(t_3 (+ x (* (* y_m z) (- (/ t y_m) t_1)))))
(if (<= t_2 (- INFINITY))
(* z (- t x))
(if (<= t_2 -5e-46)
t_3
(if (<= t_2 5e-129)
(fma z (- x) x)
(if (<= t_2 4e+270) t_3 (fma z (- t x) x)))))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double t_1 = tanh((x / y_m));
double t_2 = x + ((y_m * z) * (tanh((t / y_m)) - t_1));
double t_3 = x + ((y_m * z) * ((t / y_m) - t_1));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = z * (t - x);
} else if (t_2 <= -5e-46) {
tmp = t_3;
} else if (t_2 <= 5e-129) {
tmp = fma(z, -x, x);
} else if (t_2 <= 4e+270) {
tmp = t_3;
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) t_1 = tanh(Float64(x / y_m)) t_2 = Float64(x + Float64(Float64(y_m * z) * Float64(tanh(Float64(t / y_m)) - t_1))) t_3 = Float64(x + Float64(Float64(y_m * z) * Float64(Float64(t / y_m) - t_1))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(z * Float64(t - x)); elseif (t_2 <= -5e-46) tmp = t_3; elseif (t_2 <= 5e-129) tmp = fma(z, Float64(-x), x); elseif (t_2 <= 4e+270) tmp = t_3; 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_] := Block[{t$95$1 = N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y$95$m * z), $MachinePrecision] * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(x + N[(N[(y$95$m * z), $MachinePrecision] * N[(N[(t / y$95$m), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -5e-46], t$95$3, If[LessEqual[t$95$2, 5e-129], N[(z * (-x) + x), $MachinePrecision], If[LessEqual[t$95$2, 4e+270], t$95$3, N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]]]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{x}{y\_m}\right)\\
t_2 := x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - t\_1\right)\\
t_3 := x + \left(y\_m \cdot z\right) \cdot \left(\frac{t}{y\_m} - t\_1\right)\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{elif}\;t\_2 \leq -5 \cdot 10^{-46}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{-129}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+270}:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0Initial program 49.7%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f64100.0
Simplified100.0%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f64100.0
Simplified100.0%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -4.99999999999999992e-46 or 5.00000000000000027e-129 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.0000000000000002e270Initial program 99.9%
Taylor expanded in t around 0
lower-/.f6465.0
Simplified65.0%
if -4.99999999999999992e-46 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 5.00000000000000027e-129Initial program 98.5%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6454.3
Simplified54.3%
Taylor expanded in t around 0
mul-1-negN/A
lower-neg.f6474.5
Simplified74.5%
if 4.0000000000000002e270 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 66.5%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f64100.0
Simplified100.0%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (* z (- t x)))
(t_2 (+ x (* (* y_m z) (- (tanh (/ t y_m)) (tanh (/ x y_m)))))))
(if (<= t_2 -5e+302)
t_1
(if (<= t_2 -5e+142)
(fma t z x)
(if (<= t_2 2e-7)
(fma z (- x) x)
(if (<= t_2 5e+305) (fma t z 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 + ((y_m * z) * (tanh((t / y_m)) - tanh((x / y_m))));
double tmp;
if (t_2 <= -5e+302) {
tmp = t_1;
} else if (t_2 <= -5e+142) {
tmp = fma(t, z, x);
} else if (t_2 <= 2e-7) {
tmp = fma(z, -x, x);
} else if (t_2 <= 5e+305) {
tmp = fma(t, z, 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(y_m * z) * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m))))) tmp = 0.0 if (t_2 <= -5e+302) tmp = t_1; elseif (t_2 <= -5e+142) tmp = fma(t, z, x); elseif (t_2 <= 2e-7) tmp = fma(z, Float64(-x), x); elseif (t_2 <= 5e+305) tmp = fma(t, z, x); else tmp = t_1; end return 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[(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]}, If[LessEqual[t$95$2, -5e+302], t$95$1, If[LessEqual[t$95$2, -5e+142], N[(t * z + x), $MachinePrecision], If[LessEqual[t$95$2, 2e-7], N[(z * (-x) + x), $MachinePrecision], If[LessEqual[t$95$2, 5e+305], N[(t * z + x), $MachinePrecision], 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(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right)\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+302}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -5 \cdot 10^{+142}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x\right)\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x\right)\\
\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))))) < -5e302 or 5.00000000000000009e305 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 55.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6497.1
Simplified97.1%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6497.1
Simplified97.1%
if -5e302 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -5.0000000000000001e142 or 1.9999999999999999e-7 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 5.00000000000000009e305Initial program 99.9%
Taylor expanded in t around 0
lower-/.f6471.0
Simplified71.0%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6464.3
Simplified64.3%
if -5.0000000000000001e142 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 1.9999999999999999e-7Initial program 99.2%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6454.8
Simplified54.8%
Taylor expanded in t around 0
mul-1-negN/A
lower-neg.f6463.8
Simplified63.8%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (* z (- t x)))
(t_2 (+ x (* (* y_m z) (- (tanh (/ t y_m)) (tanh (/ x y_m)))))))
(if (<= t_2 -5e+302) t_1 (if (<= t_2 5e+305) (+ x (* z t)) 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 + ((y_m * z) * (tanh((t / y_m)) - tanh((x / y_m))));
double tmp;
if (t_2 <= -5e+302) {
tmp = t_1;
} else if (t_2 <= 5e+305) {
tmp = x + (z * t);
} else {
tmp = t_1;
}
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) :: t_2
real(8) :: tmp
t_1 = z * (t - x)
t_2 = x + ((y_m * z) * (tanh((t / y_m)) - tanh((x / y_m))))
if (t_2 <= (-5d+302)) then
tmp = t_1
else if (t_2 <= 5d+305) then
tmp = x + (z * t)
else
tmp = t_1
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 = z * (t - x);
double t_2 = x + ((y_m * z) * (Math.tanh((t / y_m)) - Math.tanh((x / y_m))));
double tmp;
if (t_2 <= -5e+302) {
tmp = t_1;
} else if (t_2 <= 5e+305) {
tmp = x + (z * t);
} 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 + ((y_m * z) * (math.tanh((t / y_m)) - math.tanh((x / y_m)))) tmp = 0 if t_2 <= -5e+302: tmp = t_1 elif t_2 <= 5e+305: tmp = x + (z * t) 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(y_m * z) * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m))))) tmp = 0.0 if (t_2 <= -5e+302) tmp = t_1; elseif (t_2 <= 5e+305) tmp = Float64(x + Float64(z * t)); 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 + ((y_m * z) * (tanh((t / y_m)) - tanh((x / y_m)))); tmp = 0.0; if (t_2 <= -5e+302) tmp = t_1; elseif (t_2 <= 5e+305) tmp = x + (z * t); 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[(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]}, If[LessEqual[t$95$2, -5e+302], t$95$1, If[LessEqual[t$95$2, 5e+305], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], 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(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right)\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+302}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;x + z \cdot t\\
\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))))) < -5e302 or 5.00000000000000009e305 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 55.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6497.1
Simplified97.1%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6497.1
Simplified97.1%
if -5e302 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 5.00000000000000009e305Initial program 99.5%
Taylor expanded in t around 0
lower-/.f6462.6
Simplified62.6%
Taylor expanded in y around 0
lower-*.f6455.4
Simplified55.4%
Final simplification60.2%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (* z (- t x)))
(t_2 (+ x (* (* y_m z) (- (tanh (/ t y_m)) (tanh (/ x y_m)))))))
(if (<= t_2 -5e+302) t_1 (if (<= t_2 5e+305) (fma t z 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 + ((y_m * z) * (tanh((t / y_m)) - tanh((x / y_m))));
double tmp;
if (t_2 <= -5e+302) {
tmp = t_1;
} else if (t_2 <= 5e+305) {
tmp = fma(t, z, 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(y_m * z) * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m))))) tmp = 0.0 if (t_2 <= -5e+302) tmp = t_1; elseif (t_2 <= 5e+305) tmp = fma(t, z, x); else tmp = t_1; end return 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[(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]}, If[LessEqual[t$95$2, -5e+302], t$95$1, If[LessEqual[t$95$2, 5e+305], N[(t * z + x), $MachinePrecision], 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(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right)\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+302}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x\right)\\
\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))))) < -5e302 or 5.00000000000000009e305 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 55.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6497.1
Simplified97.1%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6497.1
Simplified97.1%
if -5e302 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 5.00000000000000009e305Initial program 99.5%
Taylor expanded in t around 0
lower-/.f6462.6
Simplified62.6%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6455.4
Simplified55.4%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= (+ x (* (* y_m z) (- (tanh (/ t y_m)) (tanh (/ x y_m))))) 5e+305) (fma t z x) (* z (- x))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if ((x + ((y_m * z) * (tanh((t / y_m)) - tanh((x / y_m))))) <= 5e+305) {
tmp = fma(t, z, x);
} else {
tmp = z * -x;
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (Float64(x + Float64(Float64(y_m * z) * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m))))) <= 5e+305) tmp = fma(t, z, x); else tmp = Float64(z * Float64(-x)); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[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], 5e+305], N[(t * z + x), $MachinePrecision], N[(z * (-x)), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;x + \left(y\_m \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right) \leq 5 \cdot 10^{+305}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 5.00000000000000009e305Initial program 96.8%
Taylor expanded in t around 0
lower-/.f6462.1
Simplified62.1%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6455.1
Simplified55.1%
if 5.00000000000000009e305 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 58.1%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f64100.0
Simplified100.0%
Taylor expanded in t around 0
mul-1-negN/A
lower-neg.f6473.7
Simplified73.7%
Taylor expanded in z around inf
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6473.7
Simplified73.7%
Final simplification56.3%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 5e-27) (fma z (- x) 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-27) {
tmp = fma(z, -x, 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-27) tmp = fma(z, Float64(-x), 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-27], N[(z * (-x) + 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^{-27}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 5.0000000000000002e-27Initial program 96.0%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6448.5
Simplified48.5%
Taylor expanded in t around 0
mul-1-negN/A
lower-neg.f6450.8
Simplified50.8%
if 5.0000000000000002e-27 < y Initial program 88.9%
Taylor expanded in y around inf
lower-*.f64N/A
lower--.f6483.6
Simplified83.6%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 5e-27) (fma z (- x) 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 <= 5e-27) {
tmp = fma(z, -x, 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 <= 5e-27) tmp = fma(z, Float64(-x), 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, 5e-27], N[(z * (-x) + 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 \cdot 10^{-27}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 5.0000000000000002e-27Initial program 96.0%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6448.5
Simplified48.5%
Taylor expanded in t around 0
mul-1-negN/A
lower-neg.f6450.8
Simplified50.8%
if 5.0000000000000002e-27 < y Initial program 88.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6483.6
Simplified83.6%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (fma t z x))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
return fma(t, z, x);
}
y_m = abs(y) function code(x, y_m, z, t) return fma(t, z, x) end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := N[(t * z + x), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
\mathsf{fma}\left(t, z, x\right)
\end{array}
Initial program 94.4%
Taylor expanded in t around 0
lower-/.f6461.8
Simplified61.8%
Taylor expanded in y around 0
+-commutativeN/A
lower-fma.f6453.4
Simplified53.4%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (* z t))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
return z * t;
}
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 = z * t
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
return z * t;
}
y_m = math.fabs(y) def code(x, y_m, z, t): return z * t
y_m = abs(y) function code(x, y_m, z, t) return Float64(z * t) end
y_m = abs(y); function tmp = code(x, y_m, z, t) tmp = z * t; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := N[(z * t), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
z \cdot t
\end{array}
Initial program 94.4%
Taylor expanded in t around 0
lower-/.f6461.8
Simplified61.8%
Taylor expanded in x around 0
lower-*.f6414.2
Simplified14.2%
Final simplification14.2%
(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 2024215
(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))))))