Why are Different Tools Giving Different Values for 'm' in the Equation Y=mx+b?

  • Context: Undergrad 
  • Thread starter Thread starter Whalstib
  • Start date Start date
Click For Summary

Discussion Overview

The discussion revolves around the determination of the slope "m" in the linear equation y=mx+b, particularly focusing on discrepancies in the values of "m" obtained using different tools such as Excel, Numbers, Open Office, and a calculator (HP50G). Participants explore the implications of setting the y-intercept (b) to zero and the methods used to calculate "m" under different conditions.

Discussion Character

  • Exploratory
  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • Whalstib reports different values for "m" using various tools, with Excel yielding m=27040 and other tools yielding m=30270.
  • Some participants discuss the least squares method and provide mathematical formulations for calculating "m" and "b".
  • There is confusion regarding whether setting y to zero is equivalent to setting the y-intercept (b) to zero, with one participant clarifying that it is indeed about the y-intercept.
  • Participants explore the implications of assuming b=0 and how it affects the calculation of "m".
  • There are suggestions for using the HP50G to calculate "m" with b=0, including methods for obtaining necessary sums from regression analysis.

Areas of Agreement / Disagreement

Participants express differing views on the significance of setting the y-intercept to zero, and there is no consensus on the best method to calculate "m" under these conditions. The discussion remains unresolved regarding the implications of different tools and methods used.

Contextual Notes

Participants note the potential for confusion arising from different interpretations of the equation y=mx+b versus y=mx when b=0. There are also references to the limitations of various tools in performing these calculations accurately.

Who May Find This Useful

This discussion may be useful for students and practitioners in fields involving linear regression analysis, particularly those using different software tools for data analysis.

Whalstib
Messages
119
Reaction score
0
Hi,

I've run into an issue with attempting to determine "m".

In a chemistry class we're to determine "m" with one of several tools available. Most are using spread sheets which is causing the confusion.

The problem arises when it seems only Excel allows one to simply set y to zero. This is explicitly mentioned in the text but no other spread sheets I've used are able to reliably do this.

Excel gives m=27040 (with y=0)

Using Numbers and Open Office I get m=30270

Using my HP50G I get m=30270

Using ∑xy/x^2 I get m=27040

I was able to simply use ∑xy/x^2 as I only had 10 values but I could have had hundreds which would have made the operation much more complex to do by hand.

I want to believe the HP50G as I can have it at hand easier than Excel. I would assume HP50G solves with the common parameters... but the raw math and Excel are the pair which seem more likely.

So...why would one solve for y=0 or not? If it's important why is this function not readily available on common tools?

Thanks,

Whalstib
 
Mathematics news on Phys.org
The least squares method is most easily remembered as:

[tex] y = m x + b[/tex]

Take [itex][f] \equiv \frac{1}{N} \, \sum_{i = 1}^{N}{f_{i}}[/itex]. Obviously [itex][c] = c[/itex] and [itex][f + g] = [f] + [g][/itex]. Taking the average of the above equation, we get:

[tex] [x] \, m + b = [y] \\[/tex]

Multiplying the equation by x and then taking the average, we get:

[tex] [x^{2}] \, m + [x] \, b = [x y][/tex]

This system has the solution:

[tex] m = \frac{[x y] - [x] \, [y]}{[x^{2}] - [x]^{2}}[/tex]

[tex] b = [y] - m \, [x][/tex]
 
Whalstib said:
So...why would one solve for y=0 or not? If it's important why is this function not readily available on common tools?
No, best I can guess from that post is you're talking about b=0. Please try to make sense when you post a question.
 
When b=0 then it's not actually y=mx+b is it. It's a different (easier) problem of just y=mx, right!

The mean square error is proportional to :

[tex]f(m) = \sum_{i=1}^{N} \left(mx_i - y \right)^2[/tex]

So

[tex]\frac{df}{dm} = 2 \sum_{i=1}^{N} x_i ( mx_i - y_i )[/tex]

