Mode of #cas

dsolve

The general solution of a linear differential equation, or the solution of an initial-value problem, with a theorem.

#cas [dsolve y x] eq
gives the general solution of the linear differential equation eq for the function y of x, and proves that every solution is in the family.
#cas [dsolve y x, y x₀ = v₀, y' x₀ = v₁, …] eq
gives the solution with these initial values, and proves that it is the only one.

dsolve finds the general solution of a supported linear differential equation, and what I wanted from it is the complete statement, not only that the printed family solves the equation. The theorem is an equivalence about every function y : ℝ → ℝ with enough derivatives: y solves the equation exactly when it is a member of the printed family. So there are no other solutions, and with initial values the printed solution is the only one.

With rational constant coefficients the equation may have any order, and the family comes from the roots of the characteristic polynomial, exact or enclosed. A right side of polynomials, exponentials, sines and cosines gets a particular solution. A first-order equation y' + p * y = q whose coefficients depend on x is solved by an integrating factor, when the checked integrator finds the primitives it needs. Coefficients that depend on x are taken in first order only.

Details and Options

  • For an equation of order n and the printed family F, the theorem is: for every y : ℝ → ℝ with ∀ k < n, Differentiable ℝ (iteratedDeriv k y), that is, for every y that is n times differentiable on ℝ, (∀ x, eq) ↔ ∃ c₁ … cₙ, ∀ x, y x = F. In the theorem y' is deriv y x and y'' is iteratedDeriv 2 y x.
  • With initial values the theorem is (∀ x, eq) ∧ y x₀ = v₀ ∧ deriv y x₀ = v₁ ∧ … ↔ ∀ x, y x = Y for the printed solution Y. The values of y and its derivatives below the order are given at one rational point.
  • The equation is linear in y and its derivatives y', y'' and so on, and the coefficient of the highest derivative is a nonzero rational number. With rational constant coefficients, the right side is a sum of terms x ^ k * exp (a * x) * cos (b * x) and x ^ k * exp (a * x) * sin (b * x).
  • The characteristic roots are rational, roots of quadratic factors, or known by certified enclosures, named r₁, … for real roots and z₁ = α ± iβ, … for pairs of complex roots. With enclosed roots only the general solution is given.
  • A first-order equation y' + p * y = q with coefficients that depend on x is solved when the checked integrator finds a primitive P of p and a primitive of ePq, both without domain conditions.
  • A first-order equation may have parameters when p does not depend on x and q is a sum of terms of the kind above. The conditions on the parameters that the solution needs, such as k+2≠0 in the example under Scope, are hypotheses of the theorem, and the report lists them as its conditions. Initial values are not treated with parameters.
  • There are no options of its own. oracle := sympy, oracle := sage or oracle := giac gives a family that an external system proposes. Lean checks that it solves the equation, and does not check that it is the general solution (see oracle).
  • The tactic cas does not prove the equivalence. It proves that a member of the family satisfies the equation, as under Applications.

Examples (23)#

Basic Examples (2)

A second-order equation with two real characteristic roots, and the theorem that every solution is in the family:

In[1]:=
#cas [dsolve y x] (y'' + 3*y' + 2*y = 0)
Out[1]=

order 2, characteristic roots: -1, -2

