Solving for m in Y=mx+b

  • Thread starter Whalstib
  • Start date
In summary: OR3. Use the "Curve Fit" application. It will fit a straight line to data in one step without using y-intercept. The output is: m = 0.0030489 ; b = -2.1109e-16 ; r^2 = 0.9846OR4. Use the "Linear Regression" application. This will actually do a conventional linear regression, but one step will be to enter the intercept and you can enter a zero there.OR5. Use the "Least Squares" application. The screen will look like the "Linear Regression" application, but you have more flexibility because you can enter your own formula.
  • #1
Whalstib
119
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
  • #2
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]
 
  • #3
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.
 
  • #4
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:
  • #5
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]
 
  • #6
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].
 
  • #7
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
 
  • #8
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:

1. What is the meaning of "m" in the equation Y=mx+b?

"m" represents the slope of the line in the equation. It tells us how much the dependent variable (Y) changes for every unit change in the independent variable (x).

2. How do I solve for "m" in the equation Y=mx+b?

To solve for "m", you can use algebraic techniques such as isolating "m" on one side of the equation by subtracting "b" from both sides and then dividing both sides by "x". This will leave you with the equation m = (Y-b)/x.

3. Can the value of "m" be negative in the equation Y=mx+b?

Yes, the value of "m" can be positive, negative, or zero. A positive value indicates an upward sloping line, a negative value indicates a downward sloping line, and a value of zero indicates a horizontal line.

4. How does the value of "m" affect the graph of the equation Y=mx+b?

The value of "m" determines the steepness of the line in the graph. A larger value of "m" will result in a steeper line, while a smaller value of "m" will result in a flatter line.

5. Can I use the equation Y=mx+b to solve for "m" in any type of graph?

Yes, the equation Y=mx+b can be used to solve for "m" in any linear graph, which is a graph with a constant slope. It cannot be used for non-linear graphs, such as curves or exponential functions.

Similar threads

Replies
1
Views
1K
Replies
6
Views
942
  • General Math
2
Replies
38
Views
10K
Replies
6
Views
1K
  • Precalculus Mathematics Homework Help
Replies
19
Views
809
Replies
2
Views
1K
  • General Math
Replies
4
Views
3K
Replies
9
Views
2K
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
7
Views
641
Back
Top