# Mathematica Plotting Issue

**URL:** <https://community.wolfram.com/t/mathematica-plotting-issue/5937>\
**Category:** Questions\
**Tags:** engineering, mathematica, calculus\
**Created:** [June 12, 2015, 1:16am UTC](https://community.wolfram.com/t/mathematica-plotting-issue/5937 "2015-06-12T01:16:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kimrw22](https://avatars.discourse-cdn.com/v4/letter/k/3e96dc/32.png) [@kimrw22](https://community.wolfram.com/u/kimrw22)\
**Post date:** [June 12, 2015, 1:16am UTC](https://community.wolfram.com/t/mathematica-plotting-issue/5937/1 "2015-06-12T01:16:15Z")

</div>

I’m using Mathematica to solve an initial value problem, and then plot it. However, When I try and plot it I’m receiving an error message. The problem I’m trying to graph is

 ![ScreenShot2015-06-11at9.11.53PM.png](https://global.discourse-cdn.com/wolfram/original/3X/6/e/6e753be733df0bb75b3c7069d78f238aa0daf49e.png)

Here is my code:

```
\[Kappa] = 1/4; L = 4; 
  f[x_] = Piecewise[{{100*Sin[Pi*x], 0 <= x < 2}, {0, 2 <= x < 4}}]
Plot[f[x], {x, 0, 4}, AxesLabel -> Automatic, PlotRange -> Full]
un[x_, t_, n_] = Exp[-1/4*(n Pi/4)^2 t] Sin[n Pi x/4]
an[n_] = 2/4 Integrate[f[x]*Sin[n Pi x/4], {x, 0, 4}]
an[n_] = Simplify[an[n], n \[Element] Integers]
u[x_, t_, m_] = Sum[an[n] un[x, t, n], {n, 1, m}]
Plot[{f[x], u[x, 0, 1]}, {x, 0, L}, AxesLabel -> Automatic, 
 PlotLegends -> "Expressions"]
Plot[{f[x], u[x, 0, 20]}, {x, 0, L}, AxesLabel -> Automatic, 
 PlotLegends -> "Expressions"]

```

The last part of my code, where I am trying to change the value of m is where I running into issues. How can I fix this? Thanks!

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [June 12, 2015, 6:02am UTC](https://community.wolfram.com/t/mathematica-plotting-issue/5937/2 "2015-06-12T06:02:26Z")

</div>

Have you tried with a delayed definition

```
u[x_, t_, m_] := Sum[an[n] un[x, t, n], {n, 1, m}]

```

? Mathematica may have trouble finding a closed form for the symbolic sum. With the delayed definition the sum in evaluated when the parameters are numeric, which is easier.
