
(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 12 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 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))) (if (<= t_1 1e+294) t_1 (fma (- t x) z x))))
double code(double x, double y, double z, double t) {
double t_1 = x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
double tmp;
if (t_1 <= 1e+294) {
tmp = t_1;
} else {
tmp = fma((t - x), z, x);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) tmp = 0.0 if (t_1 <= 1e+294) tmp = t_1; else tmp = fma(Float64(t - x), z, x); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = 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]}, If[LessEqual[t$95$1, 1e+294], t$95$1, N[(N[(t - x), $MachinePrecision] * z + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\
\mathbf{if}\;t\_1 \leq 10^{+294}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, z, 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.00000000000000007e294Initial program 98.7%
if 1.00000000000000007e294 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 28.1%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64100.0
Applied rewrites100.0%
(FPCore (x y z t) :precision binary64 (if (<= y 1.45e+227) (fma (* (- (tanh (/ t y)) (tanh (/ x y))) z) y x) (fma (- t x) z x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.45e+227) {
tmp = fma(((tanh((t / y)) - tanh((x / y))) * z), y, x);
} else {
tmp = fma((t - x), z, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.45e+227) tmp = fma(Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * z), y, x); else tmp = fma(Float64(t - x), z, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.45e+227], N[(N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] * y + x), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.45 \cdot 10^{+227}:\\
\;\;\;\;\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\
\end{array}
\end{array}
if y < 1.4499999999999999e227Initial program 95.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6497.9
Applied rewrites97.9%
if 1.4499999999999999e227 < y Initial program 67.9%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6493.1
Applied rewrites93.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (- (/ t y) (tanh (/ x y))) (* z y) x)))
(if (<= x -2e+90)
t_1
(if (<= x -1.75e-56)
(+ x (* (/ (* (- z) (* x x)) (* (+ x t) (- x t))) (- x t)))
(if (<= x 3.4e+48) (fma (* (- (tanh (/ t y)) (/ x y)) z) y x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = fma(((t / y) - tanh((x / y))), (z * y), x);
double tmp;
if (x <= -2e+90) {
tmp = t_1;
} else if (x <= -1.75e-56) {
tmp = x + (((-z * (x * x)) / ((x + t) * (x - t))) * (x - t));
} else if (x <= 3.4e+48) {
tmp = fma(((tanh((t / y)) - (x / y)) * z), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(Float64(t / y) - tanh(Float64(x / y))), Float64(z * y), x) tmp = 0.0 if (x <= -2e+90) tmp = t_1; elseif (x <= -1.75e-56) tmp = Float64(x + Float64(Float64(Float64(Float64(-z) * Float64(x * x)) / Float64(Float64(x + t) * Float64(x - t))) * Float64(x - t))); elseif (x <= 3.4e+48) tmp = fma(Float64(Float64(tanh(Float64(t / y)) - Float64(x / y)) * z), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(z * y), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[x, -2e+90], t$95$1, If[LessEqual[x, -1.75e-56], N[(x + N[(N[(N[((-z) * N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] * N[(x - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.4e+48], N[(N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right), z \cdot y, x\right)\\
\mathbf{if}\;x \leq -2 \cdot 10^{+90}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.75 \cdot 10^{-56}:\\
\;\;\;\;x + \frac{\left(-z\right) \cdot \left(x \cdot x\right)}{\left(x + t\right) \cdot \left(x - t\right)} \cdot \left(x - t\right)\\
\mathbf{elif}\;x \leq 3.4 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.99999999999999993e90 or 3.4000000000000003e48 < x Initial program 99.0%
Taylor expanded in y around inf
lower-/.f6475.3
Applied rewrites75.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6475.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f6475.3
Applied rewrites75.3%
if -1.99999999999999993e90 < x < -1.7499999999999999e-56Initial program 86.2%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6465.1
Applied rewrites65.1%
Applied rewrites62.5%
Taylor expanded in x around inf
Applied rewrites76.9%
Applied rewrites79.2%
if -1.7499999999999999e-56 < x < 3.4000000000000003e48Initial program 91.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6493.0
Applied rewrites93.0%
Taylor expanded in x around 0
lower-/.f6486.1
Applied rewrites86.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (/ (* z t) x) x x)))
(if (<= x -3.5e+91)
t_1
(if (<= x -1.75e-56)
(+ x (* (/ (* (- z) (* x x)) (* (+ x t) (- x t))) (- x t)))
(if (<= x 5.6e+50) (fma (* (- (tanh (/ t y)) (/ x y)) z) y x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = fma(((z * t) / x), x, x);
double tmp;
if (x <= -3.5e+91) {
tmp = t_1;
} else if (x <= -1.75e-56) {
tmp = x + (((-z * (x * x)) / ((x + t) * (x - t))) * (x - t));
} else if (x <= 5.6e+50) {
tmp = fma(((tanh((t / y)) - (x / y)) * z), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(Float64(z * t) / x), x, x) tmp = 0.0 if (x <= -3.5e+91) tmp = t_1; elseif (x <= -1.75e-56) tmp = Float64(x + Float64(Float64(Float64(Float64(-z) * Float64(x * x)) / Float64(Float64(x + t) * Float64(x - t))) * Float64(x - t))); elseif (x <= 5.6e+50) tmp = fma(Float64(Float64(tanh(Float64(t / y)) - Float64(x / y)) * z), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(N[(z * t), $MachinePrecision] / x), $MachinePrecision] * x + x), $MachinePrecision]}, If[LessEqual[x, -3.5e+91], t$95$1, If[LessEqual[x, -1.75e-56], N[(x + N[(N[(N[((-z) * N[(x * x), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] * N[(x - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x - t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.6e+50], N[(N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{z \cdot t}{x}, x, x\right)\\
\mathbf{if}\;x \leq -3.5 \cdot 10^{+91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -1.75 \cdot 10^{-56}:\\
\;\;\;\;x + \frac{\left(-z\right) \cdot \left(x \cdot x\right)}{\left(x + t\right) \cdot \left(x - t\right)} \cdot \left(x - t\right)\\
\mathbf{elif}\;x \leq 5.6 \cdot 10^{+50}:\\
\;\;\;\;\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.50000000000000001e91 or 5.5999999999999996e50 < x Initial program 99.0%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6456.7
Applied rewrites56.7%
Taylor expanded in x around inf
Applied rewrites56.6%
Taylor expanded in x around 0
Applied rewrites70.6%
if -3.50000000000000001e91 < x < -1.7499999999999999e-56Initial program 86.2%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6465.1
Applied rewrites65.1%
Applied rewrites62.5%
Taylor expanded in x around inf
Applied rewrites76.9%
Applied rewrites79.2%
if -1.7499999999999999e-56 < x < 5.5999999999999996e50Initial program 91.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6493.0
Applied rewrites93.0%
Taylor expanded in x around 0
lower-/.f6486.1
Applied rewrites86.1%
(FPCore (x y z t) :precision binary64 (if (<= y 7e-59) (+ x (/ (* (* (- z) x) x) (+ x t))) (if (<= y 2.3e+84) (fma (* z y) (/ t y) x) (+ x (* (- t x) z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7e-59) {
tmp = x + (((-z * x) * x) / (x + t));
} else if (y <= 2.3e+84) {
tmp = fma((z * y), (t / y), x);
} else {
tmp = x + ((t - x) * z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 7e-59) tmp = Float64(x + Float64(Float64(Float64(Float64(-z) * x) * x) / Float64(x + t))); elseif (y <= 2.3e+84) tmp = fma(Float64(z * y), Float64(t / y), x); else tmp = Float64(x + Float64(Float64(t - x) * z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 7e-59], N[(x + N[(N[(N[((-z) * x), $MachinePrecision] * x), $MachinePrecision] / N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.3e+84], N[(N[(z * y), $MachinePrecision] * N[(t / y), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(N[(t - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{-59}:\\
\;\;\;\;x + \frac{\left(\left(-z\right) \cdot x\right) \cdot x}{x + t}\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+84}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot y, \frac{t}{y}, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(t - x\right) \cdot z\\
\end{array}
\end{array}
if y < 7.0000000000000002e-59Initial program 94.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6453.9
Applied rewrites53.9%
Applied rewrites40.3%
Taylor expanded in x around inf
Applied rewrites50.3%
Applied rewrites55.3%
if 7.0000000000000002e-59 < y < 2.2999999999999999e84Initial program 97.4%
Taylor expanded in y around inf
lower-/.f64N/A
lower--.f6452.0
Applied rewrites52.0%
Taylor expanded in x around 0
Applied rewrites65.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6465.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6465.6
Applied rewrites65.6%
if 2.2999999999999999e84 < y Initial program 79.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6488.7
Applied rewrites88.7%
Final simplification61.1%
(FPCore (x y z t) :precision binary64 (if (<= y 6.5e-59) (+ x (/ (* (* (- x) x) z) (+ x t))) (if (<= y 2.3e+84) (fma (* z y) (/ t y) x) (+ x (* (- t x) z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.5e-59) {
tmp = x + (((-x * x) * z) / (x + t));
} else if (y <= 2.3e+84) {
tmp = fma((z * y), (t / y), x);
} else {
tmp = x + ((t - x) * z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 6.5e-59) tmp = Float64(x + Float64(Float64(Float64(Float64(-x) * x) * z) / Float64(x + t))); elseif (y <= 2.3e+84) tmp = fma(Float64(z * y), Float64(t / y), x); else tmp = Float64(x + Float64(Float64(t - x) * z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.5e-59], N[(x + N[(N[(N[((-x) * x), $MachinePrecision] * z), $MachinePrecision] / N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.3e+84], N[(N[(z * y), $MachinePrecision] * N[(t / y), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(N[(t - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.5 \cdot 10^{-59}:\\
\;\;\;\;x + \frac{\left(\left(-x\right) \cdot x\right) \cdot z}{x + t}\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+84}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot y, \frac{t}{y}, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(t - x\right) \cdot z\\
\end{array}
\end{array}
if y < 6.50000000000000017e-59Initial program 94.8%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6453.9
Applied rewrites53.9%
Applied rewrites40.3%
Taylor expanded in x around inf
Applied rewrites50.3%
if 6.50000000000000017e-59 < y < 2.2999999999999999e84Initial program 97.4%
Taylor expanded in y around inf
lower-/.f64N/A
lower--.f6452.0
Applied rewrites52.0%
Taylor expanded in x around 0
Applied rewrites65.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6465.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6465.6
Applied rewrites65.6%
if 2.2999999999999999e84 < y Initial program 79.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6488.7
Applied rewrites88.7%
Final simplification57.4%
(FPCore (x y z t) :precision binary64 (if (<= y 7e-59) (fma (- x) z x) (if (<= y 2.3e+84) (fma (* z y) (/ t y) x) (+ x (* (- t x) z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7e-59) {
tmp = fma(-x, z, x);
} else if (y <= 2.3e+84) {
tmp = fma((z * y), (t / y), x);
} else {
tmp = x + ((t - x) * z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 7e-59) tmp = fma(Float64(-x), z, x); elseif (y <= 2.3e+84) tmp = fma(Float64(z * y), Float64(t / y), x); else tmp = Float64(x + Float64(Float64(t - x) * z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 7e-59], N[((-x) * z + x), $MachinePrecision], If[LessEqual[y, 2.3e+84], N[(N[(z * y), $MachinePrecision] * N[(t / y), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(N[(t - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{-59}:\\
\;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{+84}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot y, \frac{t}{y}, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(t - x\right) \cdot z\\
\end{array}
\end{array}
if y < 7.0000000000000002e-59Initial program 94.8%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6453.9
Applied rewrites53.9%
Taylor expanded in x around inf
Applied rewrites56.0%
if 7.0000000000000002e-59 < y < 2.2999999999999999e84Initial program 97.4%
Taylor expanded in y around inf
lower-/.f64N/A
lower--.f6452.0
Applied rewrites52.0%
Taylor expanded in x around 0
Applied rewrites65.6%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6465.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6465.6
Applied rewrites65.6%
if 2.2999999999999999e84 < y Initial program 79.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6488.7
Applied rewrites88.7%
(FPCore (x y z t) :precision binary64 (if (<= y 7e-59) (fma (- x) z x) (if (<= y 1.1e+84) (fma (/ (* z t) x) x x) (+ x (* (- t x) z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 7e-59) {
tmp = fma(-x, z, x);
} else if (y <= 1.1e+84) {
tmp = fma(((z * t) / x), x, x);
} else {
tmp = x + ((t - x) * z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 7e-59) tmp = fma(Float64(-x), z, x); elseif (y <= 1.1e+84) tmp = fma(Float64(Float64(z * t) / x), x, x); else tmp = Float64(x + Float64(Float64(t - x) * z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 7e-59], N[((-x) * z + x), $MachinePrecision], If[LessEqual[y, 1.1e+84], N[(N[(N[(z * t), $MachinePrecision] / x), $MachinePrecision] * x + x), $MachinePrecision], N[(x + N[(N[(t - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 7 \cdot 10^{-59}:\\
\;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+84}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z \cdot t}{x}, x, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(t - x\right) \cdot z\\
\end{array}
\end{array}
if y < 7.0000000000000002e-59Initial program 94.8%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6453.9
Applied rewrites53.9%
Taylor expanded in x around inf
Applied rewrites56.0%
if 7.0000000000000002e-59 < y < 1.0999999999999999e84Initial program 97.4%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6457.3
Applied rewrites57.3%
Taylor expanded in x around inf
Applied rewrites57.2%
Taylor expanded in x around 0
Applied rewrites68.3%
if 1.0999999999999999e84 < y Initial program 79.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6488.7
Applied rewrites88.7%
(FPCore (x y z t) :precision binary64 (if (<= y 1.8e-75) (fma (- x) z x) (+ x (* (- t x) z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.8e-75) {
tmp = fma(-x, z, x);
} else {
tmp = x + ((t - x) * z);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.8e-75) tmp = fma(Float64(-x), z, x); else tmp = Float64(x + Float64(Float64(t - x) * z)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.8e-75], N[((-x) * z + x), $MachinePrecision], N[(x + N[(N[(t - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{-75}:\\
\;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(t - x\right) \cdot z\\
\end{array}
\end{array}
if y < 1.8e-75Initial program 94.8%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6454.2
Applied rewrites54.2%
Taylor expanded in x around inf
Applied rewrites56.3%
if 1.8e-75 < y Initial program 89.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6471.3
Applied rewrites71.3%
(FPCore (x y z t) :precision binary64 (if (<= y 1.8e-75) (fma (- x) z x) (fma (- t x) z x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.8e-75) {
tmp = fma(-x, z, x);
} else {
tmp = fma((t - x), z, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.8e-75) tmp = fma(Float64(-x), z, x); else tmp = fma(Float64(t - x), z, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.8e-75], N[((-x) * z + x), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{-75}:\\
\;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\
\end{array}
\end{array}
if y < 1.8e-75Initial program 94.8%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6454.2
Applied rewrites54.2%
Taylor expanded in x around inf
Applied rewrites56.3%
if 1.8e-75 < y Initial program 89.0%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6471.3
Applied rewrites71.3%
(FPCore (x y z t) :precision binary64 (fma (- x) z x))
double code(double x, double y, double z, double t) {
return fma(-x, z, x);
}
function code(x, y, z, t) return fma(Float64(-x), z, x) end
code[x_, y_, z_, t_] := N[((-x) * z + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-x, z, x\right)
\end{array}
Initial program 93.2%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6458.9
Applied rewrites58.9%
Taylor expanded in x around inf
Applied rewrites54.4%
(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 93.2%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6458.9
Applied rewrites58.9%
Taylor expanded in x around 0
Applied rewrites16.1%
(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 2024307
(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))))))