
(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 11 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}
(FPCore (x y z t) :precision binary64 (let* ((t_1 (- (tanh (/ t y)) (tanh (/ x y))))) (if (<= (+ x (* (* y z) t_1)) 1e+306) (fma (* y t_1) z x) (* z (- t x)))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y)) - tanh((x / y));
double tmp;
if ((x + ((y * z) * t_1)) <= 1e+306) {
tmp = fma((y * t_1), z, x);
} else {
tmp = z * (t - x);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) tmp = 0.0 if (Float64(x + Float64(Float64(y * z) * t_1)) <= 1e+306) tmp = fma(Float64(y * t_1), z, x); else tmp = Float64(z * Float64(t - x)); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x + N[(N[(y * z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 1e+306], N[(N[(y * t$95$1), $MachinePrecision] * z + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\\
\mathbf{if}\;x + \left(y \cdot z\right) \cdot t\_1 \leq 10^{+306}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot t\_1, z, x\right)\\
\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))))) < 1.00000000000000002e306Initial program 97.8%
lift-*.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6499.4
Applied egg-rr99.4%
if 1.00000000000000002e306 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 22.4%
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%
Final simplification99.5%
(FPCore (x y z t) :precision binary64 (if (<= (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))) 1e+306) (fma z t x) (* z (- t x))))
double code(double x, double y, double z, double t) {
double tmp;
if ((x + ((y * z) * (tanh((t / y)) - tanh((x / y))))) <= 1e+306) {
tmp = fma(z, t, x);
} else {
tmp = z * (t - x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) <= 1e+306) tmp = fma(z, t, x); else tmp = Float64(z * Float64(t - x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[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], 1e+306], N[(z * t + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \leq 10^{+306}:\\
\;\;\;\;\mathsf{fma}\left(z, t, x\right)\\
\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))))) < 1.00000000000000002e306Initial program 97.8%
Taylor expanded in y around -inf
Simplified26.3%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6439.5
Simplified39.5%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6462.8
Simplified62.8%
if 1.00000000000000002e306 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 22.4%
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%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (* y (- (/ t y) (tanh (/ x y)))) z x)))
(if (<= x -3.8e+26)
t_1
(if (<= x 3.5e+21) (fma (* y (- (tanh (/ t y)) (/ x y))) z x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((y * ((t / y) - tanh((x / y)))), z, x);
double tmp;
if (x <= -3.8e+26) {
tmp = t_1;
} else if (x <= 3.5e+21) {
tmp = fma((y * (tanh((t / y)) - (x / y))), z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(y * Float64(Float64(t / y) - tanh(Float64(x / y)))), z, x) tmp = 0.0 if (x <= -3.8e+26) tmp = t_1; elseif (x <= 3.5e+21) tmp = fma(Float64(y * Float64(tanh(Float64(t / y)) - Float64(x / y))), z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[x, -3.8e+26], t$95$1, If[LessEqual[x, 3.5e+21], N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), z, x\right)\\
\mathbf{if}\;x \leq -3.8 \cdot 10^{+26}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 3.5 \cdot 10^{+21}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.8000000000000002e26 or 3.5e21 < x Initial program 96.7%
lift-*.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64100.0
Applied egg-rr100.0%
Taylor expanded in t around 0
lower-/.f6482.3
Simplified82.3%
if -3.8000000000000002e26 < x < 3.5e21Initial program 88.2%
lift-*.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6493.7
Applied egg-rr93.7%
Taylor expanded in x around 0
lower-/.f6485.1
Simplified85.1%
Final simplification83.9%
(FPCore (x y z t)
:precision binary64
(if (<= y 3.6e-97)
(fma z (/ 1.0 (/ (- -1.0 (/ (/ (* t t) x) x)) x)) x)
(if (<= y 4.05e+114)
(fma (* y (- (tanh (/ t y)) (/ x y))) z x)
(fma z (- t x) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.6e-97) {
tmp = fma(z, (1.0 / ((-1.0 - (((t * t) / x) / x)) / x)), x);
} else if (y <= 4.05e+114) {
tmp = fma((y * (tanh((t / y)) - (x / y))), z, x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 3.6e-97) tmp = fma(z, Float64(1.0 / Float64(Float64(-1.0 - Float64(Float64(Float64(t * t) / x) / x)) / x)), x); elseif (y <= 4.05e+114) tmp = fma(Float64(y * Float64(tanh(Float64(t / y)) - Float64(x / y))), z, x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.6e-97], N[(z * N[(1.0 / N[(N[(-1.0 - N[(N[(N[(t * t), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 4.05e+114], N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.6 \cdot 10^{-97}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{1}{\frac{-1 - \frac{\frac{t \cdot t}{x}}{x}}{x}}, x\right)\\
\mathbf{elif}\;y \leq 4.05 \cdot 10^{+114}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 3.59999999999999997e-97Initial program 92.6%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6460.8
Simplified60.8%
flip3--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
difference-cubesN/A
lift--.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6428.1
Applied egg-rr28.1%
Taylor expanded in x around -inf
mul-1-negN/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
Simplified62.6%
Taylor expanded in t around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6462.6
Simplified62.6%
if 3.59999999999999997e-97 < y < 4.0500000000000001e114Initial program 100.0%
lift-*.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64100.0
Applied egg-rr100.0%
Taylor expanded in x around 0
lower-/.f6483.8
Simplified83.8%
if 4.0500000000000001e114 < y Initial program 78.8%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6497.1
Simplified97.1%
Final simplification71.6%
(FPCore (x y z t) :precision binary64 (if (<= y 3.3e+22) (fma z (/ 1.0 (/ (- -1.0 (/ (/ (* t t) x) x)) x)) x) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.3e+22) {
tmp = fma(z, (1.0 / ((-1.0 - (((t * t) / x) / x)) / x)), x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 3.3e+22) tmp = fma(z, Float64(1.0 / Float64(Float64(-1.0 - Float64(Float64(Float64(t * t) / x) / x)) / x)), x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.3e+22], N[(z * N[(1.0 / N[(N[(-1.0 - N[(N[(N[(t * t), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.3 \cdot 10^{+22}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{1}{\frac{-1 - \frac{\frac{t \cdot t}{x}}{x}}{x}}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 3.2999999999999998e22Initial program 93.6%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6459.7
Simplified59.7%
flip3--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
difference-cubesN/A
lift--.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6428.1
Applied egg-rr28.1%
Taylor expanded in x around -inf
mul-1-negN/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
Simplified61.7%
Taylor expanded in t around inf
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
unpow2N/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6461.8
Simplified61.8%
if 3.2999999999999998e22 < y Initial program 86.3%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6482.2
Simplified82.2%
Final simplification66.5%
(FPCore (x y z t) :precision binary64 (if (<= y 1.35e-50) (fma (/ z (+ 1.0 (/ (fma t (/ t (- x)) (- t)) x))) (- x) x) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.35e-50) {
tmp = fma((z / (1.0 + (fma(t, (t / -x), -t) / x))), -x, x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.35e-50) tmp = fma(Float64(z / Float64(1.0 + Float64(fma(t, Float64(t / Float64(-x)), Float64(-t)) / x))), Float64(-x), x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.35e-50], N[(N[(z / N[(1.0 + N[(N[(t * N[(t / (-x)), $MachinePrecision] + (-t)), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * (-x) + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.35 \cdot 10^{-50}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{1 + \frac{\mathsf{fma}\left(t, \frac{t}{-x}, -t\right)}{x}}, -x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 1.35e-50Initial program 93.2%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6459.9
Simplified59.9%
flip3--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
difference-cubesN/A
lift--.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6428.1
Applied egg-rr28.1%
Taylor expanded in x around -inf
mul-1-negN/A
sub-negN/A
mul-1-negN/A
+-commutativeN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
Simplified62.5%
Applied egg-rr60.0%
if 1.35e-50 < y Initial program 88.5%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6478.3
Simplified78.3%
Final simplification65.0%
(FPCore (x y z t)
:precision binary64
(if (<= y 6.5e-188)
(fma z (/ 1.0 (/ (- -1.0 (/ t x)) x)) x)
(if (<= y 1.75e+61)
(fma z (/ 1.0 (/ (+ 1.0 (/ x t)) t)) x)
(fma z (- t x) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.5e-188) {
tmp = fma(z, (1.0 / ((-1.0 - (t / x)) / x)), x);
} else if (y <= 1.75e+61) {
tmp = fma(z, (1.0 / ((1.0 + (x / t)) / t)), x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 6.5e-188) tmp = fma(z, Float64(1.0 / Float64(Float64(-1.0 - Float64(t / x)) / x)), x); elseif (y <= 1.75e+61) tmp = fma(z, Float64(1.0 / Float64(Float64(1.0 + Float64(x / t)) / t)), x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.5e-188], N[(z * N[(1.0 / N[(N[(-1.0 - N[(t / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 1.75e+61], N[(z * N[(1.0 / N[(N[(1.0 + N[(x / t), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{-188}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{1}{\frac{-1 - \frac{t}{x}}{x}}, x\right)\\
\mathbf{elif}\;y \leq 1.75 \cdot 10^{+61}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{1}{\frac{1 + \frac{x}{t}}{t}}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 6.4999999999999998e-188Initial program 91.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6462.1
Simplified62.1%
flip3--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
difference-cubesN/A
lift--.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6430.1
Applied egg-rr30.1%
Taylor expanded in x around inf
sub-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
distribute-neg-fracN/A
lower-neg.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f6459.5
Simplified59.5%
if 6.4999999999999998e-188 < y < 1.75000000000000009e61Initial program 100.0%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6453.7
Simplified53.7%
flip3--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
difference-cubesN/A
lift--.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6421.9
Applied egg-rr21.9%
Taylor expanded in t around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f6466.0
Simplified66.0%
if 1.75000000000000009e61 < y Initial program 84.5%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6483.6
Simplified83.6%
Final simplification65.6%
(FPCore (x y z t) :precision binary64 (if (<= y 7.4e+63) (fma z (/ 1.0 (/ (+ 1.0 (/ x t)) t)) x) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7.4e+63) {
tmp = fma(z, (1.0 / ((1.0 + (x / t)) / t)), x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 7.4e+63) tmp = fma(z, Float64(1.0 / Float64(Float64(1.0 + Float64(x / t)) / t)), x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 7.4e+63], N[(z * N[(1.0 / N[(N[(1.0 + N[(x / t), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7.4 \cdot 10^{+63}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{1}{\frac{1 + \frac{x}{t}}{t}}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 7.39999999999999937e63Initial program 93.8%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6460.1
Simplified60.1%
flip3--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-fma.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
difference-cubesN/A
lift--.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
distribute-rgt-outN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f6428.2
Applied egg-rr28.2%
Taylor expanded in t around inf
lower-/.f64N/A
lower-+.f64N/A
lower-/.f6460.5
Simplified60.5%
if 7.39999999999999937e63 < y Initial program 84.5%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6483.6
Simplified83.6%
(FPCore (x y z t) :precision binary64 (if (<= y 6.8e-190) (fma z (- x) x) (if (<= y 5.5e-5) (fma z t x) (fma z (- t x) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.8e-190) {
tmp = fma(z, -x, x);
} else if (y <= 5.5e-5) {
tmp = fma(z, t, x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 6.8e-190) tmp = fma(z, Float64(-x), x); elseif (y <= 5.5e-5) tmp = fma(z, t, x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.8e-190], N[(z * (-x) + x), $MachinePrecision], If[LessEqual[y, 5.5e-5], N[(z * t + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.8 \cdot 10^{-190}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{fma}\left(z, t, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 6.79999999999999963e-190Initial program 91.8%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6462.2
Simplified62.2%
Taylor expanded in t around 0
mul-1-negN/A
lower-neg.f6455.3
Simplified55.3%
if 6.79999999999999963e-190 < y < 5.5000000000000002e-5Initial program 100.0%
Taylor expanded in y around -inf
Simplified21.3%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6439.8
Simplified39.8%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6455.5
Simplified55.5%
if 5.5000000000000002e-5 < y Initial program 87.2%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6483.4
Simplified83.4%
(FPCore (x y z t) :precision binary64 (fma z t x))
double code(double x, double y, double z, double t) {
return fma(z, t, x);
}
function code(x, y, z, t) return fma(z, t, x) end
code[x_, y_, z_, t_] := N[(z * t + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z, t, x\right)
\end{array}
Initial program 91.9%
Taylor expanded in y around -inf
Simplified24.4%
Taylor expanded in x around 0
mul-1-negN/A
lower-neg.f64N/A
lower-*.f64N/A
sub-negN/A
mul-1-negN/A
lower-fma.f64N/A
lower-/.f64N/A
cube-multN/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6440.1
Simplified40.1%
Taylor expanded in t around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f6462.2
Simplified62.2%
(FPCore (x y z t) :precision binary64 (* z t))
double code(double x, double y, double z, double t) {
return z * t;
}
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 = z * t
end function
public static double code(double x, double y, double z, double t) {
return z * t;
}
def code(x, y, z, t): return z * t
function code(x, y, z, t) return Float64(z * t) end
function tmp = code(x, y, z, t) tmp = z * t; end
code[x_, y_, z_, t_] := N[(z * t), $MachinePrecision]
\begin{array}{l}
\\
z \cdot t
\end{array}
Initial program 91.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6464.9
Simplified64.9%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6419.2
Simplified19.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 2024207
(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))))))