3
$\begingroup$

The command below:

DSolve[{s'[t] == l t, s[0] == 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] == 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[0] == s0, p[0] == p0}, {s[t], p[t]}, {t, 0, tMax}, Assumptions -> {λ > 0, μ > 0, s0 > 0, p0 > 0, tMax > 0}]
$\endgroup$
  • $\begingroup$ Why not just DSolve[{s'[t] == l t, s[0] == 0}, s[t], t]? $\endgroup$ – J. M.'s discontentment Jun 1 '16 at 0:48
  • $\begingroup$ @J.M. 1. There needs to be some restriction on t 2. That does not work when there are multiple coefficients $\endgroup$ – Henricus V. Jun 1 '16 at 0:52
  • $\begingroup$ "There needs to be some restriction on t" - then put it in the assumptions: DSolve[{s'[t] == l t, s[0] == 0}, s[t], t, Assumptions -> {0 < t < a, l > 0}]. $\endgroup$ – J. M.'s discontentment Jun 1 '16 at 1:00
  • 2
    $\begingroup$ 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. $\endgroup$ – J. M.'s discontentment Jun 1 '16 at 1:04
2
$\begingroup$
Clear[s];

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

The solution does not vary with a

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

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

So just use

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

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

eqns /. soln

(*  {True, True}  *)

Consequently,

s[t_] = l t^2/2;
| improve this answer | |
$\endgroup$
1
$\begingroup$

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[0] == s0, 
  p[0] == 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[0] == s0, p[0] == p0} /. generalsol, {C[1], C[2]}], 
    assumption], {C[1], C[2]}]

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

constant = First@
  Simplify[Solve[{Sequence @@ assumption, s[0] == s0, p[0] == p0} /. generalsol, {C[1], 
     C[2]}], 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[3] ∈ 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.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.