Thoughts Serializer

Maple

Thank god there is Maple… I was trying to calculate the analytical derivatives of a big function today. My brain almost melted, so I found out we have Maple! It is excelent! It can calculate the analytical derivatives for any function… I had to calculate the Jacobian of derivatives for this function :

    (a*A + b*B -a*x - b*y) * A_ + (c*A + d*B -c*x -d*y)*B_ -(a*x_ + c*y_)*A -(b*x_ + d*y_)*B + (a*x+b*y)*x_ + (c*x + d*y)*y_) / sqrt( (a*A + b*B -a*x - b*y)**2 + (c*A + d*B -c*x -d*y)**2

According to Maple the partial derivatives are :

    ja = ((A-x)*A_-x_*A+x*x_)/(a**2*A**2+2*a*A*b*B-2*a**2*A*x-2*a*A*b*y+b**2*B**2-2*b*B*a*x-2*b**2*B*y+a**2*x**2+2*a*x*b*y+b**2*y**2+c**2*A**2+2*c*A*d*B-2*c**2*A*x-2*c*A*d*y+d**2*B**2-2*d*B*c*x-2*d**2*B*y+c**2*x**2+2*c*x*d*y+d**2*y**2)**(0.5)-0.5*((a*A+b*B-a*x-b*y)*A_+(c*A+d*B-c*x-d*y)*B_-(a*x_+c*y_)*A-(b*x_+d*y_)*B+(a*x+b*y)*x_+(c*x+d*y)*y_)*(2*a*A**2+2*A*b*B-4*a*A*x-2*A*b*y-2*b*B*x+2*a*x**2+2*x*b*y)/(a**2*A**2+2*a*A*b*B-2*a**2*A*x-2*a*A*b*y+b**2*B**2-2*b*B*a*x-2*b**2*B*y+a**2*x**2+2*a*x*b*y+b**2*y**2+c**2*A**2+2*c*A*d*B-2*c**2*A*x-2*c*A*d*y+d**2*B**2-2*d*B*c*x-2*d**2*B*y+c**2*x**2+2*c*x*d*y+d**2*y**2)**(1.5)
    jb = ((B-y)*A_-x_*B+y*x_)/(a**2*A**2+2*a*A*b*B-2*a**2*A*x-2*a*A*b*y+b**2*B**2-2*b*B*a*x-2*b**2*B*y+a**2*x**2+2*a*x*b*y+b**2*y**2+c**2*A**2+2*c*A*d*B-2*c**2*A*x-2*c*A*d*y+d**2*B**2-2*d*B*c*x-2*d**2*B*y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*d*B*c*x-2*d**2*B*y+c**2*x**2+2*c*x*d*y+d**2*y**2)**(1.5)  
    jy = (-b*A_-d*B_+b*x_+d*y_)/(a**2*A**2+2*a*A*b*B-2*a**2*A*x-2*a*A*b*y+b**2*B**2-2*b*B*a*x-2*b**2*B*y+a**2*x**2+2*a*x*b*y+b**2*y**2+c**2*A**2+2*c*A*d*B-2*c**2*A*x-2*c*A*d*y+d**2*B**2-2*d*B*c*x-2*d**2*B*y+c**2*x**2+2*c*x*d*y+d**2*y**2)**(0.5)-0.5*((a*A+b*B-a*x-b*y)*A_+(c*A+d*B-c*x-d*y)*B_-(a*x_+c*y_)*A-(b*x_+d*y_)*B+(a*x+b*y)*x_+(c*x+d*y)*y_)*(-2*a*A*b-2*b**2*B+2*a*x*b+2*b**2*y-2*c*A*d-2*d**2*B+2*c*x*d+2*d**2*y)/(a**2*A**2+2*a*A*b*B-2*a**2*A*x-2*a*A*b*y+b**2*B**2-2*b*B*a*x-2*b**2*B*y+a**2*x**2+2*a*x*b*y+b**2*y**2+c**2*A**2+2*c*A*d*B-2*c**2*A*x-2*c*A*d*y+d**2*B**2-2*d*B*c*x-2*d**2*B*y+c**2*x**2+2*c*x*d*y+d**2*y**2)**(1.5)
    jx_= (-a*A-b*B+a*x+b*y)/(a**2*A**2+2*a*A*b*B-2*a**2*A*x-2*a*A*b*y+b**2*B**2-2*b*B*a*x-2*b**2*B*y+a**2*x**2+2*a*x*b*y+b**2*y**2+c**2*A**2+2*c*A*d*B-2*c**2*A*x-2*c*A*d*y+d**2*B**2-2*d*B*c*x-2*d**2*B*y+c**2*x**2+2*c*x*d*y+d**2*y**2)**(0.5)
    jy_= (-c*A-d*B+c*x+d*y)/(a**2*A**2+2*a*A*b*B-2*a**2*A*x-2*a*A*b*y+b**2*B**2-2*b*B*a*x-2*b**2*B*y+a**2*x**2+2*a*x*b*y+b**2*y**2+c**2*A**2+2*c*A*d*B-2*c**2*A*x-2*c*A*d*y+d**2*B**2-2*d*B*c*x-2*d**2*B*y+c**2*x**2+2*c*x*d*y+d**2*y**2)**(0.5)

Just to get an idea of what I’m going through with my master thesis… the above might be more easy to follow if you gzip it!!!