Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This works for me:

var("a,h,k,x,y")
f = (x-h)^2 - 4*a*(y-k)
Parabola = y.subs(solve(f,y))
print(Parabola)
@interact
def _(h=slider(-5,5,default=1), a=slider(-5,5,default=1),
      k=slider(-5,5,default=1)):
    if a==0: 
        print(f"Invalid value for a. Please, select another value")
    else:
        show(plot(Parabola(a=a,h=h,k=k),x,-5,5))

Parabola is a symbolic expression which depends on x, but also on a, h and k. You must explicitly substitute the values of these variables in Parabola before plotting it as a function of x. Please, also note the alternative way to define Parabola and the caution that should be taken in the case a=0.

This works for me:

var("a,h,k,x,y")
f = (x-h)^2 - 4*a*(y-k)
Parabola = y.subs(solve(f,y))
print(Parabola)
@interact
def _(h=slider(-5,5,default=1), a=slider(-5,5,default=1),
      k=slider(-5,5,default=1)):
    if a==0: 
        print(f"Invalid print("Invalid value for a. Please, select another value")
    else:
        show(plot(Parabola(a=a,h=h,k=k),x,-5,5))

Parabola is a symbolic expression which depends on x, but also on a, h and k. You must explicitly substitute the values of these variables in Parabola before plotting it as a function of x. Please, also note the alternative way to define Parabola and the caution that should be taken in the case a=0.