Make an Integral Work

48 views
Skip to first unread message

Mild Shock

unread,
Oct 20, 2023, 6:13:17 PM10/20/23
to FriCAS - computer algebra system
Possible to make FriCAS solve this integral?

/* Version: FriCAS 1.3.7, WSL2 */
/*  ^(1/3) is supposed to be the real root */

(2) -> integrate(cos(t)^(1/3)*(2+cos(t))/100, t)

           t              3+-------+
         ++  (cos(%A) + 2)\|cos(%A)
   (2)   |   ----------------------- d%A
        ++             100   

Waldek Hebisch

unread,
Oct 20, 2023, 7:41:52 PM10/20/23
to fricas...@googlegroups.com
Well, FriCAS claims tha answer is not elementary. Currently
FriCAS can not find answer in terms of "usual" special
functions and I do not know if there such an answer.

Note that what is produced above can be treated as ad-hoc
special function, so there is answer, the question is
if this is more explicit or simpler answer.

It is not clear what you mean by "Make it work"? If you
know better answer you could use rewrite rule to change
FriCAS result to a different one, but this is very limited in
scope. Due to the way FriCAS integrator works there is no
way to provide hints.

If this integral is doable in terms of popular special functions,
there is good chance that it will be handled in the future.
But not in current version.

--
Waldek Hebisch

Nasser M. Abbasi

unread,
Oct 20, 2023, 10:41:31 PM10/20/23
to FriCAS - computer algebra system
Fyi, Rubi and Mathematica 13.3.1 gives answer in terms of  Hypergeometric special function. Not sure if you consider this one the "usual" special functions you refer to:

integrand=Cos[t]^(1/3)*(2+Cos[t])/100
Integrate[integrand,t]

-(1/1400)3 Cos[t]^(4/3) Csc[t] (7 Hypergeometric2F1[1/2,2/3,5/3,Cos[t]^2]+2 Cos[t] Hypergeometric2F1[1/2,7/6,13/6,Cos[t]^2]) Sqrt[Sin[t]^2]

And Rubi gives

Int[integrand,t]
-((3 Cos[t]^(4/3) Hypergeometric2F1[1/2,2/3,5/3,Cos[t]^2] Sin[t])/(200 Sqrt[Sin[t]^2]))-(3 Cos[t]^(7/3) Hypergeometric2F1[1/2,7/6,13/6,Cos[t]^2] Sin[t])/(700 Sqrt[Sin[t]^2])

Tried Maxima, Giac and Maple and these all can't solve this either.
--Nasser

Mild Shock

unread,
Oct 21, 2023, 4:51:15 AM10/21/23
to FriCAS - computer algebra system
Thanks for the results!

A side quest of mine was to find a solution of the form:

integral[integrand, t] = const + slope*t + periodic(t)

Is this possible to instruct the CAS to bring it in this form? Now 
it seems Rubi and Mathematica dont show the result in this form.

BTW: A slope is seen in this related problem:

Problem: 
y' = cos(t) * (2 + cos(t)) / 100 
Solution: 
y(t) = c_1 + t/200 + sin(t)/50 + 1/200 sin(t) cos(t) 

Waldek Hebisch

unread,
Oct 21, 2023, 6:44:53 AM10/21/23
to 'Nasser M. Abbasi' via FriCAS - computer algebra system
On Fri, Oct 20, 2023 at 07:41:31PM -0700, 'Nasser M. Abbasi' via FriCAS - computer algebra system wrote:
> Fyi, Rubi and Mathematica 13.3.1 gives answer in terms of Hypergeometric
> special function. Not sure if you consider this one the "usual" special
> functions you refer to

Currently FriCAS do not use hypergeometric functions in aswers
to integration problems. That will probably change in the future,
but to justify the answer one needs a lot of hypergeometric
function identities and those are scattered in the literature.
Worse, while in many places one can find various identities,
justifications of the identities seem to be scarce.

Also, without ability to simplify hypergeometric answers are
of little use, so we need first strong simplifier for
hypergeometric functions. In particular we need ability
to discover when hypergeometric function (or its derivative)
is just a disguise and we are really dealing with something
simpler like elementary or Liouvillian function (actually,
theory says that all hypergeometric functions useful for
integration are disguise, "true" hypergeometric functions
can not appear as integrals of simpler functions).
> --
> You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/2ebb3f63-d2e4-42b7-b3a5-9c1c6094777en%40googlegroups.com.


--
Waldek Hebisch

Mild Shock

unread,
Oct 21, 2023, 1:55:50 PM10/21/23
to FriCAS - computer algebra system
> Also, without ability to simplify hypergeometric answers are of
> little use, so we need first strong simplifier for hypergeometric functions.

I am not sure that the lack of a strong simplifier is to blame that
I don't see a slope in those systems that can solve the integral.

Now I was trying to compute the slope, by using a definite
integral over the period instead of a indefinite integral. And I got this:

The simpler problem with cos(t) gives me:

(1) -> integrate(cos(t)*(2+cos(t))/100, t = 0..2*pi)

        (cos(2 pi) + 4)sin(2 pi) + 2 pi
   (1)  -------------------------------
                      200

Can I force sin(2 pi) getting computed as well?

The more complex problem with cos(t)^(1/3) gives me:

(2) -> integrate(cos(t)^(1/3)*(2+cos(t))/100, t = 0..2*pi)

   (2)  "potentialPole"

How can I tell the system that ^(1/3) should be real root?

Mild Shock

unread,
Oct 21, 2023, 2:36:11 PM10/21/23
to FriCAS - computer algebra system

Ok, my bad. pi is %pi in FriCAS.  The first problem was my fault.
But the second problem shows "potentialPole" even with %pi.

Waldek Hebisch

unread,
Oct 21, 2023, 3:38:28 PM10/21/23
to fricas...@googlegroups.com
On Sat, Oct 21, 2023 at 10:32:55AM -0700, Mild Shock wrote:
> > Also, without ability to simplify hypergeometric answers are of
> > little use, so we need first strong simplifier for hypergeometric
> functions.
>
> I am not sure that the lack of a strong simplifier is to blame that
> I don't see a slope in those systems that can solve the integral.
>
> Now I was trying to compute the slope, by using a definite
> integral over the period instead of a indefinite integral.
<snip>
> The more complex problem with cos(t)^(1/3) gives me:
>
> (2) -> integrate(cos(t)^(1/3)*(2+cos(t))/100, t = 0..2*pi)
>
> (2) "potentialPole"
>
> How can I tell the system that ^(1/3) should be real root?

(7) -> integrate(cos(t)^(1/3)*(2+cos(t))/100, t = 0..2*%pi, "noPole")

(7) "failed"
Type: Union(fail: failed,...)

in 99.9999% of cases FriCAS needs indefinite integral to
compute definite one. Since definite integral remains
unevaluated FriCAS can not give you definite one.

There is also another catch: FriCAS works with branches of
analytic functions. But cos(t) changes sign close to 0.
This means there are no analytic real third root close to 0.
If you take real root for small positive t, than for small
negative t analytic root must be complex. That must be
taken into account in cases where FriCAS can compute
indefinite integral.

--
Waldek Hebisch

Mild Shock

unread,
Oct 21, 2023, 5:08:32 PM10/21/23
to FriCAS - computer algebra system
I think cubic root can be extended to negative real numbers,
whereas square root cannot be extended to negative real numbers,

still giving a real numbers result, postive, zero or negative.

You would have like:

0.125^(1/3) = 0.5
(-0.125)^(1/3) = -0.5

Wolfram Alpha asks me whether I want principal root or
real-valued root. Maybe FriCAS has also such a feature somewhere?
Maybe should read the FriCAS manual.

Quick gloss over the FriCAS manual gives me, showing
the difference between principal and real-valued root:

