MathGroup Archive 2006

[Date Index] [Thread Index] [Author Index]

Search the Archive

Solve, D, and summations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg64054] Solve, D, and summations
  • From: misha <iamisha1 at comcast.net>
  • Date: Sun, 29 Jan 2006 05:57:31 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

I am (still) a new user of Mathematica and want to solve for the 
(easiest case) least squares estimators.

As usual, I want to choose b_0 and b_1 to minimize S, where S is the sum 
of squared differences.  i.e.,

In [1]:= S = sum{1,...,n}[y_i - b_0 - (b_1)*x_i]^2

Out [1]= sum{1,...,n}[y_i - b_0 - (b_1)*x_i]^2

After defining this function as above, which gave me the expression as I 
expected, I then wrote,

In [2]:= Solve[{D[S, b_0]==0, D[S, b_1]==0}, {b_0, b_1}]

But got

Out [2]= {}

I also tried it this way:

In [3]:= S[b_0, b_1] = sum{1,...,n}[y_i - b_0 - (b_1)*x_i]^2

Out [3]= sum{1,...,n}[y_i - b_0 - (b_1)*x_i]^2

In [4]:= Solve[{D[S, b_0]==0, D[S, b_1]==0}, {b_0, b_1}]

But got

Out [4]= {{}}

Is it the 'n' in the summation that is giving me the problem?

I also tried this:

In [5]:= D[S, b_0]

Out [5]= sum{1,...,n}-2*[y_i - b_0 - (b_1)*x_i]

(as expected)

In [6]:= D[S, b_1]

Out [6]= sum{1,...,n}-2*x_i*[y_i - b_0 - (b_1)*x_i]

After which I copied the returned expressions, set them to zero, and 
used Solve as below:

In [7]:= Solve[{sum{1,...,n}-2*[y_i - b_0 - (b_1)*x_i]
==0, sum{1,...,n}-2*x_i*[y_i - b_0 - (b_1)*x_i]==0}, {b_0, b_1}]

But, again, I got

Out [7]= {}

Thank you


  • Prev by Date: Re: Annoying Maximize behaviour
  • Next by Date: Re: Re: How to get range of InterpolatingFunction ?
  • Previous by thread: Generating DAGs in mathematica
  • Next by thread: Re: Solve, D, and summations