1
$\begingroup$

I've got the following result from evaluating a DSolve problem:

input[] = diffEq = Derivative[1][r][t] == (2*(c + A*t)*(1 + z))/(2 + z);
          initialConditions = r[0] == 0; 
          solution = DSolve[{diffEq, initialConditions}, r, t]
output[] = {{r -> Function[{t}, ((2*c*t + A*t^2)*(1 + z))/(2 + z)]}}

How do I use the output of this, which should be a some function r[t] in an integral like this:

input[] = Integrate[r[t], {t, t1, t0}]

I can't seem to tease the output of the DSolve into a function that can be used in the integral.

$\endgroup$
1
  • $\begingroup$ Expand your ode by R[t]==r'[t] $\endgroup$ Commented Mar 14, 2021 at 17:13

2 Answers 2

2
$\begingroup$

Try this:

diffEq = Derivative[1][r][t] == (2*(c + A*t)*(1 + z))/(2 + z);
initialConditions = r[0] == 0;
sol = DSolve[{diffEq, initialConditions}, r, t][[1, 1, 2]];
Integrate[sol[t], {t, t1, t0}]

(*  ((3 c (t0^2 - t1^2) + A (t0^3 - t1^3)) (1 + z))/(3 (2 + z))  *)

Have fun!

$\endgroup$
3
$\begingroup$

Expand your ode by R[t]==r'[t]

{ rr, RR} =DSolveValue[{{diffEq, R'[t] == r[t]}, initialConditions}, {r, R}, t]
    (*
    {Function[{t}, ((2 c t + A t^2) (1 + z))/(2 + z)], 
     Function[{t}, (
      3 c t^2 + A t^3 + 3 c t^2 z + A t^3 z + 6 C[2] + 3 z C[2])/(
      3 (2 + z))]}
*) 

RR'[t] == rr[t] // Simplify
(* True*) 
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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