Error with simple integral, "CEXPT only defined for non-negative integral exponents."

63 views
Skip to first unread message

saad khalid

unread,
Nov 7, 2017, 12:06:05 PM11/7/17
to sage-support
Hello everyone:

I am currently trying to do this integral in Cocalc:

integral(525.87*(x)^(-2.35),x,.1,1)

It gives me the following error:
"CEXPT only defined for non-negative integral exponents."

What seems to be the issue here? Plugging the same integral into WolframAlpha works fine.

William Stein

unread,
Nov 7, 2017, 12:23:49 PM11/7/17
to sage-support
On Tue, Nov 7, 2017 at 9:06 AM, saad khalid <saad...@gmail.com> wrote:
> Hello everyone:
>
> I am currently trying to do this integral in Cocalc:
>
> integral(525.87*(x)^(-2.35),x,.1,1)
>
> It gives me the following error:
> "CEXPT only defined for non-negative integral exponents."
>
> What seems to be the issue here?

Maxima integration, which we still use by default, is very buggy. Use
sympy instead -- this works:

integral(525.87*(x)^(-2.35),x,.1,1, algorithm='sympy')

See

https://cocalc.com/projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/files/support/2017-11-07-091923-integral.ipynb



>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support...@googlegroups.com.
> To post to this group, send email to sage-s...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.



--
William (http://wstein.org)

Emmanuel Charpentier

unread,
Nov 7, 2017, 4:29:38 PM11/7/17
to sage-support
Hmmm... Compare :

sage: with assuming(b!=-1): integrate(a*x^b,x)
a*x^(b + 1)/(b + 1)
sage: integrate(a*x^b,x,algorithm="fricas")
a*x*e^(b*log(x))/(b + 1)
sage: integrate(a*x^b,x,algorithm="giac")
a*x^(b + 1)/(b + 1)
import sympy
sage: sympy.integrate(a*x^b,[x])
a*Piecewise((log(x), Eq(b, -1)), (x**(b + 1)/(b + 1), True))sage: mathematica.Integrate(a*x^b,x).sage()
a*x^(b + 1)/(b + 1)
sage: maple.integrate(a*x^b,x).sage()
a*x^(b + 1)/(b + 1)

[ "with assuming() : coming attraction : that's Trac#24119, IIRC (closed, fixed) : temporary assumptions ]

  • Maxima is the only system warning explicitly that b==-1 is a special case, but not solving it.
  • Sympy does, but uses a syntax that can't (yet) be translated in Sage (Ralf Stefan is on it...).
  • Both giac and fricas solve the general case, but do not give any form of explicit warning.
  • However, fricas does *not* (over-)simplify a*x*e^(b*log(x)) into a*x^(b+1), which should warn the reader that interpretation is fishy if x<0...
  • "The competition" is not better at this, at least when used from Sage... (Further checks from their native interfaces show no enhancement).
Rough conclusion : no CAS will save your skin if you use it "naively". Sympy seems to be marginally more useful than Maxima in this specific case, but our interface to it has to be perfected (work in progress...).

--
Emmanuel Charpentier

Ralf Stephan

unread,
Nov 9, 2017, 1:40:08 AM11/9/17
to sage-support


On Tuesday, November 7, 2017 at 6:06:05 PM UTC+1, saad khalid wrote:

integral(525.87*(x)^(-2.35),x,.1,1)


This is user error because this works fine:

sage: integral(52587/100*(x)^(-235/100),x,.1,1)
8331.031741769872

Never use inexact values in integral terms.

Regards,

Ralf Stephan

unread,
Nov 9, 2017, 1:43:38 AM11/9/17
to sage-support

Robert Dodier

unread,
Nov 9, 2017, 12:46:16 PM11/9/17
to sage-s...@googlegroups.com
Well, some experimentation shows that with keepfloat = false (the
default), it works OK. But keepfloat = true (as in Sage) it bumps into
this error.

keepfloat causes trouble in other places too ... every now and then I
think we (Maxima project) should dump it.

best

Robert Dodier

Reply all
Reply to author
Forward
0 new messages