I would propose looking for the points of discontinuity ahead of time, as follows:
f[x_] = Sin[x]/x;
Excl =
Simplify[
Map[{Limit[f[t], t -> #], x==#} &,
x /. Solve[Simplify[Not[FunctionDomain[f[x], x]]], x]
]
]
(* Out = {{1, x==0}} *)
This output is "reversed" in the sense that it is the y value, then the x value, but that is the necessary format for Piecewise to be used:
g[x_] = Piecewise[Excl, f[x]];
This gives you what you want:
FunctionDomain[g[x], x]
Here's another more complicated example:
f2[x_] = Sin[x]/x + (1 - x^2)/(1 - x);
Excl2 =
Simplify[
Map[{Limit[f2[t], t -> #], x==#} &,
x /. Solve[Simplify[Not[FunctionDomain[f2[x], x]]], x]
]
];
g2[x_] = Piecewise[Excl2, f2[x]];
Simplify[FunctionDomain[g2[x], x]]
(* Out = True *)
I have no idea if this is the nicest or most compact way of doing this, but it works (I think). Here is a black box that does it:
smooth[f_] =
Function[x,
Piecewise[
Simplify[
Map[{Limit[f[t], t -> #], x == #} &,
x /. Solve[Simplify[Not[FunctionDomain[f[x], x]]], x]
]
],
f[x]]
]
I originally had this split into two functions, but I've made an edit here, because any use of x internal to finding the excluded points won't jive with the pure function we're defining.
smooth[f][x]
FunctionDomain[%, x]
(* Out = piecewise definition of smooth[f][x] *)
(* Out = True *)
smooth[f2][x]
FunctionDomain[%, x]
(* Out = piecewise definition of smooth[f][x] *)
(* Out = True *)
Both of those give the functions as before, and again confirm that this function has the full domain you want. If you want to do anything serious besides checking the domain, you want to assign this to its own symbol, i.e.
h=smooth[f];
h[0]
(* Out = 1 *)
If you just try smooth[f][0], the function tries to do what smooth normally does while also using a fixed value of x=0. That's not going to work.
This all assumes the points of discontinuity of the function are easy enough to find -- particularly, that Solve can find them. Of course, there may be cases where that isn't the case, but I wonder if that isn't something where this entire idea would be impractical.
As to your original idea, why doesn't it work (even though the function appears to have the right domain)?
When you do the following:
f[x_] := Sin[x]/x
smoothe[g_] := Limit[g[y], y -> #] &
FunctionDomain[smoothe[f][x], x]
What the call smoothe[f] returns is the expression Sin[x]/x.
Then it finds the domain of that function, as written, which is no different than finding the domain of f[x] in the first place.
Your smoothe[f][__] will give the correct value for numerical values in the blank, but not for symbolic values -- Mathematica will evaluate the limit you've packed up into smoothe as if a symbolic x would not be the point of discontinuity.
And then, when you ask for the domain, Mathematica balks and says "Sorry, I thought this should be Sin[x]/x when I did smoothe and now the domain excludes x==0, even though smoothe[f][0] exists."
(Edit: I goofed on some syntax and some weird self-correcting errors made it hard to detect, but it's fixed.)
closurefunction seems to give us a way to determine the effective domain of the OP'ssmoothe[f[x]]but doesn't give us a new function. Is that what you are proposing? – Kellen Myers Jun 20 '17 at 21:43closure[FunctionDomain[Exp[-1/x], x]]should beTrue– Carl Woll Jun 20 '17 at 23:57x/Abs[x]. You have to match left & right side limits, which I omitted. Any solution that relies onLimit[f, x -> c]without checking both sides will also have the same problem (i.e. all the other answers so far, too). This is one of those questions where, so far, the effort/reward ratio calls fastidiousness into question, imo. – Michael E2 Jun 21 '17 at 00:21Seriesmight be a better tool – Carl Woll Jun 21 '17 at 00:22SeriesonExp[-1/x]andExp[-1/x^2]return similar looking results. – Michael E2 Jun 21 '17 at 00:25