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

  • Thread starter Thread starter Whalstib
  • Start date Start date
AI Thread Summary
Different tools yield varying values for "m" in the equation Y=mx+b due to discrepancies in how they handle the y-intercept (b). Excel allows users to set y to zero directly, resulting in m=27040, while other tools like Numbers and HP50G provide m=30270. The confusion stems from whether to include the y-intercept in calculations; setting b to zero simplifies the equation to y=mx. Users express frustration over the lack of a straightforward method to impose this condition across common spreadsheet tools. Ultimately, understanding the implications of setting b to zero is crucial for accurate calculations of "m."
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:

<br /> y = m x + b<br />

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

<br /> [x] \, m + b = [y] \\<br />

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

<br /> [x^{2}] \, m + [x] \, b = [x y]<br />

This system has the solution:

<br /> m = \frac{[x y] - [x] \, [y]}{[x^{2}] - [x]^{2}}<br />

<br /> b = [y] - m \, [x]<br />
 
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 :

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

So

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

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

m = \frac{\sum x_i y_i}{\sum x_i^2}
 
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 :

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

So

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

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

m = \frac{\sum x_i y_i}{\sum x_i^2}
 
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 b \neq 0 and b = 0), you will find that:

<br /> \frac{[x y] - [x] [y]}{[x^{2}] - [x]^{2}} = \frac{[x y]}{[x^{2}]}<br />

<br /> [x^{2}] \, [x y] - [x^{2}] [x] [y] = [x^{2}] [x y] - [x]^{2} [x y]<br />

<br /> [x] ([x] [x y] - [x^{2}] [y]) = 0<br />

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

<br /> [x] [x y] - [x^{2}] [y] = 0<br />

This is equivalent to:

<br /> 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<br />

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 b = 0.
 
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 \sum x_i y_i and \sum x_i^2 from the "Summary Stats" after doing a conventional linear regression.

OR

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