Post Reply 
Some integrals with problematic evaluation
03-22-2016, 10:11 PM
Post: #1
Some integrals with problematic evaluation
The following are a few of the integrals I found the Prime CAS to have problems with. I included screen shots with the expected result. All of these are from Timofeev's book. Main problem (apart from the ubiquitous absolute values) is the usage of the signum and floor functions, which are not analytic.

   
   
   
   
   
Find all posts by this user
Quote this message in a reply
03-22-2016, 10:13 PM
Post: #2
RE: Some integrals with problematic evaluation
   
   
   
   
   
Find all posts by this user
Quote this message in a reply
03-23-2016, 06:44 AM
Post: #3
RE: Some integrals
You should enter the commandlines in plain text if you want other to be able to reproduce easily your inputs, screenshots can not be copied/pasted.
Now, the status of your examples is not completly clear. Did you find *wrong* answers or is it just more complicated than it could ideally be?
I did not look at all your examples, but one of your expected answer (4th screenshot) requires complex logarithms for x>sqrt(6)/3 which would be considered as bad by many users, while the Prime answer does not, thanks to absolute values.
You should also consider that there are several ways to express an antiderivative, and an automatic system can obviously not always find the simplest way to return it. Note also that the answer on the Prime might look complicated just because some expressions are sometimes added to ensure that the antiderivative is continuous (floor) or to ensure that it is defined in the real domain (ln(abs(..))).
Find all posts by this user
Quote this message in a reply
03-23-2016, 07:29 AM
Post: #4
RE: Some integrals with problematic evaluation
For your second example you should first enter: assume(x>0), then your desired solution is provided. A look in the user-guide: assume, additionally and about will help you setting desired domains.
Your third integral thus can be solved after assume(x>0) and assume(a>0).
Hth Arno
Find all posts by this user
Quote this message in a reply
03-23-2016, 07:35 AM (This post was last modified: 03-23-2016 07:37 AM by quinyu.)
Post: #5
RE: Some integrals with problematic evaluation
Hello, Mr. Parisse,

I have been told on the HP forum to show the screen shots, not the command line, thought it would work the same way here; my bad. I will post command line input/output here from here on.
As of the status... it is a mix. For some answers, they are just very complicated. For other answers, the included functions (floor or signum) are not analytic, so you cannot make, for example, a power series or Fourier series expansion from them. Whether or not this is a problem of course depends on your application. Nevertheless, I have shown alternatives that don't require these functions as such. I must confess I have mixed feeling about the absolute value, but I see its benefits in most cases, so I don't argue that one.
Furthermore, I find it bad when imaginary values are pulled into an expression when there is an alternative expression without them.
But there are cases when the output is just completely faulty. I believe I found 1/(a^5+x^5) as an example, where the integration is just partially executed. Don't get me wrong: I am not saying that the output contains mathematical errors - the error is that it leaves an integral term in, when the expression is fully integrable; in a manner, this is similar to what my problem is with the signum and floor functions: why use when not needed? Certainly, I know that integration in some cases becomes difficult; and therefore I did not include those cases where the ordinary hypergeometric function would be expected as part of the answer, seeing that the HP Prime doesn't use it, just like no other CAS-capable calculators on the market. It is however my hope that based on these examples, some improvements can be made to the integration algorithm, as to output a more compact or readable answer, and avoiding the unnecessary imaginary in some cases.

And thanks, Arno, I'll put the "assume" in place from now on, where it makes sense.
Find all posts by this user
Quote this message in a reply
03-23-2016, 09:55 AM
Post: #6
RE: Some integrals with problematic evaluation
I wonder who asked you to post screenshots, certainly never me! You can't do anything with screenshots except looking at them...
Don't forget that there is no table lookup inside Giac. If the system finds a way to compute the antiderivative, it will use it even if there might be a another way which does not introduce floor and so on. For example take
int(1/(2+3*cos(x)^2))
If I returned atan(2*tan(x)/(sqrt(10)))/(sqrt(10)) without the floor term, the answer would not be continuous at x=pi/2+k*pi. Your antiderivative does not require a floor term, but I don't know how you get it, it does not help me much to see it. The general algorithm I'm using for fractions of trigonometric expressions is rewrite with tangents and make the change of variable with the tangent.
I have nothing against improving the integration algorithm, but if you want to really help me do that, you should
1/ enter the commandline
2/ enter the nice looking answer you expect
3/ explain how it is obtained
Find all posts by this user
Quote this message in a reply
03-23-2016, 12:45 PM
Post: #7
RE: Some integrals with problematic evaluation
In that integral, that is exactly what is done. For an integral of the shape Int((cos(c+dx)^2*b+a)^p,x), you can rewrite with tan(c+dx)/e, where e is the product of the factors in tan(c+dx) free of x. Then the integral takes the shape Int(1/(5+2u^2),u). An integral of the shape Int(1/(a+bx^2),x) results in sqrt(a/b)atan(x/sqrt(a/b))/a. Putting it all together, we get x/sqrt(10) - atan(3sin(x)cos(x)/(2+sqrt(10)+3cos(x)^2))/sqrt(10).

