Lesson 6.2.1 found two basic solutions y1 and y2 of each equation ay′′+by′+cy=0. For y′′+5y′+4y=0 they are e−t and e−4t.
Any combination of them is also a solution. Substitute y=c1y1+c2y2: each derivative splits the same way, so the left side becomes c1 times what y1 gives plus c2 times what y2 gives.
Both are 0, so the sum is 0. For example, 2e−t−3e−4t solves y′′+5y′+4y=0.
Rule: The general solution
y=c1y1+c2y2c1,c2 any numbers
Here y1 and y2 are the two basic solutions of lesson 6.2.1. Every solution of the equation has this form, so the two constants are all that is left to choose.
In the words of lesson 3.5.1, the solutions are the span of y1 and y2: a set with two dimensions, one for each constant. The pair must be independent. e−t and 3e−t are multiples of each other, and their combinations never give e−4t.
For each case of lesson 6.2.1, the general solution reads:
roots
general solution
two real, r1 and r2
c1er1t+c2er2t
repeated, r0
(c1+c2t)er0t
complex, α±iω
eαt(c1cosωt+c2sinωt)
Try it
SymPy substitutes 2e−t−3e−4t into y′′+5y′+4y, then the combination with letters c1 and c2. Both give 0.
⌘/Ctrl + Enter runs the cell
Initial conditions: a 2 × 2 system
An initial-value problem gives the starting value and slope, y(0)=y0 and y′(0)=v0. Each condition is one linear equation in c1 and c2.
Example 1. Solve y′′+5y′+4y=0 with y(0)=1 and y′(0)=0. The general solution is y=c1e−t+c2e−4t, with slope y′=−c1e−t−4c2e−4t. At t=0:
c1+c2−c1−4c2=1=0
Adding the two equations gives −3c2=1, so c2=−31 and c1=34. The solution is y=34e−t−31e−4t. It starts at 1, flat, and falls towards 0:
t
0
0.5
1
2
3
y
1
0.763596
0.484401
0.180335
0.066381
Rule: Initial conditions
c1y1(0)+c2y2(0)=y0c1y1′(0)+c2y2′(0)=v0
A 2 × 2 system for c1 and c2. Its matrix has each basic solution's value and slope at 0 as a column. For the pairs of lesson 6.2.1 its determinant is never 0, so every y0 and v0 give exactly one solution.
In Example 1 the matrix is (1−11−4), with determinant −4+1=−3 (lesson 3.4.1). That the solution exists and is unique is a theorem about these equations; this lesson takes it as given.
Example 2. Solve y′′+2y′+5y=0 with y(0)=1 and y′(0)=0. The general solution is y=e−t(c1cos2t+c2sin2t), so y(0)=c1=1.
The slope needs the product rule (lesson 2.3.2): at t=0 it is y′(0)=−c1+2c2, where −c1 comes from the factor e−t. Setting it to 0 gives c2=21, so
y=e−t(cos2t+21sin2t)
This is the curve lesson 6.2.1's explorer draws for b=2 and c=5. At t=1 it is 0.014164, just above 0, and at t=2 it is −0.139672.
Try it
np.linalg.solve (lesson 3.3.1) finds c1 and c2 for Example 1, and np.linalg.det gives the determinant.
The formula is then compared with solve_ivp, using v=y′ as in lesson 6.2.1. The last lines solve Example 2's system.
⌘/Ctrl + Enter runs the cell
Boundary conditions: two points
A boundary-value problem gives conditions at two different points instead, such as y(0)=A and y(L)=B. They still give two linear equations in c1 and c2. The difference is that the system can fail.
Example 3: one solution. Solve y′′−y=0 with y(0)=0 and y(1)=1. The roots are ±1, so y=c1et+c2e−t, and the conditions read
c1+c2c1e+c2e−1=0=1
So c2=−c1 and c1(e−e−1)=1. Since e−e−1=2.350402, c1=0.425459. The solution passes y(0.5)=0.443409 and starts with slope y′(0)=0.850918.
Example 4: none, or infinitely many. Take y′′+y=0 with y(0)=0. The general solution is c1cost+c2sint, and y(0)=0 forces c1=0. So the candidates are c2sint, and the second condition decides.
y(2π)=1:c2sin2π=c2=1. One solution, y=sint.
y(π)=1:c2sinπ=0 for every c2, never 1. No solution.
y(π)=0: every c2 works. Infinitely many solutions, y=c2sint.
The solutions of y′′+y=0 with y(0)=0. On [0,2π] each end height is reached by exactly one curve. On [0,π] they all meet again at 0, so y(π)=0 has infinitely many solutions and y(π)=1 has none.
The 2 × 2 matrix explains it. For y(0)=A and y(L)=B it is (1cosL0sinL), with determinant sinL. When L is a multiple of π, the determinant is 0: lesson 3.3.2's rank test then gives none or infinitely many, depending on B.
The two conditions give a 2 × 2 system for c1 and c2. If its determinant is not 0 there is exactly one solution; if it is 0, lesson 3.3.2 decides between none and infinitely many.
Try it
The first lines solve Example 3's system and print c1, c2, y(0.5) and y′(0).
Then Example 4's matrix: its determinant sinL for L=2π and π, rounded so that a tiny sinπ shows as 0. The ranks of A and of [A∣b] (lesson 3.3.2) follow, for B=1 and B=0.
⌘/Ctrl + Enter runs the cell
With B=1 the ranks are 1 and 2, so there is no solution. With B=0 both are 1, below the two unknowns, so there are infinitely many.
A condition at infinity
On a half-line t≥0, the second condition can be about the far end. Solve y′′−y=0 with y(0)=1 and ybounded: it stays between two fixed numbers as t→∞.
The general solution is c1et+c2e−t. Any c1=0 makes y grow without bound, so c1=0, and y(0)=1 gives c2=1: the solution is e−t.
The equidimensional equation
Some equations have coefficients that change, in a pattern that keeps them easy. In the equidimensional equation
ax2y′′+bxy′+cy=0for x>0
each derivative is multiplied by the power of x that matches its order.
If x is in metres, y′′ is in units of y per metre squared. So x2y′′ is in units of y, like xy′ and y. Every term has the same units: hence the name.
The exponential trial of lesson 6.2.1 fails here, but a power works. For y=xp, the power rule (lesson 2.3.1) gives xy′=pxp and x2y′′=p(p−1)xp. Every term carries xp:
[ap(p−1)+bp+c]xp=0
Rule: Equidimensional equations
ax2y′′+bxy′+cy=0has the solution y=xpwhen ap(p−1)+bp+c=0
The equation for p has p(p−1) where lesson 6.2.1 had r2. With two real roots p1 and p2, the general solution is c1xp1+c2xp2, for x>0.
Example 5. For x2y′′+2xy′−2y=0, the equation for p is p(p−1)+2p−2=p2+p−2=0. A table of trial powers finds its roots:
p
−3
−2
−1
0
1
2
p(p−1)+2p−2
4
0
−2
−2
0
4
The algebra agrees: p2+p−2=(p−1)(p+2), so p=1 or p=−2. The general solution is y=c1x+c2x−2.
Now add conditions: y(1)=3, and y bounded as x→∞. The term c1x grows, so c1=0. Then y(1)=c2=3, and y=3x−2, so y(2)=0.75.
Repeated and complex powers
Put x=es, so that s=lnx. By the chain rule (lesson 2.3.3), the equation becomes a constant-coefficient equation in s, with the equation for p as its characteristic equation. Then xp=eps, and lesson 6.2.1's other two cases carry over:
A repeated root p0 gives xp0 and xp0lnx. For x2y′′−xy′+y=0, p(p−1)−p+1=(p−1)2, so the solutions are x and xlnx.
Complex roots α±iω give xαcos(ωlnx) and xαsin(ωlnx). For x2y′′+xy′+y=0, p2+1=0, and the solutions are cos(lnx) and sin(lnx).
Case study 6.4.4 uses the same change of variable on a harder equation.
Try it
The list is Example 5's table, and np.roots solves p2+p−2=0.
SymPy then substitutes x, x−2 and 3x−2 into Example 5, and xlnx and cos(lnx) into their equations. positive=True tells SymPy that x>0.
⌘/Ctrl + Enter runs the cell
Solving a boundary-value problem numerically
solve_ivp needs a starting value and a starting slope. A boundary-value problem gives a starting value and an end value instead. Shooting turns one into the other: guess the slope, solve forward, and see where the end lands.
For Example 3, start at y(0)=0 with slope s. A slope of 0.4 lands at y(1)=0.47, and a slope of 1.3 at 1.53: too low, then too high. Between them, brentq (lesson 1.3.2) finds the slope that lands on 1.
Each starting slope gives a different end height. The slope 0.8509 lands on the target y(1)=1, as the exact slope y′(0)=0.850918 of Example 3 says.
Rule: Shooting
start at y(0)=A,y′(0)=ssolve forward to Lchoose s so that y(L)=B
Each guess of s costs one run of solve_ivp. Finding s is a root-finding problem for the miss y(L)−B.
SciPy also has a ready-made solver, solve_bvp. It takes the equation as a pair (y,v) with v=y′, the two conditions as a function, and a first guess on a grid of points.
Try it
land(s) shoots from slope s and returns y(1). brentq finds the slope whose miss is 0 between 0 and 2, and the shot from it passes y(0.5)=0.443409, as Example 3 found.
solve_bvp gets the same numbers. Its bc returns how far each end is from its condition: y(0)−0 and y(1)−1.
⌘/Ctrl + Enter runs the cell
Lesson 6.2.3 practises both lessons of this module. Case study 6.2.4 puts the equidimensional equation and a condition at infinity together to value a put.
Common mistakes
Two conditions need both constants.y=c1e−t alone cannot meet y(0)=1 and y′(0)=0: it would need c1=1 and c1=0.
Differentiate the whole combination. For e−t(c1cos2t+c2sin2t), y′(0)=−c1+2c2, not 2c2.
The pair must be independent.c1e−t+c2⋅3e−t is only a multiple of e−t; its matrix has determinant 0.
A boundary-value problem may have no solution, or many.y′′+y=0 with y(0)=0 and y(π)=1 has none.
Bounded removes the growing part. On t≥0 it removes et; on x≥1 it removes positive powers such as x.
Use p(p−1), not p2. For x2y′′−6y=0 the equation is p(p−1)−6=0, with roots 3 and −2, not p2−6=0.
Powers need x>0.x−2 and xlnx are solutions on x>0; at x=0 the equation's leading coefficient ax2 is 0.
General solutions and boundary conditions
0 of 12 correct
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
How to type answers
Powers with ^: x^7, 2^(1/3), a^-2.
Multiply with * or by writing side by side: 3x^2, 2(x+1).
ln(x) is the natural log, log(x, 2) is log base 2, e is Euler's number, sqrt(x) is a square root.
sin(x), cos(x) and tan(x) take radians; write pi for π and sin(x)^2 for sin²x.
Your first answer to each question is saved: it counts towards your score and brings the question back for review.
Exact answers like ln(20)/ln(3) are best. Decimals need about 4 significant figures.
Summary card
If y1 and y2 are the two basic solutions of ay′′+by′+cy=0, the general solution is c1y1+c2y2: their span.
Initial conditions y(0)=y0, y′(0)=v0 give a 2 × 2 system for c1 and c2. Its determinant is never 0, so there is exactly one solution.
Boundary conditions y(0)=A, y(L)=B also give a 2 × 2 system, but it can have one solution, none or infinitely many. y′′+y=0 with y(0)=0 fails at L=π.
A condition "bounded as t→∞" removes the growing solution.
ax2y′′+bxy′+cy=0 for x>0: y=xp works when ap(p−1)+bp+c=0. A repeated root p0 adds xp0lnx.
Shooting finds the starting slope that hits the far condition, with solve_ivp and brentq; solve_bvp solves the problem directly.