Question

In: Computer Science

1) Using matplotlib, graph the line of slope -2 going through the point (1,1). 2) Instead...

1) Using matplotlib, graph the line of slope -2 going through the point (1,1).

2) Instead of graphing the previous line, plot 5 evenly-spaced points on that line in the interval [0,1] (including 0 and 1).

Solutions

Expert Solution

ANS 1:

CODE:

#ANS :- 1

# the below two lines are required packeges to plotting lines and points on that line.

import numpy as np

import matplotlib.pyplot as plt

x=np.linspace(0,1,5)    #linspace() is one of the important method of numpy and used to divide points as per given Number/data.

y = -2*x + 3     #Here slope m=-2 and find the intercept value c = 3 by putting the value (1, 1) since line passing through this point(1, 1)

plt.plot(x,y, '-r',label="line y=-2*x + c")   #this is used to plot line in matplotlib packages.

plt.title("line plot with slope = -2 passing through (1,1)")  #Used to set title of the graph in matplotlib

plt.show()                                                #Used to show() the ON CONSOLE plotting.

ANS 2:

CODE:

import numpy as np

import matplotlib.pyplot as plt

x=np.linspace(0,1,5)

y = -2*x + 3

plt.plot(x,y, '-r+')

plt.title("five evenly spaced point on the line")

plt.show()


Related Solutions

Graph the line with y-intercept ?5 and slope ?2.
Graph the line with y-intercept ?5 and slope ?2.
1. Provide the equation of the line that has slope ? = −4 and passes through the point (−2,1).
  1. Provide the equation of the line that has slope ? = −4 and passes through the point (−2,1). 2.Rewrite ?(?) = |? − 4| as a piecewise-defined function. 3.Rewrite ln((?4(?2+2) )/??3 ) in terms of simpler logarithms (no powers, products, or quotients inside the logarithm). 4.Test ℎ(?) = −2?^4 + 8? − 3 for symmetry and state your conclusion. 5. If the domain is restricted to the open interval (-pi/2,pi/2),find the range of f(x)=e^tan x  
1.) Write a​ slope-intercept equation for a line passing through the point (5,−3) that is parallel...
1.) Write a​ slope-intercept equation for a line passing through the point (5,−3) that is parallel to the line 5x+7y=8. Then write a second equation for a line passing through the point (5,−3) that is perpendicular to the line 5x+7y=8. 2.) Write a​ slope-intercept equation for a line passing through the point (4,−3) that is parallel to the line 4x+5y=7. Then write a second equation for a line passing through the point (4,−3) that is perpendicular to the line 4x+5y=7....
1. Find the equation of the line with slope of m = −" # and through the point (8,−1).Write your final answer in slope -intercept form.
  1. Find the equation of the line with slope of m = −" # and through the point (8,−1).Write your final answer in slope -intercept form. ______________________________ 2. Find the equation of the line through the points (2,−7) ??? (−4,−8 ). Write your final answer in slope intercept form. ______________________________ 3. Find the equation of the line which passes through the point (10,−3) & is perpendicular to the line 5?+3?=2 ______________________________
Estimate the slope of the line from its graph.
Estimate the slope of the line from its graph.
A) Find the equation of the curve with slope 4x^2/x^2+1 and passes through the point (1,0)...
A) Find the equation of the curve with slope 4x^2/x^2+1 and passes through the point (1,0) B)Find the equation of the curve with slope 4x/ x-5 and passes through the point (6,0) C) Find the equation of the curve that satisfies dy/dx = 4x^3y and whose y-intercept is 19 D) Find the equation of the curve that passes through the point (1,1) and whose slope at (x,y) is y^2/x^3
find the equation of the line that has slope - 2/3 and which passes through (-1,-6)
find the equation of the line that has slope - 2/3 and which passes through (-1,-6)
Find the line that passes through the point (0, 1) and through the point of intersection...
Find the line that passes through the point (0, 1) and through the point of intersection of the two lines  and
Find the slope of the tangent line to the graph of the given function at the...
Find the slope of the tangent line to the graph of the given function at the given value of x. Find the equation of the tangent line. y=x^4-2x^3+3; x=2 How would the slope of a tangent line be determined with the given​ information? A. Set the derivative equal to zero and solve for x. B. Substitute values of x into the equation and solve for y. Plot the resulting points to find the linear equation. C.Substitute 2 for x into...
Find the slope of the tangent line to the graph of the function at the given...
Find the slope of the tangent line to the graph of the function at the given point. f(x) = 4/3x at (1,4/3) Determine an equation of the tangent line. y = i need belp determing the equation because i got the slope right but not the equation 2. Mortgage Rates The average 30-year fixed mortgage rate in the United States in the first week of May in 2010 through 2012 is approximated by M(t) = 55.9 t2 − 0.31t +...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT