
(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 7e+230) (+ x (* (- (tanh (/ t y_m)) (tanh (/ x y_m))) (* z y_m))) (+ 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+230) {
tmp = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (z * 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 (y_m <= 7d+230) then
tmp = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (z * 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 (y_m <= 7e+230) {
tmp = x + ((Math.tanh((t / y_m)) - Math.tanh((x / y_m))) * (z * 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 y_m <= 7e+230: tmp = x + ((math.tanh((t / y_m)) - math.tanh((x / y_m))) * (z * 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 (y_m <= 7e+230) tmp = Float64(x + Float64(Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m))) * Float64(z * 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 (y_m <= 7e+230) tmp = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (z * 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[LessEqual[y$95$m, 7e+230], N[(x + N[(N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(z * y$95$m), $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 7 \cdot 10^{+230}:\\
\;\;\;\;x + \left(\tanh \left(\frac{t}{y_m}\right) - \tanh \left(\frac{x}{y_m}\right)\right) \cdot \left(z \cdot y_m\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 7.0000000000000001e230Initial program 97.5%
if 7.0000000000000001e230 < y Initial program 80.0%
Taylor expanded in y around inf 92.3%
Final simplification97.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (fma z (* y_m (- (tanh (/ t y_m)) (tanh (/ x y_m)))) x))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
return fma(z, (y_m * (tanh((t / y_m)) - tanh((x / y_m)))), x);
}
y_m = abs(y) function code(x, y_m, z, t) return fma(z, Float64(y_m * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))), x) end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := N[(z * N[(y$95$m * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
\mathsf{fma}\left(z, y_m \cdot \left(\tanh \left(\frac{t}{y_m}\right) - \tanh \left(\frac{x}{y_m}\right)\right), x\right)
\end{array}
Initial program 95.9%
+-commutative95.9%
*-commutative95.9%
associate-*l*97.8%
fma-def97.8%
Simplified97.8%
Final simplification97.8%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (or (<= t -1.45e-75) (not (<= t 1.15e+78))) (+ x (* y_m (* z (tanh (/ t y_m))))) (+ x (* z (- t (* y_m (tanh (/ x y_m))))))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if ((t <= -1.45e-75) || !(t <= 1.15e+78)) {
tmp = x + (y_m * (z * tanh((t / y_m))));
} else {
tmp = x + (z * (t - (y_m * tanh((x / y_m)))));
}
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.45d-75)) .or. (.not. (t <= 1.15d+78))) then
tmp = x + (y_m * (z * tanh((t / y_m))))
else
tmp = x + (z * (t - (y_m * tanh((x / y_m)))))
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.45e-75) || !(t <= 1.15e+78)) {
tmp = x + (y_m * (z * Math.tanh((t / y_m))));
} else {
tmp = x + (z * (t - (y_m * Math.tanh((x / y_m)))));
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if (t <= -1.45e-75) or not (t <= 1.15e+78): tmp = x + (y_m * (z * math.tanh((t / y_m)))) else: tmp = x + (z * (t - (y_m * math.tanh((x / y_m))))) return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if ((t <= -1.45e-75) || !(t <= 1.15e+78)) tmp = Float64(x + Float64(y_m * Float64(z * tanh(Float64(t / y_m))))); else tmp = Float64(x + Float64(z * Float64(t - Float64(y_m * tanh(Float64(x / y_m)))))); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if ((t <= -1.45e-75) || ~((t <= 1.15e+78))) tmp = x + (y_m * (z * tanh((t / y_m)))); else tmp = x + (z * (t - (y_m * tanh((x / y_m))))); end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[Or[LessEqual[t, -1.45e-75], N[Not[LessEqual[t, 1.15e+78]], $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 - N[(y$95$m * N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.45 \cdot 10^{-75} \lor \neg \left(t \leq 1.15 \cdot 10^{+78}\right):\\
\;\;\;\;x + y_m \cdot \left(z \cdot \tanh \left(\frac{t}{y_m}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - y_m \cdot \tanh \left(\frac{x}{y_m}\right)\right)\\
\end{array}
\end{array}
if t < -1.4500000000000001e-75 or 1.1500000000000001e78 < t Initial program 97.8%
Taylor expanded in x around 0 13.6%
associate-/r*13.6%
div-sub13.6%
rec-exp13.6%
rec-exp13.6%
tanh-def-a86.2%
Simplified86.2%
if -1.4500000000000001e-75 < t < 1.1500000000000001e78Initial program 93.9%
sub-neg93.9%
distribute-lft-in88.2%
Applied egg-rr88.2%
Taylor expanded in y around inf 88.2%
*-commutative88.2%
Simplified88.2%
Taylor expanded in z around 0 36.2%
mul-1-neg36.2%
unsub-neg36.2%
associate-/r*36.2%
Simplified92.2%
Final simplification89.1%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.15e+107) (+ 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 (y_m <= 1.15e+107) {
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 (y_m <= 1.15d+107) 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 (y_m <= 1.15e+107) {
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 y_m <= 1.15e+107: 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 (y_m <= 1.15e+107) 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 (y_m <= 1.15e+107) 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[LessEqual[y$95$m, 1.15e+107], 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}\;y_m \leq 1.15 \cdot 10^{+107}:\\
\;\;\;\;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 y < 1.15e107Initial program 98.5%
Taylor expanded in x around 0 30.7%
associate-/r*30.7%
div-sub30.7%
rec-exp30.7%
rec-exp30.7%
tanh-def-a82.0%
Simplified82.0%
if 1.15e107 < y Initial program 84.4%
Taylor expanded in y around inf 83.6%
Final simplification82.3%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.36e+107) x (if (<= y_m 1.76e+230) (* 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 <= 1.36e+107) {
tmp = x;
} else if (y_m <= 1.76e+230) {
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 <= 1.36d+107) then
tmp = x
else if (y_m <= 1.76d+230) 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 <= 1.36e+107) {
tmp = x;
} else if (y_m <= 1.76e+230) {
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 <= 1.36e+107: tmp = x elif y_m <= 1.76e+230: 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 <= 1.36e+107) tmp = x; elseif (y_m <= 1.76e+230) 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 <= 1.36e+107) tmp = x; elseif (y_m <= 1.76e+230) 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, 1.36e+107], x, If[LessEqual[y$95$m, 1.76e+230], 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 1.36 \cdot 10^{+107}:\\
\;\;\;\;x\\
\mathbf{elif}\;y_m \leq 1.76 \cdot 10^{+230}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.35999999999999998e107Initial program 98.1%
+-commutative98.1%
*-commutative98.1%
associate-*l*99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in z around 0 67.3%
if 1.35999999999999998e107 < y < 1.76000000000000003e230Initial program 92.6%
Taylor expanded in y around inf 78.1%
Taylor expanded in x around inf 73.8%
mul-1-neg73.8%
unsub-neg73.8%
Simplified73.8%
if 1.76000000000000003e230 < y Initial program 80.0%
Taylor expanded in y around inf 92.3%
Taylor expanded in z around inf 75.9%
Final simplification68.7%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.08e+108) x (if (<= y_m 2.05e+192) (* 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.08e+108) {
tmp = x;
} else if (y_m <= 2.05e+192) {
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.08d+108) then
tmp = x
else if (y_m <= 2.05d+192) 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.08e+108) {
tmp = x;
} else if (y_m <= 2.05e+192) {
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.08e+108: tmp = x elif y_m <= 2.05e+192: 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.08e+108) tmp = x; elseif (y_m <= 2.05e+192) 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.08e+108) tmp = x; elseif (y_m <= 2.05e+192) 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.08e+108], x, If[LessEqual[y$95$m, 2.05e+192], 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.08 \cdot 10^{+108}:\\
\;\;\;\;x\\
\mathbf{elif}\;y_m \leq 2.05 \cdot 10^{+192}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.0800000000000001e108Initial program 98.1%
+-commutative98.1%
*-commutative98.1%
associate-*l*99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in z around 0 67.3%
if 1.0800000000000001e108 < y < 2.05000000000000001e192Initial program 90.0%
Taylor expanded in y around inf 75.9%
Taylor expanded in x around inf 70.3%
mul-1-neg70.3%
unsub-neg70.3%
Simplified70.3%
if 2.05000000000000001e192 < y Initial program 84.0%
Taylor expanded in x around 0 34.3%
associate-/r*34.3%
div-sub34.3%
rec-exp34.3%
rec-exp34.3%
tanh-def-a73.6%
Simplified73.6%
Taylor expanded in y around inf 71.4%
+-commutative71.4%
*-commutative71.4%
Simplified71.4%
Final simplification68.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 2.3e+53) 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 <= 2.3e+53) {
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 <= 2.3d+53) 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 <= 2.3e+53) {
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 <= 2.3e+53: 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 <= 2.3e+53) 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 <= 2.3e+53) 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, 2.3e+53], 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 2.3 \cdot 10^{+53}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 2.3000000000000002e53Initial program 98.5%
+-commutative98.5%
*-commutative98.5%
associate-*l*99.4%
fma-def99.4%
Simplified99.4%
Taylor expanded in z around 0 68.6%
if 2.3000000000000002e53 < y Initial program 88.0%
Taylor expanded in y around inf 78.6%
Final simplification71.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 7.2e+107) 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 <= 7.2e+107) {
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 <= 7.2d+107) 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 <= 7.2e+107) {
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 <= 7.2e+107: 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 <= 7.2e+107) 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 <= 7.2e+107) 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, 7.2e+107], 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 7.2 \cdot 10^{+107}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 7.1999999999999995e107Initial program 98.1%
+-commutative98.1%
*-commutative98.1%
associate-*l*99.5%
fma-def99.5%
Simplified99.5%
Taylor expanded in z around 0 67.3%
if 7.1999999999999995e107 < y Initial program 86.2%
Taylor expanded in y around inf 85.4%
Taylor expanded in x around inf 63.0%
mul-1-neg63.0%
unsub-neg63.0%
Simplified63.0%
Final simplification66.5%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.5e+230) x (* z t)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 1.5e+230) {
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 <= 1.5d+230) 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 <= 1.5e+230) {
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 <= 1.5e+230: 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 <= 1.5e+230) 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 <= 1.5e+230) 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, 1.5e+230], x, N[(z * t), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y_m \leq 1.5 \cdot 10^{+230}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if y < 1.50000000000000004e230Initial program 97.5%
+-commutative97.5%
*-commutative97.5%
associate-*l*98.8%
fma-def98.8%
Simplified98.8%
Taylor expanded in z around 0 65.2%
if 1.50000000000000004e230 < y Initial program 80.0%
Taylor expanded in x around 0 22.1%
associate-/r*22.1%
div-sub22.1%
rec-exp22.1%
rec-exp22.1%
tanh-def-a67.0%
Simplified67.0%
Taylor expanded in y around inf 68.2%
+-commutative68.2%
*-commutative68.2%
Simplified68.2%
Taylor expanded in z around inf 52.2%
Final simplification64.0%
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 95.9%
+-commutative95.9%
*-commutative95.9%
associate-*l*97.8%
fma-def97.8%
Simplified97.8%
Taylor expanded in z around 0 60.8%
Final simplification60.8%
(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 2024019
(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))))))