I'll admit that I only skimmed some other threads about this. They seem rather complicated in contrast to my simple problem. I have two lines in space defined by a two-by-two coefficient matrix. I intend to manipulate on a single entry, say the (1,2)-element. In the static case I worked to display the intersection point, between the two lines, on the graph. The goal is to watch the point of intersection change as the parameter changes. My code:

a = 1;
f = 3;
c = 2;
d = 1;
g = -1;

Line1 :=  a  x + b y ;
Line2 :=  c x + d y;
IntersectionPoint := Solve[Line1 == f && Line2 == g, {x, y}]
xIntersection := x /. IntersectionPoint[[1]][[1]] 
yIntersection := y /. IntersectionPoint[[1]][[2]] 

Manipulate[ContourPlot[{a x + b y == f, c x + d y == g}, {x, -5, 5}, {y, -5, 5},
                PlotLegends -> True, Axes -> True, 
                AxesLabel -> {x, y}, 
                Epilog -> {{Text[StringJoin["Point of Intersection:", " 
                           (x,y)=(", ToString[ N[xIntersection]], 
                            ",", ToString[N[yIntersection]] , ")"], 
                           Scaled[{.62, .8}]]}}], {b, -10, 10}]
  • $\begingroup$ Update: I posted before I asked my question. If you run the above code then you will see a symbolic result displayed on the screen that does not take into account the current value of the manipulated parameter 'b'. I would like the numerical value of the intersection point displayed through the manipulated values. $\endgroup$
    – user32569
    Aug 23, 2015 at 18:02
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 0) Browse the common pitfalls question 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ Aug 23, 2015 at 18:28
  • $\begingroup$ What is the problem here? Can you spell out what does work, and what doesn't? What would you like help with? $\endgroup$
    – MarcoB
    Aug 23, 2015 at 18:53

1 Answer 1

  m = {{a, b}, {c, d}};
  Column[{r = Thread[m.{x, y} == {f, g}], s = LinearSolve[m, {f, g}]}],
  ContourPlot[Evaluate@r, {x, -5, 5}, {y, -5, 5}, PlotLabel -> s]}, {{b, 3}, 0, 3}]

Mathematica graphics


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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