disable generating warning messages from integrate command?

Messages in english

Modérateur : xcasadmin

Nasser
Messages : 13
Inscription : mer. juil. 11, 2018 11:14 pm

disable generating warning messages from integrate command?

Message par Nasser » lun. juin 19, 2023 11:29 pm

Is there a global option to set in giac to disable generating warning messages that show before the result of integration?

I will an example below.

The reason I am asking, is that I am calling giac from sagemath. And sagemath gives an exception when it gets back result with these warning in them as it does not how to parse them. And so now these integrals are counted as failed.

Here is an example

Code : Tout sélectionner

>giac
0>> integrate(1/(2*x^(1/2)+(1+x)^(1/2))^2,x)
Warning, choosing root of [1,0,%%%{-4,[1]%%%}+%%%{-2,[0]%%%},0,1] at parameters values [92.1017843988]
Warning, choosing root of [1,0,%%%{-4,[1]%%%}+%%%{-2,[0]%%%},0,1] at parameters values [1.14118046779]
2*((-5*x-1)/6/(3*x-1)+5/18*ln(abs(3*x-1))+2*(2/9*ln(sqrt(x+1)-sqrt(x))+5/36*ln(abs((sqrt(x+1)-sqrt(x))^2-3))-5/36*ln(abs(3*(sqrt(x+1)-sqrt(x))^2-1))-(10*(sqrt(x+1)-sqrt(x))^2-6)/9/(3*(sqrt(x+1)-sqrt(x))^4-10*(sqrt(x+1)-sqrt(x))^2+3)))
// Time 0.02
1>> 
If it could generate only

Code : Tout sélectionner

2*((-5*x-1)/6/(3*x-1)+5/18*ln(abs(3*x-1))+2*(2/9*ln(sqrt(x+1)-sqrt(x))+5/36*ln(abs((sqrt(x+1)-sqrt(x))^2-3))-5/36*ln(abs(3*(sqrt(x+1)-sqrt(x))^2-1))-(10*(sqrt(x+1)-sqrt(x))^2-6)/9/(3*(sqrt(x+1)-sqrt(x))^4-10*(sqrt(x+1)-sqrt(x))^2+3)))
Then it will at least not give an exception in sagemath. This is what happens in sagemath

Code : Tout sélectionner

>sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.0, Release Date: 2023-05-20                    │
│ Using Python 3.10.9. Type "help()" for help.                       │
└────────────────────────────────────────────────────────────────────┘
sage: var('x')
x
sage: integrate(1/(2*x^(1/2)+(1+x)^(1/2))^2,x, algorithm="giac")

NotImplementedError: unable to parse Giac output: Warning, choosing root of [1,0,%%%{-4,[1]%%%}+%%%{-2,[0]%%%},0,1] at parameters values [5.38357630698]
Warning, choosing root of [1,0,%%%{-4,[1]%%%}+%%%{-2,[0]%%%},0,1] at parameters values [81.1195442914]
2*((-5*(sageVARx+1)+4)/6/(3*(sageVARx+1)-4)+5/18*ln(abs(3*(sageVARx+1)-4))+2*(1/9*ln((sqrt(sageVARx)-sqrt(sageVARx+1))^2)+5/36*ln(abs((sqrt(sageVARx)-sqrt(sageVARx+1))^2-3))-5/36*ln(abs(3*(sqrt(sageVARx)-sqrt(sageVARx+1))^2-1))-(10*(sqrt(sageVARx)-sqrt(sageVARx+1))^2-6)/9/(3*(sqrt(sageVARx)-sqrt(sageVARx+1))^4-10*(sqrt(sageVARx)-sqrt(sageVARx+1))^2+3)))
sage: 
If there is a way to configure or build giac not to generate these warnings (just for the purpose of these tests), it will also improve its score of number of solved integrals. This is regardless if the result is correct or not, as that is different issue. But at least it will be able to record the result instead of now not being able to do that.

Using sagemath 10 and giac 1.9.0-55

--Nasser

parisse
Messages : 5742
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: disable generating warning messages from integrate command?

Message par parisse » jeu. juin 22, 2023 8:32 pm

