Y=mx+b Solving for m


by Whalstib
Tags: solving
Whalstib
Whalstib is offline
#1
Jul5-10, 01:10 PM
P: 119
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
Phys.Org News Partner Mathematics news on Phys.org
Researchers help Boston Marathon organizers plan for 2014 race
'Math detective' analyzes odds for suspicious lottery wins
Pseudo-mathematics and financial charlatanism
Dickfore
Dickfore is offline
#2
Jul5-10, 01:20 PM
P: 3,015
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]
uart
uart is offline
#3
Jul5-10, 02:46 PM
Sci Advisor
P: 2,751
Quote Quote by Whalstib View Post
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.

uart
uart is offline
#4
Jul5-10, 02:56 PM
Sci Advisor
P: 2,751

Y=mx+b Solving for m


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]
Whalstib
Whalstib is offline
#5
Jul5-10, 03:05 PM
P: 119
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


Quote Quote by uart View Post
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]
Dickfore
Dickfore is offline
#6
Jul5-10, 03:40 PM
P: 3,015
Quote Quote by Whalstib View Post
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].
Whalstib
Whalstib is offline
#7
Jul5-10, 04:00 PM
P: 119
Quote Quote by uart View Post
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
uart
uart is offline
#8
Jul6-10, 03:44 AM
Sci Advisor
P: 2,751
Quote Quote by Whalstib View Post
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]


Register to reply

Related Discussions
Help on Solving this Eq. Differential Equations 14
Solving 4^x + 4^-x = 8 - 2x - x^2 Precalculus Mathematics Homework 7
Solving this ODE Differential Equations 3
Need Help Solving These Set Theory, Logic, Probability, Statistics 1
please help how do i go about solving this?? Introductory Physics Homework 25