
(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 (* (- (tanh (/ t y)) (tanh (/ x y))) y) z x))
double code(double x, double y, double z, double t) {
return fma(((tanh((t / y)) - tanh((x / y))) * y), z, x);
}
function code(x, y, z, t) return fma(Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * y), z, 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] * y), $MachinePrecision] * z + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right)
\end{array}
Initial program 93.4%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6497.2
Applied rewrites97.2%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (- t x) z))
(t_2 (+ (* (* z y) (- (tanh (/ t y)) (tanh (/ x y)))) x))
(t_3 (+ (* z t) x)))
(if (<= t_2 (- INFINITY))
t_1
(if (<= t_2 -5e+17)
t_3
(if (<= t_2 4e-160) (fma (- x) z x) (if (<= t_2 1e+307) t_3 t_1))))))
double code(double x, double y, double z, double t) {
double t_1 = (t - x) * z;
double t_2 = ((z * y) * (tanh((t / y)) - tanh((x / y)))) + x;
double t_3 = (z * t) + x;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= -5e+17) {
tmp = t_3;
} else if (t_2 <= 4e-160) {
tmp = fma(-x, z, x);
} else if (t_2 <= 1e+307) {
tmp = t_3;
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(Float64(t - x) * z) t_2 = Float64(Float64(Float64(z * y) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))) + x) t_3 = Float64(Float64(z * t) + x) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= -5e+17) tmp = t_3; elseif (t_2 <= 4e-160) tmp = fma(Float64(-x), z, x); elseif (t_2 <= 1e+307) tmp = t_3; else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(t - x), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(z * y), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, Block[{t$95$3 = N[(N[(z * t), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, -5e+17], t$95$3, If[LessEqual[t$95$2, 4e-160], N[((-x) * z + x), $MachinePrecision], If[LessEqual[t$95$2, 1e+307], t$95$3, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot z\\
t_2 := \left(z \cdot y\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) + x\\
t_3 := z \cdot t + x\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq -5 \cdot 10^{+17}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-160}:\\
\;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\
\mathbf{elif}\;t\_2 \leq 10^{+307}:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0 or 9.99999999999999986e306 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 59.5%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Taylor expanded in z around inf
Applied rewrites100.0%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -5e17 or 4e-160 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 9.99999999999999986e306Initial program 99.9%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6454.4
Applied rewrites54.4%
Taylor expanded in t around inf
Applied rewrites64.3%
if -5e17 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4e-160Initial program 94.0%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6448.5
Applied rewrites48.5%
Taylor expanded in t around 0
Applied rewrites53.0%
Final simplification66.5%
(FPCore (x y z t)
:precision binary64
(if (<= y 1.8e-57)
(+ (* (pow (/ (+ (/ (fma y x (* (/ (* x y) t) x)) t) y) t) -1.0) (* z y)) x)
(if (<= y 3.85e+14)
(+
(*
(pow (/ (fma (/ (* x x) t) (/ y t) (fma y (/ x t) y)) t) -1.0)
(* z y))
x)
(+ (fma z t (* (- x) z)) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.8e-57) {
tmp = (pow((((fma(y, x, (((x * y) / t) * x)) / t) + y) / t), -1.0) * (z * y)) + x;
} else if (y <= 3.85e+14) {
tmp = (pow((fma(((x * x) / t), (y / t), fma(y, (x / t), y)) / t), -1.0) * (z * y)) + x;
} else {
tmp = fma(z, t, (-x * z)) + x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.8e-57) tmp = Float64(Float64((Float64(Float64(Float64(fma(y, x, Float64(Float64(Float64(x * y) / t) * x)) / t) + y) / t) ^ -1.0) * Float64(z * y)) + x); elseif (y <= 3.85e+14) tmp = Float64(Float64((Float64(fma(Float64(Float64(x * x) / t), Float64(y / t), fma(y, Float64(x / t), y)) / t) ^ -1.0) * Float64(z * y)) + x); else tmp = Float64(fma(z, t, Float64(Float64(-x) * z)) + x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.8e-57], N[(N[(N[Power[N[(N[(N[(N[(y * x + N[(N[(N[(x * y), $MachinePrecision] / t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] + y), $MachinePrecision] / t), $MachinePrecision], -1.0], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 3.85e+14], N[(N[(N[Power[N[(N[(N[(N[(x * x), $MachinePrecision] / t), $MachinePrecision] * N[(y / t), $MachinePrecision] + N[(y * N[(x / t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision], -1.0], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(z * t + N[((-x) * z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{-57}:\\
\;\;\;\;{\left(\frac{\frac{\mathsf{fma}\left(y, x, \frac{x \cdot y}{t} \cdot x\right)}{t} + y}{t}\right)}^{-1} \cdot \left(z \cdot y\right) + x\\
\mathbf{elif}\;y \leq 3.85 \cdot 10^{+14}:\\
\;\;\;\;{\left(\frac{\mathsf{fma}\left(\frac{x \cdot x}{t}, \frac{y}{t}, \mathsf{fma}\left(y, \frac{x}{t}, y\right)\right)}{t}\right)}^{-1} \cdot \left(z \cdot y\right) + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t, \left(-x\right) \cdot z\right) + x\\
\end{array}
\end{array}
if y < 1.8000000000000001e-57Initial program 95.5%
Taylor expanded in y around inf
lower-/.f64N/A
lower--.f6440.8
Applied rewrites40.8%
Applied rewrites40.7%
Taylor expanded in t around -inf
Applied rewrites56.3%
if 1.8000000000000001e-57 < y < 3.85e14Initial program 99.8%
Taylor expanded in y around inf
lower-/.f64N/A
lower--.f6439.2
Applied rewrites39.2%
Applied rewrites39.3%
Taylor expanded in t around inf
Applied rewrites57.7%
if 3.85e14 < y Initial program 85.2%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6483.8
Applied rewrites83.8%
Applied rewrites83.8%
Final simplification62.6%
(FPCore (x y z t)
:precision binary64
(if (<= y 1.18e-63)
(+ (* (pow (/ (+ (/ (fma y x (* (/ (* x y) t) x)) t) y) t) -1.0) (* z y)) x)
(if (<= y 1e+177)
(fma (* (- (/ t y) (tanh (/ x y))) y) z x)
(+ (fma z t (* (- x) z)) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.18e-63) {
tmp = (pow((((fma(y, x, (((x * y) / t) * x)) / t) + y) / t), -1.0) * (z * y)) + x;
} else if (y <= 1e+177) {
tmp = fma((((t / y) - tanh((x / y))) * y), z, x);
} else {
tmp = fma(z, t, (-x * z)) + x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 1.18e-63) tmp = Float64(Float64((Float64(Float64(Float64(fma(y, x, Float64(Float64(Float64(x * y) / t) * x)) / t) + y) / t) ^ -1.0) * Float64(z * y)) + x); elseif (y <= 1e+177) tmp = fma(Float64(Float64(Float64(t / y) - tanh(Float64(x / y))) * y), z, x); else tmp = Float64(fma(z, t, Float64(Float64(-x) * z)) + x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.18e-63], N[(N[(N[Power[N[(N[(N[(N[(y * x + N[(N[(N[(x * y), $MachinePrecision] / t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] + y), $MachinePrecision] / t), $MachinePrecision], -1.0], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 1e+177], N[(N[(N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(z * t + N[((-x) * z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.18 \cdot 10^{-63}:\\
\;\;\;\;{\left(\frac{\frac{\mathsf{fma}\left(y, x, \frac{x \cdot y}{t} \cdot x\right)}{t} + y}{t}\right)}^{-1} \cdot \left(z \cdot y\right) + x\\
\mathbf{elif}\;y \leq 10^{+177}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t, \left(-x\right) \cdot z\right) + x\\
\end{array}
\end{array}
if y < 1.17999999999999999e-63Initial program 95.4%
Taylor expanded in y around inf
lower-/.f64N/A
lower--.f6440.3
Applied rewrites40.3%
Applied rewrites40.3%
Taylor expanded in t around -inf
Applied rewrites56.1%
if 1.17999999999999999e-63 < y < 1e177Initial program 92.5%
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 t around 0
lower-/.f6470.2
Applied rewrites70.2%
if 1e177 < y Initial program 81.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6496.6
Applied rewrites96.6%
Applied rewrites96.6%
Final simplification63.0%
(FPCore (x y z t) :precision binary64 (if (<= y 6.6e+30) (+ (* (pow (/ (+ (/ (fma y x (* (/ (* x y) t) x)) t) y) t) -1.0) (* z y)) x) (+ (fma z t (* (- x) z)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.6e+30) {
tmp = (pow((((fma(y, x, (((x * y) / t) * x)) / t) + y) / t), -1.0) * (z * y)) + x;
} else {
tmp = fma(z, t, (-x * z)) + x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 6.6e+30) tmp = Float64(Float64((Float64(Float64(Float64(fma(y, x, Float64(Float64(Float64(x * y) / t) * x)) / t) + y) / t) ^ -1.0) * Float64(z * y)) + x); else tmp = Float64(fma(z, t, Float64(Float64(-x) * z)) + x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.6e+30], N[(N[(N[Power[N[(N[(N[(N[(y * x + N[(N[(N[(x * y), $MachinePrecision] / t), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] + y), $MachinePrecision] / t), $MachinePrecision], -1.0], $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(N[(z * t + N[((-x) * z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.6 \cdot 10^{+30}:\\
\;\;\;\;{\left(\frac{\frac{\mathsf{fma}\left(y, x, \frac{x \cdot y}{t} \cdot x\right)}{t} + y}{t}\right)}^{-1} \cdot \left(z \cdot y\right) + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t, \left(-x\right) \cdot z\right) + x\\
\end{array}
\end{array}
if y < 6.60000000000000053e30Initial program 95.9%
Taylor expanded in y around inf
lower-/.f64N/A
lower--.f6440.7
Applied rewrites40.7%
Applied rewrites40.6%
Taylor expanded in t around -inf
Applied rewrites55.2%
if 6.60000000000000053e30 < y Initial program 84.4%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6486.2
Applied rewrites86.2%
Applied rewrites86.2%
Final simplification61.8%
(FPCore (x y z t)
:precision binary64
(if (<= x -7.6e+48)
(fma (* (- (/ t y) (tanh (/ x y))) y) z x)
(if (<= x 5.4e+173)
(fma (* (- (tanh (/ t y)) (/ x y)) y) z x)
(+ (* z t) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -7.6e+48) {
tmp = fma((((t / y) - tanh((x / y))) * y), z, x);
} else if (x <= 5.4e+173) {
tmp = fma(((tanh((t / y)) - (x / y)) * y), z, x);
} else {
tmp = (z * t) + x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -7.6e+48) tmp = fma(Float64(Float64(Float64(t / y) - tanh(Float64(x / y))) * y), z, x); elseif (x <= 5.4e+173) tmp = fma(Float64(Float64(tanh(Float64(t / y)) - Float64(x / y)) * y), z, x); else tmp = Float64(Float64(z * t) + x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -7.6e+48], N[(N[(N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[x, 5.4e+173], N[(N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision] * y), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(z * t), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.6 \cdot 10^{+48}:\\
\;\;\;\;\mathsf{fma}\left(\left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right)\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{+173}:\\
\;\;\;\;\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right) \cdot y, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot t + x\\
\end{array}
\end{array}
if x < -7.60000000000000001e48Initial program 100.0%
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-/.f6473.7
Applied rewrites73.7%
if -7.60000000000000001e48 < x < 5.4000000000000002e173Initial program 90.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6496.1
Applied rewrites96.1%
Taylor expanded in y around inf
lower-/.f6480.4
Applied rewrites80.4%
if 5.4000000000000002e173 < x Initial program 100.0%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6461.0
Applied rewrites61.0%
Taylor expanded in t around inf
Applied rewrites91.7%
Final simplification80.9%
(FPCore (x y z t) :precision binary64 (if (<= y 2.55e-80) (+ (* z t) x) (+ (fma z t (* (- x) z)) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.55e-80) {
tmp = (z * t) + x;
} else {
tmp = fma(z, t, (-x * z)) + x;
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 2.55e-80) tmp = Float64(Float64(z * t) + x); else tmp = Float64(fma(z, t, Float64(Float64(-x) * z)) + x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.55e-80], N[(N[(z * t), $MachinePrecision] + x), $MachinePrecision], N[(N[(z * t + N[((-x) * z), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.55 \cdot 10^{-80}:\\
\;\;\;\;z \cdot t + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t, \left(-x\right) \cdot z\right) + x\\
\end{array}
\end{array}
if y < 2.55000000000000004e-80Initial program 95.3%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6452.6
Applied rewrites52.6%
Taylor expanded in t around inf
Applied rewrites59.0%
if 2.55000000000000004e-80 < y Initial program 89.3%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6472.8
Applied rewrites72.8%
Applied rewrites72.8%
Final simplification63.4%
(FPCore (x y z t) :precision binary64 (if (or (<= z -0.014) (not (<= z 0.029))) (* (- t x) z) (fma (- x) z x)))
double code(double x, double y, double z, double t) {
double tmp;
if ((z <= -0.014) || !(z <= 0.029)) {
tmp = (t - x) * z;
} else {
tmp = fma(-x, z, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if ((z <= -0.014) || !(z <= 0.029)) tmp = Float64(Float64(t - x) * z); else tmp = fma(Float64(-x), z, x); end return tmp end
code[x_, y_, z_, t_] := If[Or[LessEqual[z, -0.014], N[Not[LessEqual[z, 0.029]], $MachinePrecision]], N[(N[(t - x), $MachinePrecision] * z), $MachinePrecision], N[((-x) * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -0.014 \lor \neg \left(z \leq 0.029\right):\\
\;\;\;\;\left(t - x\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-x, z, x\right)\\
\end{array}
\end{array}
if z < -0.0140000000000000003 or 0.0290000000000000015 < z Initial program 88.4%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6446.0
Applied rewrites46.0%
Taylor expanded in z around inf
Applied rewrites45.5%
if -0.0140000000000000003 < z < 0.0290000000000000015Initial program 99.5%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6474.7
Applied rewrites74.7%
Taylor expanded in t around 0
Applied rewrites79.1%
Final simplification60.7%
(FPCore (x y z t) :precision binary64 (if (or (<= x -3.1e-86) (not (<= x 5e-64))) (* (- x) z) (* z t)))
double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -3.1e-86) || !(x <= 5e-64)) {
tmp = -x * z;
} else {
tmp = z * t;
}
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 ((x <= (-3.1d-86)) .or. (.not. (x <= 5d-64))) then
tmp = -x * z
else
tmp = z * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((x <= -3.1e-86) || !(x <= 5e-64)) {
tmp = -x * z;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (x <= -3.1e-86) or not (x <= 5e-64): tmp = -x * z else: tmp = z * t return tmp
function code(x, y, z, t) tmp = 0.0 if ((x <= -3.1e-86) || !(x <= 5e-64)) tmp = Float64(Float64(-x) * z); else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((x <= -3.1e-86) || ~((x <= 5e-64))) tmp = -x * z; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[x, -3.1e-86], N[Not[LessEqual[x, 5e-64]], $MachinePrecision]], N[((-x) * z), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{-86} \lor \neg \left(x \leq 5 \cdot 10^{-64}\right):\\
\;\;\;\;\left(-x\right) \cdot z\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if x < -3.09999999999999989e-86 or 5.00000000000000033e-64 < x Initial program 95.7%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6458.9
Applied rewrites58.9%
Taylor expanded in z around inf
Applied rewrites21.2%
Taylor expanded in t around 0
Applied rewrites17.1%
if -3.09999999999999989e-86 < x < 5.00000000000000033e-64Initial program 90.0%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6459.2
Applied rewrites59.2%
Taylor expanded in t around inf
Applied rewrites38.4%
Final simplification25.6%
(FPCore (x y z t) :precision binary64 (if (<= y 2.55e-80) (+ (* z t) x) (fma (- t x) z x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.55e-80) {
tmp = (z * t) + x;
} else {
tmp = fma((t - x), z, x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 2.55e-80) tmp = Float64(Float64(z * t) + x); else tmp = fma(Float64(t - x), z, x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.55e-80], N[(N[(z * t), $MachinePrecision] + x), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.55 \cdot 10^{-80}:\\
\;\;\;\;z \cdot t + x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\
\end{array}
\end{array}
if y < 2.55000000000000004e-80Initial program 95.3%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f64N/A
lower--.f6452.6
Applied rewrites52.6%
Taylor expanded in t around inf
Applied rewrites59.0%
if 2.55000000000000004e-80 < y Initial program 89.3%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6472.8
Applied rewrites72.8%
Final simplification63.4%
(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 93.4%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6459.0
Applied rewrites59.0%
Taylor expanded in z around inf
Applied rewrites30.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 93.4%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6459.0
Applied rewrites59.0%
Taylor expanded in t around inf
Applied rewrites20.4%
Final simplification20.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 2024271
(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))))))