Is it useful this way, Mr. Parisse? (And I truly would like to know if there is a way to input, say, TeX code here for a nicer display... if I start typing formulas like this, it's bound to be rather difficult to read.)
Find all posts by this user
Quote this message in a reply
03-23-2016, 12:55 PM
Post: #8
RE: Some integrals with problematic evaluation
Same with the 1/(4-cos(x)^2). After our rewrite u=tan(x), we get 1/(3+4x^2). From there, the previous rule applies, giving x/(2sqrt(3))+atan(sin(x)cos(x)/(3+2sqrt(3)+sin(x)^2))/(2sqrt(3)).
Find all posts by this user
Quote this message in a reply
03-23-2016, 01:46 PM
Post: #9
RE: Some integrals with problematic evaluation
Ok, we are doing the same change of variable, but then you are doing an additional rewriting command because atan(x/sqrt(a/b)) with x a tangent is not the same as atan(3sin(x)cos(x)/(2+sqrt(10)+3cos(x)^2)), this is the missing step.
I think I prefer an atan(tan(x)/sqrt(a/b)), because you can easily throw the floor part if you don't need a continuous antiderivative and then the answer is more compact. It seems the nspire does the same.
BTW, I don't need tex code, I prefer algebraic expressions that I can easily copy/paste.
Find all posts by this user
Quote this message in a reply
03-23-2016, 02:01 PM
Post: #10
RE: Some integrals with problematic evaluation
(03-23-2016 12:45 PM)quinyu Wrote:  Is it useful this way, Mr. Parisse?

Hello,

Might be the problem from me not being clear in the other forum. When I said you'd most likely get a deeper discussion over here, I also meant that posting the inputs in the form of int(x^2...,x) and similar in addition to the images would let people copy/paste a bit easier to allow others to more easily enter and evaluate without needing to type everything out. For example, for the first one - int(1/(4-cos(x)^2),x) can be directly copied and pasted.

Do you have the windows emulator installed? If so, it is really easy to copy and paste from that directly.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
03-23-2016, 03:01 PM
Post: #11
RE: Some integrals with problematic evaluation
Hello, Mr. Wessman,

As a principle, I don't use emulators any more; being that in the past, I did so, then got feedback that under some circumstances the emulator gives a result different from the actual calculator (I believe it was the Casio one, but either way, I cannot ever be sure that they do things the same way under the hood as how the actual calculator does - combined with the fact that the emus tend to lag behind in respect of updates, and at least the TI one is expecting me to pay for it after 30 days... why thanks TI...)

So nowadays I'm having the actual collection of calculators (the Holy Trinity of Nspire CX CAS, HP Prime and Casio CP-FX400; with the 50g as a sidekick). That way I can be sure that the results are what the calculator gives, and similarly, that bugs/crashes/resets for whatever reason are caught. There was an integral that integrated on the Prime ( int(x^5/((x+3)^2),x) ) gave a correct result, BUT pressing the "simplify" button on the result crashed the calc afterwards. I haven't tested if this is reproducible in the emu, but to be honest, I don't think it would have mattered either way.

So okay. I'll put explanation as to how integration results are obtained. I hope I did not upset anyone by posting this way. So now, on to integrate...
Find all posts by this user
Quote this message in a reply
03-23-2016, 03:15 PM (This post was last modified: 03-23-2016 03:18 PM by quinyu.)
Post: #12
RE: Some integrals with problematic evaluation
So, back to it.
Code:
int(1/(x*(1-ln(x))),x)
This is a particular case of the general form
Code:
int(1/(a+b*ln(c(d(e+fx)^p)^q)*(g+hx)),x)
with a=1, b=-1, c=1, d=1, e=0, f=1, g=0, h=1, p=1, q=1. That integral, IF fg-eh=0, can be written as
Code:
ln(a+b*ln(c(d(e+fx)^p)^q))/(bhpq)
So ln(1-1*ln(1(1(0+1x)^1)^1))/(-1), which simplifies to
Code:
-ln(1-ln(x))
The same applies to the integral after it, with int(1/(x*(1+ln(x/a))),x).
Find all posts by this user
Quote this message in a reply
03-23-2016, 03:39 PM (This post was last modified: 03-23-2016 03:40 PM by quinyu.)
Post: #13
RE: Some integrals with problematic evaluation
Code:
int((2x-5)/(3x^2-2),x)
This integral is of the
Code:
(d+ex)/(a+cx^2)
general form. IF cd^2+ae^2 is non-zero (in our case, a=-2, c=3, d=-5, e=2, so the expression is 67, non-zero), AND -a*c gives a nice square root (not negative, etc), then let q=sqrt(-a*c), and then split the integral into
Code:
(e/2+cd/2q)*int(1/(cx-q),x)+(e/2-cd/2q)*int(1/(cx+q),x)
In our case, that gives
Code:
(1-15/(2sqrt(6)))int(1/(3x-sqrt(6)),x)+(1+15/(2sqrt(6)))int(1/(3x+sqrt(6)),x)
This can be resolved by the fact that
Code:
int(1/(a+bx),x)=ln(a+bx)/b
So if we plug that all back, we get after simplification
Code:
(4-5sqrt(6))/12*ln(sqrt(2)-x*sqrt(3))+(4+5sqrt(6))/12*ln(sqrt(2)+x*sqrt(3))
Find all posts by this user
Quote this message in a reply
03-23-2016, 04:02 PM
Post: #14
RE: Some integrals with problematic evaluation
Code:
int(tan(x)*tan(x-A),x)
This integral is of the tan(a+bx)*tan(c+dx) general form, where IF b^2-d^2 is 0 AND bc-ad isn't 0, we can rewrite with secants into
Code:
-bx/d+(b/d)cos((bc-ad)/d)*int(sec(a+bx)sec(c+dx),x)
So we are now at
Code:
-x+cos(a)*int(sec(a-x)sec(x),x)
which isn't much better. Nevertheless, for an integral of the general form
Code:
int(sec(a+bx)sec(c+dx),x)
it can be split into
Code:
csc((bc-ad)/d)int(tan(a+bx),x)+csc((bc-ad)/b)int(tan(c+dx),x)
Knowing that the integral
Code:
int(tan(c+dx),x)=1/d*ln(cos(c+dx))
we apply this twice, and after the simplification of the trigonometric functions arrive to
Code:
-x+cot(a)ln(cos(a-x))-cot(a)ln(cos(x))
Find all posts by this user
Quote this message in a reply
03-23-2016, 04:05 PM (This post was last modified: 03-23-2016 04:05 PM by parisse.)
Post: #15
RE: Some integrals with problematic evaluation
Your explanations seems to be essentially what I call table lookup, very different from what I implemented inside giac : because table lookup is not general enough, it's boring and it does not give much pedagogical added value.
For example for all rational fractions, I do Hermite reduction to have a square-free denominator, then if the denominator can be factored on the field of it's coefficients, partial fraction decomposition and integration. This explains why 1/(x^5-a^5) is currently not fully integrated, since the factorization of x^5-a^5 over Q[a,x] is (x-a)*(x^4+a*x^3+a^2*x^2+a^3*x+a^4) where the second factor is irreducible: for a=1 there is code to recognize a cyclotomic polynomial and factor it, I can extend it to a symbolic a with a little code change:
http://www-fourier.ujf-grenoble.fr/%7epa...x^5-a^5))&
For assume(x>0); int(1/(x*(1-ln(x))),x), Xcas displays in step by step mode
Code:

===== Step/step primitive of 1/(x*(1-ln(x))) with respect to x =====
Integration of 1/((1-ln(x))*x): f(u)*u' where f=x->-1/(x-1) and u=ln(x)
Integrate rational fraction 1/(t_nostep-1)
Partial fraction integration of 1/(t_nostep-1)
Hence primitive of 1/(x*(1-ln(x))) with respect to x is -ln(abs(ln(x)-1))
Find all posts by this user
Quote this message in a reply
03-23-2016, 04:20 PM
Post: #16
RE: Some integrals with problematic evaluation
(03-23-2016 04:02 PM)quinyu Wrote:  
Code:
int(tan(x)*tan(x-A),x)
I think it's much easier to expand tan(x-a) then we are back to a rational fraction in tan(x). You can already get it with Xcas online http://www-fourier.ujf-grenoble.fr/%7epa...tan(x-a))&
Find all posts by this user
Quote this message in a reply
03-23-2016, 04:33 PM
Post: #17
RE: Some integrals with problematic evaluation
Yes, I know it is table lookup, and it is certainly less valuable as far as education is concerned; but it has its own strengths. I am not trying to argue away the educational value of XCAS' approach.

In fact I would love to see such step by step explanation coming from the calculator itself, and preferably know all the tricks that XCAS employs as well - seeing that unfortunately that's not the case.

As of table lookup, well, the rule set that I employ has close to 6000 such "rules" encoded - roughly 1.8Mb of Mathematica code. I agree it is a lot, and likely not very educational. (By the way, the integral I mentioned was 1/(a^5+x^5), not with a minus, but as far as the technique is concerned, that's close to irrelevant...) But it tends to get to a solution. More frequently so than baseline Mathematica, Maple and Maxima combined.

I agree that elegance also plays a great part in mathematics, and I'm not in position to criticise the XCAS system. If anything, I'm criticising what HP made out of it, which appears to be both less capable and less educational than the original; and precisely these shortcomings am I trying to point out to those who are responsible for what actually gets into a software update, as to make them reconsider. Maybe it's all in vain, I do not know. But I know there's much of hard iron in the HP, it's a shame not to put it to full use.
Find all posts by this user
Quote this message in a reply
03-23-2016, 05:19 PM
Post: #18
RE: Some integrals with problematic evaluation
6000 rules, that's a lot!
About step by step in Xcas, it is at this time experimental, like the online interface : the idea is to provide a full javascript CAS engine (no need to have a server behind once the engine has been downloaded) + interface available on all devices that have a browser, and also enable the CAS engine in LaTeX files compiled to HTML5 (by hevea), so that students can perform computations or modify examples and see the results while reading an online course.
Find all posts by this user
Quote this message in a reply
03-23-2016, 09:57 PM
Post: #19
RE: Some integrals with problematic evaluation
(03-23-2016 03:01 PM)quinyu Wrote:  As a principle, I don't use emulators any more; being that in the past, I did so, then got feedback that under some circumstances the emulator gives a result different from the actual calculator (I believe it was the Casio one, but either way, I cannot ever be sure that they do things the same way under the hood as how the actual calculator does - combined with the fact that the emus tend to lag behind in respect of updates, and at least the TI one is expecting me to pay for it after 30 days... why thanks TI...)

Makes sense. Please note that we've done everything possible to ensure that the emulator behaves identical to the device in every way possible. There are extremely rarely any differences in behavior, and these are almost exclusively hardware related things (difference in available memory, etc) and not differences in the software or behavior.


Quote:I hope I did not upset anyone by posting this way. So now, on to integrate...

Nope. I always like to see qualified people trying to poke holes in the software. Without pushing, it is pretty hard to improve.


Quote:If anything, I'm criticising what HP made out of it, which appears to be both less capable and less educational than the original; and precisely these shortcomings am I trying to point out to those who are responsible for what actually gets into a software update, as to make them reconsider.

Could you elaborate on what you mean here a bit more? Basically, we track the xcas source directly to the extent possible so any changes and improvements made end up on Prime.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
03-23-2016, 10:28 PM (This post was last modified: 03-23-2016 10:30 PM by quinyu.)
Post: #20
RE: Some integrals with problematic evaluation
Sure. Starting from the basic assumption that the HP Prime was meant to be aimed mainly at education (which might be wrong, but from the advertising that it had, that's how it came across): while it might do things, it does not have any step-by-step mode in places where it would matter the most, not even as an optional switch/configuration setting.

This can be integration, solving of general or differential equations, you name it. The calculator spits out a result, do what you will with it - in this respect, the 50g is actually more helpful with the proper settings. The Prime very frequently mashes results together using a common denominator, and from that point on, it needs a disproportionate amount of extra function calls to untangle it. If anything, have a configuration setting for whether you want to unify everything. As I see in Xcas, the output is not automatically put together in a common denominator, at least not in the current version, so it should be possible to preserve them, if it serves as the HP Prime CAS base.

Simplify... well, it might simplify or not, it's hard to measure the "simplicity" of an expression, although if I look at a tree representation of it, it would likely be possible to select the tree with smallest average depth, or something similar (perhaps have a more extended array of settings - prefer sin/cos/tan over cot/csc/sec [though this isn't a too common problem]... separate a denominator if in the numerator there is a function with a fraction on its own... try to avoid using the imaginary unit when the device is not in complex mode. Don't do multi-story fractions and such fractions that are broader than a screen, if you can help it. Stuff like these.) As it stands currently, for my perception, simplify very often fails to live up to its name (and then again, I mentioned one expression crashing the calculator on simplify. That's when I gave up further experiments on using it.) I am sure some would disagree over which expression is simpler than the other... it might worth to make some sort of survey with interested users/students.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 2 Guest(s)