Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

cyberdemon93

  • 3 years ago

As an exercise, write a function slope(x1, y1, x2, y2) that returns the slope of the line through the points (x1, y1) and (x2, y2). Then use this function in a function called intercept(x1, y1, x2, y2) that returns the y-intercept of the line through the points (x1, y1) and (x2, y2). I have done the first part but i keep getting confused when i reach the second part.

  • This Question is Closed
  1. 03225186213
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    from the first part make equation now for y intercept put x==0 in equation u will gwt intercepts

  2. FabienToune
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    If you consider the generic equation of a line : y = ax + b when you get the slope, you actually get the 'a' of your equation. You also have an x and an y (you can take for exemple x1 and y1). All you need to do is to infer the value of b, which is precisely the y-intercept asked.

  3. myndless
    • 3 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    the equation of a line is \[y=mx+b\], where m is the slope of the line, and b is the offset from the origin along the y axis. The y-intercept is the value of y where x = 0, so\[y = 0m + b\]\[y = b\] For any point that you know exists on the line, you can solve for b. \[y_1 = mx_1 + b\]\[b = y_1 - mx_1\]So all intercept(x1,y1,x2,y2) has to do is return y1 - slope(x1,y1,x2,y2) * x1

  4. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy