1
$\begingroup$

I am quite new to Mathematica and I cannot find what I'm looking for on the Stackexchange or on the Mathematica help pages.

I have the following function $$U=\int^\tau_0 \bar{u}e^{-\rho t}dt \,+ \int^\infty_\tau ve^{-\rho t}dt$$ I am trying to form a plot that shows how the value of $U$ changes as $\tau$ changes, where everything else is constant. I would like to plot from $\tau=[0,2]$.

I have set $\bar{u} = 0.5$, $\rho=1$, $v=1$ for $t>0.5$ and $v=0$ otherwise.

This is what I have tried so far:

u=0.5
v=\[Piecewise]  0   t<0.5   1   t>0.5
ρ=1
Plot[Integrate[u E^(-ρ t), {t, 0, τ}]+Integrate[v E^(-ρ t), {t, τ, infinity}], {τ, 0, 2}]

When I run this, I only get an empty set of axes from 0 to 2. I have also tried defining the function "U", and then plotting "U", but I get the same result.

How do I form a plot for $U$ against $\tau$?

$\endgroup$

closed as off-topic by Michael E2, Henrik Schumacher, MarcoB, m_goldberg, Sektor May 20 '18 at 15:45

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Michael E2, Henrik Schumacher, MarcoB, m_goldberg, Sektor
If this question can be reworded to fit the rules in the help center, please edit the question.

2
$\begingroup$

Not getting a plot usually means that there are symbols in the expressions describing the plot that cannot be resolved.

There are two issues here. 1.) I corrected the Piecewise in the definition of v. 2.) I changed infinity to Infinity. For speeding up the computation, I changed also Integrate to NIntegrate.

u = 0.5
v = Piecewise[{{0 , t < 0.5}, {1, t > 0.5}}]
ρ = 1
Plot[NIntegrate[u E^(-ρ t), {t, 0, τ}] + 
  NIntegrate[v E^(-ρ t), {t, τ, Infinity}], {τ, 0, 2}]

enter image description here

Another possibility is to compute the integrand once symbolically (this is one of the rare instance where this is possible) and plot the result:

integrand = Integrate[u E^(-ρ t), {t, 0, τ}] + 
   Integrate[v E^(-ρ t), {t, τ, Infinity}, Assumptions -> τ > 0];
Plot[integrand, {τ, 0, 2}]

Note also that I had to help Integrate to find the integral by adding the option Assumptions -> τ > 0.

$\endgroup$

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