% a = gr_acceleration(m,r,theta,phi,v)
% Compute the (four dimensional) acceleration vector a = [a0 a1 a2 a3] given
% the center mass and coordinates of the object in polar coordinates
% (r,theta,phi) and the current (four dimensional) velocity v. v(1) is the
% velocity of time (internal clock). This function has been auto generated
% to compute the following formulas as efficiently as possible:
% a0= (-2*m*v0*v1)/ (-2*m*r+r^2)
% a1= ((-4*m^3+4*m^2*r-m*r^2)*v0^2+m*r^2*v1^2+ (4*m^2*r^3-4*m*r^4+r^5)*v2^2+ (4*sin(theta)^2*m^2*r^3-4*sin(theta)^2*m*r^4+sin(theta)^2*r^5)*v3^2)/ (-2*m*r^3+r^4)
% a2= (-2*v1*v2+cos(theta)*sin(theta)*r*v3^2)/r
% a3= (-2*sin(theta)*v1-2*cos(theta)*r*v2)*v3/ (sin(theta)*r)
function a = gr_acceleration(m,r,theta,phi,v) %#codegen

%   Copyright 2010 The MathWorks, Inc.

v0 = v(1);
v1 = v(2);
v2 = v(3);
v3 = v(4);
t0=2*m;
t1=t0*v0;
t2=t1*v1;
t3= -t2;
t4=t0*r;
t5= -t4;
t6=r*r;
t7=t5+t6;
t8=t3/t7;
t9=m*m;
t10=m*t9;
t11=4*t10;
t12= -t11;
t13=4*t9;
t14=t13*r;
t15=t12+t14;
t16=m*t6;
t17=t15-t16;
t18=v0*v0;
t19=t17*t18;
t20=v1*v1;
t21=t16*t20;
t22=t19+t21;
t23=r*t6;
t24=t13*t23;
t25=4*m;
t26=r*t23;
t27=t25*t26;
t28=t24-t27;
t29=r*t26;
t30=t28+t29;
t31=v2*v2;
t32=t30*t31;
t33=t22+t32;
t34=sin(theta);
t35=t34*t34;
t36=4*t35;
t37=t36*t9;
t38=t37*t23;
t39=t36*m;
t40=t39*t26;
t41=t38-t40;
t42=t35*t29;
t43=t41+t42;
t44=v3*v3;
t45=t43*t44;
t46=t33+t45;
t47=t0*t23;
t48= -t47;
t49=t48+t26;
t50=t46/t49;
t51=2*v1;
t52=t51*v2;
t53= -t52;
t54=cos(theta);
t55=t54*t34;
t56=t55*r;
t57=t56*t44;
t58=t53+t57;
t59=t58/r;
t60=2*t34;
t61=t60*v1;
t62= -t61;
t63=2*t54;
t64=t63*r;
t65=t64*v2;
t66=t62-t65;
t67=t66*v3;
t68=t34*r;
t69=t67/t68;
a0=t8;
a1=t50;
a2=t59;
a3=t69;
a = [a0 a1 a2 a3];
