
(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 15 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 (fma (tanh (/ t y)) z (* (- z) (tanh (/ x y)))) y x))
double code(double x, double y, double z, double t) {
return fma(fma(tanh((t / y)), z, (-z * tanh((x / y)))), y, x);
}
function code(x, y, z, t) return fma(fma(tanh(Float64(t / y)), z, Float64(Float64(-z) * tanh(Float64(x / y)))), y, x) end
code[x_, y_, z_, t_] := N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * z + N[((-z) * N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\tanh \left(\frac{t}{y}\right), z, \left(-z\right) \cdot \tanh \left(\frac{x}{y}\right)\right), y, x\right)
\end{array}
Initial program 94.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6498.9
Applied rewrites98.9%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6498.9
Applied rewrites98.9%
Final simplification98.9%
(FPCore (x y z t) :precision binary64 (fma (* (- (tanh (/ t y)) (tanh (/ x y))) z) y x))
double code(double x, double y, double z, double t) {
return fma(((tanh((t / y)) - tanh((x / y))) * z), y, x);
}
function code(x, y, z, t) return fma(Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * z), y, x) end
code[x_, y_, z_, t_] := N[(N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot z, y, x\right)
\end{array}
Initial program 94.7%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6498.9
Applied rewrites98.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (fma (tanh (/ t y)) z (/ (* (- x) z) y)) y x)))
(if (<= t -2.9e-103)
t_1
(if (<= t 1.22e-166) (fma (* (- (/ t y) (tanh (/ x y))) z) y x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(fma(tanh((t / y)), z, ((-x * z) / y)), y, x);
double tmp;
if (t <= -2.9e-103) {
tmp = t_1;
} else if (t <= 1.22e-166) {
tmp = fma((((t / y) - tanh((x / y))) * z), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(fma(tanh(Float64(t / y)), z, Float64(Float64(Float64(-x) * z) / y)), y, x) tmp = 0.0 if (t <= -2.9e-103) tmp = t_1; elseif (t <= 1.22e-166) tmp = fma(Float64(Float64(Float64(t / y) - tanh(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[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * z + N[(N[((-x) * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -2.9e-103], t$95$1, If[LessEqual[t, 1.22e-166], N[(N[(N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(\tanh \left(\frac{t}{y}\right), z, \frac{\left(-x\right) \cdot z}{y}\right), y, x\right)\\
\mathbf{if}\;t \leq -2.9 \cdot 10^{-103}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.22 \cdot 10^{-166}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right) \cdot z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -2.8999999999999999e-103 or 1.22e-166 < t Initial program 95.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.1
Applied rewrites99.1%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6499.1
Applied rewrites99.1%
Taylor expanded in y around inf
Applied rewrites78.2%
Applied rewrites78.2%
if -2.8999999999999999e-103 < t < 1.22e-166Initial program 94.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-*.f6498.4
Applied rewrites98.4%
Taylor expanded in t around 0
lower-/.f6495.1
Applied rewrites95.1%
Final simplification83.8%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (fma (tanh (/ t y)) z (* (/ (- z) y) x)) y x)))
(if (<= t -3.6e-10)
t_1
(if (<= t 2.6e-80) (fma (* (- (/ t y) (tanh (/ x y))) z) y x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(fma(tanh((t / y)), z, ((-z / y) * x)), y, x);
double tmp;
if (t <= -3.6e-10) {
tmp = t_1;
} else if (t <= 2.6e-80) {
tmp = fma((((t / y) - tanh((x / y))) * z), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(fma(tanh(Float64(t / y)), z, Float64(Float64(Float64(-z) / y) * x)), y, x) tmp = 0.0 if (t <= -3.6e-10) tmp = t_1; elseif (t <= 2.6e-80) tmp = fma(Float64(Float64(Float64(t / y) - tanh(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[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * z + N[(N[((-z) / y), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]}, If[LessEqual[t, -3.6e-10], t$95$1, If[LessEqual[t, 2.6e-80], N[(N[(N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(\tanh \left(\frac{t}{y}\right), z, \frac{-z}{y} \cdot x\right), y, x\right)\\
\mathbf{if}\;t \leq -3.6 \cdot 10^{-10}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.6 \cdot 10^{-80}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right) \cdot z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -3.6e-10 or 2.6000000000000001e-80 < t Initial program 95.0%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6499.6
Applied rewrites99.6%
lift-*.f64N/A
*-commutativeN/A
lift--.f64N/A
sub-negN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6499.6
Applied rewrites99.6%
Taylor expanded in y around inf
associate-/l*N/A
associate-*r*N/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f64N/A
lower-/.f6473.8
Applied rewrites73.8%
if -3.6e-10 < t < 2.6000000000000001e-80Initial program 94.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-*.f6498.1
Applied rewrites98.1%
Taylor expanded in t around 0
lower-/.f6491.3
Applied rewrites91.3%
Final simplification82.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (/ 1.0 (/ (- -1.0 (/ (+ (/ (* t t) x) t) x)) x)) z x)))
(if (<= t -1.06e+172)
t_1
(if (<= t 1.28e+160) (fma (* (- (/ t y) (tanh (/ x y))) z) y x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((1.0 / ((-1.0 - ((((t * t) / x) + t) / x)) / x)), z, x);
double tmp;
if (t <= -1.06e+172) {
tmp = t_1;
} else if (t <= 1.28e+160) {
tmp = fma((((t / y) - tanh((x / y))) * z), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(1.0 / Float64(Float64(-1.0 - Float64(Float64(Float64(Float64(t * t) / x) + t) / x)) / x)), z, x) tmp = 0.0 if (t <= -1.06e+172) tmp = t_1; elseif (t <= 1.28e+160) tmp = fma(Float64(Float64(Float64(t / y) - tanh(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[(1.0 / N[(N[(-1.0 - N[(N[(N[(N[(t * t), $MachinePrecision] / x), $MachinePrecision] + t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[t, -1.06e+172], t$95$1, If[LessEqual[t, 1.28e+160], N[(N[(N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\frac{1}{\frac{-1 - \frac{\frac{t \cdot t}{x} + t}{x}}{x}}, z, x\right)\\
\mathbf{if}\;t \leq -1.06 \cdot 10^{+172}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 1.28 \cdot 10^{+160}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right) \cdot z, y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.05999999999999996e172 or 1.27999999999999994e160 < t Initial program 100.0%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6425.0
Applied rewrites25.0%
Applied rewrites7.0%
Taylor expanded in x around -inf
Applied rewrites63.3%
if -1.05999999999999996e172 < t < 1.27999999999999994e160Initial program 93.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-*.f6498.6
Applied rewrites98.6%
Taylor expanded in t around 0
lower-/.f6479.7
Applied rewrites79.7%
Final simplification76.5%
(FPCore (x y z t)
:precision binary64
(if (<= y 1.7e-115)
(fma (/ 1.0 (/ (- -1.0 (/ (+ (/ (* t t) x) t) x)) x)) z x)
(if (<= y 1200000000000.0)
(fma (/ 1.0 (/ (- (/ (+ (/ (* x x) t) x) t) -1.0) t)) z x)
(fma t z (- x (* x z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.7e-115) {
tmp = fma((1.0 / ((-1.0 - ((((t * t) / x) + t) / x)) / x)), z, x);
} else if (y <= 1200000000000.0) {
tmp = fma((1.0 / ((((((x * x) / t) + x) / t) - -1.0) / t)), z, x);
} else {
tmp = fma(t, z, (x - (x * z)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.7e-115) tmp = fma(Float64(1.0 / Float64(Float64(-1.0 - Float64(Float64(Float64(Float64(t * t) / x) + t) / x)) / x)), z, x); elseif (y <= 1200000000000.0) tmp = fma(Float64(1.0 / Float64(Float64(Float64(Float64(Float64(Float64(x * x) / t) + x) / t) - -1.0) / t)), z, x); else tmp = fma(t, z, Float64(x - Float64(x * z))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.7e-115], N[(N[(1.0 / N[(N[(-1.0 - N[(N[(N[(N[(t * t), $MachinePrecision] / x), $MachinePrecision] + t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[y, 1200000000000.0], N[(N[(1.0 / N[(N[(N[(N[(N[(N[(x * x), $MachinePrecision] / t), $MachinePrecision] + x), $MachinePrecision] / t), $MachinePrecision] - -1.0), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], N[(t * z + N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.7 \cdot 10^{-115}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{-1 - \frac{\frac{t \cdot t}{x} + t}{x}}{x}}, z, x\right)\\
\mathbf{elif}\;y \leq 1200000000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{\frac{\frac{x \cdot x}{t} + x}{t} - -1}{t}}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x - x \cdot z\right)\\
\end{array}
\end{array}
if y < 1.6999999999999999e-115Initial program 94.9%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6456.8
Applied rewrites56.8%
Applied rewrites36.8%
Taylor expanded in x around -inf
Applied rewrites58.5%
if 1.6999999999999999e-115 < y < 1.2e12Initial program 99.9%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6435.3
Applied rewrites35.3%
Applied rewrites24.0%
Taylor expanded in x around inf
Applied rewrites42.4%
Taylor expanded in t around -inf
Applied rewrites57.7%
if 1.2e12 < y Initial program 92.1%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6484.3
Applied rewrites84.3%
Taylor expanded in t around 0
Applied rewrites84.5%
Final simplification64.5%
(FPCore (x y z t)
:precision binary64
(if (<= y 1.5e-268)
(fma (/ 1.0 (/ (fma t (/ -1.0 x) -1.0) x)) z x)
(if (<= y 10.0)
(fma (/ 1.0 (/ (- (/ (+ (/ (* x x) t) x) t) -1.0) t)) z x)
(fma t z (- x (* x z))))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.5e-268) {
tmp = fma((1.0 / (fma(t, (-1.0 / x), -1.0) / x)), z, x);
} else if (y <= 10.0) {
tmp = fma((1.0 / ((((((x * x) / t) + x) / t) - -1.0) / t)), z, x);
} else {
tmp = fma(t, z, (x - (x * z)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.5e-268) tmp = fma(Float64(1.0 / Float64(fma(t, Float64(-1.0 / x), -1.0) / x)), z, x); elseif (y <= 10.0) tmp = fma(Float64(1.0 / Float64(Float64(Float64(Float64(Float64(Float64(x * x) / t) + x) / t) - -1.0) / t)), z, x); else tmp = fma(t, z, Float64(x - Float64(x * z))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.5e-268], N[(N[(1.0 / N[(N[(t * N[(-1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[y, 10.0], N[(N[(1.0 / N[(N[(N[(N[(N[(N[(x * x), $MachinePrecision] / t), $MachinePrecision] + x), $MachinePrecision] / t), $MachinePrecision] - -1.0), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], N[(t * z + N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{-268}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{\mathsf{fma}\left(t, \frac{-1}{x}, -1\right)}{x}}, z, x\right)\\
\mathbf{elif}\;y \leq 10:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{\frac{\frac{x \cdot x}{t} + x}{t} - -1}{t}}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x - x \cdot z\right)\\
\end{array}
\end{array}
if y < 1.4999999999999999e-268Initial program 93.2%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6462.0
Applied rewrites62.0%
Applied rewrites42.4%
Taylor expanded in x around inf
Applied rewrites54.8%
Applied rewrites54.8%
if 1.4999999999999999e-268 < y < 10Initial program 100.0%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6438.8
Applied rewrites38.8%
Applied rewrites20.6%
Taylor expanded in x around inf
Applied rewrites53.7%
Taylor expanded in t around -inf
Applied rewrites56.4%
if 10 < y Initial program 92.5%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6482.1
Applied rewrites82.1%
Taylor expanded in t around 0
Applied rewrites82.3%
Final simplification61.9%
(FPCore (x y z t) :precision binary64 (if (<= y 1.82e-81) (fma (/ 1.0 (/ (fma t (/ -1.0 x) -1.0) x)) z x) (fma t z (- x (* x z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.82e-81) {
tmp = fma((1.0 / (fma(t, (-1.0 / x), -1.0) / x)), z, x);
} else {
tmp = fma(t, z, (x - (x * z)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.82e-81) tmp = fma(Float64(1.0 / Float64(fma(t, Float64(-1.0 / x), -1.0) / x)), z, x); else tmp = fma(t, z, Float64(x - Float64(x * z))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.82e-81], N[(N[(1.0 / N[(N[(t * N[(-1.0 / x), $MachinePrecision] + -1.0), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], N[(t * z + N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.82 \cdot 10^{-81}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{\mathsf{fma}\left(t, \frac{-1}{x}, -1\right)}{x}}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x - x \cdot z\right)\\
\end{array}
\end{array}
if y < 1.82000000000000007e-81Initial program 95.1%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6456.6
Applied rewrites56.6%
Applied rewrites37.3%
Taylor expanded in x around inf
Applied rewrites56.2%
Applied rewrites56.2%
if 1.82000000000000007e-81 < y Initial program 94.0%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6471.3
Applied rewrites71.3%
Taylor expanded in t around 0
Applied rewrites71.3%
Final simplification60.9%
(FPCore (x y z t) :precision binary64 (if (<= y 1200000000000.0) (fma (/ 1.0 (/ 1.0 t)) z x) (fma t z (- x (* x z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1200000000000.0) {
tmp = fma((1.0 / (1.0 / t)), z, x);
} else {
tmp = fma(t, z, (x - (x * z)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1200000000000.0) tmp = fma(Float64(1.0 / Float64(1.0 / t)), z, x); else tmp = fma(t, z, Float64(x - Float64(x * z))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1200000000000.0], N[(N[(1.0 / N[(1.0 / t), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], N[(t * z + N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1200000000000:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\frac{1}{t}}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x - x \cdot z\right)\\
\end{array}
\end{array}
if y < 1.2e12Initial program 95.5%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6454.1
Applied rewrites54.1%
Applied rewrites35.2%
Taylor expanded in t around inf
Applied rewrites56.9%
if 1.2e12 < y Initial program 92.1%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6484.3
Applied rewrites84.3%
Taylor expanded in t around 0
Applied rewrites84.5%
Final simplification63.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- t x) z))) (if (<= z -0.011) t_1 (if (<= z 520000000.0) (fma (- x) z x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = (t - x) * z;
double tmp;
if (z <= -0.011) {
tmp = t_1;
} else if (z <= 520000000.0) {
tmp = fma(-x, z, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(t - x) * z) tmp = 0.0 if (z <= -0.011) tmp = t_1; elseif (z <= 520000000.0) tmp = fma(Float64(-x), z, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -0.011], t$95$1, If[LessEqual[z, 520000000.0], N[((-x) * z + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot z\\
\mathbf{if}\;z \leq -0.011:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 520000000:\\
\;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -0.010999999999999999 or 5.2e8 < z Initial program 88.8%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6441.7
Applied rewrites41.7%
Taylor expanded in z around inf
Applied rewrites41.7%
if -0.010999999999999999 < z < 5.2e8Initial program 100.0%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6478.3
Applied rewrites78.3%
Taylor expanded in t around 0
Applied rewrites87.2%
(FPCore (x y z t) :precision binary64 (if (<= y 1.82e-81) (fma (- x) z x) (fma t z (- x (* x z)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.82e-81) {
tmp = fma(-x, z, x);
} else {
tmp = fma(t, z, (x - (x * z)));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.82e-81) tmp = fma(Float64(-x), z, x); else tmp = fma(t, z, Float64(x - Float64(x * z))); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.82e-81], N[((-x) * z + x), $MachinePrecision], N[(t * z + N[(x - N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.82 \cdot 10^{-81}:\\
\;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x - x \cdot z\right)\\
\end{array}
\end{array}
if y < 1.82000000000000007e-81Initial program 95.1%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6456.6
Applied rewrites56.6%
Taylor expanded in t around 0
Applied rewrites54.1%
if 1.82000000000000007e-81 < y Initial program 94.0%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6471.3
Applied rewrites71.3%
Taylor expanded in t around 0
Applied rewrites71.3%
Final simplification59.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* (- x) z))) (if (<= x -1.35e+48) t_1 (if (<= x 1.75e-29) (* z t) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = -x * z;
double tmp;
if (x <= -1.35e+48) {
tmp = t_1;
} else if (x <= 1.75e-29) {
tmp = z * t;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_1 = -x * z
if (x <= (-1.35d+48)) then
tmp = t_1
else if (x <= 1.75d-29) then
tmp = z * t
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = -x * z;
double tmp;
if (x <= -1.35e+48) {
tmp = t_1;
} else if (x <= 1.75e-29) {
tmp = z * t;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = -x * z tmp = 0 if x <= -1.35e+48: tmp = t_1 elif x <= 1.75e-29: tmp = z * t else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(Float64(-x) * z) tmp = 0.0 if (x <= -1.35e+48) tmp = t_1; elseif (x <= 1.75e-29) tmp = Float64(z * t); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = -x * z; tmp = 0.0; if (x <= -1.35e+48) tmp = t_1; elseif (x <= 1.75e-29) tmp = z * t; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[((-x) * z), $MachinePrecision]}, If[LessEqual[x, -1.35e+48], t$95$1, If[LessEqual[x, 1.75e-29], N[(z * t), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(-x\right) \cdot z\\
\mathbf{if}\;x \leq -1.35 \cdot 10^{+48}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.75 \cdot 10^{-29}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.35000000000000002e48 or 1.7499999999999999e-29 < x Initial program 97.0%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6466.5
Applied rewrites66.5%
Applied rewrites33.9%
Taylor expanded in z around inf
Applied rewrites18.2%
Taylor expanded in t around 0
Applied rewrites17.6%
if -1.35000000000000002e48 < x < 1.7499999999999999e-29Initial program 92.6%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6456.1
Applied rewrites56.1%
Taylor expanded in t around inf
Applied rewrites23.6%
Final simplification20.7%
(FPCore (x y z t) :precision binary64 (if (<= y 1.82e-81) (fma (- x) z x) (fma (- t x) z x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.82e-81) {
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.82e-81) 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.82e-81], N[((-x) * z + x), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.82 \cdot 10^{-81}:\\
\;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\
\end{array}
\end{array}
if y < 1.82000000000000007e-81Initial program 95.1%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6456.6
Applied rewrites56.6%
Taylor expanded in t around 0
Applied rewrites54.1%
if 1.82000000000000007e-81 < y Initial program 94.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 (* (- t x) z))
double code(double x, double y, double z, double t) {
return (t - x) * 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 - x) * z
end function
public static double code(double x, double y, double z, double t) {
return (t - x) * z;
}
def code(x, y, z, t): return (t - x) * z
function code(x, y, z, t) return Float64(Float64(t - x) * z) end
function tmp = code(x, y, z, t) tmp = (t - x) * z; end
code[x_, y_, z_, t_] := N[(N[(t - x), $MachinePrecision] * z), $MachinePrecision]
\begin{array}{l}
\\
\left(t - x\right) \cdot z
\end{array}
Initial program 94.7%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6461.1
Applied rewrites61.1%
Taylor expanded in z around inf
Applied rewrites23.8%
(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 94.7%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6461.1
Applied rewrites61.1%
Taylor expanded in t around inf
Applied rewrites14.4%
Final simplification14.4%
(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 2024249
(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))))))