0
$\begingroup$

I am going to plot the function y[x_]:=1/x associated with horizontal finite lines. For example at y=-12,8, -6.5, -5.5, -5.0. Can anyone help me to plot it?

enter image description here

$\endgroup$
0

2 Answers 2

6
$\begingroup$

Try this:

Show[{
  Plot[-(1/x), {x, 0.06, 1}, PlotRange -> {-13, 0.1}],
  Graphics[{Red, 
      Line[{{0, #}, {-(1/#), #}}]}] & /@ {-12, -8, -6.5, -5.5, -5.0}
  }]

yielding

enter image description here

Have fun!

$\endgroup$
0
$\begingroup$

Following is the layman's way (Non-technical) to plot the required plot;

Here I am plotting each finite line from $0$ to intersection point of the line with the curve ($-1/x$). This intersection point (endpoint of the line) can be found by equating: $-1/x=-12 \rightarrow x=1/12$)

  y[x_] := -1/x
  p1 = Plot[{-12}, {x, 0, 1/12}] 
  p2 = Plot[y[x], {x, 0, 1}]
  Show[{p1, p2}, PlotRange -> All]

enter image description here

You can combine all the lines in a single plot.

   y[x_] := -1/x
   p1 = Table[Plot[{-1/n}, {x, 0, n}], {n, {1/12, 1/8, 1/6.5, 1/5.5,1/5}}];
   p2 = Plot[y[x], {x, 0.0, 1}]
   Show[{p1, p2}, PlotRange -> All]

enter image description here

$\endgroup$
2
  • $\begingroup$ finite lines!!! I think your lines are not finite. $\endgroup$
    – monfneg
    Commented Oct 9, 2018 at 8:43
  • $\begingroup$ @monfneg, Hey, I have modified. $\endgroup$ Commented Oct 9, 2018 at 9:05

Not the answer you're looking for? Browse other questions tagged or ask your own question.