The mean squared error is minimized when df/dm=0, giving :

[tex]m = \frac{\sum x_i y_i}{\sum x_i^2}[/tex]
 
Last edited:
That's it!

I forgot it's not about setting y to zero but the y intercept to zero which is b!

Since there are at least 2 ways to solve is there an easy way to convert from the y=mx+b to y=mx+0?

Any HP50G users out there that can show me how to take a simple set of data and get a y=mx+b with y intercept (b) = 0?

Thanks,

Whalstib


uart said:
When b=0 then it's not actually y=mx+b is it. It's a different (easier) problem of just y=mx, right!

The mean square error is proportional to :

[tex]f(m) = \sum_{i=1}^{N} \left( y_i - mx_i \right)[/tex]

So

[tex]\frac{df}{dm} = 2 \sum_{i=1}^{N} x_i (y_i - mx_i)[/tex]

The mean squared error is minimized when df/dm=0, giving :

[tex]m = \frac{\sum x_i y_i}{\sum x_i^2}[/tex]
 
Whalstib said:
That's it!

I forgot it's not about setting y to zero but the y intercept to zero which is b!

Since there are at least 2 ways to solve is there an easy way to convert from the y=mx+b to y=mx+0?

If you equate the two different formulas for m (with [itex]b \neq 0[/itex] and [itex]b = 0[/itex]), you will find that:

[tex] \frac{[x y] - [x] [y]}{[x^{2}] - [x]^{2}} = \frac{[x y]}{[x^{2}]}[/tex]

[tex] [x^{2}] \, [x y] - [x^{2}] [x] [y] = [x^{2}] [x y] - [x]^{2} [x y][/tex]

[tex] [x] ([x] [x y] - [x^{2}] [y]) = 0[/tex]

Since [itex][x] \neq 0[/itex], it must mean that:

[tex] [x] [x y] - [x^{2}] [y] = 0[/tex]

This is equivalent to:

[tex] b = [y] - m [x] = [y] - [x] \, \frac{[x y] - [x] [y]}{[x^{2}] - [x]^{2}} = \frac{[x^{2}] [y] - [x]^{2} [y] - [x] [x y] + [x]^{2} [y]}{[x^{2}] - [x]^{2}} = \frac{[x^{2}] [y] - [x] [x y]}{[x^{2}] - [x]^{2}} = 0[/tex]

since the numerator is zero. The bottom line is, if b really is zero, then your result will not change by including another fitting parameter (b) in your fitting model, because it wll really turn out to be zero and the two formulas for m ought to give the same result. If, on the other hand, it turns out the calculated value for b is not zero, then is certainly makes no sense to impose that restriction on the fitting model. The values for m that you get by the two formulas are different then, but the correct one is the one I gave, because it does not make the additional assumption of [itex]b = 0[/itex].
 
uart said:
No, best I can guess from that post is you're talking about b=0. Please try to make sense when you post a question.

yea sorry..

I was discussing this amongst friends and eventually got away from y intercept to simply y which still make sense to us in context but not those of you joining me on line.

Shows me I just need to slow down..

Thanks for actually figuring it out!

W
 
Whalstib said:
Any HP50G users out there that can show me how to take a simple set of data and get a y=mx+b with y intercept (b) = 0?

I don't have a HP50G, but I can think of several ways that might be available.

1. You should be able to get both [itex]\sum x_i y_i[/itex] and [itex]\sum x_i^2[/itex] from the "Summary Stats" after doing a conventional linear regression.

OR

2. Enter x and y as vectors and use dot products. [itex]m = (\tilde{x} \cdot \tilde{y}) \div (\tilde{x} \cdot \tilde{x})[/itex]
 
Last edited:

Similar threads

  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
Replies
7
Views
3K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 9 ·
Replies
9
Views
4K
Replies
44
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
4
Views
3K
  • · Replies 0 ·
Replies
0
Views
3K