y(x)=c1e−x+c2e−2x
y(x) = c₁*exp(-x) + c₂*exp(-(2*x))
Input (linear equation of order 2 with constant coefficients)
(y'' + 3*y' + 2*y = 0)

Checked by Lean’s kernel: The general solution, and every solution has this form

∀ (y : ℝ → ℝ),
  (∀ k < 2, Differentiable ℝ (iteratedDeriv k y)) →
    ((∀ (x : ℝ), iteratedDeriv 2 y x + 3 * deriv y x + 2 * y x = 0) ↔
      ∃ c₁ c₂, ∀ (x : ℝ), y x = c₁ * Real.exp (-x) + c₂ * Real.exp (-(2 * x)))
The certificate: 1 checked step
  1. The general solution, and every solution has this form

    ∀ (y : ℝ → ℝ),
      (∀ k < 2, Differentiable ℝ (iteratedDeriv k y)) →
        ((∀ (x : ℝ), iteratedDeriv 2 y x + 3 * deriv y x + 2 * y x = 0) ↔
          ∃ c₁ c₂, ∀ (x : ℝ), y x = c₁ * Real.exp (-x) + c₂ * Real.exp (-(2 * x)))

    Checked by Lean’s kernel


With initial values, the only solution:

In[2]:=
#cas [dsolve y x, y 0 = 1, y' 0 = 0] (y'' + y = 0)
Out[2]=

order 2, characteristic roots: ±i

y(x)=cos(x)
y(x) = cos(x)
Input (linear equation of order 2 with constant coefficients)
(y'' + y = 0)

Checked by Lean’s kernel: The unique solution of the initial-value problem

∀ (y : ℝ → ℝ),
  (∀ k < 2, Differentiable ℝ (iteratedDeriv k y)) →
    ((∀ (x : ℝ), iteratedDeriv 2 y x + y x = 0) ∧ y 0 = 1 ∧ deriv y 0 = 0 ↔ ∀ (x : ℝ), y x = Real.cos x)
The certificate: 1 checked step
  1. The unique solution of the initial-value problem

    ∀ (y : ℝ → ℝ),
      (∀ k < 2, Differentiable ℝ (iteratedDeriv k y)) →
        ((∀ (x : ℝ), iteratedDeriv 2 y x + y x = 0) ∧ y 0 = 1 ∧ deriv y 0 = 0 ↔ ∀ (x : ℝ), y x = Real.cos x)

    Checked by Lean’s kernel

Scope (9)

A double root, and a pair of complex roots:

In[3]:=
#cas [dsolve y x] (y'' - 2*y' + y = 0)
Out[3]=

order 2, characteristic roots: 1 (multiplicity 2)

y(x)=c1ex+c2xex
y(x) = c₁*exp(x) + c₂*x*exp(x)
Input (linear equation of order 2 with constant coefficients)
(y'' - 2*y' + y = 0)

Checked by Lean’s kernel: The general solution, and every solution has this form

∀ (y : ℝ → ℝ),
  (∀ k < 2, Differentiable ℝ (iteratedDeriv k y)) →
    ((∀ (x : ℝ), iteratedDeriv 2 y x - 2 * deriv y x + y x = 0) ↔
      ∃ c₁ c₂, ∀ (x : ℝ), y x = c₁ * Real.exp x + c₂ * (x * Real.exp x))
The certificate: 1 checked step
  1. The general solution, and every solution has this form

    ∀ (y : ℝ → ℝ),
      (∀ k < 2, Differentiable ℝ (iteratedDeriv k y)) →
        ((∀ (x : ℝ), iteratedDeriv 2 y x - 2 * deriv y x + y x = 0) ↔
          ∃ c₁ c₂, ∀ (x : ℝ), y x = c₁ * Real.exp x + c₂ * (x * Real.exp x))

    Checked by Lean’s kernel

In[4]:=
#cas [dsolve y x] (y'' + 2*y' + 5*y = 0)
Out[4]=

order 2, characteristic roots: -1 ± 2 i

y(x)=c1e−xcos(2x)+c2e−xsin(2x)
y(x) = c₁*exp(-x)*cos(2*x) + c₂*exp(-x)*sin(2*x)
Input (linear equation of order 2 with constant coefficients)
(y'' + 2*y' + 5*y = 0)

Checked by Lean’s kernel: The general solution, and every solution has this form

∀ (y : ℝ → ℝ),
  (∀ k < 2, Differentiable ℝ (iteratedDeriv k y)) →
    ((∀ (x : ℝ), iteratedDeriv 2 y x + 2 * deriv y x + 5 * y x = 0) ↔
      ∃ c₁ c₂,
        ∀ (x : ℝ), y x = c₁ * (Real.exp (-x) * Real.cos (2 * x)) + c₂ * (Real.exp (-x) * Real.sin (2 * x)))
The certificate: 1 checked step
  1. The general solution, and every solution has this form

    ∀ (y : ℝ → ℝ),
      (∀ k < 2, Differentiable ℝ (iteratedDeriv k y)) →
        ((∀ (x : ℝ), iteratedDeriv 2 y x + 2 * deriv y x + 5 * y x = 0) ↔
          ∃ c₁ c₂,
            ∀ (x : ℝ), y x = c₁ * (Real.exp (-x) * Real.cos (2 * x)) + c₂ * (Real.exp (-x) * Real.sin (2 * x)))

    Checked by Lean’s kernel


Irrational roots from a quadratic factor:

In[5]:=
#cas [dsolve y x] (y'' - 2*y = 0)
Out[5]=

order 2, characteristic roots: ±√2

y(x)=c1e2x+c2e−2x
y(x) = c₁*exp(sqrt(2)*x) + c₂*exp(-(sqrt(2)*x))
Input (linear equation of order 2 with constant coefficients)
(y'' - 2*y = 0)

Checked by Lean’s kernel: The general solution, and every solution has this form

∀ (y : ℝ → ℝ),
  (∀ k < 2, Differentiable ℝ (iteratedDeriv k y)) →
    ((∀ (x : ℝ), iteratedDeriv 2 y x = 2 * y x) ↔
      ∃ c₁ c₂, ∀ (x : ℝ), y x = c₁ * Real.exp (√2 * x) + c₂ * Real.exp (-(√2 * x)))
The certificate: 1 checked step
  1. The general solution, and every solution has this form

    ∀ (y : ℝ → ℝ),
      (∀ k < 2, Differentiable ℝ (iteratedDeriv k y)) →
        ((∀ (x : ℝ), iteratedDeriv 2 y x = 2 * y x) ↔
          ∃ c₁ c₂, ∀ (x : ℝ), y x = c₁ * Real.exp (√2 * x) + c₂ * Real.exp (-(√2 * x)))

    Checked by Lean’s kernel


A right side gets a particular solution. At resonance it has a factor x:

In[6]:=
#cas [dsolve y x] (y'' + y = sin x)
Out[6]=

order 2, characteristic roots: ±i

y(x)=−12xcos(x)+c1cos(x)+c2sin(x)
y(x) = -(1/2*x*cos(x)) + c₁*cos(x) + c₂*sin(x)
Input (linear equation of order 2 with constant coefficients)
(y'' + y = sin x)

Checked by Lean’s kernel: The general solution, and every solution has this form

∀ (y : ℝ → ℝ),
  (∀ k < 2, Differentiable ℝ (iteratedDeriv k y)) →
    ((∀ (x : ℝ), iteratedDeriv 2 y x + y x = Real.sin x) ↔
      ∃ c₁ c₂, ∀ (x : ℝ), y x = -(1 / 2 * x * Real.cos x) + c₁ * Real.cos x + c₂ * Real.sin x)
The certificate: 1 checked step
  1. The general solution, and every solution has this form

    ∀ (y : ℝ → ℝ),
      (∀ k < 2, Differentiable ℝ (iteratedDeriv k y)) →
        ((∀ (x : ℝ), iteratedDeriv 2 y x + y x = Real.sin x) ↔
          ∃ c₁ c₂, ∀ (x : ℝ), y x = -(1 / 2 * x * Real.cos x) + c₁ * Real.cos x + c₂ * Real.sin x)

    Checked by Lean’s kernel

In[7]:=
#cas [dsolve y x] (2*y'' + y = cos x * exp x)
Out[7]=

order 2, characteristic roots: ±1/2√2 i

y(x)=ex(117cos(x)+417sin(x))+c1cos(122x)+c2sin(122x)
y(x) = exp(x)*(1/17*cos(x) + 4/17*sin(x)) + c₁*cos(1/2*sqrt(2)*x) + c₂*sin(1/2*sqrt(2)*x)
Input (linear equation of order 2 with constant coefficients)
(2*y'' + y = cos x * exp x)

Checked by Lean’s kernel: The general solution, and every solution has this form

∀ (y : ℝ → ℝ),
  (∀ k < 2, Differentiable ℝ (iteratedDeriv k y)) →
    ((∀ (x : ℝ), 2 * iteratedDeriv 2 y x + y x = Real.cos x * Real.exp x) ↔
      ∃ c₁ c₂,
        ∀ (x : ℝ),
          y x =
            Real.exp x * (1 / 17 * Real.cos x + 4 / 17 * Real.sin x) + c₁ * Real.cos (1 / 2 * √2 * x) +
              c₂ * Real.sin (1 / 2 * √2 * x))
The certificate: 1 checked step
  1. The general solution, and every solution has this form

    ∀ (y : ℝ → ℝ),
      (∀ k < 2, Differentiable ℝ (iteratedDeriv k y)) →
        ((∀ (x : ℝ), 2 * iteratedDeriv 2 y x + y x = Real.cos x * Real.exp x) ↔
          ∃ c₁ c₂,
            ∀ (x : ℝ),
              y x =
                Real.exp x * (1 / 17 * Real.cos x + 4 / 17 * Real.sin x) + c₁ * Real.cos (1 / 2 * √2 * x) +
                  c₂ * Real.sin (1 / 2 * √2 * x))

    Checked by Lean’s kernel


A first-order equation with a polynomial right side:

In[8]:=
#cas [dsolve y x] (y' + 2*y = x)
Out[8]=

order 1, characteristic roots: -2

y(x)=−14+12x+c1e−2x
y(x) = -(1/4) + 1/2*x + c₁*exp(-(2*x))
Input (linear equation of order 1 with constant coefficients)
(y' + 2*y = x)

Checked by Lean’s kernel: The general solution, and every solution has this form

∀ (y : ℝ → ℝ),
  Differentiable ℝ y →
    ((∀ (x : ℝ), deriv y x + 2 * y x = x) ↔
      ∃ c₁, ∀ (x : ℝ), y x = -(1 / 4) + 1 / 2 * x + c₁ * Real.exp (-(2 * x)))
The certificate: 1 checked step
  1. The general solution, and every solution has this form

    ∀ (y : ℝ → ℝ),
      Differentiable ℝ y →
        ((∀ (x : ℝ), deriv y x + 2 * y x = x) ↔
          ∃ c₁, ∀ (x : ℝ), y x = -(1 / 4) + 1 / 2 * x + c₁ * Real.exp (-(2 * x)))

    Checked by Lean’s kernel


Third order, with three rational roots:

In[9]:=
#cas [dsolve y x] (y''' - 6*y'' + 11*y' - 6*y = 0)
Out[9]=

order 3, characteristic roots: 1, 2, 3

y(x)=c1ex+c2e2x+c3e3x
y(x) = c₁*exp(x) + c₂*exp(2*x) + c₃*exp(3*x)
Input (linear equation of order 3 with constant coefficients)
(y''' - 6*y'' + 11*y' - 6*y = 0)

Checked by Lean’s kernel: The general solution, and every solution has this form

∀ (y : ℝ → ℝ),
  (∀ k < 3, Differentiable ℝ (iteratedDeriv k y)) →
    ((∀ (x : ℝ), iteratedDeriv 3 y x - 6 * iteratedDeriv 2 y x + 11 * deriv y x = 6 * y x) ↔
      ∃ c₁ c₂ c₃, ∀ (x : ℝ), y x = c₁ * Real.exp x + c₂ * Real.exp (2 * x) + c₃ * Real.exp (3 * x))
The certificate: 1 checked step
  1. The general solution, and every solution has this form

    ∀ (y : ℝ → ℝ),
      (∀ k < 3, Differentiable ℝ (iteratedDeriv k y)) →
        ((∀ (x : ℝ), iteratedDeriv 3 y x - 6 * iteratedDeriv 2 y x + 11 * deriv y x = 6 * y x) ↔
          ∃ c₁ c₂ c₃, ∀ (x : ℝ), y x = c₁ * Real.exp x + c₂ * Real.exp (2 * x) + c₃ * Real.exp (3 * x))

    Checked by Lean’s kernel


Initial values for an equation of order 3:

In[10]:=
#cas [dsolve y x, y 0 = 0, y' 0 = 1, y'' 0 = 0] (y''' + y' = 0)
Out[10]=

order 3, characteristic roots: 0, ±i

y(x)=sin(x)
y(x) = sin(x)
Input (linear equation of order 3 with constant coefficients)
(y''' + y' = 0)

Checked by Lean’s kernel: The unique solution of the initial-value problem

∀ (y : ℝ → ℝ),
  (∀ k < 3, Differentiable ℝ (iteratedDeriv k y)) →
    ((∀ (x : ℝ), iteratedDeriv 3 y x + deriv y x = 0) ∧ y 0 = 0 ∧ deriv y 0 = 1 ∧ iteratedDeriv 2 y 0 = 0 ↔
      ∀ (x : ℝ), y x = Real.sin x)
The certificate: 1 checked step
  1. The unique solution of the initial-value problem

    ∀ (y : ℝ → ℝ),
      (∀ k < 3, Differentiable ℝ (iteratedDeriv k y)) →
        ((∀ (x : ℝ), iteratedDeriv 3 y x + deriv y x = 0) ∧ y 0 = 0 ∧ deriv y 0 = 1 ∧ iteratedDeriv 2 y 0 = 0 ↔
          ∀ (x : ℝ), y x = Real.sin x)

    Checked by Lean’s kernel


The roots of r4+1 are enclosed, and the theorem states their enclosures first:

In[11]:=
#cas [dsolve y x] (y'''' + y = 0)
Out[11]=

order 4, the roots of r^4 + 1 = 0: z₁ = α ± iβ, α ∈ [-0.70710680, -0.70710676], β ∈ [0.70710676, 0.70710680], z₂ = α ± iβ, α ∈ [0.70710676, 0.70710680], β ∈ [0.70710676, 0.70710680]

y(x) = c₁*exp(re(z₁)*x)*cos(im(z₁)*x) + c₂*exp(re(z₁)*x)*sin(im(z₁)*x) + c₃*exp(re(z₂)*x)*cos(im(z₂)*x) + c₄*exp(re(z₂)*x)*sin(im(z₂)*x)
Input (linear equation of order 4 with constant coefficients)
(y'''' + y = 0)

Checked by Lean’s kernel: The roots of the characteristic factor without closed form, by certified enclosures, and the general solution

let z₁ := CAS.AlgRoot.complex [1, 0, 0, 0, 1] (-0.70710678) 0.70710678 2e-8;
let z₂ := CAS.AlgRoot.complex [1, 0, 0, 0, 1] 0.70710678 0.70710678 2e-8;
(z₁.re ∈ Set.Icc (-0.70710680) (-0.70710676) ∧ z₁.im ∈ Set.Icc 0.70710676 0.70710680 ∧ z₁ ^ 4 + 1 = 0) ∧
  (z₂.re ∈ Set.Icc 0.70710676 0.70710680 ∧ z₂.im ∈ Set.Icc 0.70710676 0.70710680 ∧ z₂ ^ 4 + 1 = 0) ∧
    ∀ (y : ℝ → ℝ),
      (∀ k < 4, Differentiable ℝ (iteratedDeriv k y)) →
        ((∀ (x : ℝ), iteratedDeriv 4 y x + y x = 0) ↔
          ∃ c₁ c₂ c₃ c₄,
            ∀ (x : ℝ),
              y x =
                c₁ * (Real.exp (z₁.re * x) * Real.cos (z₁.im * x)) +
                      c₂ * (Real.exp (z₁.re * x) * Real.sin (z₁.im * x)) +
                    c₃ * (Real.exp (z₂.re * x) * Real.cos (z₂.im * x)) +
                  c₄ * (Real.exp (z₂.re * x) * Real.sin (z₂.im * x)))
The certificate: 1 checked step
  1. The roots of the characteristic factor without closed form, by certified enclosures, and the general solution

    let z₁ := CAS.AlgRoot.complex [1, 0, 0, 0, 1] (-0.70710678) 0.70710678 2e-8;
    let z₂ := CAS.AlgRoot.complex [1, 0, 0, 0, 1] 0.70710678 0.70710678 2e-8;
    (z₁.re ∈ Set.Icc (-0.70710680) (-0.70710676) ∧ z₁.im ∈ Set.Icc 0.70710676 0.70710680 ∧ z₁ ^ 4 + 1 = 0) ∧
      (z₂.re ∈ Set.Icc 0.70710676 0.70710680 ∧ z₂.im ∈ Set.Icc 0.70710676 0.70710680 ∧ z₂ ^ 4 + 1 = 0) ∧
        ∀ (y : ℝ → ℝ),
          (∀ k < 4, Differentiable ℝ (iteratedDeriv k y)) →
            ((∀ (x : ℝ), iteratedDeriv 4 y x + y x = 0) ↔
              ∃ c₁ c₂ c₃ c₄,
                ∀ (x : ℝ),
                  y x =
                    c₁ * (Real.exp (z₁.re * x) * Real.cos (z₁.im * x)) +
                          c₂ * (Real.exp (z₁.re * x) * Real.sin (z₁.im * x)) +
                        c₃ * (Real.exp (z₂.re * x) * Real.cos (z₂.im * x)) +
                      c₄ * (Real.exp (z₂.re * x) * Real.sin (z₂.im * x)))

    Checked by Lean’s kernel


A coefficient that depends on x, by an integrating factor, without and with an initial value:

In[12]:=
#cas [dsolve y x] (y' + 2*x*y = x)
Out[12]=

integrating factor e ^ P

y(x)=(12ex2+C)e−x2
y(x) = (1/2*exp(x^2) + C)*exp(-x^2)
Input (linear equation of order one with a variable coefficient)
(y' + 2*x*y = x)

Checked by Lean’s kernel: The general solution by the integrating factor, and every solution has this form

∀ (y : ℝ → ℝ),
  Differentiable ℝ y →
    ((∀ (x : ℝ), deriv y x + 2 * x * y x = x) ↔
      ∃ C, ∀ (x : ℝ), y x = (1 / 2 * Real.exp (x ^ 2) + C) * Real.exp (-x ^ 2))
The certificate: 1 checked step
  1. The general solution by the integrating factor, and every solution has this form

    ∀ (y : ℝ → ℝ),
      Differentiable ℝ y →
        ((∀ (x : ℝ), deriv y x + 2 * x * y x = x) ↔
          ∃ C, ∀ (x : ℝ), y x = (1 / 2 * Real.exp (x ^ 2) + C) * Real.exp (-x ^ 2))

    Checked by Lean’s kernel

In[13]:=
#cas [dsolve y x, y 0 = 1] (y' - 2*x*y = 0)
Out[13]=

integrating factor e ^ P

y(x)=ex2
y(x) = exp(x^2)
Input (linear equation of order one with a variable coefficient)
(y' - 2*x*y = 0)

Checked by Lean’s kernel: The unique solution of the initial-value problem

∀ (y : ℝ → ℝ),
  Differentiable ℝ y → ((∀ (x : ℝ), deriv y x = 2 * x * y x) ∧ y 0 = 1 ↔ ∀ (x : ℝ), y x = Real.exp (x ^ 2))
The certificate: 1 checked step
  1. The unique solution of the initial-value problem

    ∀ (y : ℝ → ℝ),
      Differentiable ℝ y → ((∀ (x : ℝ), deriv y x = 2 * x * y x) ∧ y 0 = 1 ↔ ∀ (x : ℝ), y x = Real.exp (x ^ 2))

    Checked by Lean’s kernel


A first-order equation with a parameter. The theorem has the hypothesis k+2≠0, since the family divides by k+2:

In[14]:=
#cas [dsolve y x] (y' + k * y = exp (2 * x))
Out[14]=

integrating factor e ^ (p x)

y(x)=(e(k+2)xk+2+C)e−kx
y(x) = (exp((k + 2)*x)/(k + 2) + C)*exp(-(k*x))
Input (linear equation of order one with symbolic coefficients)
(y' + k * y = exp (2 * x))
Conditions
k+2≠0

Checked by Lean’s kernel: The general solution by the integrating factor, and every solution has this form

∀ (k : ℝ),
  k + 2 ≠ 0 →
    ∀ (y : ℝ → ℝ),
      Differentiable ℝ y →
        ((∀ (x : ℝ), deriv y x + k * y x = Real.exp (2 * x)) ↔
          ∃ C, ∀ (x : ℝ), y x = (Real.exp ((k + 2) * x) / (k + 2) + C) * Real.exp (-(k * x)))
The certificate: 1 checked step
  1. The general solution by the integrating factor, and every solution has this form

    ∀ (k : ℝ),
      k + 2 ≠ 0 →
        ∀ (y : ℝ → ℝ),
          Differentiable ℝ y →
            ((∀ (x : ℝ), deriv y x + k * y x = Real.exp (2 * x)) ↔
              ∃ C, ∀ (x : ℝ), y x = (Real.exp ((k + 2) * x) / (k + 2) + C) * Real.exp (-(k * x)))

    Checked by Lean’s kernel

Options (1)

An external system can propose a family, here for an equation whose leading coefficient is x. Lean checks that the family solves the equation, and the report says that its completeness is not checked:

In[15]:=
#cas [dsolve y x, oracle := sympy] (x * y' + y = 0)

Quoted from tests/oracle/Oracles.lean, where #guard_msgs pins the output (the part shown).

Out[15]=

a family of solutions (checked); that it is the general solution is not

y(x)=c1x
y(x) = c1/x

Applications (1)

A member of the family of y' + 2*y = x in a proof. cas proves that it satisfies y' = x - 2*y, and only the three standard axioms are used:

In[16]:=
theorem dsolve_solution (c₁ x : ℝ) :
    HasDerivAt (fun x ↦ -(1 / 4) + 1 / 2 * x + c₁ * Real.exp (-(2 * x)))
      (x - 2 * (-(1 / 4) + 1 / 2 * x + c₁ * Real.exp (-(2 * x)))) x := by
  cas

#print axioms dsolve_solution
Out[16]=

dsolve_solution depends on the axioms propext, Classical.choice, Quot.sound.

Properties and Relations (1)

The laplace transform turns y'' + y = sin x with y 0 = 0 and y' 0 = 0 into Y(s)=1/(s2+1)2, and inverseLaplace gives back the solution, the member of the family under Scope with c1=0 and c2=1/2:

In[17]:=
#cas [inverseLaplace s t] (1 / (s ^ 2 + 1) ^ 2)
Out[17]=

an inverse Laplace transform (its transform is F for s > σ; uniqueness is not claimed)

12sin(t)−12tcos(t)
1/2*sin(t) - 1/2*t*cos(t)
Domain
s > 0
Input (proper rational function of s)
(1 / (s ^ 2 + 1) ^ 2)

Checked by Lean’s kernel: Inverse Laplace transform

∀ (s : ℝ),
  0 < s →
    MeasureTheory.IntegrableOn (fun t ↦ Real.exp (-(s * t)) * (1 / 2 * Real.sin t - 1 / 2 * (t * Real.cos t)))
        (Set.Ioi 0) MeasureTheory.volume ∧
      ∫ (t : ℝ) in Set.Ioi 0, Real.exp (-(s * t)) * (1 / 2 * Real.sin t - 1 / 2 * (t * Real.cos t)) =
        1 / (s ^ 2 + 1) ^ 2
The certificate: 1 checked step
  1. Inverse Laplace transform

    ∀ (s : ℝ),
      0 < s →
        MeasureTheory.IntegrableOn (fun t ↦ Real.exp (-(s * t)) * (1 / 2 * Real.sin t - 1 / 2 * (t * Real.cos t)))
            (Set.Ioi 0) MeasureTheory.volume ∧
          ∫ (t : ℝ) in Set.Ioi 0, Real.exp (-(s * t)) * (1 / 2 * Real.sin t - 1 / 2 * (t * Real.cos t)) =
            1 / (s ^ 2 + 1) ^ 2

    Checked by Lean’s kernel

Possible Issues (8)

Coefficients that depend on x are taken in first order only:

In[18]:=
#cas [dsolve y x] (y'' + x*y = 0)
Out[18]=

Error

dsolve: the coefficient of the derivative of order 0 is not a rational constant

The integrating factor of y' + x*y = 1 is ex2/2, which has no elementary primitive:

In[19]:=
#cas [dsolve y x] (y' + x*y = 1)
Out[19]=

Error

dsolve: the checked integrator found no primitive of e ^ P times the right side

The primitive of the coefficient 1/x is a logarithm, which the integrator proves away from x=0 only. The mode does not treat such conditions:

In[20]:=
#cas [dsolve y x] (y' + y/x = 0)
Out[20]=

Error

dsolve: the primitive of the coefficient holds only under domain conditions, which this command does not treat

Parameters are taken in first order only:

In[21]:=
#cas [dsolve y x] (y'' + k*y = 0)
Out[21]=

Error

dsolve: symbolic coefficients are treated for first-order equations

The equation must be linear in y and its derivatives:

In[22]:=
#cas [dsolve y x] (y' * y = 1)
Out[22]=

Error

dsolve: the equation is not linear in y and its derivatives

The equation must be about the function named in the brackets. Here it is z, so write #cas [dsolve z x]:

In[23]:=
#cas [dsolve y x] (z'' + z = 0)
Out[23]=

Error

dsolve: the equation has no derivative of y

The initial values must be given at one point. For a boundary-value problem, fit the constants of the general solution:

In[24]:=
#cas [dsolve y x, y 0 = 1, y 1 = 2] (y'' + y = 0)
Out[24]=

Error

dsolve: the initial values must be given at one point

With enclosed characteristic roots, only the general solution is given:

In[25]:=
#cas [dsolve y x, y 0 = 1, y' 0 = 0, y'' 0 = 0] (y''' - 2 * y = 0)
Out[25]=

Error

dsolve: initial values are not treated when some characteristic roots are known only by enclosures

Neat Examples (1)

The fifth roots of unity: r5−1=(r−1)(r4+r3+r2+r+1), and the four complex roots are enclosed:

In[26]:=
#cas [dsolve y x] (y''''' - y = 0)
Out[26]=

order 5, characteristic roots: 1 and the roots of r^4 + r^3 + r^2 + r + 1 = 0: z₁ = α ± iβ, α ∈ [-0.80901701, -0.80901697], β ∈ [0.58778523, 0.58778527], z₂ = α ± iβ, α ∈ [0.30901697, 0.30901701], β ∈ [0.95105650, 0.95105654]

y(x) = c₁*exp(x) + c₂*exp(re(z₁)*x)*cos(im(z₁)*x) + c₃*exp(re(z₁)*x)*sin(im(z₁)*x) + c₄*exp(re(z₂)*x)*cos(im(z₂)*x) + c₅*exp(re(z₂)*x)*sin(im(z₂)*x)
Input (linear equation of order 5 with constant coefficients)
(y''''' - y = 0)

Checked by Lean’s kernel: The roots of the characteristic factor without closed form, by certified enclosures, and the general solution

let z₁ := CAS.AlgRoot.complex [1, 1, 1, 1, 1] (-0.80901699) 0.58778525 2e-8;
let z₂ := CAS.AlgRoot.complex [1, 1, 1, 1, 1] 0.30901699 0.95105652 2e-8;
(z₁.re ∈ Set.Icc (-0.80901701) (-0.80901697) ∧
    z₁.im ∈ Set.Icc 0.58778523 0.58778527 ∧ z₁ ^ 4 + z₁ ^ 3 + z₁ ^ 2 + z₁ + 1 = 0) ∧
  (z₂.re ∈ Set.Icc 0.30901697 0.30901701 ∧
      z₂.im ∈ Set.Icc 0.95105650 0.95105654 ∧ z₂ ^ 4 + z₂ ^ 3 + z₂ ^ 2 + z₂ + 1 = 0) ∧
    ∀ (y : ℝ → ℝ),
      (∀ k < 5, Differentiable ℝ (iteratedDeriv k y)) →
        ((∀ (x : ℝ), iteratedDeriv 5 y x = y x) ↔
          ∃ c₁ c₂ c₃ c₄ c₅,
            ∀ (x : ℝ),
              y x =
                c₁ * Real.exp x + c₂ * (Real.exp (z₁.re * x) * Real.cos (z₁.im * x)) +
                      c₃ * (Real.exp (z₁.re * x) * Real.sin (z₁.im * x)) +
                    c₄ * (Real.exp (z₂.re * x) * Real.cos (z₂.im * x)) +
                  c₅ * (Real.exp (z₂.re * x) * Real.sin (z₂.im * x)))
The certificate: 1 checked step
  1. The roots of the characteristic factor without closed form, by certified enclosures, and the general solution

    let z₁ := CAS.AlgRoot.complex [1, 1, 1, 1, 1] (-0.80901699) 0.58778525 2e-8;
    let z₂ := CAS.AlgRoot.complex [1, 1, 1, 1, 1] 0.30901699 0.95105652 2e-8;
    (z₁.re ∈ Set.Icc (-0.80901701) (-0.80901697) ∧
        z₁.im ∈ Set.Icc 0.58778523 0.58778527 ∧ z₁ ^ 4 + z₁ ^ 3 + z₁ ^ 2 + z₁ + 1 = 0) ∧
      (z₂.re ∈ Set.Icc 0.30901697 0.30901701 ∧
          z₂.im ∈ Set.Icc 0.95105650 0.95105654 ∧ z₂ ^ 4 + z₂ ^ 3 + z₂ ^ 2 + z₂ + 1 = 0) ∧
        ∀ (y : ℝ → ℝ),
          (∀ k < 5, Differentiable ℝ (iteratedDeriv k y)) →
            ((∀ (x : ℝ), iteratedDeriv 5 y x = y x) ↔
              ∃ c₁ c₂ c₃ c₄ c₅,
                ∀ (x : ℝ),
                  y x =
                    c₁ * Real.exp x + c₂ * (Real.exp (z₁.re * x) * Real.cos (z₁.im * x)) +
                          c₃ * (Real.exp (z₁.re * x) * Real.sin (z₁.im * x)) +
                        c₄ * (Real.exp (z₂.re * x) * Real.cos (z₂.im * x)) +
                      c₅ * (Real.exp (z₂.re * x) * Real.sin (z₂.im * x)))

    Checked by Lean’s kernel

See Also

ndsolve · laplace · rsolve · integrate · oracle