# Differential equations

1. May 31, 2005

### watermint

Differential equation

I have an equation that my teacher asked me to solve it using computer programming. I am stuck at how to do because I just learnt C++ for about 3 months. Can you help me write a solution to the following problem in C++?
$$\frac{dv}{dt}=t$$
Thank you

Last edited: May 31, 2005
2. May 31, 2005

### watermint

3. May 31, 2005

### BobG

Seems to me you should break it down by it's parts. You have a dependent variable 'v', the derivative of the dependent variable 'dv', an independent variable 't', and the derivative of t 'dt' v, dv, and t could have coefficients. In this case, the coefficient for v is 0 and the coefficients for dv and t are 1.

You'll have to program each individual step in solving the problem. Separating the variables is no problem (multiply both sides by dt). You have to also program the integration. Both sides are simple anti-derivatives using the power law. That adds a variable for each side - the power associated with v and the power associated with t.

Your program should integrate both sides by adding one to the power and then dividing the result by the new power.

After separating the variables in your separable differential equation:

$$v^0 dv = t^1 dt$$

After integrating both sides, your equation becomes:

$$\frac{v^1}{1} = \frac{t^2}{2} + c$$

(If you're writing a program for this, it helps to write out everything that's happening, even the parts you automatically drop out when you're doing this by hand.)

Since c is assumed to be zero, you can thankfully disregard it. Your coefficients all have values that allow you to ignore them in this example, but you could actually handle other coefficients in your program without much trouble.

4. May 31, 2005

### Andrew Mason

The solution is:

[tex]v = \frac{ds}{dt} = \frac{1}{2}t^2 + C[/itex]

[tex]s = \frac{1}{6}t^3 + Ct + D[/itex]

Do you want the program to calculate s for a given t or do you want it to solve the differential equation (ie do an integration)?

AM

5. May 31, 2005

### Hurkyl

Staff Emeritus
This question doesn't make sense to me, unless the teacher is asking him to perform a numerical integration... you should remember how to compute an integral numerically from your Calc II course...

6. May 31, 2005

### whozum

Why did you assume it to be a second order DE?