Input:

% declare symbols
syms F0 F1 F2 F3 F4 F5 F6 F7 F8;
F = [F0 F3 F6 
     F1 F4 F7 
     F2 F5 F8];
C = (F.')*F;
I_C = trace(C);
II_C = (1/2)*(I_C^2 - trace(C^2));
III_C = det(C);
E = 0.5 * (C - eye(3));
F = reshape(F, 9, 1);

% declare strain energy
syms mu J lambda;
strain_energy = mu/2 * (I_C - 3) - mu * log(J) + lambda / 2 * log(J)^2;

% differentiate
Rd_sym = sym('TEMP')*ones(1,9);
for i = 1:9
  Rd_sym(1,i) = -diff(strain_energy, F(i));
end
Kd_sym = sym('TEMP')*ones(9*9,1);
for i = 1:9
  for j = 1:9
    Kd_sym((i-1)*9+j) = diff(Rd_sym(1,i), F(j) );
  end
end

% generate C code
stiffnessDensity = maple('codegen[C]', Kd_sym, 'optimized');

Output:

void NEO_HOOKEAN::stiffnessDensity(const Real* F, Real* stiffness)
{
  const double mu = _mu;

  stiffness[0] = -mu;
  stiffness[1] = 0.0;
  stiffness[2] = 0.0;
  stiffness[3] = 0.0;
  stiffness[4] = 0.0;
  stiffness[5] = 0.0;
  stiffness[6] = 0.0;
  stiffness[7] = 0.0;
  stiffness[8] = 0.0;
  
  stiffness[9] = 0.0;
  stiffness[10] = -mu;
  stiffness[11] = 0.0;
  stiffness[12] = 0.0;
  stiffness[13] = 0.0;
  stiffness[14] = 0.0;
  stiffness[15] = 0.0;
  stiffness[16] = 0.0;
  stiffness[17] = 0.0;
  
  stiffness[18] = 0.0;
  stiffness[19] = 0.0;
  stiffness[20] = -mu;
  stiffness[21] = 0.0;
  stiffness[22] = 0.0;
  stiffness[23] = 0.0;
  stiffness[24] = 0.0;
  stiffness[25] = 0.0;
  stiffness[26] = 0.0;
  
  stiffness[27] = 0.0;
  stiffness[28] = 0.0;
  stiffness[29] = 0.0;
  stiffness[30] = -mu;
  stiffness[31] = 0.0;
  stiffness[32] = 0.0;
  stiffness[33] = 0.0;
  stiffness[34] = 0.0;
  stiffness[35] = 0.0;
  
  stiffness[36] = 0.0;
  stiffness[37] = 0.0;
  stiffness[38] = 0.0;
  stiffness[39] = 0.0;
  stiffness[40] = -mu;
  stiffness[41] = 0.0;
  stiffness[42] = 0.0;
  stiffness[43] = 0.0;
  stiffness[44] = 0.0;
  
  stiffness[45] = 0.0;
  stiffness[46] = 0.0;
  stiffness[47] = 0.0;
  stiffness[48] = 0.0;
  stiffness[49] = 0.0;
  stiffness[50] = -mu;
  stiffness[51] = 0.0;
  stiffness[52] = 0.0;
  stiffness[53] = 0.0;
  
  stiffness[54] = 0.0;
  stiffness[55] = 0.0;
  stiffness[56] = 0.0;
  stiffness[57] = 0.0;
  stiffness[58] = 0.0;
  stiffness[59] = 0.0;
  stiffness[60] = -mu;
  stiffness[61] = 0.0;
  stiffness[62] = 0.0;
  
  stiffness[63] = 0.0;
  stiffness[64] = 0.0;
  stiffness[65] = 0.0;
  stiffness[66] = 0.0;
  stiffness[67] = 0.0;
  stiffness[68] = 0.0;
  stiffness[69] = 0.0;
  stiffness[70] = -mu;
  stiffness[71] = 0.0;

  stiffness[72] = 0.0;
  stiffness[73] = 0.0;
  stiffness[74] = 0.0;
  stiffness[75] = 0.0;
  stiffness[76] = 0.0;
  stiffness[77] = 0.0;
  stiffness[78] = 0.0;
  stiffness[79] = 0.0;
  stiffness[80] = -mu;
}