开发者

Simplify a series in Mathematica

I'm having some issues simplifying some functions in mathematica. In a program I wrote I have a few functions calculated with the Sum function, many of the terms end up being multiplied by zero. I want the function to be printed but simplified. I try using FullSimplify, but it takes forever to run. I then tried using Simplify, but it doesn't work. Here is an example of a 开发者_开发问答function I'm getting,

2. Sqrt[-(-1+x) x]+
0. Sin[2 ArcCos[-1+2 x]]+
0. Sin[3 ArcCos[-1+2 x]]+
0. Sin[4 ArcCos[-1+2 x]]+
0. Sin[5 ArcCos[-1+2 x]]+
0. Sin[6 ArcCos[-1+2 x]]+
0. Sin[7 ArcCos[-1+2 x]]+
0. Sin[8 ArcCos[-1+2 x]]+
0. Sin[9 ArcCos[-1+2 x]]+
0. Sin[10 ArcCos[-1+2 x]]+
0. Sin[11 ArcCos[-1+2 x]]+
0. Sin[12 ArcCos[-1+2 x]]+
0. Sin[13 ArcCos[-1+2 x]]+
0. Sin[14 ArcCos[-1+2 x]]+
0. Sin[15 ArcCos[-1+2 x]]+
0. Sin[16 ArcCos[-1+2 x]]+
0. Sin[17 ArcCos[-1+2 x]]+
0. Sin[18 ArcCos[-1+2 x]]+
0. Sin[19 ArcCos[-1+2 x]]+
0. Sin[20 ArcCos[-1+2 x]]+
0. Sin[21 ArcCos[-1+2 x]]+
0. Sin[22 ArcCos[-1+2 x]]+
0. Sin[23 ArcCos[-1+2 x]]+
0. Sin[24 ArcCos[-1+2 x]]+
0. Sin[25 ArcCos[-1+2 x]]+
0. Sin[26 ArcCos[-1+2 x]]

So, why wouldn't this simplify to

2. Sqrt[-(-1+x) x]

I also have a follow up question that is not exactly as important. But, lets say four of those terms have non-zero coefficients, is it possible to combine them into one term that is a numerical approximation of the original?

Thanks to anyone that replies!


Say hello to machine precision.

(* exact *)
0 Sin[x]
Out[1]= 0

(* machine precision *)
0. Sin[x]
Out[2]= 0. Sin[x]

Use Chop to set numbers absurdly close to zero, to 0 exactly.

expr = 2. Sqrt[-(-1 + x) x] + 0. Sin[2 ArcCos[-1 + 2 x]] + 
   0. Sin[3 ArcCos[-1 + 2 x]] + 0. Sin[4 ArcCos[-1 + 2 x]] + 
   0. Sin[5 ArcCos[-1 + 2 x]] + 0. Sin[6 ArcCos[-1 + 2 x]] + 
   0. Sin[7 ArcCos[-1 + 2 x]] + 0. Sin[8 ArcCos[-1 + 2 x]] + 
   0. Sin[9 ArcCos[-1 + 2 x]] + 0. Sin[10 ArcCos[-1 + 2 x]] + 
   0. Sin[11 ArcCos[-1 + 2 x]] + 0. Sin[12 ArcCos[-1 + 2 x]] + 
   0. Sin[13 ArcCos[-1 + 2 x]] + 0. Sin[14 ArcCos[-1 + 2 x]] + 
   0. Sin[15 ArcCos[-1 + 2 x]] + 0. Sin[16 ArcCos[-1 + 2 x]] + 
   0. Sin[17 ArcCos[-1 + 2 x]];

Chop[expr]
Out[4]= 2. Sqrt[(1 - x) x]


Behind those "0." terms there are hidden some very tiny (but non-zero) numbers. You can slash them using Chop.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