#12 Stack Overflow from Infinite Recursion


I noticed that the attached simple test program fails
with a stack
overflow due to infinite recursion in the second EV() call.

Before D(Pow(x,1/2),x)
After D(Pow(x,1/2),x)
Before D(Pow(x,-1/2),x)
Exception in thread "main" java.lang.StackOverflowError

When I run it with some extra instrumentation (printing
rules that are
applied, from HRuleSet.testDownRules()), I see that it
appears to be
applying the rule
to List(1/2), then List(-1/2), and then repeating.

I'll keep looking into this, to nail down exactly
what's happening.
Perhaps some rules don't interact well, or a rule
should be added.
This might also be related to the fact that the
function isn't defined
for x<0, or that the second function has a pole (goes
to infinity)
at x=0. However, even if the function behaves poorly,
we'll want it
to report that problem cleanly, so this is a bug.

As I said, I'm researching this one, but I'm also
reporting it as a
matter of proper practice.


  • Scott Lett

    Scott Lett - 2004-04-03

    Logged In: YES

    Preston, does this mean that you're working on Hartmath

  • Preston Pfarner

    Preston Pfarner - 2004-04-03

    Logged In: YES

    Yes, I am working on HartMath some, but I've been idle for
    the last couple of weeks because I was on vacation. It's
    possible that it makes more sense to put effort into hmath
    (hmath.org), a possible successor. *shrug*

    On this bug, I've found that at some point in the process of
    evaluating a derivative (even D(x,x)) the rules for Sin()
    appear to be put into List(). I don't know how this is
    happening, but it's definitely not good. This is obviously
    wrong, and I haven't tracked it down yet.

    For another example, if I evaluate List(Multiply(1/4,Pi)) on
    its own, I get no simplification. If I do it after a
    derivative has been evaluated, I get
    List(Multiply(1/4,Pi))=1. Naturally, this would be true if
    the "List" were "Sin", but somewhere in there the wrong
    rules are being loaded. I have some more introspection to
    add, and then it'll probably become clear (and be fixed).

    While the dynamic on-the-fly loading of capabilities is nice
    for latency (start-up speed) reasons, it can defer bugs like
    this until some condition occurs, making them harder to find.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks