Ask Your Question
0

NotImplementedError

asked 2020-08-12 22:04:15 +0200

ortollj gravatar image

updated 2020-08-12 22:16:18 +0200

Hi

UBUNTU 18.04, SageMath 9.1, Jupyter Notebook

its ok when I set matrixForm=False, but I got NotImplementedError error when I choose matrixForm=True.

Why ?

var('r0_0,r0_1,r1_0,r1_1,p_0,p_1,v_0,v_1,x,y')
def projectvOnV(v,V) :
    # projection matrix
    x=V[0];y=V[1]
    projectM=matrix(SR,[(x^2/(x^2 + y^2), x*y/(x^2 + y^2)),
         (x*y/(x^2 + y^2), y^2/(x^2 + y^2))])

    return projectM*v

matrixForm=True

if matrixForm :
    Vr0 = matrix(SR,[r0_0,r0_1]).transpose()
    Vr1 = matrix(SR,[r1_0,r1_1]).transpose()
    Vp = matrix(SR,[p_0,p_1]).transpose()

else :
    Vr0 = vector(SR,[r0_0,r0_1])
    Vr1 = vector(SR,[r1_0,r1_1])
    Vp = vector(SR,[p_0,p_1])



Vp=Vr0-Vr1
Vp_0=projectvOnV(Vr0,Vp)# vector Vr0 projeted on Vp

show("Vp : ",Vp,Vp.parent())
show("Vp_0 : ",Vp_0,Vp_0.parent())

Vin=Vr0-Vp_0
displayedObject=[Vin,Vr0,Vr1,Vp,Vp_0]
if matrixForm :
    for e in displayedObject :
        e=vector(e)
@interact
def _( thetaNumVr0=slider(0.01,2*pi,0.05,default=3.5),
        rhoNumVr0=slider(0.01,4,0.05,default=2),
        thetaNumVr1=slider(0.01,2*pi,0.05,default=5),
        rhoNumVr1=slider(0.01,4,0.05,default=1)):
        numL=[r0_0==rhoNumVr0*cos(thetaNumVr0),r0_1==rhoNumVr0*sin(thetaNumVr0),
             r1_0==rhoNumVr1*cos(thetaNumVr1),r1_1==rhoNumVr1*sin(thetaNumVr1)]

        plt=plot(arrow([0,0],Vr0.subs(numL),color="red",width=3,linestyle='dashed'))
        plt+=text("Vr0",(Vr0*4/5+vector([0.1,0.1])).subs(numL),color="red",fontsize=10)                          

        plt+=plot(arrow([0,0],Vr1.subs(numL),color="blue",width=3,linestyle='dashed'))
        plt+=text("Vr1",(Vr1*4/5+vector([0,0.1])).subs(numL),color="blue",fontsize=10)                          

        plt+=plot(arrow((Vr1).subs(numL).list(),(Vr1+Vp).subs(numL),color="grey",width=3,linestyle='dashed'))
        plt+=text("Vp",((Vr1+Vp).subs(numL))/2,color="grey",fontsize=10)                          

        plt+=plot(arrow([0,0],(Vp_0).subs(numL),color="pink",width=3,linestyle='dashed'))
        plt+=text("Vp_0",(Vp_0*4/5+vector([0.1,0.1])).subs(numL),color="pink",fontsize=10)                          

        plt+=plot(arrow([0,0],(Vin).subs(numL),color="black",width=3,linestyle='solid'))
        plt+=text("Vin",(Vin*4/5+vector([0.1,0.1])).subs(numL),color="black",fontsize=10)                          

        show(plt,aspect_ratio=1)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2020-08-13 23:26:03 +0200

Florentin Jaffredo gravatar image

The problem comes from this line:

x=V[0];y=V[1]

If V is a matrix, then x and y become rows, not symbolic variables. In the next line x^2 triggers the error, since a row squared doesn't make sense. Simply Replace it with

x=V[0, 0]; y=V[1, 0]
edit flag offensive delete link more

Comments

ortollj gravatar imageortollj ( 2020-08-14 07:09:54 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-08-12 22:04:15 +0200

Seen: 764 times

Last updated: Aug 13 '20