common[exp_List]:=Block[{factor,tempexp,gcd},
(* 判斷是否為乘法,是的話因式分解;不是的話,加係數1在做因式分解 *)
(* 最後將乘法改成陣列 *)
tempexp=If[SameQ[Head@#,Times],Factor[#],
{1,Factor[#]}]&/@exp/.Times->List;
tempexp=Flatten/@tempexp;
(* 公因式 *)
factor=Intersection@@tempexp;
(* 係數的公因數 *)
gcd=GCD@@tempexp[[All,1]];
(* 輸出 *)
{Times@@factor*gcd,Times@@#/Times@@factor/gcd&/@tempexp}
]
Mathematica 教學 多項式公因式分解
由 戴忠淵 於 2014年1月16日星期四
下午6:21 發表

讀者回應 ( 0 意見 )
訂閱發佈留言 (Atom)
發佈留言
Please leave your name and tell me what you thought about this site. Comments, suggestions and views are welcomed.
如果這篇文章對你有幫助,那請留個訊息給我~