3
$\begingroup$

I am trying to solve for the constant of integration in simple calculus problems.

v[t_] := Integrate[-0.08 t, t] + C
v[t]

gives me

C - 0.04 t^2

Which is good, but then when I try

Solve[v[0] == 8]

It gives me an error because Im trying to integrate with respect to zero, because my function changes that.

I assume there is something really simple that I'm missing on how to make this work.

$\endgroup$
1
  • $\begingroup$ the problem is when you do v[0] then inside the function t=0 and you can't integrate with respect to zero. Another option is to write Solve[(v[t] /. t -> 0) == 8] if you want to keep the delay assignment. And it is a good idea to add the variables you are solving for, so it is explicit. $\endgroup$
    – Nasser
    Commented Jul 3, 2021 at 5:09

1 Answer 1

8
$\begingroup$

Use an immediate assignment to define v:

v[t_] = Integrate[-0.08 t, t] + c
(*    c - 0.04 t^2    *)

Solve[v[0] == 8]
(*    {{c -> 8.}}    *)

Here's a tutorial on the distinction between immediate and delayed assignments.

Alternatively, use a definite integral:

t0 = 0;
v0 = 8;
v[t_] = v0 + Integrate[-0.08 s, {s, t0, t}]
(*    8 - 0.04 t^2    *)
$\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.