# DSolve with coefficients and assumptions

The command below:

DSolve[{s'[t] == l t, s == 0}, {s[t]}, {t, 0, a}]


gives the error

DSolve::alliv: The function s[t] was specified without dependence on all the independent variables. Each function must depend on all the independent variables.

I am trying to make l a constant coefficient. How do I get around this problem? I also want to be able to add the following:

Assumptions -> {l > 0, a > 0}


Edit: Removing a causes the error to no longer appear but I want a to be there. The following seems to work:

wrap_l = l
wrap_a = a
DSolve[{s'[t] == wrap_l t, s == 0}, {s[t]}, {t, 0, wrap_a}]


Is there a cleaner solution? The command I want to achieve is

DSolve[{s'[t] == -λ s[t] p[t], p'[t] == μ s[t] p[t], s == s0, p == p0}, {s[t], p[t]}, {t, 0, tMax}, Assumptions -> {λ > 0, μ > 0, s0 > 0, p0 > 0, tMax > 0}]

• Why not just DSolve[{s'[t] == l t, s == 0}, s[t], t]? Jun 1, 2016 at 0:48
• @J.M. 1. There needs to be some restriction on t 2. That does not work when there are multiple coefficients Jun 1, 2016 at 0:52
• "There needs to be some restriction on t" - then put it in the assumptions: DSolve[{s'[t] == l t, s == 0}, s[t], t, Assumptions -> {0 < t < a, l > 0}]. Jun 1, 2016 at 1:00
• For your more complex example, the version without initial conditions works: DSolve[{s'[t] == -a s[t] p[t], p'[t] == b s[t] p[t]}, {s[t], p[t]}, t]; you should be able to work backwards from there. Jun 1, 2016 at 1:04

Clear[s];

eqns = {s'[t] == l t, s == 0};


The solution does not vary with a

Table[DSolve[eqns, s, {t, 0, a}][], {a, Range[5, 50, 5]}] // Union

(*  {{s -> Function[{t}, (l t^2)/2]}}  *)


So just use

soln = DSolve[eqns, s, t][]

(*  {s -> Function[{t}, (l t^2)/2]}  *)

eqns /. soln

(*  {True, True}  *)


Consequently,

s[t_] = l t^2/2;


I think the warning DSolve::alliv is an evidence of bug, you may contact WRI. As a workaround, just use the old syntax

DSolve[{s'[t] == -λ s[t] p[t], p'[t] == μ s[t] p[t], s == s0,
p == p0}, {s[t], p[t]}, t]


DSolve warns it used inverse function, but it's not a big deal. If you still feel worried, let's solve it in another way. First obtain the general solution:

generalsol =
First@DSolve[{s'[t] == -λ s[t] p[t], p'[t] == μ s[t] p[t]}, {s, p}, t]


Plug it back into the boundary condition and solve for the constants:

assumption = {λ > 0, μ > 0, s0 > 0, p0 > 0};

constant = First@
Solve[Simplify[Reduce[{s == s0, p == p0} /. generalsol, {C, C}],
assumption], {C, C}]


The combination of Solve, Simplify, Reduce is a result of trial and error, you can also use

constant = First@
Simplify[Solve[{Sequence @@ assumption, s == s0, p == p0} /. generalsol, {C,
C}], assumption]


which also works but a little slower.

Finally plug the sonstant back into the general solution:

Simplify[{s[t], p[t]} /. generalsol /. constant, C ∈ Integers]
(* {(s0 (p0 λ + s0 μ))/(
E^(t (p0 λ + s0 μ)) p0 λ + s0 μ), (
E^(t (p0 λ + s0 μ)) p0 (p0 λ + s0 μ))/(
E^(t (p0 λ + s0 μ)) p0 λ + s0 μ)} *)


It's the same as what we got with the one line solution above.