First-order differential equations
Suppose we know how a quantity changes, but not its value at every moment. Can that information help us recover the quantity? The rate of change, the derivative and the notation come from the derivative page; section 01 brings them back in full. A simpler mathematical example will let us see the difficulty. Differentiating gives . We will reverse that question: if we are given , what function could be? Here the unknown is a whole function, not a single number.
We will first solve that small problem and check the answer. Then we will build the calculus tools needed for a rule involving both the input and the unknown function. Only after we have found and checked solutions will we turn their slopes into a field of short lines, and use those lines to understand a numerical approximation.
Find a function, then check it
A function gives an output for each allowed input. Write the input as x and the output as . For , input 2 gives output 4. A derivative tells us a different thing: how the output changes near the current input. We will briefly recover that meaning before reversing the calculation.
Keep an input fixed and move to , where is a nonzero input change. The output changes from to . Expand the product, subtract the old output, and divide by the input change:
This quotient is an average change per unit of input over the interval. As approaches zero from either side, approaches . That limiting local rate is the derivative, written or . The prime and both ask for differentiation with respect to . We never put into the fraction.
Reverse the question
Now suppose only is given. We must find a differentiable function whose derivative equals at every input in the interval being studied. An equation asking for a function through its derivative is a differential equation. Here the highest derivative is the first derivative, so it is first order. There is just one independent input, ; this is what “ordinary” distinguishes from equations involving several independent inputs.
Our calculation already supplies one solution: . But add a constant , a number that stays fixed while changes. The difference of the two new outputs is : the two copies of cancel. The derivative is still . Therefore every function solves the equation. The constant changes the height, not this rate.
Could another kind of solution be missing? Subtract from any solution and call the difference . Its difference quotient is the difference of the two original quotients, so taking their limits gives . A differentiable function with zero derivative throughout an interval is constant there. The argument below explains why this rules out other solutions, rather than relying on a few plotted examples.
Why zero derivative forces a constant
Take any two inputs . Suppose their heights differed, so the slope of their joining line were nonzero. Subtract that line from and call the result . Then . Either is zero throughout, or, being continuous, it has a positive maximum or negative minimum inside. At such an interior turning point the derivative is zero: the difference quotients from the left and right have opposite signs and must have the same limit. In the constant case the derivative is also zero. But everywhere, so it could never be zero if . This contradiction forces . Since the two inputs were arbitrary, is constant throughout the interval.
So the whole family is . To select one member, give a function value as well: means that input 0 must give output 3. Substitution gives , hence . Our answer is . Check both requirements: its derivative is , and its value at 0 is 3. The extra requirement is an initial condition. It specifies a height, not another derivative.
In the graph below, horizontal position is the input x and vertical height is the output y. A line through two graph points has slope equal to its height change divided by its horizontal change: the same difference quotient we calculated. Adding C to every height shifts the curve up or down without changing that quotient. Compare the curves, and turn on the initial condition to see which curve passes through the required point.
Teal is our selected function. Gold joins its two points; its slope is an average over a nonzero interval. Grey keeps the other functions available for comparison.
Change the height, then compare the changes
Keep x and h fixed while changing C. Both endpoint heights move by the same amount, so their difference stays the same.
A smaller nonzero h brings the gold secant slope closer to 2x. The derivative is the limiting value derived in the text, not the finite secant value.
Three tools from calculus
Our next equation will involve the value of the unknown function as well as its derivative. Before using any new calculus rule, we will build it from changes that we can write down. Keep the distinction in view: a derivative gives a local rate; an antiderivative reverses differentiation.
1 · Undoing a derivative
If , we call an antiderivative of , and write . For example , so . The constant is there because adding a constant to a function does not change its slope. The key fact we will use is the reverse: if two functions have the same derivative everywhere on an interval, they differ by a constant there.
Our next target is . Unlike , its right side still contains the unknown value . Dividing by a nonzero would give . We therefore need to recognise the derivative of an expression built from itself. Putting the output of one function into another is called composition. For example, if and , then : the output becomes the input of the squaring rule.
In the notation for an antiderivative, the integral sign asks us to reverse differentiation. The tells us which input variable is being used. For example, the derivative of with respect to is , so its reverse calculation gives plus an arbitrary constant. A different input name, such as , would be accompanied by instead.
2 · The chain rule
If a function is applied to , then when changes, changes only because changes. Its slope is the slope of at the current , times the slope of :
Check it on a case we can expand: with and , expanding gives , whose derivative is ; the chain rule gives , the same. The factor , here , is the part that will matter most.
Why the chain rule also works when an inner change is zero
The derivative definition says that a difference quotient approaches a fixed value. Write the difference between the quotient and its limit as r. Then the quotient equals the derivative plus r, and r tends to zero. Multiplying by the input change writes the output change as a linear part plus a smaller error. We apply this to each of the two functions: the output change of the inner one is the input change of the outer one.
Why do the two rates multiply? Write the small input change as and the resulting change in as . Differentiability means , where tends to zero. Likewise, the change in is , where tends to zero; set . Divide this latter expression by the nonzero . Since tends to and stays bounded, the extra product tends to zero. What remains is . This also covers without ever dividing by .
3 · Build the logarithm and its inverse
For , the chain rule asks for a function whose derivative at is . We can construct one for positive by accumulated signed area. Starting at 1, record the area under the positive curve up to . If , use the negative of the area from to 1, so moving backwards reverses the change. Call this function ; it has .
If the endpoint moves from to , the added area is a thin strip. Area divided by its signed width lies between the smallest and largest heights of on that strip. These are and . As , both approach , so . This area function is the natural logarithm, written . Its definition is not a rule we guessed to fit the equation; the thin-strip calculation explains its derivative.
Read the horizontal coordinate as u and the height as 1/u. Teal marks the area between 1 and z. Gold marks the small strip between z and z + δ.
Watch the two bounding heights meet
Moving right adds area and has positive width. Area divided by width is an average height between the two endpoint heights.
L(z) records the area accumulated from 1 to the endpoint. Changing δ inspects its rate at z without changing that starting reference.
We also need to undo the logarithm. First see why it is possible. Its value increases strictly: moving to a larger endpoint adds a region of positive area. For positive fixed , the chain rule gives , the same derivative with respect to as . Their difference is therefore constant in . At , the difference is , proving .
Repeated use gives . Taking and gives , hence . The area from 1 to 2 is positive, so . Increasing the positive integer makes these values grow without bound in either direction. Continuity and strict increase therefore give exactly one positive input for every real output . Call that input : by definition .
The addition rule for logarithms gives , hence . Also . If we name by the letter , then repeated multiplication gives for integers. We write and call it the exponential. Thus for , and .
To find its derivative, let and change by a nonzero amount . The quotient approaches ; taking the reciprocal shows . Therefore . For an inner function , the chain rule now gives the formula below.
Finally, our later solution might be negative. For , its absolute value is , so the logarithm can be applied to . The chain rule gives . Thus for every . Zero stays excluded because neither division by zero nor its logarithm is defined.
Separating the variables
Now we solve with exactly. The plan is to rearrange the equation until each side is the derivative of something we know, then use tool 1. We go step by step.
Step 1 · Look for constant solutions first
We are about to divide by , and dividing by zero is not allowed, so first ask: is a solution? The constant function has slope , and the rule gives . Both sides agree, so is a solution. Write it down now, because the division in the next step would silently lose it.
Step 2 · Divide by where is not zero
Step 3 · Recognise the left side as a derivative
Use the function , whose derivative is for . Put into it. The chain rule says that the derivative of is , exactly our left side. The right side, , is the derivative of . So the equation says that two functions have the same derivative:
Step 4 · Undo the derivative
By tool 1, two functions with the same derivative differ by a constant, which we call :
Step 5 · Undo the logarithm
Apply the exponential to both sides and use :
Step 6 · Remove the absolute value and put back
is either or . It cannot jump from one to the other, because a continuous function would have to pass through on the way, and we are working where is not zero. So , where stands for , any number except . Allowing as well brings back the solution from step 1. These solutions can be written together as
Here can be any real number, including zero.
Step 7 · Use the initial condition
Put : , and we want , so and .
Step 8 · Check
Differentiate with tool 3: , so the rule holds; and , so the starting value holds. Both checks are needed: one tests the slope rule, the other the starting point.
You will often see steps 2 to 4 written in a shorthand: “, integrate both sides, .” This is a compressed record of what we just did, not a new rule. The left side was integrated with respect to like the right side; the chain rule is what lets it be written in terms of . Whenever the shorthand looks mysterious, go back to step 3.
An equation is called separable because its right side splits into a function of and a function of . On an interval where stays nonzero and the functions being integrated are continuous, divide to get . Choose antiderivatives and . The chain rule then gives . This is already a relation describing the solution; isolate when possible, then use the initial condition and check. Constant values with must be checked in the original equation separately.
Making a product
Now take . As a slope rule, : below height the slope is positive, above it negative, and at the graph stays level. We could separate the variables again, but we use it to learn a second method that also works when separation fails: equations of the form , called linear first-order equations, because and appear only to the first power.
We want a derivative we can undo. A product may help, so first work out its derivative. Write and . Expanding the new product gives . Divide by and let tend to zero. The first two terms tend to and . The last is , which tends to zero because and . Thus . Our equation contains the same two kinds of term. Can a multiplier make its left side exactly this product derivative?
Multiply the whole equation by : . For the left side to be we need . The function does it, since by tool 3. It is never zero, so multiplying by it loses no solutions. Now follow the steps:
The third step undoes the derivative: has derivative , so the two sides differ by a constant . The last step divides by . With : , so and . Check: and . The case is the level solution . In the model, the left graph shows and the right graph the product : whatever the starting height, every curve has the same slope at a given , so they differ only by constants, exactly as the third step says.
The original height
The new height
The decimal values are rounded to three places. The symbolic equalities keep the exact cancellation visible.
Move the initial height while keeping fixed. The two separate terms change, but their sum stays . The cancellation is . Both plots use the exact formula derived above; the picture illustrates this equality, while the product-rule calculation proves it.
Now let and be given continuous functions on the interval of interest, in the equation . Matching the product rule requires . Choose an antiderivative and set . The chain rule gives , exactly what we need, and is positive. This multiplier is called an integrating factor. Multiplying the equation gives . Reverse differentiation and divide by the nonzero to obtain:
Return now to the earlier equation . We can check that no solution crosses zero and then leaves it. Differentiate the product : its derivative is by the equation. The product must be a single constant throughout the interval, including any zeros. Thus really is the complete family here. The product rule just derived makes this check valid even at a zero of y.
More examples
Solve with . Because is not defined at and our starting point has , we work only with . Here , so and the integrating factor is . Multiplying by gives , and the left side is by the product rule. Undo the derivative, using , and divide by :
At : , so and . Check: and ; adding, the fractions with cancel and leave . At the solution is .
Try these
First, solve with . Second, solve with . For each, check both the equation and the starting value, then open the answer.
Answer to the first: separate the variables
Step 1: is a solution. Steps 2 to 4: , so , because . Steps 5 and 6: for any . Step 7: , so . Step 8: and . A negative answer is fine: the sign was kept in .
Answer to the second: an integrating factor
Here , so and the factor is . Multiplying: , that is . Undoing the derivative: , so . From : , so and . Check: and .
In the exact methods, we rearranged the equation into the derivative of an expression we could recognise, then reversed differentiation. The chain rule justified separation and the product rule justified the integrating factor. Next we will return to a solution we already know, inspect its local slopes, and ask how to construct an approximate path directly from those slopes.
A rule for the slope
We have solved and checked . Now return to the same equation with a different question: what does it tell us about the direction of a solution at one point? No new solution method is needed to read that local information.
Read it as a rule for the slope. At any point of the graph we are looking for, the slope must equal times times . We can use the rule at a point without knowing the graph: at the slope must be ; at it must be ; anywhere on the line it must be . An equation like this, linking an unknown function with its derivative, is called a differential equation. Ours contains only the first derivative, so it is first order.
Move the point in the model and watch its short slope line. Then switch on the slopes at other points: the whole picture of little lines is called a slope field. A solution is a curve that is tangent to the little line at every point it passes through.
We already found . For a chosen point , substitute it: . The exponential is positive, so division is allowed and . Therefore the solution through that point is . This is why the model can draw a whole curve after we select a point. It is using our derived solution, not guessing a curve from thirteen dots.
Gold: and the short line with the required slope. Teal: recorded points and the formula-based solution. Grey dashes, when shown, give the required slope at other points.
Choose a starting point
Keep fixed. Move using the two sliders, then calculate its required slope. Each change clears the old recorded curve.
The triangle belongs to the tangent line: for a horizontal change of 0.2 its vertical change is 0.2m. The actual curved solution need not have that exact finite change.
Notice that many curves fit the slope field, one through each starting point. To pick one, we also give a starting value, for example : the curve must pass through the point . Such a starting value is called an initial condition. It gives a height at one , not another slope.
Following the slopes
We have an exact answer for through : . Keep it as a comparison while we try another construction using only the rule. At the slope is . Along that point's tangent line, a horizontal step leaves the height at 1. At the new, approximate point the rule gives slope . A second step raises the height by , giving 1.08. We have replaced a changing slope over each interval by its value at the interval's start:
Take one step at a time and compare the approximate point with the exact height at the same input. This is Euler’s method, a basic numerical method. For this example and these positive steps, reducing the step gives a closer approximation over the displayed interval. That observation is not a promise for every equation or step size. More accurate numerical methods also exist. The point here is to see precisely which approximation one Euler step makes.
Teal: the path made of straight steps, each with the slope the rule gives at its starting point. Grey: the exact solution , which we have already derived.
Walk along the slopes
Here “start” means the approximate point at the beginning of the latest step, and “new” means its endpoint. Decimal readouts are rounded to three places; the calculation keeps the unrounded values.
At the current input, compare the Euler height with the exact height:
Subtract the Euler height from the exact height at that same input:
