Showing posts with label differential equation. Show all posts
Showing posts with label differential equation. Show all posts

Friday, March 11, 2016

Differential equation: A special case ($f'(x) - f(x) =...$)

Question:
Solve a differential equation.
\[
f'(x) - f(x) = -2\sin x
\]
The initial condition is $f(0) = 1$.

Answer:
When you find the form, $f'(x) - f(x) =...$, we can utilize the following relation:
\[
[f(x)e^{-x}]' = e^{-x}[f'(x) - f(x)]
\]
If we apply this formula to the above differential equation, we get
\[
[f(x)e^{-x}]' = e^{-x}[-2\sin x]
\]
For the right hand side, we used $f'(x) - f(x) = -2\sin x$. Then, integrate both sides of above equation.
\begin{equation}
f(x)e^{-x} = -2\int e^{-x}\sin x dx
\end{equation}
For the right hand side, we just consider integration by parts of the following factor:
\begin{eqnarray*}
& & \int e^{-x}\sin x dx = -e^{-x}\sin x - \int (-1)e^{-x}\cos x dx  \\
\rightarrow & & \int e^{-x}\sin x dx = -e^{-x}\sin x - e^{-x}\cos x - \int (-1)e^{-x}(-1)\sin x dx  \\
\rightarrow & & \int e^{-x}\sin x dx + \int e^{-x}\sin x dx = -e^{-x}\sin x - e^{-x}\cos x   \\
\rightarrow & & 2\int e^{-x}\sin x dx = -e^{-x}(\sin x + \cos x)   \\
\rightarrow & & \int e^{-x}\sin x dx = -\frac{1}{2}e^{-x}(\sin x + \cos x) + C
\end{eqnarray*}
Plug this into (1).
\begin{eqnarray}
f(x)e^{-x} &=& e^{-x}(\sin x + \cos x) + C  \\
\end{eqnarray}
Use the initial condition, $f(0) = 1$.
\[
f(0) = \sin 0 + \cos 0 + C = 1 + C = 1
\]
Thus, $C = 0$. The final result is
\[
f(x) = \sin x + \cos x
\]

Powered by Hirophysics.com

Monday, February 22, 2016

A special type of differential equation III

Question:
Solve $(x^2\cos x - y)dx + xdy = 0$.

Answer:
Rewrite the equation.
\[
\frac{dy}{dx}-\frac{y}{x}=-x\cos x
\]
When the right hand side is zero, the solution is $y=Cx$. Using variation of constants, we make $C$ as a function of $x$. Namely, $y=C(x)x$ and plug it in the above equation.
\begin{eqnarray}
& & \frac{d(C(x)x)}{dx}-\frac{C(x)x}{x}=-x\cos x  \\
& & C'(x)x+C(x)-C(x)=-x\cos x  \\
& & C'(x) = - \cos x  \\
& & C(x) = - \sin x + C
\end{eqnarray}
We know $C(x)=\frac{y}{x}$, so
\begin{eqnarray}
& & \frac{y}{x} = - \sin x + C \\
& & y = x(-\sin x + C)
\end{eqnarray}

Powered by Hirophysics.com

A special type of differential equation II

Question:
(1) Solve
$x\frac{dy}{dx}+y=0$
(2) Solve
$x\frac{dy}{dx}+y=x\ln x$ by using the result from (1).

Answer:
(1) The differential equation can be expressed as
\[
x\frac{dy}{dx}+\frac{dx}{dx}y =0, \qquad \rightarrow  x'y + xy' =0
\]
Namely,
\[
\frac{d(xy)}{dx}=0 \qquad \rightarrow xy=C \quad \rightarrow \rightarrow y=\frac{C}{x}
\]

