Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Get the slope of a line in my example?

  1. Jul 11, 2011 #1
    Hi,

    I've these values:

    Code (Text):

    # x     y=f(x)
    50      1957768251
    100     3915542997
    150     5873311096
    500     19577709464
    1000   39155455160
    1500   58686574963
    2000   78292255800
    2500   97888617384
    3000   117466340329
    3500   137044056081
    4000   156491263529
    4500   176177759312
     
    These values represents a straight line in a graph. Using the equation y=mx+b, and assuming b=0, I would like to know the slope of the straight line. Since, it's the m variable that gives me the slope, so,

    [itex]m=\frac{y}{x}[/itex]


    Applying this equation, I get the results:

    Code (Text):

    39155365
    39155429
    39155407
    39155418
    39155455
    39124383
    39146127
    39155446
    39155446
    39155444
    39122815
    39150613
     
    With these results, the slope is around 39000000??? Shouldn't I get a more reasonable value, like 3???

    What is the slope?

    Thanks,
     
  2. jcsd
  3. Jul 11, 2011 #2
    39000000 looks about right. The better way to do this is a least squares fit, but it won't give you a radically different result.
     
  4. Jul 11, 2011 #3

    gb7nash

    User Avatar
    Homework Helper

    The slope is nowhere near 3. How did you get the y-values? Without knowing what you did to get these values, I would guess that it's roundoff error. But it looks like the slope is around 39000000 as you said.

    Just out of curiousity, what's the context of this problem? It would be more helpful if we knew what you were trying to do.
     
  5. Jul 11, 2011 #4
    Why do you expect the slope to be around 3? do you know something we don't?

    First of all...if you think that slope values should be reasonable, you are mistaken...think about it, a line that is vertical has a slope of infinite!

    Second, if you know ahead of time what you are looking for and know that the slope should be around 3...then, you may have a type-cast-ing problem or printing problem or something...what kind of environment/programming language are you using to do this work? are you performing a REAL calculation and assigning this to an INTEGER variable? or what?
     
  6. Jul 12, 2011 #5
    f(x) is the time spent in executing the whole computer program.
    To understand my problem, I must explain the program.

    I've 2 versions of a program. The difference between them is that one of them execute 3 times more than one of them.

    For example, in program one, it accepts the input 50 and returns the solution at a time t.
    [itex]t=f(x)[/itex]

    The program two, it accepts the input 50, and execute the same instructions 3 times before return a result.
    [itex]t'=3f(x)[/itex]

    Now I get it what's my problem. I'm just putting part of the results, I must put the rest of the results to get the value that I want, which is 3.

    Thank you for your answers.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Get the slope of a line in my example?
  1. Mid-line of two slopes (Replies: 6)

Loading...