First-Order Differential Equation Solver: dy/dx + a y = b x + c

Solve a first-order linear differential equation such as dy/dx + y = x, with a starting value, step by step.

Calculated from standard textbook formulas, with every step shown. The formulas are fixed, so the working does not need checking: what matters is the numbers you type in. Use these calculators only if you are competent to choose the inputs (loads, material strength, dimensions, supports) and check your units and assumptions. For learning and checking your own working: design and sign-off are for a qualified engineer. Drafting Central does not store the numbers you type.

How this calculator works

A first-order linear differential equation has the form dy/dx + a y = f(x). The standard method is the integrating factor: multiply both sides by e^(a x) so that the left side becomes the derivative of y e^(a x), then integrate and divide by e^(a x).

The answer is always a particular solution, which follows the right-hand side, plus a constant times e^(-a x), which is the part that dies away if a is positive. The starting value fixes the constant. For dy/dx + y = x with y(0) = 0, the answer is y = x - 1 + e^(-x).

This solver covers a constant a and a right-hand side of the form b x + c, which comes up in cooling, charging circuits, mixing tanks and simple motion with drag. It shows the integrating factor, the particular solution, the constant, the solution and a graph.

Formulas used

  • \mu = e^{ax}
  • y_p = \frac{b}{a}x + \frac{c}{a} - \frac{b}{a^2}
  • y = y_p + D\,e^{-a(x-x_0)}

Worked example

With the default numbers in the calculator above:

  1. The equation and the starting value: dy/dx + 1.00 y = 1.00 x + 0.00
  2. Integrating factor: e^(1.00 x)
  3. A particular solution (the part that follows the right side): y_p = 1.00 x + (-1.00)
  4. Constant from the starting value: 1.00
  5. The solution: y = 1.00 x + (-1.00) + (1.00) e^(-1.00 (x - 0.00))
  6. Time constant of the part that dies away: 1.00
  7. Value of y at the x you chose: 1.14

Change the numbers in the calculator to see the full working, every step, for your own case.

A second worked example

A different case, with these numbers: a (the number multiplying y) 2; b (the number multiplying x on the right) 0; c (the constant on the right) 4; x to find y at 1.

  1. The equation and the starting value: dy/dx + 2.00 y = 0.00 x + 4.00
  2. Integrating factor: e^(2.00 x)
  3. A particular solution (the part that follows the right side): y_p = 0.00 x + (2.00)
  4. Constant from the starting value: -2.00
  5. The solution: y = 0.00 x + (2.00) + (-2.00) e^(-2.00 (x - 0.00))
  6. Time constant of the part that dies away: 0.50
  7. Value of y at the x you chose: 1.73

Common questions

What is an integrating factor?

A function you multiply the whole equation by so that the left side becomes the derivative of a product, which can then be integrated directly.

How do I check the answer?

Differentiate your solution, add a times your solution, and you should get b x + c back. Also check that it gives y0 at x0.

What if a changes with x?

This tool needs a constant a. The integrating factor method still works for a changing a, but the integral is harder.

Related calculators

Got a question about this? Ask an engineering question and get a plain-language answer with references.

Further reading: Any university engineering mathematics text (first-order linear ordinary differential equations); Kreyszig, Advanced Engineering Mathematics.

Need a calculator we do not have?

Tell us what you would like to calculate. We read every request and build the most asked-for ones.

We store your request (and your email if you give it) to decide what to build. We do not store the numbers you type into calculators.

Embed this calculator on your own page

Copy this code into your page. The calculator runs inside the frame and links back to Drafting Central.

Need this drawn, designed or checked?

Drafting Central is a mechanical engineering and drafting business working with customers across Australia and around the world. A calculator gives you the numbers; we can turn them into drawings and designs.

Need help with a real project?

Talk to Drafting Central →

← All engineering calculators