(2) Use variation of constants. When $x \ln x = 0$, $y=\frac{C(x)}{x}$. Then, plug it in the original equation.
\begin{eqnarray*}
& & x\frac{d}{dx}\frac{C(x)}{x}+\frac{C(x)}{x}=x \ln x  \\
& & \frac{xC'(x)-C(x)}{x^2}x+\frac{C(x)}{x}=x\ln x  \\
& & C'(x) = x \ln x
\end{eqnarray*}
Integrate both sides.
\begin{eqnarray*}
C(x) &=& \int x\ln x dx  \\
C(x) &=& \frac{x^2}{2}\ln x - \int \left(\frac{1}{x} \frac{x^2}{2}\right)dx  \\
C(x) &=&  \frac{x^2}{2}\ln x - \frac{x^2}{4}+ C
\end{eqnarray*}
Since $C=xy$, we have
\begin{eqnarray*}
xy &=&  \frac{x^2}{2}\ln x - \frac{x^2}{4} + C \\
y &=& \frac{x}{2}\ln x - \frac{x}{4} + \frac{C}{x}
\end{eqnarray*}

Powered by Hirophysics.com

A special type of differential equation I

Question:
(1) Find the general solution of
$\frac{dy}{dx}+P(x)y=Q(x)$, where $P(x)$ and $Q(x)$ are functions of $x$.
(2) Solve the following differential equation:
$x\frac{dy}{dx}+2y=\sin x$

Answer:
(1) Multiply $e^{\int P(x)dx}$ by both sides.
\[
e^{\int P(x)dx}\frac{dy}{dx}+P(x)e^{\int P(x)dx}y=e^{\int P(x)dx}Q(x)
\]
We can notice that the left hand side can be modified as follows:
\[
\frac{d}{dx}\left(e^{\int P(x)dx}y\right) = e^{\int P(x)dx}Q(x)
\]
Integrate both sides in terms of $x$.
\begin{eqnarray*}
e^{\int P(x)dx}y &=& \int e^{\int P(x)dx}Q(x)dx + C \\
y &=& e^{-\int P(x)dx}\left(\int e^{\int P(x)dx}Q(x)dx + C \right)
\end{eqnarray*}

The other solution of (1) When $Q(x) = 0$, the solution is $y=Ce^{-\int P(x)dx}$. Therefore, when $Q(x) \neq 0$, the constant $C$ can be a function of $x$ and then find the $C(x)$. $y=Ce^{-\int P(x)dx}$ can be plugged in the original equation:
\begin{eqnarray*}
\frac{d}{dx}Ce^{-\int P(x)dx}+P(x)y&=&Q(x)  \\
C'e^{-\int P(x)dx}-CP(x)e^{-\int P(x)dx}+P(x)y&=&Q(x) \\
C'e^{-\int P(x)dx}-P(x)y+P(x)y&=&Q(x) \\
C'&=&Q(x)e^{\int P(x)dx}  \\
C(x) &=& \int Q(x)e^{\int P(x)dx}dx+C
\end{eqnarray*}
Since $C(x)=e^{\int P(x)dx}y$, we have
\begin{eqnarray*}
e^{\int P(x)dx}y &=& \int Q(x)e^{\int P(x)dx}dx+C \\
y &=& e^{-\int P(x)dx}\left(\int Q(x)e^{\int P(x)dx}dx+C \right)
\end{eqnarray*}

(2) The given equation can be modified as
\[
\frac{dy}{dx}+\frac{2y}{x}=\frac{\sin x}{x}
\]
From the previous discussion, $P(x)=2/x$ and $Q(x)=\sin x/x$. So plug them in to the previous result.
\[
y = e^{-\int \frac{2}{x}dx}\left(\int \frac{\sin x}{x}e^{\int \frac{2}{x}dx}dx+C \right)
\]
Think about the function $f(x)=e^{-\int \frac{2}{x}dx}$. This becomes $f(x)=e^{-2\ln x}$. In order to simplify it, take log of both sides.
\begin{eqnarray*}
\ln f(x) &=& \ln e^{-2\ln x}  \\
\ln f(x) &=& -2\ln x  \\
\ln f(x) &=& \ln x^{-2}  \\
f(x) &=& x^{-2}
\end{eqnarray*}
Thus, we have
\[
y = \frac{1}{x^2}\left(\int \frac{\sin x}{x}x^2 dx+C \right)
\]
For the final steps,
\begin{eqnarray}
y &=& \frac{1}{x^2}\left(\int x\sin x dx+C \right)  \\
&=&  \frac{1}{x^2}\left([-x\cos x + \int\cos x dx]+C \right)  \\
&=&  \frac{1}{x^2}\left(-x\cos x + \sin x + C \right)
\end{eqnarray}

Powered by Hirophysics.com

Sunday, February 21, 2016

Resistor and inductor circuit with a steady voltage source

Question:
A circuit that has a resistor, $R$, and an inductor, $L$, which are connected in series with a DC voltage source $V$. The initial value of the current is $I(t=0)=0$ A. Find the current as a function of time.

Answer:
From Kirchoff's law, the generated voltage is consumed by each element.
\[
V-RI-L\frac{dI}{dt}=0
\]
\begin{eqnarray}
RI+L\frac{dI}{dt} &=& V  \\
I' + \frac{1}{\tau}I &=& \frac{V}{L}
\end{eqnarray}
where $I'=\frac{dI}{dt}$ and $\tau=\frac{L}{R}$. Now, let $D\equiv \frac{d}{dt}$.
\begin{equation}
\left(D+\frac{1}{\tau}\right)I=\frac{V}{L}  \\
\end{equation}
The fundamental solution is
\begin{equation}
I_f = C_1e^{-\frac{t}{\tau}}
\end{equation}
The particular solution is
\begin{equation}
I_p = \frac{1}{D+\frac{1}{\tau}}\cdot \frac{V}{L}=\frac{1}{0+\frac{1}{\tau}}\cdot \frac{V}{L}=\frac{V}{R}
\end{equation}
Therefore, we have the general solution.
\begin{equation}
I = C_1e^{-\frac{t}{\tau}} + \frac{V}{R}
\end{equation}
When $t=0$, $I=0$. So $0=C_1+V/R$ and $C_1=-V/R$. Then, the current is expressed as
\[
I(t) = -\frac{V}{R}e^{-\frac{t}{\tau}}+\frac{V}{R}
\]
or
\[
I(t) = \frac{V}{R}(1-e^{-\frac{t}{\tau}})
\]

Powered by Hirophysics.com

Saturday, February 13, 2016

Damped oscillator: Spring motion

Question:
A 0.400-kg object is attached to a spring of its force constant $k=200$ N/m and this motion is subject to a resistive force, $-bv$, which is proportional to the velocity. If the damped frequency is 99.5 % of the undamped frequency, find the value of $b$.

Answer:
The equation of motion gives:
\[
\sum F = -kx - b\frac{dx}{dt} = m\frac{d^2x}{dt^2}
\]
Let us put $\frac{dx}{dt}=x'\equiv Dx$ and $\frac{d^2x}{dt^2}=x''\equiv D^2x$. The differential equation becomes
\begin{eqnarray}
x''+\frac{b}{m}x'+\frac{k}{m}x &=& 0  \quad \mathrm{or} \\
\left(D^2+\frac{b}{m}D+\frac{k}{m}\right)x &=& 0
\end{eqnarray}
Let us also put $\omega_0 = \sqrt{\frac{k}{m}}$, which is called the rational frequency. This system is a damped oscillation, so the discriminant must be negative. Namely,
\begin{equation}
\left(\frac{b}{m}\right)^2 - 4\omega^2 < 0 \ \rightarrow \ \left(\frac{b}{m}\right)^2 < 4\omega^2
\end{equation}
The solution should be
\begin{equation}
D = -\frac{b}{2m} \pm \sqrt{\omega^2_0 - \frac{1}{4}\frac{b^2}{m^2}}i
\end{equation}
Therefore,
\begin{equation}
x = Ae^{-\frac{m}{2m}t}\cos(\omega t + \phi)
\end{equation}
where $\omega=\sqrt{\omega^2_0 - \frac{1}{4}\frac{b^2}{m^2}}$, which is called the damped frequency. This frequency is 99.5% of the undamped, so
\begin{eqnarray}
& & 0.995\omega_0 = \sqrt{\omega^2_0 - \frac{1}{4}\frac{b^2}{m^2}}  \\
& & 0.010\omega^2_0 = \frac{1}{4}\frac{b^2}{m^2}  \\
& & b = \sqrt{0.010 \times 4 \frac{k}{m} m^2}   \\
& & b = \sqrt{0.040 km}
\end{eqnarray}
Therefore,
\[
b = 1.789 \ \mathrm{kg/s}
\]

Powered by Hirophysics.com

Friday, February 5, 2016

The bounded solution of a differential equation

Question:
Find the bounded solution of the following ordinary differential equation:
\[ \frac{dx}{dt} = 2x + \sin t \]
for $-\infty < t < \infty$.

Answer:
In order to obtain the general solution, consider
\[ \frac{dx}{dt}-2x_g = 0 \]
Let us put $D \equiv \frac{d}{dt}$ as an operator. Thus, the above will become:
\[ (D - 2)x_g = 0 \]
Thus, we can have
\[ x_g = Ce^{2t} \]
Now, consider the particular solution. Use the operator to express the whole equation.
\[ (D-2)x_p = \sin t \]
$\sin t$ can in general be replaced with exponential function $e^{it}$, and the imaginary part of the final result will be taken.
\begin{eqnarray*}
x_p &=& \frac{1}{D-2}e^{it}   \\
   &=&  \frac{1}{i-2}e^{it}   \\
   &=&  \frac{-1}{2-i}e^{it}  \\
   &=&  \frac{-1}{2-i}\frac{2+i}{2+i}e^{it}  \\
   &=&  \frac{-(2+i)}{4+1}e^{it}  \\
   &=&  \frac{-(2+i)}{5}e^{it}  \\
   &=&  \frac{-2-i}{5}(\cos t + i\sin t)  \\
   &=&   \left(-\frac{2}{5}\cos t + \frac{1}{5}\sin t \right) + i \left(-\frac{1}{5}\cos t - \frac{2}{5}\sin t \right)
\end{eqnarray*}
The particular solution is the imaginary part.
\[ x_p = -\frac{1}{5}\cos t - \frac{2}{5}\sin t \]
The entire solution is
\[ x = Ce^{2t}-\frac{1}{5}\cos t - \frac{2}{5}\sin t \]
The first term makes the solution diverged when $t \rightarrow \pm\infty$. Therefore, the term has to be eliminated. Namely, $C = 0$. The solution bounded is
\[ x = -\frac{1}{5}\cos t - \frac{2}{5}\sin t \]

\Powered by Hirophysics.com