Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #12404 > unrolled thread
| Started by | Tang Laoya <tanglaoya1989@gmail.com> |
|---|---|
| First post | 2012-11-22 00:50 +0000 |
| Last post | 2012-11-23 08:35 +0000 |
| Articles | 3 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
How to calculate the partial derivative? Tang Laoya <tanglaoya1989@gmail.com> - 2012-11-22 00:50 +0000
Re: How to calculate the partial derivative? Tang Laoya <tanglaoya1989@gmail.com> - 2012-11-22 09:41 +0000
Re: How to calculate the partial derivative? Tang Laoya <tanglaoya1989@gmail.com> - 2012-11-23 08:35 +0000
| From | Tang Laoya <tanglaoya1989@gmail.com> |
|---|---|
| Date | 2012-11-22 00:50 +0000 |
| Subject | How to calculate the partial derivative? |
| Message-ID | <k8jss7$5nl$1@smc.vnet.net> |
Dear all, I am trying to calculate the partial derivative by mathematica, I have the following commands: L1=a1+b1*x+c1*y; L2=a2+b2*x+c2*y; L3=a3+b3*x+c3*y; NN=L1*L2; DNx=D[NN,x]; I got the following result: DNex=b2 (a1+b1 x+c1 y)+b1 (a2+b2 x+c2 y) How to do to have the following result? DNex=b2*L1 + b1 * L2 Thanks, Tang Laoya
[toc] | [next] | [standalone]
| From | Tang Laoya <tanglaoya1989@gmail.com> |
|---|---|
| Date | 2012-11-22 09:41 +0000 |
| Message-ID | <k8ks07$858$1@smc.vnet.net> |
| In reply to | #12404 |
Dear all,
Sorry for my unsuitable example. My final program is as follows, could anyone please help me to take a look at it?
Thanks,
Tang Laoya
Clear["Global`*"];
L1 = (a1 + b1 x + c1 y + d1 z)/6/V;
L2 = (a2 + b2 x + c2 y + d2 z)/6/V;
L3 = (a3 + b3 x + c3 y + d3 z)/6/V;
L4 = (a4 + b4 x + c4 y + d4 z)/6/V;
nod = 10;
NN = Table[0, {nod}];
NN[[1]] = L1 (2 L1 - 1);
NN[[2]] = L2 (2 L2 - 1);
NN[[3]] = L3 (2 L3 - 1);
NN[[4]] = L4 (2 L4 - 1);
NN[[5]] = 4 L1 L2;
NN[[6]] = 4 L2 L3;
NN[[7]] = 4 L3 L1;
NN[[8]] = 4 L3 L4;
NN[[9]] = 4 L4 L1;
NN[[10]] = 4 L2 L4;
NNT = Flatten[Table[NN[[i]], {i, 1, nod}]];
Print["Dimensions of NNT:", Dimensions[NNT]];
DNx = D[NNT, x]
(* How to do to let the DNx have such express? For example, DNx[[1]] = b1/6/V*(2*L1-1) + L1*b1/3/V *)
DNy = D[NNT, y]
DNz = D[NNT, z]
DNxx = Transpose[{DNx}].{DNx};
DNyy = Transpose[{DNy}].{DNy};
DNzz = Transpose[{DNz}].{DNz};
Print["Dimensions of DNxx:", Dimensions[DNxx]];
K = DNxx + DNyy + DNzz;
(* I wish to replace all express "L1^aa*L2^bb*L3^cc*L4^dd" in matrix K by "aa!*bb!*cc!dd!/((aa+bb+cc+dd+3)!)*6*V", how to do? in the express, the aa, bb, cc or dd could be ZERO *)
K = Expand[K];
Print["Simplifying K"];
K = Simplify[K]
[toc] | [prev] | [next] | [standalone]
| From | Tang Laoya <tanglaoya1989@gmail.com> |
|---|---|
| Date | 2012-11-23 08:35 +0000 |
| Message-ID | <k8ncgh$dib$1@smc.vnet.net> |
| In reply to | #12420 |
Dear Dr. Hanlon,
Thank you very much for your kindly reply. Your method works for me, that's great.
Now I have another question:
I wish Mathematica give me an express which I can code by Fortran with smallest number of floating operations. For example, if I have:
bb1 = -Det[{{1, 1, 1}, {y2, y3, y4}, {z2, z3, z4}}];
the result by Mathematica is:
y3 z2 - y4 z2 - y2 z3 + y4 z3 + y2 z4 - y3 z4
I wish it output the result like this:
z2 (y3-y4) - z3 (y2-y4) + z4 (y2-y3)
What should I do?
Thanks,
Tang Laoya
On Thursday, November 22, 2012 5:43:45 PM UTC+8, Tang Laoya wrote:
> Dear all,
>
>
>
> Sorry for my unsuitable example. My final program is as follows, could anyone please help me to take a look at it?
>
>
>
>
>
> Thanks,
>
> Tang Laoya
>
>
>
>
>
> Clear["Global`*"];
>
> L1 = (a1 + b1 x + c1 y + d1 z)/6/V;
>
> L2 = (a2 + b2 x + c2 y + d2 z)/6/V;
>
> L3 = (a3 + b3 x + c3 y + d3 z)/6/V;
>
> L4 = (a4 + b4 x + c4 y + d4 z)/6/V;
>
>
>
> nod = 10;
>
> NN = Table[0, {nod}];
>
> NN[[1]] = L1 (2 L1 - 1);
>
> NN[[2]] = L2 (2 L2 - 1);
>
> NN[[3]] = L3 (2 L3 - 1);
>
> NN[[4]] = L4 (2 L4 - 1);
>
> NN[[5]] = 4 L1 L2;
>
> NN[[6]] = 4 L2 L3;
>
> NN[[7]] = 4 L3 L1;
>
> NN[[8]] = 4 L3 L4;
>
> NN[[9]] = 4 L4 L1;
>
> NN[[10]] = 4 L2 L4;
>
>
>
> NNT = Flatten[Table[NN[[i]], {i, 1, nod}]];
>
> Print["Dimensions of NNT:", Dimensions[NNT]];
>
>
>
> DNx = D[NNT, x]
>
> (* How to do to let the DNx have such express? For example, DNx[[1]] = b1/6/V*(2*L1-1) + L1*b1/3/V *)
>
>
>
> DNy = D[NNT, y]
>
> DNz = D[NNT, z]
>
> DNxx = Transpose[{DNx}].{DNx};
>
> DNyy = Transpose[{DNy}].{DNy};
>
> DNzz = Transpose[{DNz}].{DNz};
>
> Print["Dimensions of DNxx:", Dimensions[DNxx]];
>
>
>
> K = DNxx + DNyy + DNzz;
>
>
>
> (* I wish to replace all express "L1^aa*L2^bb*L3^cc*L4^dd" in matrix K by "aa!*bb!*cc!dd!/((aa+bb+cc+dd+3)!)*6*V", how to do? in the express, the aa, bb, cc or dd could be ZERO *)
>
>
>
> K = Expand[K];
>
> Print["Simplifying K"];
>
> K = Simplify[K]
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web