Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Re: Looping

  • To: mathgroup at smc.vnet.net
  • Subject: [mg95959] Re: [mg95896] Re: Looping
  • From: Adam Strzebonski <adams at wolfram.com>
  • Date: Fri, 30 Jan 2009 05:48:24 -0500 (EST)
  • References: <glmt16$mqu$1@smc.vnet.net> <200901291056.FAA18117@smc.vnet.net> <96061AD3-433E-4217-AC48-C21E57BB602F@mimuw.edu.pl> <4981EC6A.6040809@wolfram.com> <B0BC0BFE-3AC1-4A65-A5B1-CABB07C4ACD4@mimuw.edu.pl>
  • Reply-to: adams at wolfram.com

Andrzej Kozlowski wrote:
> 
> On 29 Jan 2009, at 18:50, Adam Strzebonski wrote:
> 
>> Andrzej Kozlowski wrote:
>>> On 29 Jan 2009, at 11:56, David Bailey wrote:
>>>> Jeff Albert wrote:
>>>>> I have a program written in Mathematica that has been running now 
>>>>> for about three days.  How can I tell if it's in a loop?
>>>>>
>>>> The best approach is to start small, and work your way up to a big
>>>> problem like that if necessary. Start by aborting the calculation and
>>>> then start testing much smaller examples.
>>>>
>>>> Some Mathematica functions - such as Simplify or FullSymplify - seem to
>>>> get stuck in this sort of way - if they do that, they will hang for 
>>>> ever.
>>>>
>>>> David Bailey
>>>> http://www.dbaileyconsultancy.co.uk
>>>>
>>> I doubt very much that they they ever get "stuck" in the way you 
>>> describe. Both Simplify and FullSimplify make use of algebraic 
>>> algorithms some of which have very high complexity (e.g. exponential 
>>> or even double exponential in the number of variables). Even when it 
>>> seems that the expression you are simplifying involves only a few 
>>> variables, its algorithmic complexity may be high because 
>>> transcendental parts of expressions are often treated as independent 
>>> variables. Of course, the human time scale: minutes, hours, 
>>> lifetimes, has not particular place in computer algebra so there is 
>>> no reason at all why your program should not run for 10 years and 
>>> then suddenly come up with an answer.
>>> In fact, I believe Simplify and FullSimplify have some built in 
>>> protection against infinite loops so they are probably somewhat less 
>>> likely to fall into them than some other functions. Also, note that 
>>> both Simplify and FullSimplify have the option TimeConstraint, which 
>>> can be sometimes useful in dealing with complex expressions. If you 
>>> run FullSimplify on an expression with TimeConstraint set to, say, an 
>>> hour, and if it returns to you the same expression that you 
>>> originally gave to it as input, it won't necessarily mean that it had 
>>> entered an infinite loop but more likely that it had attempted a 
>>> transformation or a sequence of transformations which it could not 
>>> complete before the time limit expired.
>>> Andrzej Kozlowski
>>
>> Yes, Simplify and FullSimplify have built in protection against
>> infinite loops, but no global time limit.
>>
>> The TimeConstraint option specifies a time limit allowed for a single
>> transformation. If the time limit expires the current transformation
>> is aborted, but then (Full)Simplify will attempt other transformations
>> with a fresh time allowance for each new transformation. The default
>> value of TimeConstraint is 5 minutes for Simplify and Infinity for
>> FullSimplify.
>>
>> Best Regards,
>>
>> Adam Strzebonski
>> Wolfram Research
>>
>>
> 
> Thanks a lot.  I have forgotten about his local limit/global limit 
> matter. I now recall we have actually discussed it on this forum before.
> I think both this time and last time I confused the option TimeContraint 
> with the Mathematica function TimeConstrained. If I am not mistaken, 
> that latter will provide  global time constraint on the entire 
> computation but unfortunately, it will return $Aborted rather than the 
> simplest form of the expression found so far when the time limit is 
> exceeded. I think I know a rather clunky way to get this simplest form 
> found by (Full)Simplify before the computation was aborted (roughly 
> equivalent to doing a Trace) but is there a nice and efficient way of 
> doing this? If not, would it not be possible and useful to add this 
> ability to (Full)Simplify?
> 
> With best regards
> 
> Andrzej Kozlowski
> 
> 
> 

Currently there is no way to get the simplest form found by an aborted
Simplify computation. When TimeConstrained interrupts a computation
the control goes back to TimeConstrained and the results of all
computations done inside are lost (unless they have been saved before
the interrupt was issued). But it sounds like a useful thing to be
able to get the best simplification found in a specified time.
I will implement it for the next version.

Best regards,
Adam Strzebonski


  • References:
    • Re: Looping
      • From: David Bailey <dave@removedbailey.co.uk>
  • Prev by Date: Re: Re: Significant slow-down with Mathematica 7 (vs 6).
  • Next by Date: Re: Simplifying and Rearranging Expressions
  • Previous by thread: Re: Re: Looping
  • Next by thread: Re: Looping