Maybe try to modify icas.cc and redirect logs with logptr(0,contextptr) before any evaluation.
But why don't you calI giac directly? I understand that it may be easier for you, but it will not return an accurate report on giac native performance, even if you remove these logs it will add parsing/printing time to giac benchmarks.
In short you are building a report of "Giac inside sage". But "Giac inside sage" is only a tiny part of giac users, most giac users are either using Geogebra CAS window, or Xcas or Xcas for Firefox or one of the calculator ports of giac (KhiCAS). I would really appreciate if giac had it's own native report in a future release of your comparison, independant of sage.

Nasser
Messages : 13
Inscription : mer. juil. 11, 2018 11:14 pm

Re: disable generating warning messages from integrate command?

Message par Nasser » jeu. juin 22, 2023 9:12 pm

Maybe try to modify icas.cc and redirect logs with logptr(0,contextptr) before any evaluation.
Sorry, I do not know how to do that. I am not going to dig into advanced and complex C++ code and try to change things I do not understand.

I was hoping you could provide a configuration switch to turn these off before building giac from source. This will be much easier for users who wish to turn off these messages.
But why don't you calI giac directly? I understand that it may be easier for you, but it will not return an accurate report on giac native performance
I only use giac for integration to compare it with other cas systems. It is much much easier to use the same code for testing giac that I use for maxima and fricas. I spend long time and many months debugging that code.

There are many things involved than just calling integrate. Code to grade the result, generate latex, leaf size calculation, checking status, setting 3 minutes timeout, recording result, formating, writing to files, etc...

All of this is now done in same Python sagemath scripts for all cas I use with sagemath. Having to rewrite all this in custom giac code, just to get a little more accurate time used?

As all other things are the same. The most important aspect is getting the anti-derivative, grading it, and getting leaf count. None of these will change if I use giac directly.

Only difference is that time used to do the integration will be little off. I agree. Instead of say 30 seconds, may be it will take 15 seconds if using giac directly. For me, this is not worth spending 3-4 months rewriting all the code I have in Python in giac, and since I am not familiar with giac direct programing much to start with. If I had the time it will be better ofcourse to write custom code for each CAS in its own environment than using sagemath. I agree with that. But I do not have the time nor the skill to do that now and then to maintain 3 different scripts instead of just one based on sagemath.

If you could provide a switch to turn off these warnings, I could use it and this will improve giac score as these are many such integrals that fail now due to this problem. If this is not possible, no problem. I just thought to ask if there was such a switch or configuration option. That is all.

best,
--Nasser

parisse
Messages : 5742
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: disable generating warning messages from integrate command?

Message par parisse » ven. juin 23, 2023 6:01 am

You will find an implementation of partial redirection to a file of giac logs here
https://www-fourier.univ-grenoble-alpes ... mp/icas.cc
To redirect, run in your shell a command like
export GIAC_LOG_FILE=log
I don't know if this will solve the issue (I'm not a sage user)

About giac standalone testing, I don't think it's 3 or 4 months of work, and you could do it partially (most important integrals first). I have already checks for a few of your tests that could help you do that
https://www-fourier.univ-grenoble-alpes ... p/test.tgz
For example chk_intinda will run "0 Independent test suites\Apostol Problems.txt", the inputs are inside the file intinda.

I do not want to underestimate the required work it would represent for you, but you should understand that by only testing giac inside sage, I'm feeling that you are undervaluating my own work. Sage is in direct competition with Giac/Xcas, and as you mentionned Sage limitations will give lower scoring for giac in your benchmarks. I know that Xcas is not as good as commercial competitors like Maple or Mathematica for integration, but it performs very well for usual integrals that do not involve special functions, and Xcas is much more accessible/lightweight/embeddable than Sage (or other CAS). Sage is mainly used by maths researchers and the students they are teaching to, while Giac is much more mainstream in education, Geogebra has millions of users, it is also the builtin CAS of the HP Prime calculator, available on the Casio FXCG50, fx-9750GIII, TI Nspire (all ndless-compatible models), and Numworks.
I estimate that the number of users exposed to giac integration is probably of the same order size than for Maple or Mathematica.

Répondre