
(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 13 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+216) (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+216) {
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+216) 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+216], 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^{+216}:\\
\;\;\;\;\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.9999999999999998e216Initial program 95.6%
+-commutative95.6%
associate-*l*98.0%
fma-define98.0%
Simplified98.0%
if 4.9999999999999998e216 < y Initial program 51.1%
Taylor expanded in y around inf 100.0%
Final simplification98.1%
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 2e+289) t_1 (* z (- t x)))))
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 <= 2e+289) {
tmp = t_1;
} else {
tmp = 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) :: t_1
real(8) :: tmp
t_1 = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (y_m * z))
if (t_1 <= 2d+289) then
tmp = t_1
else
tmp = 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 t_1 = x + ((Math.tanh((t / y_m)) - Math.tanh((x / y_m))) * (y_m * z));
double tmp;
if (t_1 <= 2e+289) {
tmp = t_1;
} else {
tmp = z * (t - x);
}
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 <= 2e+289: tmp = t_1 else: tmp = z * (t - x) 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 <= 2e+289) tmp = t_1; else tmp = Float64(z * Float64(t - x)); 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 <= 2e+289) tmp = t_1; else tmp = z * (t - x); 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, 2e+289], t$95$1, N[(z * N[(t - x), $MachinePrecision]), $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 2 \cdot 10^{+289}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 2.0000000000000001e289Initial program 97.9%
if 2.0000000000000001e289 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 36.7%
Taylor expanded in y around inf 95.0%
Taylor expanded in z around inf 95.0%
Final simplification97.7%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 6.2e-36)
x
(if (<= y_m 0.00125)
(* z (- (* y_m (tanh (/ t y_m))) x))
(if (<= y_m 1.15e+75) 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 <= 6.2e-36) {
tmp = x;
} else if (y_m <= 0.00125) {
tmp = z * ((y_m * tanh((t / y_m))) - x);
} else if (y_m <= 1.15e+75) {
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 <= 6.2e-36) tmp = x; elseif (y_m <= 0.00125) tmp = Float64(z * Float64(Float64(y_m * tanh(Float64(t / y_m))) - x)); elseif (y_m <= 1.15e+75) 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, 6.2e-36], x, If[LessEqual[y$95$m, 0.00125], N[(z * N[(N[(y$95$m * N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y$95$m, 1.15e+75], 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 6.2 \cdot 10^{-36}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 0.00125:\\
\;\;\;\;z \cdot \left(y\_m \cdot \tanh \left(\frac{t}{y\_m}\right) - x\right)\\
\mathbf{elif}\;y\_m \leq 1.15 \cdot 10^{+75}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 6.1999999999999997e-36 or 0.00125000000000000003 < y < 1.1499999999999999e75Initial program 96.1%
Taylor expanded in x around inf 66.0%
if 6.1999999999999997e-36 < y < 0.00125000000000000003Initial program 99.5%
Taylor expanded in x around 0 35.7%
+-commutative35.7%
Simplified69.0%
Taylor expanded in z around inf 25.0%
associate-/l*25.0%
rec-exp25.0%
rec-exp25.0%
tanh-def-a26.5%
Simplified26.5%
if 1.1499999999999999e75 < y Initial program 80.2%
Taylor expanded in y around inf 84.7%
+-commutative84.7%
fma-define84.8%
Simplified84.8%
Final simplification69.2%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (or (<= t -1.75e-90) (not (<= t 3.8e-34))) (+ x (* y_m (* z (tanh (/ t y_m))))) (+ x (* z (- t x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if ((t <= -1.75e-90) || !(t <= 3.8e-34)) {
tmp = x + (y_m * (z * tanh((t / 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 ((t <= (-1.75d-90)) .or. (.not. (t <= 3.8d-34))) then
tmp = x + (y_m * (z * tanh((t / 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 ((t <= -1.75e-90) || !(t <= 3.8e-34)) {
tmp = x + (y_m * (z * Math.tanh((t / 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 (t <= -1.75e-90) or not (t <= 3.8e-34): tmp = x + (y_m * (z * math.tanh((t / 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 ((t <= -1.75e-90) || !(t <= 3.8e-34)) tmp = Float64(x + Float64(y_m * Float64(z * tanh(Float64(t / 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 ((t <= -1.75e-90) || ~((t <= 3.8e-34))) tmp = x + (y_m * (z * tanh((t / 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[Or[LessEqual[t, -1.75e-90], N[Not[LessEqual[t, 3.8e-34]], $MachinePrecision]], N[(x + N[(y$95$m * N[(z * N[Tanh[N[(t / 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}\;t \leq -1.75 \cdot 10^{-90} \lor \neg \left(t \leq 3.8 \cdot 10^{-34}\right):\\
\;\;\;\;x + y\_m \cdot \left(z \cdot \tanh \left(\frac{t}{y\_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if t < -1.7499999999999999e-90 or 3.8000000000000001e-34 < t Initial program 98.1%
Taylor expanded in x around 0 7.5%
associate-/r*7.5%
div-sub7.5%
rec-exp7.5%
rec-exp7.5%
tanh-def-a90.3%
Simplified90.3%
if -1.7499999999999999e-90 < t < 3.8000000000000001e-34Initial program 85.6%
Taylor expanded in y around inf 81.8%
Final simplification86.9%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (tanh (/ t y_m))))
(if (<= y_m 1.75e-43)
(+ 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 <= 1.75e-43) {
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 <= 1.75d-43) 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 <= 1.75e-43) {
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 <= 1.75e-43: 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 <= 1.75e-43) 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 <= 1.75e-43) 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, 1.75e-43], 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 1.75 \cdot 10^{-43}:\\
\;\;\;\;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 < 1.74999999999999999e-43Initial program 95.8%
Taylor expanded in x around 0 17.1%
associate-/r*17.1%
div-sub17.1%
rec-exp17.1%
rec-exp17.1%
tanh-def-a80.7%
Simplified80.7%
if 1.74999999999999999e-43 < y Initial program 85.9%
Taylor expanded in x around 0 47.9%
+-commutative47.9%
Simplified84.9%
Final simplification81.8%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.2e+75) 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.2e+75) {
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.2e+75) 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.2e+75], 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.2 \cdot 10^{+75}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 1.2e75Initial program 96.2%
Taylor expanded in x around inf 65.6%
if 1.2e75 < y Initial program 80.2%
Taylor expanded in y around inf 84.7%
+-commutative84.7%
fma-define84.8%
Simplified84.8%
Final simplification69.3%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 2.2e+28)
x
(if (or (<= y_m 8.8e+219) (not (<= y_m 7.6e+236)))
(* x (- 1.0 z))
(* z t))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 2.2e+28) {
tmp = x;
} else if ((y_m <= 8.8e+219) || !(y_m <= 7.6e+236)) {
tmp = x * (1.0 - z);
} else {
tmp = 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 <= 2.2d+28) then
tmp = x
else if ((y_m <= 8.8d+219) .or. (.not. (y_m <= 7.6d+236))) then
tmp = x * (1.0d0 - z)
else
tmp = 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 <= 2.2e+28) {
tmp = x;
} else if ((y_m <= 8.8e+219) || !(y_m <= 7.6e+236)) {
tmp = x * (1.0 - z);
} else {
tmp = z * t;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 2.2e+28: tmp = x elif (y_m <= 8.8e+219) or not (y_m <= 7.6e+236): tmp = x * (1.0 - z) else: tmp = z * t return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 2.2e+28) tmp = x; elseif ((y_m <= 8.8e+219) || !(y_m <= 7.6e+236)) tmp = Float64(x * Float64(1.0 - z)); else tmp = 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 <= 2.2e+28) tmp = x; elseif ((y_m <= 8.8e+219) || ~((y_m <= 7.6e+236))) tmp = x * (1.0 - z); else tmp = 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, 2.2e+28], x, If[Or[LessEqual[y$95$m, 8.8e+219], N[Not[LessEqual[y$95$m, 7.6e+236]], $MachinePrecision]], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * t), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 2.2 \cdot 10^{+28}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 8.8 \cdot 10^{+219} \lor \neg \left(y\_m \leq 7.6 \cdot 10^{+236}\right):\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < 2.19999999999999986e28Initial program 96.0%
Taylor expanded in x around inf 67.1%
if 2.19999999999999986e28 < y < 8.8000000000000006e219 or 7.59999999999999973e236 < y Initial program 82.1%
Taylor expanded in x around 0 52.9%
+-commutative52.9%
Simplified85.9%
Taylor expanded in x around inf 59.1%
mul-1-neg59.1%
unsub-neg59.1%
Simplified59.1%
if 8.8000000000000006e219 < y < 7.59999999999999973e236Initial program 99.5%
Taylor expanded in y around inf 100.0%
Taylor expanded in x around 0 100.0%
Final simplification65.8%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 2.6e+28) x (if (<= y_m 1.85e+197) (* x (- 1.0 z)) (* z (- t x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 2.6e+28) {
tmp = x;
} else if (y_m <= 1.85e+197) {
tmp = x * (1.0 - z);
} else {
tmp = 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 <= 2.6d+28) then
tmp = x
else if (y_m <= 1.85d+197) then
tmp = x * (1.0d0 - z)
else
tmp = 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 <= 2.6e+28) {
tmp = x;
} else if (y_m <= 1.85e+197) {
tmp = x * (1.0 - z);
} else {
tmp = z * (t - x);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 2.6e+28: tmp = x elif y_m <= 1.85e+197: tmp = x * (1.0 - z) else: tmp = z * (t - x) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 2.6e+28) tmp = x; elseif (y_m <= 1.85e+197) tmp = Float64(x * Float64(1.0 - z)); else tmp = 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 <= 2.6e+28) tmp = x; elseif (y_m <= 1.85e+197) tmp = x * (1.0 - z); else tmp = 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, 2.6e+28], x, If[LessEqual[y$95$m, 1.85e+197], N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 2.6 \cdot 10^{+28}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 1.85 \cdot 10^{+197}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.6000000000000002e28Initial program 96.0%
Taylor expanded in x around inf 67.1%
if 2.6000000000000002e28 < y < 1.8500000000000002e197Initial program 95.2%
Taylor expanded in x around 0 47.0%
+-commutative47.0%
Simplified87.8%
Taylor expanded in x around inf 55.5%
mul-1-neg55.5%
unsub-neg55.5%
Simplified55.5%
if 1.8500000000000002e197 < y Initial program 56.6%
Taylor expanded in y around inf 95.1%
Taylor expanded in z around inf 73.6%
Final simplification65.8%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 4e+75) x (if (<= y_m 1.85e+198) (+ x (* z t)) (* z (- t x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 4e+75) {
tmp = x;
} else if (y_m <= 1.85e+198) {
tmp = x + (z * t);
} else {
tmp = 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+75) then
tmp = x
else if (y_m <= 1.85d+198) then
tmp = x + (z * t)
else
tmp = 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+75) {
tmp = x;
} else if (y_m <= 1.85e+198) {
tmp = x + (z * t);
} else {
tmp = z * (t - x);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 4e+75: tmp = x elif y_m <= 1.85e+198: tmp = x + (z * t) else: tmp = z * (t - x) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 4e+75) tmp = x; elseif (y_m <= 1.85e+198) tmp = Float64(x + Float64(z * t)); else tmp = 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+75) tmp = x; elseif (y_m <= 1.85e+198) tmp = x + (z * t); else tmp = 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+75], x, If[LessEqual[y$95$m, 1.85e+198], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 4 \cdot 10^{+75}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 1.85 \cdot 10^{+198}:\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.99999999999999971e75Initial program 96.2%
Taylor expanded in x around inf 65.6%
if 3.99999999999999971e75 < y < 1.8499999999999999e198Initial program 93.9%
Taylor expanded in x around 0 33.5%
associate-/r*33.5%
div-sub33.5%
rec-exp33.5%
rec-exp33.5%
tanh-def-a72.3%
Simplified72.3%
Taylor expanded in y around inf 60.0%
*-commutative60.0%
Simplified60.0%
if 1.8499999999999999e198 < y Initial program 56.6%
Taylor expanded in y around inf 95.1%
Taylor expanded in z around inf 73.6%
Final simplification65.5%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 5.2e+196) x (if (<= y_m 2.1e+241) (* z t) (- (* z x)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 5.2e+196) {
tmp = x;
} else if (y_m <= 2.1e+241) {
tmp = z * t;
} else {
tmp = -(z * 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 <= 5.2d+196) then
tmp = x
else if (y_m <= 2.1d+241) then
tmp = z * t
else
tmp = -(z * 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 <= 5.2e+196) {
tmp = x;
} else if (y_m <= 2.1e+241) {
tmp = z * t;
} else {
tmp = -(z * x);
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 5.2e+196: tmp = x elif y_m <= 2.1e+241: tmp = z * t else: tmp = -(z * x) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 5.2e+196) tmp = x; elseif (y_m <= 2.1e+241) tmp = Float64(z * t); else tmp = Float64(-Float64(z * x)); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 5.2e+196) tmp = x; elseif (y_m <= 2.1e+241) tmp = z * t; else tmp = -(z * x); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 5.2e+196], x, If[LessEqual[y$95$m, 2.1e+241], N[(z * t), $MachinePrecision], (-N[(z * x), $MachinePrecision])]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 5.2 \cdot 10^{+196}:\\
\;\;\;\;x\\
\mathbf{elif}\;y\_m \leq 2.1 \cdot 10^{+241}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;-z \cdot x\\
\end{array}
\end{array}
if y < 5.20000000000000024e196Initial program 95.9%
Taylor expanded in x around inf 62.3%
if 5.20000000000000024e196 < y < 2.1e241Initial program 87.8%
Taylor expanded in y around inf 88.9%
Taylor expanded in x around 0 52.4%
if 2.1e241 < y Initial program 31.7%
Taylor expanded in x around 0 71.5%
+-commutative71.5%
Simplified71.5%
Taylor expanded in z around inf 52.5%
associate-/l*52.5%
rec-exp52.5%
rec-exp52.5%
tanh-def-a52.5%
Simplified52.5%
Taylor expanded in y around 0 52.5%
mul-1-neg52.5%
distribute-lft-neg-out52.5%
*-commutative52.5%
Simplified52.5%
Final simplification61.6%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.2e+75) 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.2e+75) {
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.2d+75) 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.2e+75) {
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.2e+75: 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.2e+75) 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.2e+75) 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.2e+75], 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.2 \cdot 10^{+75}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.2e75Initial program 96.2%
Taylor expanded in x around inf 65.6%
if 1.2e75 < y Initial program 80.2%
Taylor expanded in y around inf 84.7%
Final simplification69.3%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 9.5e+198) x (* z t)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 9.5e+198) {
tmp = x;
} else {
tmp = 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 <= 9.5d+198) then
tmp = x
else
tmp = 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 <= 9.5e+198) {
tmp = x;
} else {
tmp = z * t;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 9.5e+198: tmp = x else: tmp = z * t return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 9.5e+198) tmp = x; else tmp = 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 <= 9.5e+198) tmp = x; else tmp = 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, 9.5e+198], x, N[(z * t), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 9.5 \cdot 10^{+198}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < 9.5e198Initial program 95.9%
Taylor expanded in x around inf 62.3%
if 9.5e198 < y Initial program 56.6%
Taylor expanded in y around inf 95.1%
Taylor expanded in x around 0 41.2%
Final simplification60.8%
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 93.1%
Taylor expanded in x around inf 59.7%
Final simplification59.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 2024040
(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))))))