# Question:Help on code optimization

## Question:Help on code optimization

Maple

Hi everyone,

Can somebody help me to make this code faster? Or if somebody have fast computer and can execute it and give me the result.

When I execute it, I don't have the result of the last command and get the error of not enough memory allocation or something.

Here is the code:

`>restart;with(LinearAlgebra):with(VectorCalculus):with(linalg):> a1:=1:> a2:=1:> T:=<x1,x2,x3,x4,y1,y2,y3,y4,u1,u2,u3,u4>:> > dx:=sqrt((x1-x3)^2+(x2-x4)^2):> x1dot:=a2/(2*pi*dx^2)*<x4-x2,x1-x3>:`
`> x2dot:=a1/(2*pi*dx^2)*<x2-x4,x3-x1>:`
`> > dy1:=sqrt((x1-y1)^2+(x2-y2)^2):> dy2:=sqrt((x3-y1)^2+(x4-y2)^2):> dy3:=sqrt((x3-y3)^2+(x4-y4)^2):> dy4:=sqrt((x3-y3)^2+(x4-y4)^2):> `
`>y1dot:=a1/(2*pi*dy1^2)*<x2-y2,y1-x1>+a2/(2*pi*dy2^2)*<x4-y2,y1-x3>+<u1,u2>:> y2dot:=a1/(2*pi*dy3^2)*<x2-y4,y3-x1>+a2/(2*pi*dy4^2)*<x4-y4,y3-x3>+<u3,u4>:`
`xdot:=<x1dot,x2dot>:`
`zdot:=<xdot,y1dot,y2dot>:`
`> l:=convert(<zdot,-u1,u2,-u3,u4>,Vector):`
`g1:=<0,0,0,0,0,0,0,0,1,0,0,0>:> g2:=<0,0,0,0,0,0,0,0,0,1,0,0>:> g3:=<0,0,0,0,0,0,0,0,0,0,1,0>:> g4:=<0,0,0,0,0,0,0,0,0,0,0,1>:`
`Lie Bracket Function> LB:=proc(m,w)> convert(evalm(multiply(Jacobian(convert(w,Vector),convert(T,list)),m)-multiply(Jacobian(convert(m,Vector),convert(T,list)),w)),Vector[column]):> end:> C:=Matrix([g1,g2,g3,g4,LB(l,g1),LB(l,g2),LB(l,g3),LB(l,g4),LB(l,LB(l,g1)),LB(l,LB(l,g2)),LB(l,LB(l,g3)),LB(l,LB(l,g4))]):> Rank(C);> `

Thanks

﻿