1

Hi I'm trying to visualize a 2D equation that I have previously solved as I vary a parameter 'b'. First I solve for 'y' in terms of 'x' and 'b', then I intend to use Manipulate.

sol = Solve[y+b==2*x,y]
Manipulate[Plot[y/.sol,{x,-1,1}],{b,-2,2}]

In this simplified example I'm expecting a line of slope 2 to move up and down as I vary 'b' but I just get a blank graph.

mikado
  • 16,741
  • 2
  • 20
  • 54

1 Answers1

0

This is a tricky. The problem is that the argument b needs to appear explicitly in the Manipulate expression. One solution, perhaps not simplest, is as follows

sol = Solve[y + b == 2*x, y]
y1[x_, b_] = y /. sol[[1, 1]]
Manipulate[Plot[y1[x, b], {x, -1, 1}], {b, -2, 2}]
mikado
  • 16,741
  • 2
  • 20
  • 54
  • I understand, thank you! It's strange that Manipulate can't handle 'b' implicitly.. but this still works :) Thanks! – Matthew James Sep 30 '18 at 11:45
  • This is a very nice and simple solution to a tricky problem. I have been looking for it for quite a long time. Thank you! – HdoMat Jun 18 '21 at 19:30