Error when integrating absolute value

12062019, 02:00 PM
Post: #1




Error when integrating absolute value
So I have come across a problem when integrating in regards to absolute value.
See my picture below. The correct answer should be 4k. This has become a problem for my students computing double integrals. Students with competitive brand calculators have the correct answer as 4k but students with the HP have an answer as 2k. The problem is resolved if I take the k outside the integral, but I should be able to leave the k inside and receive the correct result. Is there any way this calculator can be fixed so this answer becomes correct? Thanks. 

12062019, 02:53 PM
Post: #2




RE: Error when integrating absolute value
What is your input?
TW Although I work for HP, the views and opinions I post here are my own. 

12062019, 03:23 PM
Post: #3




RE: Error when integrating absolute value
(12062019 02:53 PM)Tim Wessman Wrote: What is your input? I will take a picture of my calculator if you'd like. See my attached image. I get two entirely different answers. 

12062019, 03:27 PM
Post: #4




RE: Error when integrating absolute value
(12062019 02:53 PM)Tim Wessman Wrote: What is your input? If you want a purely numeric problem with this calculator, look at this attached image. I receive an answer of 3. The result should be 9. This can be confirmed on wolfram alpha. See both images in this post. 

12062019, 06:55 PM
Post: #5




RE: Error when integrating absolute value  
12062019, 08:02 PM
Post: #6




RE: Error when integrating absolute value
(12062019 06:55 PM)Aries Wrote: Same result (9) here with CX II This is the correct answer. The HP Prime provides 3 as an answer, which is obviously not correct. If you were to approximate the volume with say 10000 rectangular prisms, (I wrote a MATLAB script to do this) you will receive 9 as well. I'm not sure why integrating absolute value and trigonometric functions provide such wrong answers. Hopefully this is addressed. 

12062019, 08:11 PM
Post: #7




RE: Error when integrating absolute value
I guess you mean int(k*abs(cos(x)),x,pi/2,3*pi/2);
There is a warning displayed in the terminal. If you compute the integral without k, the calculator can check the discontinuities of the antiderivative, but not with k, the check is disabled because checking for more complex inputs could raise endless computations. This input is simple, it's certainly possible to solve this case, but at some point you will find a similar error, whatever I code. 

12062019, 08:24 PM
Post: #8




RE: Error when integrating absolute value
(12062019 08:11 PM)parisse Wrote: I guess you mean int(k*abs(cos(x)),x,pi/2,3*pi/2); Sure, but there are no discontinuities of cosine and all values are real. And in the other problem I showed above, it's purely numeric and it's providing me with an incorrect answer. I should be getting 9 and I'm getting 3. You could see the other reply as well. 

12062019, 08:42 PM
Post: #9




RE: Error when integrating absolute value
(12062019 08:24 PM)LCieParagon Wrote: Sure, but there are no discontinuities of cosine and all values are real.Please read the whole warning. The problem comes from singulatiries in sign(cos(variable_name)) inside the antiderivative. Quote:And in the other problem I showed above, it's purely numeric and it's providing me with an incorrect answer. I should be getting 9 and I'm getting 3. You could see the other reply as well.It's not purely numeric, because you must compute the inner integral symbolically. In fact, it's the same problem, fixing singularity checks for the first integral returns 9 for the second one. BTW, if you want to help us fixing bugs, please post plain text commandlines that I can easily paste in the emulator, pictures can not be pasted (and they waste Internet bandwidth...). 

12062019, 11:54 PM
(This post was last modified: 12072019 01:11 AM by Albert Chan.)
Post: #10




RE: Error when integrating absolute value
\(\large I =\int_0^{3\pi \over 2} \int_0^{3\pi \over 2} \cos y \; \sin x dx\, dy
= \int_0^{3\pi \over 2} \sin x dx \times \int_0^{3\pi \over 2} \cos ydy \) Since it wrap the sine/cosine with the absolute value function, each quadrant sum to area of 1 \(\large → I = 3 × 3 = 9\) 

12082019, 11:35 PM
(This post was last modified: 12092019 12:23 AM by pinkman.)
Post: #11




RE: Error when integrating absolute value
(12062019 08:42 PM)parisse Wrote: Please read the whole warning. The problem comes from singulatiries in sign(cos(variable_name)) inside the antiderivative. Hi Bernard, thanks for trying to help us, but I’m really confused or puzzled by your answer that I don’t understand. I know the problem of the singularities, but for me there is no doubt that ∫(ABS(cos(x)),x,π/2,3*π/2) = 4, and ∫(k*ABS(cos(x)),x,π/2,3*π/2) = k*4 in the real domain, k being a constant. Am I wrong? 

12092019, 04:24 AM
(This post was last modified: 12092019 05:06 AM by Stevetuc.)
Post: #12




RE: Error when integrating absolute value
There must be a solution that is viable on a calculator since Casio have achieved it. Perhaps they use a parser to move the constant outside the integral.


12092019, 06:51 AM
Post: #13




