Differential Equation Solver

Solve ordinary differential equations with AI-powered step-by-step solutions

Drag & drop or click to add images or PDF

Math Input
dy/dx = 2xy
y'' + 4y = 0
dy/dx + y/x = x^2
y'' - 3y' + 2y = e^x

What is a Differential Equation?

A differential equation (DE) is an equation that relates a function to its derivatives. An ordinary differential equation (ODE) involves a function of one variable:

F(x,y,y,y,,y(n))=0F\left(x, y, y', y'', \ldots, y^{(n)}\right) = 0

The order of a DE is the highest derivative that appears. The degree is the power of the highest-order derivative (when the equation is polynomial in derivatives).

First-order ODE: y=f(x,y)y' = f(x, y)

Second-order ODE: y+p(x)y+q(x)y=g(x)y'' + p(x)y' + q(x)y = g(x)

A solution is a function y(x)y(x) that satisfies the equation on some interval. The general solution contains arbitrary constants (one per order). An initial value problem (IVP) specifies conditions like y(x0)=y0y(x_0) = y_0 to determine a unique particular solution.

Differential equations model real-world phenomena: population growth, radioactive decay, spring-mass systems, electrical circuits, heat conduction, and fluid flow.

How to Solve Differential Equations

Method 1: Separation of Variables

For equations of the form dydx=f(x)g(y)\frac{dy}{dx} = f(x)g(y):

  1. Separate: dyg(y)=f(x)dx\frac{dy}{g(y)} = f(x)\,dx
  2. Integrate both sides: dyg(y)=f(x)dx\int \frac{dy}{g(y)} = \int f(x)\,dx

Example: dydx=2xy\frac{dy}{dx} = 2xydyy=2xdx\frac{dy}{y} = 2x\,dxlny=x2+C\ln|y| = x^2 + Cy=Aex2y = Ae^{x^2}

Method 2: Integrating Factor (First-Order Linear)

For y+P(x)y=Q(x)y' + P(x)y = Q(x), multiply by the integrating factor μ(x)=eP(x)dx\mu(x) = e^{\int P(x)\,dx}:

ddx[μ(x)y]=μ(x)Q(x)\frac{d}{dx}[\mu(x) \cdot y] = \mu(x) \cdot Q(x)

Then integrate both sides to find yy.

Example: y+2y=exy' + 2y = e^{-x}. Here P(x)=2P(x) = 2, so μ=e2x\mu = e^{2x}. Multiply: (e2xy)=ex(e^{2x}y)' = e^{x}. Integrate: e2xy=ex+Ce^{2x}y = e^x + C, so y=ex+Ce2xy = e^{-x} + Ce^{-2x}.

Method 3: Characteristic Equation (Constant Coefficients)

For ay+by+cy=0ay'' + by' + cy = 0, solve the characteristic equation ar2+br+c=0ar^2 + br + c = 0:

DiscriminantRootsGeneral Solution
b24ac>0b^2 - 4ac > 0r1r2r_1 \neq r_2 (real)y=C1er1x+C2er2xy = C_1 e^{r_1 x} + C_2 e^{r_2 x}
b24ac=0b^2 - 4ac = 0r1=r2=rr_1 = r_2 = ry=(C1+C2x)erxy = (C_1 + C_2 x)e^{rx}
b24ac<0b^2 - 4ac < 0r=α±βir = \alpha \pm \beta iy=eαx(C1cosβx+C2sinβx)y = e^{\alpha x}(C_1 \cos\beta x + C_2 \sin\beta x)

Method 4: Undetermined Coefficients

For ay+by+cy=g(x)ay'' + by' + cy = g(x) where g(x)g(x) is a polynomial, exponential, sine, cosine, or combination:

  1. Find the general solution to the homogeneous equation
  2. Guess a particular solution form based on g(x)g(x)
  3. Substitute and solve for coefficients
  4. General solution = homogeneous + particular

Method 5: Variation of Parameters

A general method for y+p(x)y+q(x)y=g(x)y'' + p(x)y' + q(x)y = g(x) when the homogeneous solutions y1,y2y_1, y_2 are known:

yp=y1y2gWdx+y2y1gWdxy_p = -y_1 \int \frac{y_2 g}{W}\,dx + y_2 \int \frac{y_1 g}{W}\,dx

where W=y1y2y2y1W = y_1 y_2' - y_2 y_1' is the Wronskian.

Comparison of Methods

MethodApplies ToKey Indicator
Separationy=f(x)g(y)y' = f(x)g(y)Variables can be separated
Integrating Factory+P(x)y=Q(x)y' + P(x)y = Q(x)First-order linear
Characteristic Eq.Constant-coefficient homogeneousay+by+cy=0ay'' + by' + cy = 0
Undetermined Coeff.Constant-coeff. with special g(x)g(x)RHS is polynomial/exp/trig
Variation of ParamsAny second-order linearGeneral non-homogeneous

Common Mistakes to Avoid

  • Forgetting the constant of integration: In separation of variables, the constant must be included before solving for yy, as it affects the final form of the solution.
  • Incorrect integrating factor: The integrating factor for y+P(x)y=Q(x)y' + P(x)y = Q(x) is eP(x)dxe^{\int P(x)\,dx}. Make sure the equation is in standard form (coefficient of yy' must be 1) before identifying P(x)P(x).
  • Missing the repeated-root case: When the characteristic equation has a repeated root rr, the second solution is xerxxe^{rx}, not just erxe^{rx} again.
  • Wrong particular solution guess: If your guess for ypy_p is already a solution to the homogeneous equation, multiply by xx (or x2x^2 if needed) to get a valid form.
  • Ignoring initial conditions: The general solution has arbitrary constants. Apply initial conditions only after finding the complete general solution.

