# [Maxima] Partial differentiation of a sum??

Julien Martin balteo at gmail.com
Sun Oct 17 14:03:15 CDT 2010

```Thanks all!
It works using expand(foo) as suggested by Robert.
I am also going to have a look at the lsquare package.
J.

2010/10/17 Robert Dodier <robert.dodier at gmail.com>

> On 10/17/10, Julien Martin <balteo at gmail.com> wrote:
>
> > I am working with the least squares method, I would like to differentiate
> a
> > sum as follows and I am having problems.
> > What I want to achieve:
> > -define a sum
> > -differentiate it with respect to "a" and "b" respectively.
> > -solve the resulting system.
> >
> > *exp:sum((y_i-a*x_i-b)^2,i,1,n);
> > one:diff(exp,a,1)=0;
> > two:diff(exp,b,1)=0;
> > linsolve([one, two], [a,b]);
>
> Subscripted variables are denoted by square brackets in Maxima.
> x_i is just an arbitrary symbol, x[i] is a subscripted variable.
>
> By default, Maxima doesn't assume sum is linear.
> Try declare(sum, linear).
>
> Also try expand(foo) where foo is your derivative expression.
>
> Naming a user variable exp is probably going to eventually
> lead to obscure problems since exp is the exponential function.
>
> If you want to solve least squares problems in general,
> take a look at the lsquares package.
> ?? lsquares finds some info about that.
>
> HTH
>
> Robert Dodier
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.math.utexas.edu/pipermail/maxima/attachments/20101017/131a4f0a/attachment.html>
```