
(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 (fma (* y (- (tanh (/ t y)) (tanh (/ x y)))) z x))
double code(double x, double y, double z, double t) {
return fma((y * (tanh((t / y)) - tanh((x / y)))), z, x);
}
function code(x, y, z, t) return fma(Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), z, x) end
code[x_, y_, z_, t_] := N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), z, x\right)
\end{array}
Initial program 94.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-*.f6497.7
Applied rewrites97.7%
Final simplification97.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (* y (- (/ t y) (tanh (/ x y)))) z x)))
(if (<= x -7.4e-9)
t_1
(if (<= x 1.3e+25)
(fma (* y (fma (- x) (/ 1.0 y) (tanh (/ t 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 <= -7.4e-9) {
tmp = t_1;
} else if (x <= 1.3e+25) {
tmp = fma((y * fma(-x, (1.0 / y), tanh((t / 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 <= -7.4e-9) tmp = t_1; elseif (x <= 1.3e+25) tmp = fma(Float64(y * fma(Float64(-x), Float64(1.0 / y), tanh(Float64(t / 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, -7.4e-9], t$95$1, If[LessEqual[x, 1.3e+25], N[(N[(y * N[((-x) * N[(1.0 / y), $MachinePrecision] + N[Tanh[N[(t / y), $MachinePrecision]], $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 -7.4 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+25}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \mathsf{fma}\left(-x, \frac{1}{y}, \tanh \left(\frac{t}{y}\right)\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -7.4e-9 or 1.2999999999999999e25 < x Initial program 97.1%
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 rewrites100.0%
Taylor expanded in t around 0
lower-/.f6478.6
Applied rewrites78.6%
if -7.4e-9 < x < 1.2999999999999999e25Initial program 91.2%
Taylor expanded in x around 0
lower-/.f6475.5
Applied rewrites75.5%
lift-*.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift-/.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-*.f6479.6
Applied rewrites79.6%
lift-/.f64N/A
lift-tanh.f64N/A
lift-/.f64N/A
sub-negN/A
+-commutativeN/A
lift-/.f64N/A
div-invN/A
lift-/.f64N/A
distribute-lft-neg-inN/A
lower-fma.f64N/A
lower-neg.f6479.7
Applied rewrites79.7%
Final simplification79.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (* y (- (/ t y) (tanh (/ x y)))) z x)))
(if (<= x -7.4e-9)
t_1
(if (<= x 1.3e+25) (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 <= -7.4e-9) {
tmp = t_1;
} else if (x <= 1.3e+25) {
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 <= -7.4e-9) tmp = t_1; elseif (x <= 1.3e+25) 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, -7.4e-9], t$95$1, If[LessEqual[x, 1.3e+25], 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 -7.4 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.3 \cdot 10^{+25}:\\
\;\;\;\;\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 < -7.4e-9 or 1.2999999999999999e25 < x Initial program 97.1%
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 rewrites100.0%
Taylor expanded in t around 0
lower-/.f6478.6
Applied rewrites78.6%
if -7.4e-9 < x < 1.2999999999999999e25Initial program 91.2%
Taylor expanded in x around 0
lower-/.f6475.5
Applied rewrites75.5%
lift-*.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift-/.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-*.f6479.6
Applied rewrites79.6%
Final simplification79.1%
(FPCore (x y z t)
:precision binary64
(if (<= y 8.2e-218)
(fma (/ (* t y) y) z x)
(if (<= y 4.8e+172)
(fma (* z (- (tanh (/ t y)) (/ x y))) y x)
(fma z (- t x) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.2e-218) {
tmp = fma(((t * y) / y), z, x);
} else if (y <= 4.8e+172) {
tmp = fma((z * (tanh((t / y)) - (x / y))), y, x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 8.2e-218) tmp = fma(Float64(Float64(t * y) / y), z, x); elseif (y <= 4.8e+172) tmp = fma(Float64(z * Float64(tanh(Float64(t / y)) - Float64(x / y))), y, x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 8.2e-218], N[(N[(N[(t * y), $MachinePrecision] / y), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[y, 4.8e+172], N[(N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.2 \cdot 10^{-218}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t \cdot y}{y}, z, x\right)\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+172}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), y, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 8.1999999999999995e-218Initial program 94.5%
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-*.f6497.6
Applied rewrites97.6%
Taylor expanded in y around inf
remove-double-negN/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
remove-double-negN/A
lower--.f6451.6
Applied rewrites51.6%
lift--.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6449.3
Applied rewrites49.3%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6461.1
Applied rewrites61.1%
if 8.1999999999999995e-218 < y < 4.8000000000000001e172Initial program 98.6%
Taylor expanded in x around 0
lower-/.f6466.5
Applied rewrites66.5%
lift-*.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift-/.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6466.6
Applied rewrites66.6%
if 4.8000000000000001e172 < y Initial program 71.2%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Final simplification65.3%
(FPCore (x y z t) :precision binary64 (if (<= y 8.2e-218) (fma (/ (* t y) y) z x) (fma (* y (- (tanh (/ t y)) (/ x y))) z x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8.2e-218) {
tmp = fma(((t * y) / y), z, x);
} else {
tmp = fma((y * (tanh((t / y)) - (x / y))), z, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 8.2e-218) tmp = fma(Float64(Float64(t * y) / y), z, x); else tmp = fma(Float64(y * Float64(tanh(Float64(t / y)) - Float64(x / y))), z, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 8.2e-218], N[(N[(N[(t * y), $MachinePrecision] / y), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8.2 \cdot 10^{-218}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t \cdot y}{y}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), z, x\right)\\
\end{array}
\end{array}
if y < 8.1999999999999995e-218Initial program 94.5%
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-*.f6497.6
Applied rewrites97.6%
Taylor expanded in y around inf
remove-double-negN/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
remove-double-negN/A
lower--.f6451.6
Applied rewrites51.6%
lift--.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6449.3
Applied rewrites49.3%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6461.1
Applied rewrites61.1%
if 8.1999999999999995e-218 < y Initial program 93.7%
Taylor expanded in x around 0
lower-/.f6467.4
Applied rewrites67.4%
lift-*.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift-/.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-*.f6470.7
Applied rewrites70.7%
Final simplification64.6%
(FPCore (x y z t) :precision binary64 (if (<= y 2.15e+15) (fma (- (/ (* y x) y)) z x) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.15e+15) {
tmp = fma(-((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 <= 2.15e+15) tmp = fma(Float64(-Float64(Float64(y * x) / y)), z, x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.15e+15], N[((-N[(N[(y * x), $MachinePrecision] / y), $MachinePrecision]) * z + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.15 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(-\frac{y \cdot x}{y}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 2.15e15Initial program 95.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-*.f6498.1
Applied rewrites98.1%
Taylor expanded in y around inf
remove-double-negN/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
remove-double-negN/A
lower--.f6448.5
Applied rewrites48.5%
lift--.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6448.5
Applied rewrites48.5%
Taylor expanded in t around 0
mul-1-negN/A
lower-neg.f6447.7
Applied rewrites47.7%
if 2.15e15 < y Initial program 87.1%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6479.6
Applied rewrites79.6%
Final simplification53.4%
(FPCore (x y z t) :precision binary64 (if (<= y 8e-218) (fma (/ (* t y) y) z x) (if (<= y 2.15e+15) (fma z (- x) x) (fma z (- t x) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 8e-218) {
tmp = fma(((t * y) / y), z, x);
} else if (y <= 2.15e+15) {
tmp = fma(z, -x, x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 8e-218) tmp = fma(Float64(Float64(t * y) / y), z, x); elseif (y <= 2.15e+15) tmp = fma(z, Float64(-x), x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 8e-218], N[(N[(N[(t * y), $MachinePrecision] / y), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[y, 2.15e+15], N[(z * (-x) + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 8 \cdot 10^{-218}:\\
\;\;\;\;\mathsf{fma}\left(\frac{t \cdot y}{y}, z, x\right)\\
\mathbf{elif}\;y \leq 2.15 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 8.0000000000000003e-218Initial program 94.5%
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-*.f6497.6
Applied rewrites97.6%
Taylor expanded in y around inf
remove-double-negN/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
remove-double-negN/A
lower--.f6451.6
Applied rewrites51.6%
lift--.f64N/A
associate-*l/N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f6449.3
Applied rewrites49.3%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6461.1
Applied rewrites61.1%
if 8.0000000000000003e-218 < y < 2.15e15Initial program 99.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6446.1
Applied rewrites46.1%
Taylor expanded in t around 0
mul-1-negN/A
lower-neg.f6454.1
Applied rewrites54.1%
if 2.15e15 < y Initial program 87.1%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6479.6
Applied rewrites79.6%
Final simplification63.1%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* z (- t x)))) (if (<= z -4.6e-28) t_1 (if (<= z 3.5e+18) (fma z (- x) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = z * (t - x);
double tmp;
if (z <= -4.6e-28) {
tmp = t_1;
} else if (z <= 3.5e+18) {
tmp = fma(z, -x, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(z * Float64(t - x)) tmp = 0.0 if (z <= -4.6e-28) tmp = t_1; elseif (z <= 3.5e+18) tmp = fma(z, Float64(-x), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.6e-28], t$95$1, If[LessEqual[z, 3.5e+18], N[(z * (-x) + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(t - x\right)\\
\mathbf{if}\;z \leq -4.6 \cdot 10^{-28}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{+18}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.59999999999999971e-28 or 3.5e18 < z Initial program 87.4%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6441.4
Applied rewrites41.4%
Taylor expanded in z around inf
remove-double-negN/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
remove-double-negN/A
lower--.f6440.8
Applied rewrites40.8%
if -4.59999999999999971e-28 < z < 3.5e18Initial program 99.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6477.9
Applied rewrites77.9%
Taylor expanded in t around 0
mul-1-negN/A
lower-neg.f6483.3
Applied rewrites83.3%
(FPCore (x y z t) :precision binary64 (if (<= t -4.6e-189) (* t z) (if (<= t 3.8e-108) (- (* x z)) (* t z))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -4.6e-189) {
tmp = t * z;
} else if (t <= 3.8e-108) {
tmp = -(x * z);
} else {
tmp = t * z;
}
return tmp;
}
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
real(8) :: tmp
if (t <= (-4.6d-189)) then
tmp = t * z
else if (t <= 3.8d-108) then
tmp = -(x * z)
else
tmp = t * z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (t <= -4.6e-189) {
tmp = t * z;
} else if (t <= 3.8e-108) {
tmp = -(x * z);
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -4.6e-189: tmp = t * z elif t <= 3.8e-108: tmp = -(x * z) else: tmp = t * z return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -4.6e-189) tmp = Float64(t * z); elseif (t <= 3.8e-108) tmp = Float64(-Float64(x * z)); else tmp = Float64(t * z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -4.6e-189) tmp = t * z; elseif (t <= 3.8e-108) tmp = -(x * z); else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -4.6e-189], N[(t * z), $MachinePrecision], If[LessEqual[t, 3.8e-108], (-N[(x * z), $MachinePrecision]), N[(t * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.6 \cdot 10^{-189}:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;t \leq 3.8 \cdot 10^{-108}:\\
\;\;\;\;-x \cdot z\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if t < -4.5999999999999996e-189 or 3.79999999999999973e-108 < t Initial program 94.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6456.0
Applied rewrites56.0%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6419.8
Applied rewrites19.8%
if -4.5999999999999996e-189 < t < 3.79999999999999973e-108Initial program 92.3%
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-*.f6495.5
Applied rewrites95.5%
Taylor expanded in y around inf
remove-double-negN/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
remove-double-negN/A
lower--.f6469.0
Applied rewrites69.0%
Taylor expanded in z around inf
*-commutativeN/A
remove-double-negN/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
remove-double-negN/A
lower--.f6428.1
Applied rewrites28.1%
Taylor expanded in t around 0
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6428.1
Applied rewrites28.1%
Final simplification21.9%
(FPCore (x y z t) :precision binary64 (if (<= y 2.15e+15) (fma z (- x) x) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.15e+15) {
tmp = fma(z, -x, x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 2.15e+15) tmp = fma(z, Float64(-x), x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.15e+15], N[(z * (-x) + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.15 \cdot 10^{+15}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 2.15e15Initial program 95.8%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6457.2
Applied rewrites57.2%
Taylor expanded in t around 0
mul-1-negN/A
lower-neg.f6454.0
Applied rewrites54.0%
if 2.15e15 < y Initial program 87.1%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6479.6
Applied rewrites79.6%
(FPCore (x y z t) :precision binary64 (* z (- t x)))
double code(double x, double y, double z, double t) {
return z * (t - x);
}
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 - x)
end function
public static double code(double x, double y, double z, double t) {
return z * (t - x);
}
def code(x, y, z, t): return z * (t - x)
function code(x, y, z, t) return Float64(z * Float64(t - x)) end
function tmp = code(x, y, z, t) tmp = z * (t - x); end
code[x_, y_, z_, t_] := N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z \cdot \left(t - x\right)
\end{array}
Initial program 94.2%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6461.2
Applied rewrites61.2%
Taylor expanded in z around inf
remove-double-negN/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
remove-double-negN/A
lower--.f6424.5
Applied rewrites24.5%
(FPCore (x y z t) :precision binary64 (* t z))
double code(double x, double y, double z, double t) {
return t * z;
}
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 = t * z
end function
public static double code(double x, double y, double z, double t) {
return t * z;
}
def code(x, y, z, t): return t * z
function code(x, y, z, t) return Float64(t * z) end
function tmp = code(x, y, z, t) tmp = t * z; end
code[x_, y_, z_, t_] := N[(t * z), $MachinePrecision]
\begin{array}{l}
\\
t \cdot z
\end{array}
Initial program 94.2%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6461.2
Applied rewrites61.2%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6415.6
Applied rewrites15.6%
Final simplification15.6%
(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 2024214
(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))))))