Message Boards Message Boards

0
|
1126 Views
|
11 Replies
|
4 Total Likes
View groups...
Share
Share this post:

Comparison of Different Integration Results from FriCAS and Wolfram Language

Posted 2 months ago

Dear Wolfram Community,

I have encountered a question regarding the comparison of two integration results obtained from FriCAS and Mathematica, and I was hoping to get your insights on this topic.

I calculated the integral of the following function using both FriCAS and Mathematica:

(4*x - 1)/sqrt(x^4 - 2*x^3 + 3*x^2 + 2*x + 1)

In FriCAS, I got the following result:

log((x^2 - 2 x + 2) sqrt[x^4 - 2 x^3 + 3 x^2 + 2 x + 1]  + x^4 - 3 x^3 + 5 x^2 - 2 x)

In Mathematica, using IntegrateAlgebraic, I got the following result:

 In[19]:= Integrate[(4 x - 1)/Sqrt[x^4 - 2*x^3 + 3*x^2 + 2*x + 1], x]
Out[19]= -Log[-2 x + 5 x^2 - 3 x^3 + 
   x^4 + (-2 + 2 x - x^2) Sqrt[1 + 2 x + 3 x^2 - 2 x^3 + x^4]]

As you can see, these two results are different in form, although they are supposed to be equivalent. I was wondering if you could provide some insights into the following questions:

Why are the results obtained from FriCAS and Mathematica different in form? Are there any general methods to check that these two different results are indeed equivalent in their respective domains?

I have tried comparing these two functions graphically, using different line styles and markers to distinguish them. However, this method can only check for equivalence at a finite number of points and does not provide a formal proof.

Thank you in advance for your help and guidance. I look forward to reading your responses.

See here for the related discussion.

Kind regards,
Zhao

POSTED BY: Hongyi Zhao
11 Replies

It is straightforward to verify that both are correct antiderivatives.

integrand = (4*x-1)/Sqrt[x^4 - 2*x^3 + 3*x^2 + 2*x + 1];
primWL = -Log[-2*x + 5*x^2 - 3*x^3 + x^4 + (-2 + 2*x - x^2)*
    Sqrt[1 + 2*x + 3*x^2 - 2*x^3 + x^4]];
primFC = Log[(x^2 - 2*x + 2)*Sqrt[x^4 - 2*x^3 + 3*x^2 + 2*x + 1] + x^4 -
    3*x^3 + 5*x^2 - 2*x];  

In[8]:= Simplify[D[primWL,x]-integrand]

(* Out[8]= 0 *)

In[9]:= Simplify[D[primFC,x]-integrand]

(* Out[9]= 0 *)

As for why they differ, it will amount to differences in paths taken in the respective codes.

POSTED BY: Daniel Lichtblau
Posted 2 months ago

Only FriCAS one plots.

POSTED BY: ZAQU zaqu
Posted 1 month ago

Can Wolfram calculate the indefinite integral of: integrate (((-4x-8)log(x)+(-2x^2-4x))/(3xexp(2*log(x)+x)^2-x), x)

When I enter it, it gives me a definite integral result: NIntegrate[(-4 x - 2 x^2 + (-8 - 4 x) Log[x])/(-x + 3 E^(2 x) x^5), {x, 1, Infinity}]

Thanks

POSTED BY: Gene Connor

It does not calculate the indefinite integral, but it does not turn it into a numeric definite integral either:

Integrate[((-4 x - 8) Log[x] + (-2 x^2 - 4 x))/(
 3 x  Exp[2*log[x] + x]^2 - x), x]
POSTED BY: Gianluca Gorni
Posted 1 month ago

Why doesn't Mathematica calculate the indefinite integral? Is it outside the abilities of the software? If so, can you guess why? Thanks

POSTED BY: Gene Connor

It is out of the capabilities of the software, because another free online tool can find a primitive, which is easily checked:

f[x_] = (x + 2 Log[x])^2 + 1/2  (Log[3] Log[-1 + 3  E^(2 x)  x^4] +
      PolyLog[2, 1 - 3  E^(2 x)  x^4]);
f'[x] - ((-4  x - 8)  Log[x] + (-2  x^2 - 4  x))/(
     3  x   Exp[2*Log[x] + x]^2 - x) //
  PowerExpand // Simplify
POSTED BY: Gianluca Gorni
Posted 2 months ago

"As you can see, these two results are different in form, although they are supposed to be equivalent."

FriCAS one is more correct, and it is not surprising, as it has almost complete Risch- Davenport-Trager-Bronstein-Miller algorithm. It even has the mistakes Davenport did (see paper that corrects Davenport https://www.intlpress.com/site/pub/pages/journals/items/acta/content/vols/0225/0002/a002/) fixed.

Indeed, if you do Plot

only

Plot[-Log[(x^2 - 2 x + 2) Sqrt[x^4 - 2 x^3 + 3 x^2 + 2 x + 1] + x^4 - 3 x^3 + 5 x^2 - 2 x], {x, -10, 10}]

plots. The other does not Plot because it is complex (and not just that it has some complex numbers inside, those can be plotted sometimes).

That was already discussed on stack.

POSTED BY: ZAQU zaqu
Posted 2 months ago

Indeed, if you do Plot

only

Plot[-Log[(x^2 - 2 x + 2) Sqrt[x^4 - 2 x^3 + 3 x^2 + 2 x + 1] + x^4 - 3 x^3 + 5 x^2 - 2 x], {x, -10, 10}]

plots. The other does not Plot because it is complex (and not just that it has some complex numbers inside, those can be plotted sometimes).

You should say:

only

Plot[Log[(x^2 - 2 x + 2) Sqrt[x^4 - 2 x^3 + 3 x^2 + 2 x + 1] + x^4 - 
3 x^3 + 5 x^2 - 2 x], {x, -10, 10}]

plots.

In fact, as for the result given by Wolfram, while running plot, I noticed that an image of a similar shape flashed and then disappeared.

POSTED BY: Hongyi Zhao
Posted 2 months ago

FriCAS claims to have this feature: integration (most complete implementation of the Risch algorithm), what about wolfram?

POSTED BY: Hongyi Zhao
Posted 2 months ago

It appears that the two algorithms may have chosen a different branch of complex log.

Table[x=RandomReal[{-10,10}];
  N[-Log[(x^2-2x+2)Sqrt[x^4-2x^3+3x^2+2x+1]+x^4-3x^3+5x^2-2x]-
     Log[-2x+5x^2-3x^3+x^4+(-2+2x-x^2)Sqrt[1+2x+3x^2-2x^3+x^4]]],{20}]

which displays

{-1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 ],
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I,
 -1.38629-3.14159 I}

With a bit of detective work you should be able to determine the exact value that is approximately -1.38629.

If you try to plot the real or imaginary component of that difference over a larger range, perhaps over -100..100 or more, then you may see what looks like noise for the larger values of x. But if you use increased precision, perhaps Plot[Re[N[difference,64]],{x,-100,100},WorkingPrecision->64] then the noise is removed and the difference between the two solutions again appears to be constant.

The difference between the two results might be -2*Log[2]-Pi*I

POSTED BY: Bill Nelson

That claimed difference is correct. This can be seen by noting that the product of the log arguments in the respective results (which are algebraic conjugates), once expanded, is -4. Since one factor is positive the law of logarithms applies (log(a*b)=log(a)+log(b)). So -log(b) is equivalent to log(a) as an antiderivative, and the difference is log(-4) (or its negative, depending on which is subtracted from the other).

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract