
(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 (* (tanh (/ x y)) (- z))) y x))
double code(double x, double y, double z, double t) {
return fma(fma(tanh((t / y)), z, (tanh((x / y)) * -z)), y, x);
}
function code(x, y, z, t) return fma(fma(tanh(Float64(t / y)), z, Float64(tanh(Float64(x / y)) * Float64(-z))), y, x) end
code[x_, y_, z_, t_] := N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * z + N[(N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision] * (-z)), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\tanh \left(\frac{t}{y}\right), z, \tanh \left(\frac{x}{y}\right) \cdot \left(-z\right)\right), y, x\right)
\end{array}
Initial program 94.7%
lift-*.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6497.9
Applied egg-rr97.9%
lift-/.f64N/A
lift-tanh.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
sub-negN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6497.9
Applied egg-rr97.9%
Final simplification97.9%
(FPCore (x y z t) :precision binary64 (fma (* z (- (tanh (/ t y)) (tanh (/ x y)))) y x))
double code(double x, double y, double z, double t) {
return fma((z * (tanh((t / y)) - tanh((x / y)))), y, x);
}
function code(x, y, z, t) return fma(Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), y, x) end
code[x_, y_, z_, t_] := N[(N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), y, x\right)
\end{array}
Initial program 94.7%
lift-*.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
lift--.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6497.9
Applied egg-rr97.9%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma z (/ -1.0 (/ (- -1.0 (/ (+ x (/ (* x x) t)) t)) t)) x)))
(if (<= x -1.8e+23)
t_1
(if (<= x 7.6e-11)
(fma (fma (tanh (/ t y)) z (/ (* z (- x)) y)) y x)
(if (<= x 4e+197) (fma (* z (- (/ t y) (tanh (/ x y)))) y x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = fma(z, (-1.0 / ((-1.0 - ((x + ((x * x) / t)) / t)) / t)), x);
double tmp;
if (x <= -1.8e+23) {
tmp = t_1;
} else if (x <= 7.6e-11) {
tmp = fma(fma(tanh((t / y)), z, ((z * -x) / y)), y, x);
} else if (x <= 4e+197) {
tmp = fma((z * ((t / y) - tanh((x / y)))), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(z, Float64(-1.0 / Float64(Float64(-1.0 - Float64(Float64(x + Float64(Float64(x * x) / t)) / t)) / t)), x) tmp = 0.0 if (x <= -1.8e+23) tmp = t_1; elseif (x <= 7.6e-11) tmp = fma(fma(tanh(Float64(t / y)), z, Float64(Float64(z * Float64(-x)) / y)), y, x); elseif (x <= 4e+197) tmp = fma(Float64(z * Float64(Float64(t / y) - tanh(Float64(x / y)))), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(-1.0 / N[(N[(-1.0 - N[(N[(x + N[(N[(x * x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[x, -1.8e+23], t$95$1, If[LessEqual[x, 7.6e-11], N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * z + N[(N[(z * (-x)), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[x, 4e+197], N[(N[(z * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, \frac{-1}{\frac{-1 - \frac{x + \frac{x \cdot x}{t}}{t}}{t}}, x\right)\\
\mathbf{if}\;x \leq -1.8 \cdot 10^{+23}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7.6 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\tanh \left(\frac{t}{y}\right), z, \frac{z \cdot \left(-x\right)}{y}\right), y, x\right)\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+197}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.7999999999999999e23 or 3.9999999999999998e197 < x Initial program 99.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6464.3
Simplified64.3%
flip--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
difference-of-squaresN/A
lift--.f64N/A
lower-*.f64N/A
lower-+.f6427.2
Applied egg-rr27.2%
Taylor expanded in t around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
Simplified82.0%
if -1.7999999999999999e23 < x < 7.5999999999999996e-11Initial program 91.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
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6496.0
Applied egg-rr96.0%
lift-/.f64N/A
lift-tanh.f64N/A
lift-/.f64N/A
lift-tanh.f64N/A
sub-negN/A
distribute-rgt-inN/A
lower-fma.f64N/A
lower-*.f64N/A
lower-neg.f6496.0
Applied egg-rr96.0%
Taylor expanded in x around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6484.5
Simplified84.5%
if 7.5999999999999996e-11 < x < 3.9999999999999998e197Initial 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
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6499.9
Applied egg-rr99.9%
Taylor expanded in t around 0
lower-/.f6485.7
Simplified85.7%
Final simplification84.0%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma z (/ -1.0 (/ (- -1.0 (/ (+ x (/ (* x x) t)) t)) t)) x)))
(if (<= x -1.8e+23)
t_1
(if (<= x 5e-13)
(fma (* z (- (tanh (/ t y)) (/ x y))) y x)
(if (<= x 4e+197) (fma (* z (- (/ t y) (tanh (/ x y)))) y x) t_1)))))
double code(double x, double y, double z, double t) {
double t_1 = fma(z, (-1.0 / ((-1.0 - ((x + ((x * x) / t)) / t)) / t)), x);
double tmp;
if (x <= -1.8e+23) {
tmp = t_1;
} else if (x <= 5e-13) {
tmp = fma((z * (tanh((t / y)) - (x / y))), y, x);
} else if (x <= 4e+197) {
tmp = fma((z * ((t / y) - tanh((x / y)))), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(z, Float64(-1.0 / Float64(Float64(-1.0 - Float64(Float64(x + Float64(Float64(x * x) / t)) / t)) / t)), x) tmp = 0.0 if (x <= -1.8e+23) tmp = t_1; elseif (x <= 5e-13) tmp = fma(Float64(z * Float64(tanh(Float64(t / y)) - Float64(x / y))), y, x); elseif (x <= 4e+197) tmp = fma(Float64(z * Float64(Float64(t / y) - tanh(Float64(x / y)))), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(-1.0 / N[(N[(-1.0 - N[(N[(x + N[(N[(x * x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[x, -1.8e+23], t$95$1, If[LessEqual[x, 5e-13], N[(N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], If[LessEqual[x, 4e+197], N[(N[(z * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, \frac{-1}{\frac{-1 - \frac{x + \frac{x \cdot x}{t}}{t}}{t}}, x\right)\\
\mathbf{if}\;x \leq -1.8 \cdot 10^{+23}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), y, x\right)\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+197}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.7999999999999999e23 or 3.9999999999999998e197 < x Initial program 99.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6464.3
Simplified64.3%
flip--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
difference-of-squaresN/A
lift--.f64N/A
lower-*.f64N/A
lower-+.f6427.2
Applied egg-rr27.2%
Taylor expanded in t around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
Simplified82.0%
if -1.7999999999999999e23 < x < 4.9999999999999999e-13Initial program 92.5%
Taylor expanded in x around 0
lower-/.f6480.2
Simplified80.2%
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-*.f6483.8
Applied egg-rr83.8%
if 4.9999999999999999e-13 < x < 3.9999999999999998e197Initial program 92.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
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6499.3
Applied egg-rr99.3%
Taylor expanded in t around 0
lower-/.f6485.3
Simplified85.3%
Final simplification83.6%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma z (/ -1.0 (/ (- -1.0 (/ (+ x (/ (* x x) t)) t)) t)) x)))
(if (<= x -1.8e+23)
t_1
(if (<= x 1.32e+163) (fma (* z (- (tanh (/ t y)) (/ x y))) y x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma(z, (-1.0 / ((-1.0 - ((x + ((x * x) / t)) / t)) / t)), x);
double tmp;
if (x <= -1.8e+23) {
tmp = t_1;
} else if (x <= 1.32e+163) {
tmp = fma((z * (tanh((t / y)) - (x / y))), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(z, Float64(-1.0 / Float64(Float64(-1.0 - Float64(Float64(x + Float64(Float64(x * x) / t)) / t)) / t)), x) tmp = 0.0 if (x <= -1.8e+23) tmp = t_1; elseif (x <= 1.32e+163) tmp = fma(Float64(z * Float64(tanh(Float64(t / y)) - Float64(x / y))), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(-1.0 / N[(N[(-1.0 - N[(N[(x + N[(N[(x * x), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[x, -1.8e+23], t$95$1, If[LessEqual[x, 1.32e+163], N[(N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, \frac{-1}{\frac{-1 - \frac{x + \frac{x \cdot x}{t}}{t}}{t}}, x\right)\\
\mathbf{if}\;x \leq -1.8 \cdot 10^{+23}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 1.32 \cdot 10^{+163}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.7999999999999999e23 or 1.31999999999999995e163 < x Initial program 99.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6463.2
Simplified63.2%
flip--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
difference-of-squaresN/A
lift--.f64N/A
lower-*.f64N/A
lower-+.f6426.2
Applied egg-rr26.2%
Taylor expanded in t around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
Simplified80.4%
if -1.7999999999999999e23 < x < 1.31999999999999995e163Initial program 92.3%
Taylor expanded in x around 0
lower-/.f6478.1
Simplified78.1%
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-*.f6482.8
Applied egg-rr82.8%
Final simplification82.0%
(FPCore (x y z t) :precision binary64 (if (<= y 4.8e-39) (fma z (/ -1.0 (/ (+ 1.0 (/ (+ t (/ (* t t) x)) x)) x)) x) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.8e-39) {
tmp = fma(z, (-1.0 / ((1.0 + ((t + ((t * t) / x)) / x)) / x)), x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 4.8e-39) tmp = fma(z, Float64(-1.0 / Float64(Float64(1.0 + Float64(Float64(t + Float64(Float64(t * t) / x)) / x)) / x)), x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.8e-39], N[(z * N[(-1.0 / N[(N[(1.0 + N[(N[(t + N[(N[(t * t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.8 \cdot 10^{-39}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{-1}{\frac{1 + \frac{t + \frac{t \cdot t}{x}}{x}}{x}}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 4.80000000000000031e-39Initial program 97.8%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6454.6
Simplified54.6%
flip--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
difference-of-squaresN/A
lift--.f64N/A
lower-*.f64N/A
lower-+.f6440.6
Applied egg-rr40.6%
Taylor expanded in x around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
Simplified64.2%
if 4.80000000000000031e-39 < y Initial program 86.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6486.4
Simplified86.4%
Final simplification70.6%
(FPCore (x y z t) :precision binary64 (if (<= y 4.8e-39) (fma z (/ 1.0 (/ (- -1.0 (/ t x)) x)) x) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.8e-39) {
tmp = fma(z, (1.0 / ((-1.0 - (t / x)) / x)), x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 4.8e-39) tmp = fma(z, Float64(1.0 / Float64(Float64(-1.0 - Float64(t / x)) / x)), x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.8e-39], N[(z * N[(1.0 / N[(N[(-1.0 - N[(t / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.8 \cdot 10^{-39}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{1}{\frac{-1 - \frac{t}{x}}{x}}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 4.80000000000000031e-39Initial program 97.8%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6454.6
Simplified54.6%
flip--N/A
clear-numN/A
lower-/.f64N/A
lower-/.f64N/A
lower-+.f64N/A
difference-of-squaresN/A
lift--.f64N/A
lower-*.f64N/A
lower-+.f6440.6
Applied egg-rr40.6%
Taylor expanded in x around inf
sub-negN/A
mul-1-negN/A
distribute-neg-inN/A
+-commutativeN/A
distribute-neg-fracN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6461.0
Simplified61.0%
if 4.80000000000000031e-39 < y Initial program 86.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6486.4
Simplified86.4%
Final simplification68.3%
(FPCore (x y z t) :precision binary64 (if (<= y 4.8e-39) (fma (/ z -1.0) (/ (* y x) y) x) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.8e-39) {
tmp = fma((z / -1.0), ((y * x) / y), x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 4.8e-39) tmp = fma(Float64(z / -1.0), Float64(Float64(y * x) / y), x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 4.8e-39], N[(N[(z / -1.0), $MachinePrecision] * N[(N[(y * x), $MachinePrecision] / y), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.8 \cdot 10^{-39}:\\
\;\;\;\;\mathsf{fma}\left(\frac{z}{-1}, \frac{y \cdot x}{y}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 4.80000000000000031e-39Initial program 97.8%
Taylor expanded in x around 0
lower-/.f6464.9
Simplified64.9%
Taylor expanded in t around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6448.4
Simplified48.4%
lift-*.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lift-neg.f64N/A
neg-mul-1N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f64N/A
lower-*.f6452.5
Applied egg-rr52.5%
if 4.80000000000000031e-39 < y Initial program 86.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6486.4
Simplified86.4%
(FPCore (x y z t) :precision binary64 (if (<= y 3.5e-39) (- x (/ (* z (* y x)) y)) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.5e-39) {
tmp = x - ((z * (y * x)) / y);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 3.5e-39) tmp = Float64(x - Float64(Float64(z * Float64(y * x)) / y)); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.5e-39], N[(x - N[(N[(z * N[(y * x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{-39}:\\
\;\;\;\;x - \frac{z \cdot \left(y \cdot x\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 3.5e-39Initial program 97.8%
Taylor expanded in x around 0
lower-/.f6464.9
Simplified64.9%
Taylor expanded in t around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6448.4
Simplified48.4%
lift-*.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f6448.4
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6454.2
Applied egg-rr54.2%
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f6452.0
Applied egg-rr52.0%
if 3.5e-39 < y Initial program 86.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6486.4
Simplified86.4%
Final simplification61.8%
(FPCore (x y z t) :precision binary64 (if (<= y 3.5e-39) (- x (/ (* y (* z x)) y)) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.5e-39) {
tmp = x - ((y * (z * x)) / y);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 3.5e-39) tmp = Float64(x - Float64(Float64(y * Float64(z * x)) / y)); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.5e-39], N[(x - N[(N[(y * N[(z * x), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.5 \cdot 10^{-39}:\\
\;\;\;\;x - \frac{y \cdot \left(z \cdot x\right)}{y}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 3.5e-39Initial program 97.8%
Taylor expanded in x around 0
lower-/.f6464.9
Simplified64.9%
Taylor expanded in t around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6448.4
Simplified48.4%
lift-*.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
lift-*.f64N/A
+-commutativeN/A
lower-+.f6448.4
lift-*.f64N/A
lift-/.f64N/A
associate-*r/N/A
lower-/.f64N/A
lift-*.f64N/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f6454.2
Applied egg-rr54.2%
lift-*.f64N/A
lift-*.f64N/A
lift-neg.f64N/A
lift-/.f64N/A
+-commutativeN/A
lift-/.f64N/A
lift-neg.f64N/A
distribute-frac-neg2N/A
unsub-negN/A
lower--.f64N/A
lower-/.f6454.2
Applied egg-rr54.2%
if 3.5e-39 < y Initial program 86.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6486.4
Simplified86.4%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* z (- t x)))) (if (<= z -1.8e-19) t_1 (if (<= z 4500000000.0) (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 <= -1.8e-19) {
tmp = t_1;
} else if (z <= 4500000000.0) {
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 <= -1.8e-19) tmp = t_1; elseif (z <= 4500000000.0) 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, -1.8e-19], t$95$1, If[LessEqual[z, 4500000000.0], 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 -1.8 \cdot 10^{-19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 4500000000:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -1.8000000000000001e-19 or 4.5e9 < z Initial program 90.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6446.2
Simplified46.2%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6445.9
Simplified45.9%
if -1.8000000000000001e-19 < z < 4.5e9Initial program 98.5%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6481.1
Simplified81.1%
Taylor expanded in t around 0
mul-1-negN/A
lower-neg.f6487.9
Simplified87.9%
(FPCore (x y z t) :precision binary64 (if (<= t -4.5) (* t z) (if (<= t 6e-70) (* z (- x)) (* t z))))
double code(double x, double y, double z, double t) {
double tmp;
if (t <= -4.5) {
tmp = t * z;
} else if (t <= 6e-70) {
tmp = z * -x;
} 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.5d0)) then
tmp = t * z
else if (t <= 6d-70) then
tmp = z * -x
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.5) {
tmp = t * z;
} else if (t <= 6e-70) {
tmp = z * -x;
} else {
tmp = t * z;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if t <= -4.5: tmp = t * z elif t <= 6e-70: tmp = z * -x else: tmp = t * z return tmp
function code(x, y, z, t) tmp = 0.0 if (t <= -4.5) tmp = Float64(t * z); elseif (t <= 6e-70) tmp = Float64(z * Float64(-x)); else tmp = Float64(t * z); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (t <= -4.5) tmp = t * z; elseif (t <= 6e-70) tmp = z * -x; else tmp = t * z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[t, -4.5], N[(t * z), $MachinePrecision], If[LessEqual[t, 6e-70], N[(z * (-x)), $MachinePrecision], N[(t * z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -4.5:\\
\;\;\;\;t \cdot z\\
\mathbf{elif}\;t \leq 6 \cdot 10^{-70}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;t \cdot z\\
\end{array}
\end{array}
if t < -4.5 or 6.0000000000000003e-70 < t Initial program 94.4%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6453.8
Simplified53.8%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6424.9
Simplified24.9%
if -4.5 < t < 6.0000000000000003e-70Initial program 95.2%
Taylor expanded in x around 0
lower-/.f6470.3
Simplified70.3%
Taylor expanded in t around 0
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6465.0
Simplified65.0%
Taylor expanded in z around inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
mul-1-negN/A
lower-neg.f6423.1
Simplified23.1%
Final simplification24.2%
(FPCore (x y z t) :precision binary64 (if (<= y 4.8e-39) (fma z (- x) x) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.8e-39) {
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 <= 4.8e-39) 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, 4.8e-39], N[(z * (-x) + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.8 \cdot 10^{-39}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 4.80000000000000031e-39Initial program 97.8%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6454.6
Simplified54.6%
Taylor expanded in t around 0
mul-1-negN/A
lower-neg.f6455.5
Simplified55.5%
if 4.80000000000000031e-39 < y Initial program 86.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6486.4
Simplified86.4%
(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.7%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6463.7
Simplified63.7%
Taylor expanded in z around inf
lower-*.f64N/A
lower--.f6427.6
Simplified27.6%
(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.7%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6463.7
Simplified63.7%
Taylor expanded in t around inf
*-commutativeN/A
lower-*.f6418.1
Simplified18.1%
Final simplification18.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 2024208
(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))))))