# `plot`::`Sum`

Graphical primitive for symbolic sums

MuPAD® notebooks will be removed in a future release. Use MATLAB® live scripts instead.

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```plot::Sum(`ex`, `i = m .. n`, <`a = amin .. amax`>, `options`)
plot::Sum(sum(`ex`, `i = m .. n`), <`a = amin .. amax`>, `options`)
```

## Description

`plot::Sum(ex, i = m..n)` creates a plot of summing `ex` over the range `m..n`.

`plot::Sum` creates a visual display of partial sums over a finite interval. Mathematically, ```plot::Sum(ex, i = m..n)``` plots the function .

To ease the use of `plot::Sum` in programs, symbolic sums are accepted in the input and `plot::Sum` takes care not to evaluate these. It is highly recommended, though, not to use this syntax in interactive applications, to avoid premature evaluation.

## Attributes

AttributePurposeDefault Value
`AffectViewingBox`influence of objects on the `ViewingBox` of a scene`TRUE`
`AntiAliased`antialiased lines and points?`FALSE`
`Color`the main color`RGB::Blue`
`Filled`filled or transparent areas and surfaces`FALSE`
`FillColor`color of areas and surfaces`RGB::Red`
`FillPattern`type of area filling`Solid`
`Frames`the number of frames in an animation`50`
`Function`function expression or procedure
`Legend`makes a legend entry
`LegendText`short explanatory text for legend
`LegendEntry`add this object to the legend?`FALSE`
`LineColor`color of lines`RGB::Blue`
`LineWidth`width of lines`0.35`
`LineColor2`color of lines`RGB::DeepPink`
`LineStyle`solid, dashed or dotted lines?`Solid`
`LinesVisible`visibility of lines`TRUE`
`LineColorType`line coloring types`Flat`
`LineColorFunction`functional line coloring
`LineColorDirection`the direction of color transitions on lines[`0`, `1`]
`LineColorDirectionX`x-component of the direction of color transitions on lines`0`
`LineColorDirectionY`y-component of the direction of color transitions on lines`1`
`Name`the name of a plot object (for browser and legend)
`ParameterEnd`end value of the animation parameter
`ParameterName`name of the animation parameter
`ParameterBegin`initial value of the animation parameter
`ParameterRange`range of the animation parameter
`PointColor`the color of points`RGB::MidnightBlue`
`PointsVisible`visibility of mesh points`FALSE`
`TimeEnd`end time of the animation`10.0`
`TimeBegin`start time of the animation`0.0`
`TimeRange`the real time span of an animation`0.0` .. `10.0`
`Title`object title
`TitleFont`font of object titles[`" sans-serif "`, `11`]
`TitlePosition`position of object titles
`TitleAlignment`horizontal alignment of titles w.r.t. their coordinates`Center`
`TitlePositionX`position of object titles, x component
`TitlePositionY`position of object titles, y component
`Visible`visibility`TRUE`
`VisibleAfter`object visible after this time value
`VisibleBefore`object visible until this time value
`VisibleFromTo`object visible during this time range
`VisibleAfterEnd`object visible after its animation time ended?`TRUE`
`VisibleBeforeBegin`object visible before its animation time starts?`TRUE`
`XMax`final value of parameter “x”
`XMin`initial value of parameter “x”
`XName`name of parameter “x”
`XRange`range of parameter “x”

## Examples

### Example 1

It is well known that . We use `plot::Sum` to display the first 100 partial sums:

```plot(plot::Sum(1/j^2, j = 1..100), plot::Function2d(PI^2/6, x=1..101, LineStyle = Dashed))```

With more partial sums, the steps approximate points:

`plot(plot::Sum(sin(j^2)/j, j=1..500))`

### Example 2

To show some of the formatting options of `plot::Sum`, we use the following sum:

`s := plot::Sum(1/j, j = 1..20)`

By default, this object is displayed as follows:

`plot(s)`

To change parameters, we can select them in the inspector and change the values, we can give other values directly in the `plot` command or we can set the new values in our object `s`:

```s::PointsVisible := TRUE: s::LinesVisible := FALSE: s::PointColor := RGB::Green: plot(s)```

### Example 3

`plot::Sum` allows animation in the usual way, for example, in the term to sum:

`plot(plot::Sum(sin(a*i^2)/i, i = 1..50, a = 0..PI))`

Another interesting parameter to animate is the summation range:

`plot(plot::Sum((-1)^j/j, j = 1..jmax, jmax = 1..50))`

## Parameters

 `ex` Arithmetical expression in `i` and the animation parameter `a`, if that is used. `ex` is equivalent to the attribute `Function`. `i` An identifier or indexed identifier. `i` is equivalent to the attribute `XName`. `m .. n` The range of `i`. `m` and `n` may be expressions in the animation parameter `a`. Summation goes over `m +` integer. If `n - m` is not an integer, `n` will not be reached. `m` .. `n` is equivalent to the attributes `XRange`, `XMin`, `XMax`. `a` Animation parameter, specified as `a```` = amin..amax```, where `amin` is the initial parameter value, and `amax` is the final parameter value.