Confusing about an integral's result

Hi,

I use following command to investigate profit rate in terms of stock at t (S[t]) and demand at t as weel as price at t (market-clearing). In the first three lines, I havent subsituite in a expression of S[t] in terms of demand[t]. And I have profit rate = Demand[t] p[t] - [Sigma] S[t]

However, when i substitute by

S[t] = S0 - \!\(\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(t\)]\(Demand[
     t] \[DifferentialD]t\)\)

(S0 is the initial stock), the result seems different from the expression for profit rate above. The first two parts of the result are the same as the expression above, but i don’t know where -t [Sigma] (-D0 + a p[t]) comes from. Could you help me explain this? (I guess it might be a math problem?)

Thank you

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST

The rules explain how to format your code properly. Posting code Images doesn’t help other members to copy your code. Please EDIT your post and make sure code blocks start on a new paragraph and look framed and colored like this.

int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]

You can also embed notebook or attach notebook.

You are living dangerously by using the same variable t for both the integration variable and the endpoint of the interval of integration. It seems that an object of the form Integrate[f[t], {t, 0, t}] is treated in a funny way by Integrate:

D[Integrate[f[t], {t, 0, t}], t]
Integrate[Integrate[f[t], {t, 0, t}], {t, a, b}]

Is the following what you wanted?

Clear[s, demand];
demand[t_] = d0 - a p[t];
s[t_] = s0 - Integrate[demand[r], {r, 0, t}];
Integrate[p[u] demand[u], {u, 0, t}] - 
 Integrate[s[u] \[Sigma], {u, 0, t}]
profitRate[t_] = D[%, t]