Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

y=mx + c

Name: Dongus the dingus !p0dOyZT//A 2011-02-09 11:08

This isn't my homework.

I was writing some fucntions in python to find the intercept for a straight line.

The code it self works but I'm rather confused.

I chose some arbritary coordinates: (10,1) (1,2)

Now the gradient is -9 because (10-1)/(1-2)= -9.

To find the intercept I rearranged y = mx + c to y - mx = c and put (10,1) into it.

1 - (-9*10) = c
91 = c

To check the result I put the other coordinate in (like a good mathematician)

2 - (-9*1)= c
2 + 9 = c
11 = c
WTF BBQ!!!


My python code if you give a shit:

def slope(x1,y1,x2,y2,):
    dx=x1-x2
    dy=y1-y2
    grad=dx/dy
    return float(grad)

def intercept(x1,y1,x2,y2):
    temp=slope(x1,y1,x2,y2)
    c=y1-(temp*x1)
    print c

Name: Anonymous 2011-02-09 11:49

It's simple; you mixed up your point coordinate order.  When you calculated for m, you used 10 from (10,1) as a y coordinate.  When you plugged the chugged to check your answers, 10 became an x coordinate.

For points(y,x) (10,1) and (2,1) the slope is -9.  The intercept:
C = y + 9x
C = 10 + 9*1 = 19;
C = 1 + 9*2 = 19;

Name: Anonymous 2011-02-09 12:17

>>2
Now that's my goof.  The second point is supposed to be (1,2) like OP listed.  The math is still solid.

Name: Anonymous 2011-02-10 5:47

lol y=mx+c is noob tier

Name: Anonymous 2011-02-17 16:24


Don't change these.
Name: Email:
Entire Thread Thread List