#set document(title: "1.4 Linear equations and the integrating factor", author: "Jiří Lebl") #set page(width: 8.5in, height: auto, margin: 1in) #import "@preview/cetz:0.5.2" #set text(font: ("STIX Two Text", "Libertinus Serif", "New Computer Modern"), size: 10.5pt, lang: "en") #show math.equation: set text(font: ("STIX Two Math", "New Computer Modern Math")) #set par(justify: true, leading: 0.62em, spacing: 0.9em) #set enum(spacing: 1.1em) // room between list items so tall inline fractions don't collide #set list(spacing: 1.1em) #set table(stroke: 0.5pt + rgb("#c7ccd3")) #let BLUE = rgb("#183B6F") // brand navy — section bars + example/solution labels (white on navy 11.09:1) #let ORANGE = rgb("#A94509") // brand primary-700 — AA-safe deep orange for TEXT (5.93:1 on white; raw brand #F37021 is 2.94:1 and must never carry text) #let RED = rgb("#DC2626") // brand error-600 #let GREEN = rgb("#059669") // brand success-600 (decoration only; small green text uses green-text #007942) #show heading.where(level: 1): it => block(width: 100%, above: 0pt, below: 16pt, fill: gradient.linear(BLUE, rgb("#2C5AA0")), inset: (x: 14pt, y: 12pt), radius: 3pt, text(fill: white, weight: "bold", size: 19pt, it.body)) #show heading.where(level: 2): it => block(width: 100%, above: 18pt, below: 10pt, fill: BLUE, inset: (x: 10pt, y: 6pt), radius: 2pt, text(fill: white, weight: "bold", size: 12pt, it.body)) #show heading.where(level: 3): it => text(fill: ORANGE, weight: "bold", size: 12.5pt, it.body) #show heading.where(level: 4): it => text(fill: BLUE, weight: "bold", size: 10.5pt, it.body) #let examplebox(label, title, body) = block(width: 100%, breakable: true, fill: rgb("#EFF1F5"), stroke: 0.5pt + rgb("#CFDDF0"), radius: 4pt, inset: 10pt, above: 12pt, below: 12pt)[ #block(below: 6pt)[#box(fill: BLUE, inset: (x: 6pt, y: 2pt), radius: 2pt, text(fill: white, weight: "bold", size: 8.5pt, label)) #h(0.4em) #strong[#title]] #body] // rail = decorative left rule (raw brand token); labelcolor = AA-safe label text shade #let notebox(label, rail, labelcolor, tint, body) = block(width: 100%, breakable: true, fill: tint, stroke: (left: 3pt + rail), inset: (left: 10pt, rest: 8pt), radius: (right: 4pt), above: 11pt, below: 11pt)[ #text(fill: labelcolor, weight: "bold", size: 7.5pt, tracking: 0.5pt)[#upper(label)] #linebreak() #body] #let solutionbox(body) = block(above: 4pt, below: 8pt)[ #text(fill: BLUE, weight: "bold", size: 8.5pt)[Solution] #linebreak() #body] #let figph(msg) = block(width: 100%, height: 60pt, fill: rgb("#f6f7f9"), stroke: (paint: rgb("#c7ccd3"), dash: "dashed"), radius: 4pt, inset: 10pt)[ #align(center + horizon, text(fill: rgb("#889"), style: "italic", size: 9pt, msg))] // Standardize inlined figure sizes: measure the natural CeTZ canvas, then scale to a // consistent envelope (aspect-aware; see build_typst.py FIG_* constants). Unlike the // print preamble, dimensions are FLOORED: in an editor a user can trim a figure to a // degenerate 1-D shape (a bare line), and w/h or tw/w would then divide by zero. #let _STD_W = 3.5 #let _WIDE_W = 5.6 #let _MAX_H = 3.4 #let _ASPECT_WIDE = 2.2 #let _UPSCALE_MAX = 1.15 #let stdfig(body) = context { let m = measure(body) let w = calc.max(m.width / 1in, 0.01) let h = calc.max(m.height / 1in, 0.01) let tw = if w / h > _ASPECT_WIDE { _WIDE_W } else { _STD_W } let s = calc.min(tw / w, _MAX_H / h, _UPSCALE_MAX) align(center, box(scale(x: s * 100%, y: s * 100%, reflow: true, body))) } #show figure: set block(breakable: false) #set figure(gap: 8pt) #show figure.caption: set text(size: 8.5pt, fill: rgb("#555")) == 1.4#h(0.6em)Linear equations and the integrating factor One of the most important types of equations we will learn how to solve are the so-called linear equations. In fact, the majority of the course is about linear equations. In this lecture we focus on the first order linear equation. A first order equation is linear if we can put it into the form: #math.equation(block: true, alt: "y prime plus p open parenthesis x close parenthesis y equals f open parenthesis x close parenthesis .")[$y^(′) + p ( x ) y = f ( x ) .$] Here the word “linear” means linear in #math.equation(block: false, alt: "y")[$y$] and #math.equation(block: false, alt: "y prime")[$y^(′)$]; no higher powers nor functions of #math.equation(block: false, alt: "y")[$y$] or #math.equation(block: false, alt: "y prime")[$y^(′)$] appear. The dependence on #math.equation(block: false, alt: "x")[$x$] can be more complicated. Solutions of linear equations have nice properties. For example, the solution exists wherever #math.equation(block: false, alt: "p open parenthesis x close parenthesis")[$p ( x )$] and #math.equation(block: false, alt: "f open parenthesis x close parenthesis")[$f ( x )$] are defined, and has the same regularity (read: it is just as nice). But most importantly for us right now, there is a method for solving linear first order equations. The trick is to rewrite the left hand side of (1.4.1) as a derivative of a product of #math.equation(block: false, alt: "y")[$y$] with another function. To this end we find a function #math.equation(block: false, alt: "r open parenthesis x close parenthesis")[$r ( x )$] such that #math.equation(block: true, alt: "r open parenthesis x close parenthesis y prime plus r open parenthesis x close parenthesis p open parenthesis x close parenthesis y equals the fraction d over d x [ r open parenthesis x close parenthesis y ]")[$r ( x ) y^(′) + r ( x ) p ( x ) y = frac(d, d x) [ r ( x ) y ]$] This is the left hand side of (1.4.1) multiplied by #math.equation(block: false, alt: "r open parenthesis x close parenthesis")[$r ( x )$]. So if we multiply (1.4.1) by #math.equation(block: false, alt: "r open parenthesis x close parenthesis")[$r ( x )$], we obtain #math.equation(block: true, alt: "the fraction d over d x [ r open parenthesis x close parenthesis y ] equals r open parenthesis x close parenthesis f open parenthesis x close parenthesis")[$frac(d, d x) [ r ( x ) y ] = r ( x ) f ( x )$] Now we integrate both sides. The right hand side does not depend on #math.equation(block: false, alt: "y")[$y$] and the left hand side is written as a derivative of a function. Afterwards, we solve for#math.equation(block: false, alt: "y")[$y$]. The function #math.equation(block: false, alt: "r open parenthesis x close parenthesis")[$r ( x )$] is called the integrating factor and the method is called the integrating factor method. We are looking for a function #math.equation(block: false, alt: "r open parenthesis x close parenthesis")[$r ( x )$], such that if we differentiate it, we get the same function back multiplied by #math.equation(block: false, alt: "p open parenthesis x close parenthesis")[$p ( x )$]. That seems like a job for the exponential function! Let #math.equation(block: true, alt: "r open parenthesis x close parenthesis equals e to the power ∫ p open parenthesis x close parenthesis d x")[$r ( x ) = e^(∫ p ( x ) d x)$] We compute: #math.equation(block: true, alt: "y prime plus p open parenthesis x close parenthesis y equals f open parenthesis x close parenthesis ,; e to the power ∫ p open parenthesis x close parenthesis d x y prime plus e to the power ∫ p open parenthesis x close parenthesis d x p open parenthesis x close parenthesis y equals e to the power ∫ p open parenthesis x close parenthesis d x f open parenthesis x close parenthesis ,; the fraction d over d x [ e to the power ∫ p open parenthesis x close parenthesis d x y ] equals e to the power ∫ p open parenthesis x close parenthesis d x f open parenthesis x close parenthesis ,; e to the power ∫ p open parenthesis x close parenthesis d x y equals ∫ e to the power ∫ p open parenthesis x close parenthesis d x f open parenthesis x close parenthesis d x plus C ,; y equals e to the power minus ∫")[$y^(′) + p ( x ) y = f ( x ) , \ e^(∫ p ( x ) d x) y^(′) + e^(∫ p ( x ) d x) p ( x ) y = e^(∫ p ( x ) d x) f ( x ) , \ frac(d, d x) [ e^(∫ p ( x ) d x) y ] = e^(∫ p ( x ) d x) f ( x ) , \ e^(∫ p ( x ) d x) y = ∫ e^(∫ p ( x ) d x) f ( x ) d x + C , \ y = e^(− ∫ p ( x ) d x) ( ∫ e^(∫ p ( x ) d x) f ( x ) d x + C ) .$] Of course, to get a closed form formula for #math.equation(block: false, alt: "y")[$y$], we need to be able to find a closed form formula for the integrals appearing above. #examplebox("Example 1")[][ Solve #math.equation(block: true, alt: "y prime plus 2 x y equals e to the power x minus x squared , y open parenthesis 0 close parenthesis equals minus 1")[$y^(′) + 2 x y = e^(x − x^(2)) , #h(1em) y ( 0 ) = − 1$] #solutionbox[ First note that #math.equation(block: false, alt: "p open parenthesis x close parenthesis equals 2 x")[$p ( x ) = 2 x$] and #math.equation(block: false, alt: "f open parenthesis x close parenthesis equals e to the power x minus x squared")[$f ( x ) = e^(x − x^(2))$]. The integrating factor is #math.equation(block: false, alt: "r open parenthesis x close parenthesis equals e to the power ∫ p open parenthesis x close parenthesis d x equals e to the power x squared")[$r ( x ) = e^(∫ p ( x ) d x) = e^(x^(2))$]. We multiply both sides of the equation by #math.equation(block: false, alt: "r open parenthesis x close parenthesis")[$r ( x )$] to get #math.equation(block: true, alt: "e to the power x squared y prime plus 2 x e to the power x squared y equals e to the power x minus x squared e to the power x squared ,; the fraction d over d x [ e to the power x squared y ] equals e to the power x .")[$e^(x^(2)) y^(′) + 2 x e^(x^(2)) y = e^(x − x^(2)) e^(x^(2)) , \ frac(d, d x) [ e^(x^(2)) y ] = e^(x) .$] We integrate #math.equation(block: true, alt: "e to the power x squared y equals e to the power x plus C ,; y equals e to the power x minus x squared plus C e to the power minus x squared .")[$e^(x^(2)) y = e^(x) + C , \ y = e^(x − x^(2)) + C e^(− x^(2)) .$] Next, we solve for the initial condition #math.equation(block: false, alt: "minus 1 equals y open parenthesis 0 close parenthesis equals 1 plus C")[$− 1 = y ( 0 ) = 1 + C$], so #math.equation(block: false, alt: "C equals minus 2")[$C = − 2$]. The solution is #math.equation(block: true, alt: "y equals e to the power x minus x squared minus 2 e to the power minus x squared .")[$y = e^(x − x^(2)) − 2 e^(− x^(2)) .$] Note that we do not care which antiderivative we take when computing #math.equation(block: false, alt: "e to the power ∫ p open parenthesis x close parenthesis d x")[$e^(∫ p ( x ) d x)$]. You can always add a constant of integration, but those constants will not matter in the end. ] ] #notebox("Your Turn", rgb("#8a94a6"), rgb("#556666"), rgb("#f7f8fa"))[ Try it! Add a constant of integration to the integral in the integrating factor and show that the solution you get in the end is the same as what we got above. An advice: Do not try to remember the formula itself, that is way too hard. It is easier to remember the process and repeat it. ] Since we cannot always evaluate the integrals in closed form, it is useful to know how to write the solution in definite integral form. A definite integral is something that you can plug into a computer or a calculator. Suppose we are given#math.equation(block: true, alt: "y prime plus p open parenthesis x close parenthesis y equals f open parenthesis x close parenthesis , y open parenthesis x sub 0 close parenthesis equals y sub 0")[$y^(′) + p ( x ) y = f ( x ) , #h(1em) y ( x_(0) ) = y_(0)$]. Look at the solution and write the integrals as definite integrals.#math.equation(block: true, alt: "y open parenthesis x close parenthesis equals e to the power ∫ minus x sub 0 x p open parenthesis s close parenthesis d s open parenthesis ∫ x sub 0 x e to the power ∫ x sub 0 t p open parenthesis s close parenthesis d s f open parenthesis t close parenthesis d t plus y sub 0 close parenthesis")[$y ( x ) = e^(∫ − x_(0) x p ( s ) d s) ( ∫_(x_(0))^(x) e^(∫_(x_(0))^(t) p ( s ) d s) f ( t ) d t + y_(0) )$]You should be careful to properly use dummy variables here. If you now plug such a formula into a computer or a calculator, it will be happy to give you numerical answers. #notebox("Your Turn", rgb("#8a94a6"), rgb("#556666"), rgb("#f7f8fa"))[ Check that #math.equation(block: false, alt: "y open parenthesis x sub 0 close parenthesis equals y sub 0")[$y ( x_(0) ) = y_(0)$] in formula (1.4.2). ] #notebox("Your Turn", rgb("#8a94a6"), rgb("#556666"), rgb("#f7f8fa"))[ Write the solution of the following problem as a definite integral, but try to simplify as far as you can. You will not be able to find the solution in closed form. #math.equation(block: true, alt: "y prime plus y equals e to the power x squared minus x , y open parenthesis 0 close parenthesis equals 10")[$y^(′) + y = e^(x^(2) − x) , #h(1em) y ( 0 ) = 10$] ] #notebox("Note", rgb("#8a94a6"), rgb("#556666"), rgb("#f7f8fa"))[ #emph[Note] Before we move on, we should note some interesting properties of linear equations. First, for the linear initial value problem #math.equation(block: false, alt: "y prime plus p open parenthesis x close parenthesis y equals f open parenthesis x close parenthesis")[$y^(′) + p ( x ) y = f ( x )$], #math.equation(block: false, alt: "y open parenthesis x sub 0 close parenthesis equals y sub 0")[$y ( x_(0) ) = y_(0)$], there is always an explicit formula (1.4.2) for the solution. Second, it follows from the formula (1.4.2) that if #math.equation(block: false, alt: "p open parenthesis x close parenthesis")[$p ( x )$] and #math.equation(block: false, alt: "f open parenthesis x close parenthesis")[$f ( x )$] are continuous on some interval #math.equation(block: false, alt: "open parenthesis a , b close parenthesis")[$( a , b )$], then the solution #math.equation(block: false, alt: "y open parenthesis x close parenthesis")[$y ( x )$] exists and is differentiable on #math.equation(block: false, alt: "open parenthesis a , b close parenthesis")[$( a , b )$]. Compare with the simple nonlinear example we have seen previously, #math.equation(block: false, alt: "y prime equals y squared")[$y^(′) = y^(2)$], and compare to #link("https://math.libretexts.org/Bookshelves/Differential_Equations/Differential_Equations_for_Engineers_(Lebl)/1%3A_First_order_ODEs/1.2%3A_Slope_fields#Theorem1.2.1")[Theorem 1.2.1]. ] #examplebox("Example 2")[][ Let us discuss a common simple application of linear equations. This type of problem is used often in real life. For example, linear equations are used in figuring out the concentration of chemicals in bodies of water (rivers and lakes). #figure(figph[Diagram of an upright cylindrical tank holding 60 litres with 10 kilograms of salt. Brine at 0.1 kilograms per litre enters at 5 litres per minute; the tank drains at 3 litres per minute.], alt: "Diagram of an upright cylindrical tank holding 60 litres with 10 kilograms of salt. Brine at 0.1 kilograms per litre enters at 5 litres per minute; the tank drains at 3 litres per minute.", caption: [Figure #math.equation(block: false, alt: "1")[$1$]]) A #math.equation(block: false, alt: "100")[$100$] liter tank contains #math.equation(block: false, alt: "10")[$10$] kilograms of salt dissolved in #math.equation(block: false, alt: "60")[$60$] liters of water. Solution of water and salt (brine) with concentration of #math.equation(block: false, alt: "0.1")[$0.1$] kilograms per liter is flowing in at the rate of #math.equation(block: false, alt: "5")[$5$] liters a minute. The solution in the tank is well stirred and flows out at a rate of #math.equation(block: false, alt: "3")[$3$] liters a minute. How much salt is in the tank when the tank is full? #solutionbox[ Let us come up with the equation. Let #math.equation(block: false, alt: "x")[$x$] denote the kilograms of salt in the tank, let #math.equation(block: false, alt: "t")[$t$] denote the time in minutes. For a small change #math.equation(block: false, alt: "Δ t")[$Δ t$] in time, the change in #math.equation(block: false, alt: "x")[$x$] (denoted #math.equation(block: false, alt: "Δ x")[$Δ x$]) is approximately #math.equation(block: true, alt: "Δ x approximately equals (rate in x concentration in) Δ t minus (rate out x concentration out) Δ t .")[$Δ x ≈ "(rate in x concentration in)" Δ t − "(rate out x concentration out)" Δ t .$] Dividing through by #math.equation(block: false, alt: "Δ t")[$Δ t$] and taking the limit #math.equation(block: false, alt: "Δ t → 0")[$Δ t → 0$] we see that #math.equation(block: true, alt: "the fraction d x over d t equals (rate in x concentration in) minus (rate out x concentration out)")[$frac(d x, d t) = "(rate in x concentration in)" − "(rate out x concentration out)"$] In our example, we have #math.equation(block: true, alt: "rate in equals 5 ,; concentration in equals 0.1 ,; rate out equals 3 ,; concentration out equals the fraction x over volume equals the fraction x over 60 plus open parenthesis 5 minus 3 close parenthesis t .")[$"rate in" = 5 , \ "concentration in" = 0.1 , \ "rate out" = 3 , \ "concentration out" = frac(x, "volume") = frac(x, 60 + ( 5 − 3 ) t) .$] Our equation is, therefore, #math.equation(block: true, alt: "the fraction d x over d t equals (5 x 0.1) minus open parenthesis 3 the fraction x over 60 plus 2 t close parenthesis")[$frac(d x, d t) = "(5 x 0.1)" − ( 3 frac(x, 60 + 2 t) )$] Or in the form (1.4.1) #math.equation(block: true, alt: "the fraction d x over d t plus the fraction 3 over 60 plus 2 t x equals 0.5")[$frac(d x, d t) + frac(3, 60 + 2 t) x = 0.5$] Let us solve. The integrating factor is #math.equation(block: true, alt: "r open parenthesis t close parenthesis equals exp open parenthesis ∫ the fraction 3 over 60 plus 2 t d t close parenthesis equals exp open parenthesis the fraction 3 over 2 ln open parenthesis 60 plus 2 t close parenthesis close parenthesis equals open parenthesis 60 plus 2 t close parenthesis to the power 3 / 2")[$r ( t ) = "exp" ( ∫ frac(3, 60 + 2 t) d t ) = "exp" ( frac(3, 2) ln ( 60 + 2 t ) ) = attach(( 60 + 2 t ), t: 3 / 2)$] We multiply both sides of the equation to get #math.equation(block: true, alt: "open parenthesis 60 plus 2 t close parenthesis to the power 3 / 2 the fraction d x over d t plus open parenthesis 60 plus 2 t close parenthesis to the power 3 / 2 the fraction 3 over 60 plus 2 t x equals 0.5 open parenthesis 60 plus 2 t close parenthesis to the power 3 / 2 ,; the fraction d over d t [ open parenthesis 60 plus 2 t close parenthesis to the power 3 / 2 x ] equals 0.5 open parenthesis 60 plus 2 t close parenthesis to the power 3 / 2 ,; open parenthesis 60 plus 2 t close parenthesis to the power 3 / 2 x equals ∫ 0.5 open parenthesis 60 plus 2 t close parenthesis to the power 3 / 2 d t plus C ,; x equals open parenthesis 60 plus 2 t close parenthesis to the power minus 3 / 2 ∫ the fraction open parenthesis 60 plus 2 t close parenthesis to the power 3 / 2 over 2 d t plus C open p")[$( 60 + 2 t )^(3 / 2) frac(d x, d t) + ( 60 + 2 t )^(3 / 2) frac(3, 60 + 2 t) x = 0.5 ( 60 + 2 t )^(3 / 2) , \ frac(d, d t) [ ( 60 + 2 t )^(3 / 2) x ] = 0.5 ( 60 + 2 t )^(3 / 2) , \ ( 60 + 2 t )^(3 / 2) x = ∫ 0.5 ( 60 + 2 t )^(3 / 2) d t + C , \ x = ( 60 + 2 t )^(− 3 / 2) ∫ frac(( 60 + 2 t )^(3 / 2), 2) d t + C ( 60 + 2 t )^(− 3 / 2) , \ x = ( 60 + 2 t )^(− 3 / 2) frac(1, 10) ( 60 + 2 t )^(5 / 2) + C ( 60 + 2 t )^(− 3 / 2) , \ x = frac(( 60 + 2 t ), 10) + C ( 60 + 2 t )^(− 3 / 2) .$] We need to find #math.equation(block: false, alt: "C")[$C$]. We know that at #math.equation(block: false, alt: "t equals 0")[$t = 0$], #math.equation(block: false, alt: "x equals 10")[$x = 10$]. So #math.equation(block: true, alt: "10 equals x open parenthesis 0 close parenthesis equals the fraction 60 over 10 plus C open parenthesis 60 close parenthesis to the power minus 3 / 2 equals 6 plus C open parenthesis 60 close parenthesis to the power minus 3 / 2")[$10 = x ( 0 ) = frac(60, 10) + C attach(( 60 ), t: − 3 / 2) = 6 + C attach(( 60 ), t: − 3 / 2)$] or #math.equation(block: true, alt: "C equals 4 open parenthesis 60 to the power 3 / 2 close parenthesis approximately equals 1859.03 .")[$C = 4 ( 60^(3 / 2) ) ≈ 1859.03 .$] We are interested in #math.equation(block: false, alt: "x")[$x$] when the tank is full. So we note that the tank is full when #math.equation(block: false, alt: "60 plus 2 t equals 100")[$60 + 2 t = 100$], or when #math.equation(block: false, alt: "t equals 20")[$t = 20$]. So #math.equation(block: true, alt: "x open parenthesis 20 close parenthesis equals the fraction 60 plus 40 over 10 plus C open parenthesis 60 plus 40 close parenthesis to the power minus 3 / 2; approximately equals 10 plus 1859.03 open parenthesis 100 close parenthesis to the power minus 3 / 2 approximately equals 11.86 .")[$x ( 20 ) = frac(60 + 40, 10) + C attach(( 60 + 40 ), t: − 3 / 2) \ ≈ 10 + 1859.03 attach(( 100 ), t: − 3 / 2) ≈ 11.86 .$] See Figure #math.equation(block: false, alt: "2")[$2$] for the graph of #math.equation(block: false, alt: "x")[$x$] over #math.equation(block: false, alt: "t")[$t$]. #figure(figph[Plot of salt in the tank against time 0 to 20, on a vertical scale covering only 10.0 to 12.0. The curve starts flat at 10, rises throughout, and is still climbing near 11.9 at time 20.], alt: "Plot of salt in the tank against time 0 to 20, on a vertical scale covering only 10.0 to 12.0. The curve starts flat at 10, rises throughout, and is still climbing near 11.9 at time 20.", caption: [Figure #math.equation(block: false, alt: "2")[$2$]: Graph of the solution #math.equation(block: false, alt: "x")[$x$] kilograms of salt in the tank at time #math.equation(block: false, alt: "t")[$t$].]) The concentration at the end is approximately #math.equation(block: false, alt: "0.1186")[$0.1186$] #super[kg]/#sub[liter] and we started with #math.equation(block: false, alt: "the fraction 1 over 6")[$frac(1, 6)$] or #math.equation(block: false, alt: "0.167")[$0.167$] #super[kg]/#sub[liter]. ] ]