Examples

Step 1: Separate variables: dyy=dxx\frac{dy}{y} = \frac{dx}{x}
Step 2: Integrate both sides: lny=lnx+C\ln|y| = \ln|x| + C
Step 3: Exponentiate: y=Axy = Ax where A=eCA = e^C. Apply y(1)=3y(1) = 3: 3=A13 = A \cdot 1, so A=3A = 3
Answer: y=3xy = 3x

Step 1: Write the characteristic equation: r2+4=0r^2 + 4 = 0
Step 2: Solve: r=±2ir = \pm 2i (complex roots with α=0\alpha = 0, β=2\beta = 2)
Step 3: General solution: y=C1cos(2x)+C2sin(2x)y = C_1 \cos(2x) + C_2 \sin(2x)
Answer: y=C1cos(2x)+C2sin(2x)y = C_1 \cos(2x) + C_2 \sin(2x)

Step 1: Identify P(x)=1P(x) = 1, Q(x)=exQ(x) = e^{-x}. Integrating factor: μ=e1dx=ex\mu = e^{\int 1\,dx} = e^x
Step 2: Multiply through: (exy)=exex=1(e^x y)' = e^x \cdot e^{-x} = 1
Step 3: Integrate: exy=x+Ce^x y = x + C, so y=(x+C)exy = (x + C)e^{-x}
Answer: y=(x+C)exy = (x + C)e^{-x}

Frequently Asked Questions

An ordinary differential equation (ODE) involves derivatives with respect to one independent variable. A partial differential equation (PDE) involves partial derivatives with respect to two or more independent variables, such as the heat equation or wave equation.

The order is the highest derivative present in the equation. A first-order DE contains y' but not y'' or higher. A second-order DE contains y'' but not y''' or higher. Higher order means more arbitrary constants in the general solution.

An initial value problem (IVP) is a differential equation together with conditions specifying the value of the solution (and possibly its derivatives) at a particular point. These conditions determine the arbitrary constants, giving a unique particular solution.

No. Most differential equations cannot be solved in closed form. Only special classes have explicit analytical solutions. For others, numerical methods like Euler's method or Runge-Kutta are used to approximate solutions.

Related Solvers

DerivativeIntegralLimitSeries
Try AI-Math for Free

Get step-by-step solutions to any math problem. Upload a photo or type your question.

Start Solving