(2) -> complexSolve(x^3 = -1/8, 0.0001)

   (2)
   [x = 0.25 - 0.4330127025_0231027603 %i,
    x = 0.25 + 0.4330127025_0231027603_1494140625 %i, x = - 0.5]

(3) -> solve(x^3 = -1/8, 0.0001)

   (3)  [x = - 0.5]

But how tell integral what root to use?

Waldek Hebisch

unread,
Oct 21, 2023, 6:07:38 PM10/21/23
to fricas...@googlegroups.com
On Sat, Oct 21, 2023 at 02:08:32PM -0700, Mild Shock wrote:
> I think cubic root can be extended to negative real numbers,

Some people define odd roots of real numbers to be negative.
This is reasonable if you deal with equation solving as
ambiguity is already there. However, this is problematic
for symbolic computation. Namely in symbolic computation
we deal with expressions and normal expressions give you
_complex_ functions that are analytic except for at most
countable set of singular points. Computing integrals
is based on differential fields, that is we want to divide
by functions. Division is fine for analytic functions
as set of zeros is at most countable and zeros are isolated.
But field implies that equation

s^3 = x

has exaxtly 3 solutions. One is usual principal root
solution, and two other are obtained from principal
root multiply by third degree roots of 1. To avoid
misunderstanding: above x means expression defininig
identity function on complex plane.

Once you introduce your real root of degree 3, we no
longer have a field, but ring with zero divisors.
In general this causes unsolvable problems (see
Richardson), but there is a lot of simple examples
that can be easily handled by splitting into parts,
each part analytic (living in its own filed).

In FriCAS currently any splittings needed to handle
such things must be introduced by user. So instead
of

integrate(sin(x)*(cos(x))^(1/3), x =0..2*%pi)

you need

integrate(sin(x)*(cos(x))^(1/3), x = -%pi/2..%pi/2, "noPole")

and

integrate(sin(x)*(cos(x))^(1/3), x =%pi/2..(3/2)*%pi, "noPole")

Also, you may need to mangle one or both to get desired
branch. Note "noPole" is really a statement that no singularities
prevent correct computation of integral. If you use
it in cases when there are singulatities you may get wrong
result.

> Wolfram Alpha asks me whether I want principal root or
> real-valued root. Maybe FriCAS has also such a feature somewhere?

No.

> Maybe should read the FriCAS manual.
>
> Quick gloss over the FriCAS manual gives me, showing
> the difference between principal and real-valued root:
>
> (2) -> complexSolve(x^3 = -1/8, 0.0001)
>
> (2)
> [x = 0.25 - 0.4330127025_0231027603 %i,
> x = 0.25 + 0.4330127025_0231027603_1494140625 %i, x = - 0.5]
>
> (3) -> solve(x^3 = -1/8, 0.0001)
>
> (3) [x = - 0.5]
>
> But how tell integral what root to use?

In general that is extremaly messy. If roots are independent,
then in a sense it does not metter, result is valid for
each choice of roots. But once you get to things like

sqrt(x*y) - sqrt(x)*sqrt(y)

situation gets more tricky. Also "obvious" properies fail:
"compute integral and then plug in numbers for parameters" is not
equivalent to "plug in numbers for parameters and then compute
integral". As indicated, in FriCAS those troubles are left
to user. User may split integral into parts and resolve
dependencies between roots.

--
Waldek Hebisch

Mild Shock

unread,
Oct 21, 2023, 6:49:08 PM10/21/23
to FriCAS - computer algebra system
The slope multiplied by the distance would be, 
using real-valued root (the Wolfram Alpha assumption):

integral_0^(2 π) 1/100 (2 + cos(t)) cos(t)^(1/3) dt = 0.0364298

But I am not sure whether the interval - π/2 to  π/2, 
as you suggest, would give me the slope. The factor
cos(t)^(1/3)  is indeed positive in this  interval, but 

the integrand itself is not symmetric, for example the 
range  π/2 to π is not a  mirror of the range 0 to π/2. Also 
the smaller interval  doesn't improve integrability:

(1) -> integrate(cos(t)^(1/3)*(2+cos(t))/100, t = -%pi/2..%pi/2, "noPole")

   (1)  "failed"

Maybe there is a function in FriCAS for some 
numerical integral algorithm? Have to check the FriCAS
manual, maybe I find something.

Maybe we can validate the Wolfram Alpha result,
show some agreement?

Waldek Hebisch

unread,
Oct 22, 2023, 5:20:17 PM10/22/23
to fricas...@googlegroups.com
On Sat, Oct 21, 2023 at 03:49:08PM -0700, Mild Shock wrote:
> The slope multiplied by the distance would be,
> using real-valued root (the Wolfram Alpha assumption):
>
> integral_0^(2 π) 1/100 (2 + cos(t)) cos(t)^(1/3) dt = 0.0364298
> https://www.wolframalpha.com/input?i=integ_0%5E%282*pi%29+cos%28t%29%5E%281%2F3%29+%282%2Bcos%28t%29%29+%2F100+dt&assumption=%22%5E%22+-%3E+%22Real%22
>
> But I am not sure whether the interval - π/2 to π/2,
> as you suggest, would give me the slope.

I suggested splitting interval into two parts: one where cos is
positive and one where it is negative. You then need to add
both parts, taking only one would be wrong.

> The factor
> cos(t)^(1/3) is indeed positive in this interval, but
>
> the integrand itself is not symmetric, for example the
> range π/2 to π is not a mirror of the range 0 to π/2. Also
> the smaller interval doesn't improve integrability:
>
> (1) -> integrate(cos(t)^(1/3)*(2+cos(t))/100, t = -%pi/2..%pi/2, "noPole")
>
> (1) "failed"

Yes, I was illustrating general principle. Above the approach
breaks down because FriCAS can not compute indefinite integral.
However, in cases when FriCAS can compute indefinite integral
you may have trouble due to singularities and choice of
brnaches. Splitting is a fairly general method to limit
troubles caused by singularities.

> Maybe there is a function in FriCAS for some
> numerical integral algorithm? Have to check the FriCAS
> manual, maybe I find something.

There is 'romberg' in NumericalQuadrature package.

--
Waldek Hebisch

Mild Shock

unread,
Oct 22, 2023, 6:35:13 PM10/22/23
to FriCAS - computer algebra system
>  There is 'romberg' in NumericalQuadrature package.

Is this something under the heading "FriCAS API"?

I have no clue how to load a package, and I even
don't understand how I get into a ")" prompt?

All I see when I start FriCAS is a "->" prompt:

(1) -> 

Dima Pasechnik

unread,
Oct 22, 2023, 6:49:10 PM10/22/23
to fricas...@googlegroups.com
On Mon, Oct 23, 2023 at 12:35 AM Mild Shock <burs...@gmail.com> wrote:
>
> > There is 'romberg' in NumericalQuadrature package.
>
> Is this something under the heading "FriCAS API"?
>
> I have no clue how to load a package, and I even
> don't understand how I get into a ")" prompt?

")" is not a prompt, it's part of a command you type at "->" prompt,
> --
> You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to fricas-devel...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/5ae78271-f75f-45b0-99dc-0ec802fc572an%40googlegroups.com.

Waldek Hebisch

unread,
Oct 23, 2023, 6:37:43 AM10/23/23
to fricas...@googlegroups.com
On Sun, Oct 22, 2023 at 03:35:13PM -0700, Mild Shock wrote:
> > There is 'romberg' in NumericalQuadrature package.
>
> Is this something under the heading "FriCAS API"?
>
> I have no clue how to load a package,

NumericalQuadrature is included in FriCAS, FriCAS will load it
automaticallty. I gave package name so that you can find
documentation (for example "FriCAS API"). Example use it at
end of:

http://wiki.fricas.org/mathaction/SandBoxSymbolicSumsAndProducts/


--
Waldek Hebisch
Reply all
Reply to author
Forward
0 new messages