RE: Error when integrating absolute value
(12082019 11:35 PM)pinkman Wrote:No, but ask yourself, how did you get this result? You probably cut the integral in several parts. The problem here is to find the cut positions. You have to solve an equation for that, and after I had problems with more complicated inputs, I decided to solve this equation only if it was univariate. This is not the case if there is a parameter, that's why you got the warning and a wrong answer. I have already modified the source code to solve it for this input because the dependancy in k can easily be removed, now you will get 4*k. But keep in mind that in other situations, it might be wrong, you should always read carefully the warnings and check your answer if there is a warning.(12062019 08:42 PM)parisse Wrote: Please read the whole warning. The problem comes from singulatiries in sign(cos(variable_name)) inside the antiderivative. 

12092019, 01:40 PM
(This post was last modified: 12092019 01:41 PM by pinkman.)
Post: #14




RE: Error when integrating absolute value
(12092019 06:51 AM)parisse Wrote: No, but ask yourself, how did you get this result? You probably cut the integral in several parts. Yes I did. I even did twice before writing my question! (12092019 06:51 AM)parisse Wrote: The problem here is to find the cut positions. You have to solve an equation for that, and after I had problems with more complicated inputs, I decided to solve this equation only if it was univariate. This is not the case if there is a parameter, that's why you got the warning and a wrong answer. Ok understood, but just to be sure: if k is not a function of x, and here it is not, it is a coefficient (a constant factor), not a parameter, isn’t it? Because you had the right result 4 without the k, and this constant k is out of the abs() operand, it doesn’t interfere with the result, doesn’t it? (12092019 06:51 AM)parisse Wrote: I have already modified the source code to solve it for this input because the dependancy in k can easily be removed, now you will get 4*k. But keep in mind that in other situations, it might be wrong, you should always read carefully the warnings and check your answer if there is a warning. What kind of situations? A function of x? It would be revealed by the symbolic preprocessing, no? Are there any other situations? Please note: these are real questions, not reproaches or provocation. I just want to be sure I understand the limits of CAS, because sometimes, even in presence of a warning message, I (we all?) blindly trust the machine Et puis aussi c’est barbant de tout écrire en anglais ! Je veux juste savoir dans quels cas ce k aurait une influence sur l’intérieur de l’intégrale. Merci ! Thibault  not collector but in love with the few HP models I own  Also musician : http://walruspark.co 

12092019, 02:08 PM
Post: #15




RE: Error when integrating absolute value
(12092019 01:40 PM)pinkman Wrote: Et puis aussi c’est barbant de tout écrire en anglais ! Je veux juste savoir dans quels cas ce k aurait une influence sur l’intérieur de l’intégrale. Merci ! It may be boring (did I get that right?) but it's the lingua franca of the board. Although his English is impeccable, I'm sure Parisse would be even more comfortable posting in French but it is what it is. Tom L Cui bono? 

12092019, 02:19 PM
Post: #16




RE: Error when integrating absolute value
(12092019 02:08 PM)toml_12953 Wrote:(12092019 01:40 PM)pinkman Wrote: Et puis aussi c’est barbant de tout écrire en anglais ! Je veux juste savoir dans quels cas ce k aurait une influence sur l’intérieur de l’intégrale. Merci ! It was my minute of rebellion! Yes boring is the right translation. I just wanted to be sure Bernard felt that I was not challenging him, but asking. A try of translation of my french paragraph: “And, also, it’s boring to write all this stuff in English! I just want to know in what cases this k would have influenced the integral.” Regards and sorry, je ne le referai plus*! (*) I won’t do it again 

12092019, 02:26 PM
Post: #17




RE: Error when integrating absolute value
calculatrice


12102019, 09:24 PM
Post: #18




RE: Error when integrating absolute value
The change I made in the source is : before checking that the antiderivative is univariate, check if it is a product and remove terms that do not depend on x.
About the warning: there might be problems if for example the antiderivative has a dependency on k that can not be removed easily, for example if it contains a sign(cos(x)k). If you get a warning, you should check the answer. If an integral is univariate and has bounded limits, the CAS does a numeric check, then you can be confident. If an integral has parameter, a good way to check the answer is give one or 2 values to the parameter. Or alternatively, compute the antiderivative, and make a plot for some value of k, check discontinuities. And if you want to discuss Prime CAS in French, please register to the Forum de Xcas, there is a section about calculators. I'd be more than happy to answer in French, but here it would not be polite to have a discussion in French (unless we translate it to English of course). 

12102019, 10:41 PM
Post: #19




RE: Error when integrating absolute value
Very clear, thanks a lot!
If CPU time was unlimited I would also suggest to implement the test with few values of the parameter, to add a comment to the warning, like ‘CAS checked this result for random values of k’. Thanks for the invitation on the Xcas forum. And yes I know the courtesy code, I was just joking because I sometimes hit my limit in English. And as written, it was a little help to make you feel I was really asking, not criticizing. 

12132019, 04:40 PM
Post: #20




RE: Error when integrating absolute value
Sorry for being ignorant, but how do we update the calculator to have the latest versions of XCas?
Thanks. 

« Next Oldest  Next Newest »

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