Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: FullSimplify Hang?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg62257] Re: FullSimplify Hang?
  • From: ted.ersek at tqci.net
  • Date: Thu, 17 Nov 2005 17:03:51 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Igor Touzov wanted to abort FullSimplify when it takes too long, and see
what was the simplest expression it found before aborting.  Andrzej
Kozlowski had a approach that would work if not for the fact that it's
very slow. I think I changed Andrzej's approach to make it useful.

Consider expr below.
-------------------------------

In[1]:=
  expr=TrigExpand[Sin[5x]-Sin[7x]+Cos[3y]]


In[4]:=
  ls=Hold[];
  FullSimplify[expr,
     ComplexityFunction->( ((ls=Hold@@{ls,#});LeafCount[#])& )
  ]

Out[5]=
  Cos[3 y]+Sin[5 x]-Sin[7 x]

-------------------
If FullSimplify takes to long make the menu selection
(Kernel | Abort evaluation).  Then the code below can be used to see what
progress FullSimplify has made.
-------------------


In[6]:=
  ls=List@@Union[Flatten[ls]];

  (* Use values for variables that make expr numeric. *)
  (* I use arbitrary precision for better reliability. *)
  ls=Select[ls,((#==N[expr])/.{x->2.5`25,y->2.5`25})&];

  ls=Sort[ls,LeafCount[#1]<LeafCount[#2]&];

  (*User FullSimplify to double check*)
  ls=Select[ls,(FullSimplify[#-expr==0]&)]


Out[6]=
   (* Get a list of expressions FullSimplify could have returned. *)
   (* The list is sorted by LeafCount. *)


------------------------
It can also help a lot to make intelligent use of
Together, Apart, Cancel, Collect, TrigExpand, TrigToExp,
Developer`TrigToRadicals, and similar functions before using
Simplify or FullSimplify.

Regards,
   Ted Ersek




  • Prev by Date: Performance Improvement - Need help
  • Next by Date: Re: Magnetic Pendulum
  • Previous by thread: Re: FullSimplify Hang?
  • Next by thread: not a homework assignment