
(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 9 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}
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 1.3e+194) (fma y (* z (- (tanh (/ t y)) (tanh (/ x y)))) x) (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.3e+194) {
tmp = fma(y, (z * (tanh((t / y)) - tanh((x / y)))), x);
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 1.3e+194) tmp = fma(y, Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 1.3e+194], N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.3 \cdot 10^{+194}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.2999999999999999e194Initial program 94.7%
+-commutative94.7%
associate-*l*98.7%
fma-def98.7%
Simplified98.7%
if 1.2999999999999999e194 < y Initial program 90.8%
associate-*l*82.2%
Simplified82.2%
Taylor expanded in y around inf 95.9%
Final simplification98.5%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 1.8e+194) (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))) (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.8e+194) {
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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 (y <= 1.8d+194) then
tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y)))))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.8e+194) {
tmp = x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 1.8e+194: tmp = x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y))))) else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 1.8e+194) tmp = Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.8e+194) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 1.8e+194], 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], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.8 \cdot 10^{+194}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.8e194Initial program 94.7%
associate-*l*98.7%
Simplified98.7%
if 1.8e194 < y Initial program 90.8%
associate-*l*82.2%
Simplified82.2%
Taylor expanded in y around inf 95.9%
Final simplification98.5%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (or (<= y 1.75e+44) (and (not (<= y 3.7e+77)) (<= y 1.25e+132))) (+ x (* (tanh (/ t y)) (* y z))) (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 1.75e+44) || (!(y <= 3.7e+77) && (y <= 1.25e+132))) {
tmp = x + (tanh((t / y)) * (y * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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 ((y <= 1.75d+44) .or. (.not. (y <= 3.7d+77)) .and. (y <= 1.25d+132)) then
tmp = x + (tanh((t / y)) * (y * z))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if ((y <= 1.75e+44) || (!(y <= 3.7e+77) && (y <= 1.25e+132))) {
tmp = x + (Math.tanh((t / y)) * (y * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if (y <= 1.75e+44) or (not (y <= 3.7e+77) and (y <= 1.25e+132)): tmp = x + (math.tanh((t / y)) * (y * z)) else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if ((y <= 1.75e+44) || (!(y <= 3.7e+77) && (y <= 1.25e+132))) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((y <= 1.75e+44) || (~((y <= 3.7e+77)) && (y <= 1.25e+132))) tmp = x + (tanh((t / y)) * (y * z)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[Or[LessEqual[y, 1.75e+44], And[N[Not[LessEqual[y, 3.7e+77]], $MachinePrecision], LessEqual[y, 1.25e+132]]], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.75 \cdot 10^{+44} \lor \neg \left(y \leq 3.7 \cdot 10^{+77}\right) \land y \leq 1.25 \cdot 10^{+132}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.75e44 or 3.69999999999999995e77 < y < 1.25e132Initial program 95.0%
associate-*l*98.6%
Simplified98.6%
Taylor expanded in x around 0 27.6%
associate-*r*27.4%
associate-/r*27.4%
div-sub27.4%
rec-exp27.4%
rec-exp27.4%
tanh-def-a83.0%
Simplified83.0%
if 1.75e44 < y < 3.69999999999999995e77 or 1.25e132 < y Initial program 91.2%
associate-*l*91.0%
Simplified91.0%
Taylor expanded in y around inf 86.1%
Final simplification83.5%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (let* ((t_1 (tanh (/ t y)))) (if (<= y 2.6e+34) (+ x (* t_1 (* y z))) (+ x (* z (- (* y t_1) x))))))
y = abs(y);
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 2.6e+34) {
tmp = x + (t_1 * (y * z));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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 = tanh((t / y))
if (y <= 2.6d+34) then
tmp = x + (t_1 * (y * z))
else
tmp = x + (z * ((y * t_1) - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (y <= 2.6e+34) {
tmp = x + (t_1 * (y * z));
} else {
tmp = x + (z * ((y * t_1) - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 2.6e+34: tmp = x + (t_1 * (y * z)) else: tmp = x + (z * ((y * t_1) - x)) return tmp
y = abs(y) function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 2.6e+34) tmp = Float64(x + Float64(t_1 * Float64(y * z))); else tmp = Float64(x + Float64(z * Float64(Float64(y * t_1) - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 2.6e+34) tmp = x + (t_1 * (y * z)); else tmp = x + (z * ((y * t_1) - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 2.6e+34], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(N[(y * t$95$1), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 2.6 \cdot 10^{+34}:\\
\;\;\;\;x + t_1 \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(y \cdot t_1 - x\right)\\
\end{array}
\end{array}
if y < 2.59999999999999997e34Initial program 95.3%
associate-*l*98.5%
Simplified98.5%
Taylor expanded in x around 0 27.3%
associate-*r*27.1%
associate-/r*27.1%
div-sub27.1%
rec-exp27.1%
rec-exp27.1%
tanh-def-a83.2%
Simplified83.2%
if 2.59999999999999997e34 < y Initial program 90.9%
associate-*l*92.5%
Simplified92.5%
Taylor expanded in x around 0 58.0%
+-commutative58.0%
Simplified93.6%
unsub-neg93.6%
*-commutative93.6%
Applied egg-rr93.6%
Final simplification85.3%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 1.46e+37) x (if (<= y 1.22e+79) (- x (* z x)) (if (<= y 1.1e+99) x (+ x (* z t))))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.46e+37) {
tmp = x;
} else if (y <= 1.22e+79) {
tmp = x - (z * x);
} else if (y <= 1.1e+99) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
NOTE: y should be positive before calling this function
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 (y <= 1.46d+37) then
tmp = x
else if (y <= 1.22d+79) then
tmp = x - (z * x)
else if (y <= 1.1d+99) then
tmp = x
else
tmp = x + (z * t)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.46e+37) {
tmp = x;
} else if (y <= 1.22e+79) {
tmp = x - (z * x);
} else if (y <= 1.1e+99) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 1.46e+37: tmp = x elif y <= 1.22e+79: tmp = x - (z * x) elif y <= 1.1e+99: tmp = x else: tmp = x + (z * t) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 1.46e+37) tmp = x; elseif (y <= 1.22e+79) tmp = Float64(x - Float64(z * x)); elseif (y <= 1.1e+99) tmp = x; else tmp = Float64(x + Float64(z * t)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.46e+37) tmp = x; elseif (y <= 1.22e+79) tmp = x - (z * x); elseif (y <= 1.1e+99) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 1.46e+37], x, If[LessEqual[y, 1.22e+79], N[(x - N[(z * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.1e+99], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.46 \cdot 10^{+37}:\\
\;\;\;\;x\\
\mathbf{elif}\;y \leq 1.22 \cdot 10^{+79}:\\
\;\;\;\;x - z \cdot x\\
\mathbf{elif}\;y \leq 1.1 \cdot 10^{+99}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 1.4599999999999999e37 or 1.22000000000000002e79 < y < 1.09999999999999989e99Initial program 95.4%
+-commutative95.4%
associate-*l*98.6%
fma-def98.6%
Simplified98.6%
Taylor expanded in y around 0 70.1%
if 1.4599999999999999e37 < y < 1.22000000000000002e79Initial program 99.6%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in y around inf 86.4%
Taylor expanded in t around 0 63.2%
mul-1-neg63.2%
distribute-lft-neg-out63.2%
*-commutative63.2%
Simplified63.2%
if 1.09999999999999989e99 < y Initial program 89.3%
associate-*l*91.2%
Simplified91.2%
Taylor expanded in x around 0 39.7%
associate-*r*39.4%
associate-/r*39.4%
div-sub39.4%
rec-exp39.4%
rec-exp39.4%
tanh-def-a77.7%
Simplified77.7%
Taylor expanded in y around inf 67.3%
+-commutative67.3%
*-commutative67.3%
Simplified67.3%
Final simplification69.5%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 1.5e+39) x (+ x (* z (- t x)))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.5e+39) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
NOTE: y should be positive before calling this function
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 (y <= 1.5d+39) then
tmp = x
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.5e+39) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 1.5e+39: tmp = x else: tmp = x + (z * (t - x)) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 1.5e+39) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.5e+39) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 1.5e+39], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.5 \cdot 10^{+39}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.5e39Initial program 95.3%
+-commutative95.3%
associate-*l*98.5%
fma-def98.5%
Simplified98.5%
Taylor expanded in y around 0 69.9%
if 1.5e39 < y Initial program 90.9%
associate-*l*92.5%
Simplified92.5%
Taylor expanded in y around inf 84.7%
Final simplification73.0%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= x -2.4e-162) x (if (<= x -6.2e-257) (* z t) x)))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.4e-162) {
tmp = x;
} else if (x <= -6.2e-257) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
NOTE: y should be positive before calling this function
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 <= (-2.4d-162)) then
tmp = x
else if (x <= (-6.2d-257)) then
tmp = z * t
else
tmp = x
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.4e-162) {
tmp = x;
} else if (x <= -6.2e-257) {
tmp = z * t;
} else {
tmp = x;
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if x <= -2.4e-162: tmp = x elif x <= -6.2e-257: tmp = z * t else: tmp = x return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (x <= -2.4e-162) tmp = x; elseif (x <= -6.2e-257) tmp = Float64(z * t); else tmp = x; end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -2.4e-162) tmp = x; elseif (x <= -6.2e-257) tmp = z * t; else tmp = x; end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[x, -2.4e-162], x, If[LessEqual[x, -6.2e-257], N[(z * t), $MachinePrecision], x]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \cdot 10^{-162}:\\
\;\;\;\;x\\
\mathbf{elif}\;x \leq -6.2 \cdot 10^{-257}:\\
\;\;\;\;z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if x < -2.4000000000000002e-162 or -6.20000000000000016e-257 < x Initial program 96.3%
+-commutative96.3%
associate-*l*99.1%
fma-def99.1%
Simplified99.1%
Taylor expanded in y around 0 70.8%
if -2.4000000000000002e-162 < x < -6.20000000000000016e-257Initial program 74.5%
associate-*l*78.6%
Simplified78.6%
Taylor expanded in x around 0 2.9%
associate-*r*2.3%
associate-/r*2.3%
div-sub2.3%
rec-exp2.4%
rec-exp2.4%
tanh-def-a66.0%
Simplified66.0%
Taylor expanded in y around inf 45.5%
+-commutative45.5%
*-commutative45.5%
Simplified45.5%
Taylor expanded in z around inf 45.3%
Final simplification68.5%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 (if (<= y 4.2e+98) x (+ x (* z t))))
y = abs(y);
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.2e+98) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
NOTE: y should be positive before calling this function
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 (y <= 4.2d+98) then
tmp = x
else
tmp = x + (z * t)
end if
code = tmp
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 4.2e+98) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
y = abs(y) def code(x, y, z, t): tmp = 0 if y <= 4.2e+98: tmp = x else: tmp = x + (z * t) return tmp
y = abs(y) function code(x, y, z, t) tmp = 0.0 if (y <= 4.2e+98) tmp = x; else tmp = Float64(x + Float64(z * t)); end return tmp end
y = abs(y) function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 4.2e+98) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := If[LessEqual[y, 4.2e+98], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
y = |y|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.2 \cdot 10^{+98}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 4.20000000000000008e98Initial program 95.5%
+-commutative95.5%
associate-*l*98.6%
fma-def98.6%
Simplified98.6%
Taylor expanded in y around 0 69.3%
if 4.20000000000000008e98 < y Initial program 89.3%
associate-*l*91.2%
Simplified91.2%
Taylor expanded in x around 0 39.7%
associate-*r*39.4%
associate-/r*39.4%
div-sub39.4%
rec-exp39.4%
rec-exp39.4%
tanh-def-a77.7%
Simplified77.7%
Taylor expanded in y around inf 67.3%
+-commutative67.3%
*-commutative67.3%
Simplified67.3%
Final simplification69.0%
NOTE: y should be positive before calling this function (FPCore (x y z t) :precision binary64 x)
y = abs(y);
double code(double x, double y, double z, double t) {
return x;
}
NOTE: y should be positive before calling this function
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
end function
y = Math.abs(y);
public static double code(double x, double y, double z, double t) {
return x;
}
y = abs(y) def code(x, y, z, t): return x
y = abs(y) function code(x, y, z, t) return x end
y = abs(y) function tmp = code(x, y, z, t) tmp = x; end
NOTE: y should be positive before calling this function code[x_, y_, z_, t_] := x
\begin{array}{l}
y = |y|\\
\\
x
\end{array}
Initial program 94.4%
+-commutative94.4%
associate-*l*97.3%
fma-def97.3%
Simplified97.3%
Taylor expanded in y around 0 65.1%
Final simplification65.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 2023336
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:herbie-target
(+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))