%% Specify Initial Condition for Function with Different One-Sided Limits
% Solve the differential equation \frac{\textrm{dy}}{\textrm{dx}}=\frac{1}{x^2 }e^{-\frac{1}{x}} without specifying the initial condition.

syms y(x)
eqn = diff(y) == exp(-1/x)/x^2;
ySol(x) = dsolve(eqn)

% To eliminate constants from the solution, specify the initial condition y\left(0\right)=1\ldotp

cond = y(0) == 1;
S = dsolve(eqn,cond)

% The function e^{-\frac{1}{x}} in the solution ySol(x) has different one-sided limits at x=0. The function has a right-side limit, \lim_{x\to 0^+ } \;e^{-\frac{1}{x}} =0, but it has undefined left-side limit, \lim_{x\to 0^- } \;e^{-\frac{1}{x}} =\infty.
% When you specify the condition y(x0) for a function with different one-sided limits at x0, dsolve treats the condition as a limit from the right, \lim \;x\to x_0^+.
%
% Copyright 2019 The MathWorks, Inc.