Re: [fricas-devel] integration
On Sat, Jul 29, 2023 at 07:00:36AM +, '68th' via FriCAS - computer algebra system wrote: > --- Original Message --- > On Thursday, July 27th, 2023 at 12:30 PM, Waldek Hebisch > wrote: > > > ex1 := (1+tan(gamma/2)^2)/(k^2+l^2*tan(gamma/2)^2) > > d_subst := (k/l)u > > inv_subst := l/ktan(gamma/2) > > exs := subst(ex1/D(inv_subst, gamma), tan(gamma/2)= d_subst) > > iis := integrate(exs, u) > > subst(iis, u = inv_subst) > > Thank you very much! Now I can do all my calculations in FriCAS. Glad to hear this. -- Waldek Hebisch -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/ZMYwO3lJFDSOOKT7%40fricas.math.uni.wroc.pl.
Re: [fricas-devel] integration
--- Original Message --- On Thursday, July 27th, 2023 at 12:30 PM, Waldek Hebisch wrote: > ex1 := (1+tan(gamma/2)^2)/(k^2+l^2*tan(gamma/2)^2) > d_subst := (k/l)u > inv_subst := l/ktan(gamma/2) > exs := subst(ex1/D(inv_subst, gamma), tan(gamma/2)= d_subst) > iis := integrate(exs, u) > subst(iis, u = inv_subst) Thank you very much! Now I can do all my calculations in FriCAS. -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/ZPzFrq80qPTGSnoUxQda4gKzvBruu5Po1kU5rRE1r6wlVx5J81FV8LKuWOila8AzT_QPNAkSwxCxTgpiKRbLii7ldEDkX1Nhr19Op0IBVEk%3D%40proton.me.
Re: [fricas-devel] integration
On Wed, Jul 26, 2023 at 02:51:21PM +, '68th' via FriCAS - computer algebra system wrote: > --- Original Message --- > On Tuesday, July 25th, 2023 at 3:10 PM, Waldek Hebisch > wrote: > > > Well, you can do substitution, pass that to integrate and do > > backsubstitution. > > If I do > > u := l/k*tan(gamma/2) > > then I can't use it in > > integrate(1/(1+u^2),u) > Cannot find a definition or applicable library operation named integrate with > argument type(s) > Expression(Integer) > Expression(Integer) > > How to do u-substitution in FriCAS? ex1 := (1+tan(gamma/2)^2)/(k^2+l^2*tan(gamma/2)^2) d_subst := (k/l)*u inv_subst := l/k*tan(gamma/2) exs := subst(ex1/D(inv_subst, gamma), tan(gamma/2)= d_subst) iis := integrate(exs, u) subst(iis, u = inv_subst) Note that you need to provide both direct substitution and an inverse one. And you can substitute only for kernels, that is things like tan(x/2), exp(x^2), etc. With that constraints commands above will work for many substitutions. You just need to give the kernel (tan(gamma/2) in this case), new variable (u int this case), direct substitution and inverse substitution. As I wrote, when FriCAS thinks that substitutions are useful it finds and applies them automatically. In general equation u = f(k) may be not solvable for k, but you can do substitutions essentially via pattern matching. In FriCAS this gets messy because user would have to supply appropriate rewrite rules. Still, the case above where we substitute for kernels and both substitutions are give by formulas covers many important special cases. -- Waldek Hebisch -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/ZMJjYFzNtv5rDSzV%40fricas.math.uni.wroc.pl.
Re: [fricas-devel] integration
--- Original Message --- On Tuesday, July 25th, 2023 at 3:10 PM, Waldek Hebisch wrote: > Well, you can do substitution, pass that to integrate and do > backsubstitution. If I do u := l/k*tan(gamma/2) then I can't use it in integrate(1/(1+u^2),u) Cannot find a definition or applicable library operation named integrate with argument type(s) Expression(Integer) Expression(Integer) How to do u-substitution in FriCAS? -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/M59PH77iyzY6ktTZrKULT3_cQuRYHTaGUNxRjYjx6cT_pMikm5mWJiK4EGSFhb1qc-9ndXPsCtl2Yp8IUePQaZGIRjVEIVbB5MqGuLQaQc4%3D%40proton.me.
Re: [fricas-devel] integration
On Mon, Jul 24, 2023 at 05:12:37PM +, '68th' via FriCAS - computer algebra system wrote: > --- Original Message --- > On Sunday, July 23rd, 2023 at 8:36 PM, Waldek Hebisch > wrote: > > > )trace INTEF )math > > Can ')trace' be somehow used for 'normalize' to see its intermediate steps? Try )trace EFSTRUC )math But you will see that there are two steps, one transforms function to standard form, for example expressing trignomentric functions in terms of tangents, and the second one i normalization proper. You will get more info using )trace LINDEP )math For example, normalize(exp(2*x) - exp(x)^2) tries to find linear dependence over integrs between 1 and 2. But trace does not say why this system? Well, the rule is: look arguments of all expnential and logaritms which appear in your expression. In this case you get exp(x) and exp(2*x) as exponentials and there are no logratims. Arguments of exponentials are x and 2x. Then we form derivatives of arguments, that is 1 and 2 and we try to find releation over integers. Well, 2*1 = 2. From this we infer that exp(2*x)/exp(x)^2 is a constant, if fact 1. So we replace exp(2*x) by exp(x)^2 and we get exp(x)^2 - exp(x)^2 that is zero (internally replacement and simplifiaction is done together. Note that things like EFSTRUC or LINDEP are abbreviations, FriCAS hyperdoc browse command or )show command show that full name is ElementaryFunctionStructurePackage. From browse you can go to source and see what each function is doing. > > Theory says that this is simplest possible expression > > of similar form. > > That's not how I found the simpler antiderivative. I don't use complex > exponential functions. It only takes a right u-substitution. But in general substitutions are hard to find. Expressing trigonometic functions in terms of complex exponential is much easier (purely mechanical). > > But in this case it does not work. > > Okay, FriCAS magic doesn't work. The question is: is it still possible to > make FriCAS find the simpler antiderivative? Can a user have any control over > the integration process? Let's say: > > u := l/k*tan(gamma/2) > > If I will be able to do all the necessary transformation to the integrand, > can I then use u as the second argument in the 'integrate' command? Well, you can do substitution, pass that to integrate and do backsubstitution. But 'integrate' is an algorithm, it dully performs all its steps. And FriCAS gives you warranty that when there are no algebraics and antiderivative is elementary than FriCAS will find an antiderivative. If you deviate from prescribed steps, then there is no such warranty, So FriCAS can not allow variation for elementary integrals. Once integral is determined to be nonelementry, than there is some possibility for variation. But there is another aspect: allowing more things internally means more code in integrator. For example, in the past FriCAS would handle your integral directly in terms of tangent, whithout introducing complex numbers. I think that this version would automatically find equvalent of you substitution. Corresponding code was developed it the hope that working it terms of tangents would give better integrals. But while using tangents would give improvement, in other cases tangents lead to more complicated integration. On avergage complex transformation seem to give better results. So code for handling tangent was removed, it is better to improve/fix transformation stage. -- Waldek Hebisch -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/ZL/l83pth4%2BBwLU4%40fricas.math.uni.wroc.pl.
Re: [fricas-devel] integration
--- Original Message --- On Sunday, July 23rd, 2023 at 8:36 PM, Waldek Hebisch wrote: > )trace INTEF )math Can ')trace' be somehow used for 'normalize' to see its intermediate steps? > Theory says that this is simplest possible expression > of similar form. That's not how I found the simpler antiderivative. I don't use complex exponential functions. It only takes a right u-substitution. > But in this case it does not work. Okay, FriCAS magic doesn't work. The question is: is it still possible to make FriCAS find the simpler antiderivative? Can a user have any control over the integration process? Let's say: u := l/k*tan(gamma/2) If I will be able to do all the necessary transformation to the integrand, can I then use u as the second argument in the 'integrate' command? -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/7o4jPF9rxFT4krtUvU0jIDKrZGvr7bAQRLk1BaaFMuuSGTd-bUcHPTUqUZ8q2zKUlIsSecA-i1xfcBifD72kr_cvIE6UGQXeU0WFLaOCtQ4%3D%40proton.me.
Re: [fricas-devel] integration
On Sun, Jul 23, 2023 at 04:53:12PM +, '68th' via FriCAS - computer algebra system wrote: > Okay, here's the integrand: > > ex1 := (1+tan(gamma/2)^2)/(k^2+l^2*tan(gamma/2)^2) > > Let's find the antiderivative: > > ex2 := integrate(ex1,gamma) > > And this is a simpler variant of the antiderivative: > > ex3 := (2*atan(l/k*tan(gamma/2)))/(k*l) > > Let's do a simple comparison: > > normalize(ex2-ex3) > > Oops, the difference is -π/(2kl). However: > > D(ex2,gamma)-D(ex3,gamma) > > returns zero. > How can make FriCAS find the simpler antiderivative? Ideally FriCAS sould automatically find simpler form. ATM we are getting more complex one, depending on point of view this is a bug or missing feature. I you want more info, you can see intermediate results of integration. Namely do: )trace INTEF )math and then issue integration command. This produces a bit more of output, but the important part is: 2 222 %i gamma22 --+ 2 %i k l (l - k )%e - l - k > %E log(- %E + -) --+ 22 22 2 1 l - k l - k %E + = 0 2 2 k l The sum part means sum over roots of polynomial below the summation sign. This is quadratic polynomial with two purely imaginary roots. So we get expression in terms logarithms with complex arguments. Theory says that this is simplest possible expression of similar form. The final result is obtained transforming complex logaritms into sums of atan and real logarithm. Above real logarithm cancel and what remains is sum of two identical atans, so has only one term. When done naively, this transformation results in effect that you see (some people call it "atan doubling"). Transformation code performs extra computation designed to avoid this effect. But in this case it does not work. -- Waldek Hebisch -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/ZL2PVvydHuioq4ef%40fricas.math.uni.wroc.pl.
[fricas-devel] integration
Okay, here's the integrand: ex1 := (1+tan(gamma/2)^2)/(k^2+l^2*tan(gamma/2)^2) Let's find the antiderivative: ex2 := integrate(ex1,gamma) And this is a simpler variant of the antiderivative: ex3 := (2*atan(l/k*tan(gamma/2)))/(k*l) Let's do a simple comparison: normalize(ex2-ex3) Oops, the difference is -π/(2kl). However: D(ex2,gamma)-D(ex3,gamma) returns zero. How can make FriCAS find the simpler antiderivative? -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/lu5nC29kFNXHtzvymIwOXZ9Su0rtaoYrAq5rwBL_7pmfiOv34d0X_cV3i2eSECVEkJwsJIgEfhlBy40M4IHLHZ5XtHCxW51LqgRrxWRH3NM%3D%40proton.me.
[fricas-devel] Integration with elliptic functions
I have now commited preliminary routine for integration in terms of elliptic integrals. It only handles integrals of the first and second kind (integrals of third kind are unhandled) and among them onlu few classic form. Still, it can do a lot of classic examples like: (2) -> integrate(1/sqrt(4*x^3 - 3*x -2), x) (2) weierstrassPInverse(3,2,x) Type: Union(Expression(Integer),...) (3) -> D(%, x) 1 (3) - +--+ | 3 \|4 x - 3 x - 2 Type: Expression(Integer) Note that derivatives of our elliptic integrals contain specific form of roots. It may happen that function that we want to integrate contain different form of roots. Integrator transform roots "moving" powers trough roots, but most our routines do not do so. Due to this derivative of integral may contain different roots than integrand and ATM normalize is not able to simplify resulting difference to 0. For example: (4) -> integrate(1/sqrt(x^3 + 2), x) (4) 2 weierstrassPInverse(0,- 8,x) Type: Union(Expression(Integer),...) (5) -> D(%, x) 2 (5) --- ++ | 3 \|4 x + 8 Type: Expression(Integer) There is factor 4 under root and normalize do not see that the above is the same as the integrand. -- Waldek Hebisch -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/20220613221251.GB14822%40fricas.math.uni.wroc.pl.
Re: [fricas-devel] Integration example
On Sat, Jul 11, 2020 at 05:28:55AM +0300, h-x h.-x wrote: > Thank you for your explanation! > I followed your steps somewhat, and I'm sorry in advance for putting here > this blob of mathcad worksheet, but > there was no way I could handle all that manually, and I feel taking > screenshots from a live sheet is the simplest way > to show how I worked my way through... > [image: image.png] > ...at least not yet... BUT, at this point, B, which is a poly in t with > coefficients in ???(x), will have to be a multiple of BSR?? in order to "bring > BSR up"; > then we could collect further "around" BSR... > > -- and, finally, B and B' have the same degree as polynomials in exp(ix), > and the multiple of (t??-1)(t??+1) in the second summand > will never vanish, and we need it to vanish in order to obtain the* > constant expression* you denoted as c (which I estimated to be 1/sqrt(2))? > > Do I understand you correctly? > > So, for this example, the only part that remains a mystery is the structure > theorem that dictates that we shall look for the antiderivative in form > (B/t)*BSR + W, > both B and W from ???(x)[t], and we search for them by differentiating said > form and checking if such polys are even possible... > > No possibilities for new logarithms in the answer? Well, W contains all logarithms. Let me state basic principle first: function that have no finite poles is of form A + B*BSR where BSR is as you wrote and A and B are in Q(x)[t]. Without root this is well known, at least when you write K=Q(x) and consider elements of K(t). Now, usual proof of this in case of K(t) uses unique factorization in K[t]. It is known that after extending K(t) by our square root we no longer have unique factorization in K[t] extended by the root (which is natural ring if one wants to ape transcendental theory). Fortunately, for looking at poles it is enough to work using K[t] as a base ring and consider modules over it. To fix notation I will use L to denote K(t) extended by square root and f to dentote integrand. One can check that derivative of logarithm can not have pole at t=0. Since our f have poles there, those poles must come from derivative of element of L, call it g. So f - g' has no pole at 0. Also, f has no finte poles outside 0. Outside 0 logarithm give only poles of multiplicity 1. OTOH if g has finite pole outside 0, then g' has multiple pole. Multiple pole can not cancel with pole of multiplicity 1. So, g has no finite poles outside 0. Any element of L can be written as C + D*BSR where BSR is the root and A, B are in K(t). In particular g = C + D*BSR with appropriate C and D. As we argued, g has no finite poles outside 0. At 0 g has pole of multiplicity 1. It is easy to see that replacing BSR by -BSR in all formulas we will get valid equality (this replacement can be vieved as using Galois theory, but is an easy special case). Using such replacement one can see that C = 0. Our argument about poles means that D has pole of multiplicity 1 at 0 and no other finite poles. Consequently, D = t^(-1)*B where B is in K[t]. Now, B = b + t*E where E is in K[t], so g = b*t^(-1) + E Differentiating E*BSR we see that it has no pole at 0, so in order for f - g' to have no pole at 0, we need f - (b*t^(-1)*BSR)' to have no pole at 0. Now we expand both terms into powers of t. To have on pole at 0 coefficients of t^(-1) must cancel which leads to equation that I gave previously: c = b' - ib/2 Solution to this equation is exponential, so not in K = Q(x). Comparing to your argument, we do not look at higher terms in B. In fact, in cases where we can integrate by parts (solve equation similar to the above), we stop once we arrive at t^0 in power series expansion. We need to do similar thing at infinity (in practice we replace t by t^(-1) and change root to match). This ends one stage if integration procedure. After this stage we have reduced problem to integrand which has no poles at 0 and at infinity and ony poles of multiplicity 1 at other places. Now we need to determine logarithmic part. Here, lack of unique factorization is more serious. Explaining what to do with logarithmic would make this message much longer, so today I stop here. -- Waldek Hebisch -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/fricas-devel/20200713151413.GA11415%40math.uni.wroc.pl.
Re: [fricas-devel] Integration
Do you think there are some easier sub-tasks that we can help? For example, writing these tests in FriCAS format, adding rules for some elliptic cases, etc. On 10/24/18 3:01 AM, Waldek Hebisch wrote: > I looked a bit at FriCAS failures in Rubi testsutite. More than > 8000 positions in testsutite contains elliptic integrals in > answer. FriCAS currently can not generate ellipic integrals > in answers, so unless the integral really is elementary > (it happens sometimes, but is quite rare) FriCAS can not > do it. This is more than 10% of the testsuite and single > biggest reason for failures. > > More about this: it seems that most elliptic cases is > very simple, easily reducing to defining formulas > by few substitutions. It seem relatively easy to add > ad-hoc handling for such cases. Main problem is that > we do not want to loose completeness for elementary cases, > so we can generate elliptics only after we decided that > integral is nonelementary. > > Probably next biggest problem is polylogaritms (of order 5000 > positions). We can handle one case, when argument of > polylogarithm is an exponential. But Rubi testsuite seem > to contain mostly different case. > > There are also integrals expressed in terms of hypergeometric > functions (few thousends). They are used to integrate > algebraic functions and some mixed cases involving > algebraics and exponentials. I need to look closer, > but at least some of them we should be able to handle > like existing code for incomplete gamma. > > Together the cases above seem to cover vast majority of > failures on Rubi testsuite. There are also failures > which current FriCAS methods in principle should handle, > but are not handled due to incomplete or buggy implementation. > > ATM better handling of the above is still in planning stage. > I have made nice theoretical progress, both for elliptic > functions and for polylogarithms. But in both cases > theory is still too weak to give complete algorithm. > So we probably should try adding ad-hoc extentions. > There is reasonable chance that such extentions will > be part of complete implementation in the future. > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
[fricas-devel] Integration
I looked a bit at FriCAS failures in Rubi testsutite. More than 8000 positions in testsutite contains elliptic integrals in answer. FriCAS currently can not generate ellipic integrals in answers, so unless the integral really is elementary (it happens sometimes, but is quite rare) FriCAS can not do it. This is more than 10% of the testsuite and single biggest reason for failures. More about this: it seems that most elliptic cases is very simple, easily reducing to defining formulas by few substitutions. It seem relatively easy to add ad-hoc handling for such cases. Main problem is that we do not want to loose completeness for elementary cases, so we can generate elliptics only after we decided that integral is nonelementary. Probably next biggest problem is polylogaritms (of order 5000 positions). We can handle one case, when argument of polylogarithm is an exponential. But Rubi testsuite seem to contain mostly different case. There are also integrals expressed in terms of hypergeometric functions (few thousends). They are used to integrate algebraic functions and some mixed cases involving algebraics and exponentials. I need to look closer, but at least some of them we should be able to handle like existing code for incomplete gamma. Together the cases above seem to cover vast majority of failures on Rubi testsuite. There are also failures which current FriCAS methods in principle should handle, but are not handled due to incomplete or buggy implementation. ATM better handling of the above is still in planning stage. I have made nice theoretical progress, both for elliptic functions and for polylogarithms. But in both cases theory is still too weak to give complete algorithm. So we probably should try adding ad-hoc extentions. There is reasonable chance that such extentions will be part of complete implementation in the future. -- Waldek Hebisch -- 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+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
Re: [fricas-devel] Integration?
When 'integrate' returns a list of results, there are conditions associated with them. More specifically, it tries to ensure (y)^(1/n) is real when n is even, aka ensure y is positive. So in the example of 'integrate(1/(x^4+2*a*x^2+a^2-1),x)', the first answer, (-a-1) and (-a+1) should be positive, aka a <=-1 The second, (-a-1) and (a-1) should be positive, which is impossible. (Current code checks sign of the product.) The third (a+1) and (-a+1) should be positive, aka -1<=a<=1 The fourth (a-1) and (a+1) should be positive, aka a>=1. Clearly there are much room for improvement in the algorithm. See 'irexpand.spad', especially the function 'pairsum' and 'compatible?'. -- 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+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
Re: [fricas-devel] Integration?
On 03/13/2018 12:53 PM, Waldek Hebisch wrote: When trying to integrate: integrate(1/(x^4+2*a*x^2+a^2-1),x) I get a list containing "all possible solutions"; that's okay, but how do I determine what conditions the alternatives hold for? Is there an automated way; or do I have to evaluate each solution separately Well, each solution is supposed to be correct solution. Which one is more appropriate depends on conditions unknown to the integrator. ?Dealing with the same problem I tried: complexIntergrate() and got one solution. Should I just go with complexIntegrate() all the time? _You_ decide what you need. But in general result of 'complexIntegrate' is likely to be futher from user input than result of 'integrate'. I am evaluating the Rubi test suite in Maxima and trying fricas as a fall back when Maxima fails; and trying to keep the interface simple. Depends what you want to check. In some tests I checked all solutions returned by FriCAS, in other cases just the first result. I am just differentiating the integral produced and matching that to the integrand. Then doing a "leaf count" of the resulting integral and comparing that to the Rubi form. Actually falling back on Fricas is probably cheating, and won't fly with the Rubi author. i.e. if Maxima returns an unevaluated value I call Fricas :) I can't resist showing that there is a free program that does solve the integral. I suppose that one could weld the two together (say like Sage does) and communicate by real "pipes" rather than through the disk :) ; and just call them different "modes". Since they have different Goals (typed vs. nontyed (more or less)) that seems better than rewriting or merging both; or some such. RayR -- 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+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
Re: [fricas-devel] Integration?
> > When trying to integrate: > integrate(1/(x^4+2*a*x^2+a^2-1),x) > I get a list containing "all possible solutions"; that's okay, but how > do I determine what conditions the alternatives hold for? Is there an > automated way; or do I have to evaluate each solution separately Well, each solution is supposed to be correct solution. Which one is more appropriate depends on conditions unknown to the integrator. > ?Dealing with the same problem I tried: > complexIntergrate() > and got one solution. > Should I just go with complexIntegrate() all the time? _You_ decide what you need. But in general result of 'complexIntegrate' is likely to be futher from user input than result of 'integrate'. > I am evaluating the Rubi test suite in Maxima and trying fricas as a > fall back when Maxima fails; and trying to keep the interface simple. Depends what you want to check. In some tests I checked all solutions returned by FriCAS, in other cases just the first result. -- Waldek Hebisch -- 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+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
[fricas-devel] Integration?
When trying to integrate: integrate(1/(x^4+2*a*x^2+a^2-1),x) I get a list containing "all possible solutions"; that's okay, but how do I determine what conditions the alternatives hold for? Is there an automated way; or do I have to evaluate each solution separately ?Dealing with the same problem I tried: complexIntergrate() and got one solution. Should I just go with complexIntegrate() all the time? I am evaluating the Rubi test suite in Maxima and trying fricas as a fall back when Maxima fails; and trying to keep the interface simple. Ray -- 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+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
[fricas-devel] Integration paper
You can find at: https://arxiv.org/abs/1802.05544 my paper about integration (Liouville principle) in terms of special function. This is first part, giving almost no algorithms. But the theory there forms basis for extension of Risch algorithm implemented in FriCAS. -- Waldek Hebisch -- 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+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at https://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
Re: [fricas-devel] Integration in terms of erf
someone wrote: (63) is up to piecewise constant D(Gamma(c, a*exp(-b*x)), x). Oh, good. I could not derive this and even Mathematica can not compute the indefinite integral. The constant is b*a^c I think. Current code can not handle irrational case of incomplete Gamma function, so all integrals like this are left unevaluated in current version. Ok. Thanks for the explanation. I am working on this, but due to branches the result will not be pretty. Great. If you write code for that and improve the integrator even further, this will be another spot where Fricas integrator is better than Mathematica. (This is nice to see because they make some claim.) Of course I am looking at competition. But my main point is to eliminate weak spots in FriCAS. Simple cases of irrational Gamma should be easy to do. However, if full generality irrational Gamma is a bit more complicated than most other cases of Ei/erf/Gamma stuff. Namely, main idea is that Ei/erf/Gamma is associated to an exponential. In most erf/Gamma cases there is only finitely many possible erf/Gamma terms assosicated with given exponential. If this is the case possible Gamma terms can be determined idependently of the integrand and one can set up system of linear equations to determine constant coefficients of the terms. In Ei case there are infinite numer of possible Ei-s, but one can compute most of neccessary ones from the integrand, except for finite (small) number of special cases which again depend only on the integrand. Two subcases of erf (currently unhandled) have infinite number of possibilities, here possibilties are parametrized by integers. In case of irrational Gamma there may be multidimensional family of possible Gamma terms. More precisely, looking at top exponential we get infinite number of candidates, and only examining integrand we can decide which one actually occur. Actually main idea in erf/Gamma case is that e^f where f \in M(t) may lead to erf only if a*(f+b) is a square for a in M and b in M (or in logaritmic case b = rt + b_0 with integer r and b_0 in M). If t is a log and f is second degree polynomial in t, this can lead to infinite number of solutions. The other infinite family came from similar situation, where we have algebraic extension by square root of linear polynomial, t is a log and f in linear in t and the square root. Otherwise there is only finitely many ways to complete the square. If solution satisfies extra conditions, then it leads to candidate for erf/Gamma term. Currently in transcendental case I get all solutions to the problem of completing squares (or higher powers). However, checking for extra conditions is incomplete, I just drop unhandled candidates... One unhandled case is: integrate(%e^(b/z^2+a*z^2),z) because it needs algebraic extension of constants to complete the square but there are some other unhandled cases. Beside purely transcendental functions I would like to handle algebraic extensions. Here big problem is that general case is unimplemented even for elementary functions (transcedental case makes important use of routines and algorithms for elementary case). I did a little hack to handle algebraic extension by root of linear polynomial in integration variable (change of variables reduces this to transcendental case). But I would like to do more. Actually, it seems that I know how to handle efficiently parts specific to Ei/erf/Gamma. So the hardest part is elementary. Beside Ei/erf/Gamma I am thinking about polylogs and elliptic integrals. For polylog theoretical situation is quite unclear: there is a method which can handle many cases. I have no couterexamples but also no proof that the method always works. Also elliptic integrals seem to be an open problem. -- Waldek Hebisch hebi...@math.uni.wroc.pl -- 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+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at http://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
Re: [fricas-devel] Integration in terms of erf
Hi, First is elementary, so probably always worked. Yes, I just did not try. Running on Axiom from May 2012 seems to confirm this. (AFAIK Axiom integrator has not changed much in the last years.) The second one, that is (61) contains case missed by FriCAS 1.2.2. Ah, very nice! Thanks. (63) is up to piecewise constant D(Gamma(c, a*exp(-b*x)), x). Oh, good. I could not derive this and even Mathematica can not compute the indefinite integral. The constant is b*a^c I think. Current code can not handle irrational case of incomplete Gamma function, so all integrals like this are left unevaluated in current version. Ok. Thanks for the explanation. I am working on this, but due to branches the result will not be pretty. Great. If you write code for that and improve the integrator even further, this will be another spot where Fricas integrator is better than Mathematica. (This is nice to see because they make some claim.) AFAICS (62) is not doable in terms of Ei and Gamma incomplete. That can well be the case. Integration by parts won't help here. -- 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+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at http://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
Re: [fricas-devel] Integration in terms of erf
Hi, I just commited new code for integration in terms of erf and incomplete Gamma. Great! It also fills a gap in handling of Ei, now all branches for handling Ei with transcendental arguments are implemented. Perfect. erf/Gamma part has significant gaps, but still is quite capable. Simple examples: (1) - integrate(exp(x)*exp(1/exp(x) - x), x) 1 (1) - Ei(---) x %e Type: Union(Expression(Integer),...) (2) - integrate((x+2)*exp(1/(x^2))/x^3, x) 1 -- 2 1 +---+ x - erfi(-)\|%pi - 2%e x (2) --- 2 Type: Union(Expression(Integer),...) (3) - integrate((x+1)*exp(-x^3-3*x^2-3*x-1), x) 2 3 2 Gamma(-,x + 3x + 3x + 1) 3 (3) - -- 3 Type: Union(Expression(Integer),...) Indeed, very nice! I had a quick look into the test cases too. BTW: Here are a few integrals I was working with right these days: (60) - integrate(exp(-a*exp(-b*x)) * exp(-b*x), x) - b x - a %e %e (60) - a b Type: Union(Expression(Integer),...) (61) - integrate(exp(-a*exp(-b*x)) * exp(-b*x) * x, x) - b x - a %e - b x b x %e+ Ei(- a %e ) (61) --- 2 a b Type: Union(Expression(Integer),...) It is good to see that Fricas can handle them, although I'm not sure how new this actually is. I did not try it before this mail thread. (62) - integrate(exp(-a*exp(-b*x)) * exp(-b*x) * x^2, x) x- %A b ++2 - %A b - a %e (62) | %A %e %ed%A ++ Type: Union(Expression(Integer),...) (63) - integrate(exp(-a*exp(-b*x)) * exp(-b*x)^c, x) x - %A b ++- a %e - %A b c (63) | %e(%e ) d%A ++ Type: Union(Expression(Integer),...) These fail but probably for a good reason because there exists no indefinite integral. Fricas could now prove this, in principle, given that the Risch extension is complete. -- 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+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at http://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
[fricas-devel] Integration in terms of erf
I just commited new code for integration in terms of erf and incomplete Gamma. It also fills a gap in handling of Ei, now all branches for handling Ei with transcendental arguments are implemented. erf/Gamma part has significant gaps, but still is quite capable. Simple examples: (1) - integrate(exp(x)*exp(1/exp(x) - x), x) 1 (1) - Ei(---) x %e Type: Union(Expression(Integer),...) (2) - integrate((x+2)*exp(1/(x^2))/x^3, x) 1 -- 2 1 +---+ x - erfi(-)\|%pi - 2%e x (2) --- 2 Type: Union(Expression(Integer),...) (3) - integrate((x+1)*exp(-x^3-3*x^2-3*x-1), x) 2 3 2 Gamma(-,x + 3x + 3x + 1) 3 (3) - -- 3 Type: Union(Expression(Integer),...) -- Waldek Hebisch hebi...@math.uni.wroc.pl -- 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+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at http://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
Re: [fricas-devel] Integration in terms of Ei.
someone wrote: At some point we should start documenting what part of Risch and which extensions are implemented in one central place. And also under what circumstances it failes, where the gaps and missing bits are. Theoretically situation is clear: - transcendental part of Risch is considered implemented - in algebraic part we have errors in places corresponding to unimplemeted parts. Search for things like FAIL. Notably, current integrator can not determine logarithmic part, polynomial part nor solve RDE in general case of algebraics depending on tanscendental. In partucular integrator is supposed to return unevaluated integral only when it is nonelementary. In practice we have: (255) - integrate(sqrt(tan(x)^2 + 2*tan(x) + 2), x) x +---+ ++ | 2 (255) | \|tan(%A) + 2tan(%A) + 2 d%A ++ Type: Union(Expression(Integer),...) but the integral is elementary. The problem is caused by factoring over rationals, while we should factor over appropriate algebraice extension. Also: (258) - t1 := exp(x) x (258) %e Type: Expression(Integer) (259) - t2 := exp(1/(1 + t1)) 1 --- x %e + 1 (259) %e Type: Expression(Integer) (260) - t3 := log(x*t2) 1 --- x %e + 1 (260) log(x %e ) Type: Expression(Integer) (261) - integrate(D(t3^2 -2*(1/(1+t1))*t3, x), x) (261) INTSIGN , x , 1 %A %A 3 %A 2 %A %e + 1%A 2 (2(%e ) + 6(%e ) + 6%e + 2)log(%A %e) - 2(%e ) + %A (2%A - 4)%e - 2 / %A 3 %A 2 %A %A (%e ) + 3%A (%e ) + 3%A %e + %A * d%A Type: Union(Expression(Integer),...) This one is caused by integrator assuming that the integral can be done using existing logarithms from base field. Elementary integral can always be done using logarithms from base field, but if one insists of using specific logarithms, then logarithms from extensions may help. In particular, above integrator discards 't3' as useless in integrating '1/x' but in fact 't3' is needed: (263) - D(t3, x) - D(t2,x)/t2 1 (263) - x Type: Expression(Integer) The things above may be considered bugs, but fixing them requires writing new routines. I have fixed a few bugs in rdeef related to Bronstein weakly normalized condition but I think that it still has problem, because it makes assumption which currently is not valid (we need extra code elsewere to make sure it holds). Other suspect place (related to bug above) is limited integration routine -- it seems to make too strong assumption on how logs may appear in an integral. We have partial implementation for extension of Risch algorithm to fields containing primitives. Missing part is parametric integration routine -- currently this is done by 'lfextlimint' but the method is a hack which only works in simple cases. We need more general routine. Uniplemented part of 'li' routine are somewhat like bugs above: we should factor taking into account algebraics, we should arrange logs in special way (condition is the same as needed for routine responsible for weakly normalized). The 'Ei' routine has the same problems like 'li'. Extra missing part is handling of 'Ei(f)' where top transcendental in 'f' does not appear in denominator of f'/f. The exponential case of 'polylog' routine has similar problems like 'li' and extra one due to possibility of terms like '(f1+f2)/(exp(k*f1)exp(f2) - 1)' with |k| 1, where 'f1' contains top transcenental (currently the routine may miss corresponding polylog terms). -- Waldek Hebisch hebi...@math.uni.wroc.pl -- 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+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at http://groups.google.com/group/fricas-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [fricas-devel] Integration in terms of Ei.
Hi, I have just commited new routine for integration in terms of Ei. With the new routine FriCAS can do all examples from Cherry paper. Wow, this is great! What a surprise to begin this week with :-) Thanks a lot for doing the work. This moves Fricas forward by another step. The new routine is still incomplete, the major ommisions beeing things like 'D(Ei(exp(x)), x)' or 'D(Ei(x/(log(x) + x)), x)'. Some simpler ommisions are handled by pattern matcher, but this is a significant gap. Yes, the first one, exp(exp(x)), is done by patterns now. But if you fill the gap, this part can probably be removed from INTPM. Or maybe not, because of integrands like: (16) - D(Ei(exp(sqrt(x))), x) +-+ \|x %e %e (16) +-+ 2\|x Type: Expression(Integer) (17) - integrate(%, x) +-+ \|x (17) Ei(%e) Type: Union(Expression(Integer),...) There are few other shortcuts. And the code is limited to tanscendental case (it will just give up on algebraics). Still, it seem to be most powerful Ei integrator implemented, it is easy to generate a lot of examples which it handles and no of usual competiton can do (the added tests may give you some idea). This is always a motivating to see. BTW: This is first part. There is other part which is going to handle erf, gamma incomplete and missing case above. However the second part requires some work to finish (it is in quite rough state now). At least the work has started. So thanks again. With erf, we probably get Fresnel and related Function too? At some point we should start documenting what part of Risch and which extensions are implemented in one central place. And also under what circumstances it failes, where the gaps and missing bits are. -- 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+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at http://groups.google.com/group/fricas-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [fricas-devel] Integration in terms of Ei.
someone wrote: The new routine is still incomplete, the major ommisions beeing things like 'D(Ei(exp(x)), x)' or 'D(Ei(x/(log(x) + x)), x)'. Some simpler ommisions are handled by pattern matcher, but this is a significant gap. Yes, the first one, exp(exp(x)), is done by patterns now. But if you fill the gap, this part can probably be removed from INTPM. Or maybe not, because of integrands like: (16) - D(Ei(exp(sqrt(x))), x) +-+ \|x %e %e (16) +-+ 2\|x Type: Expression(Integer) (17) - integrate(%, x) +-+ \|x (17) Ei(%e) Type: Union(Expression(Integer),...) Well, it would be easy to do in Ei integrator sligtly better job that pattern matcher is now doing. However, pattern matcher currently can handle only a single term, and may be fooled by simple transformations. For example, now (15) - integrate((2*exp(x) + 1)*exp(exp(x))/(exp(x) + 1), x) xx Ei(%e + 1) + %e Ei(%e ) (15) %e with the first Ei handled by new routine and second by pattern matcher. But pattern matcher would fail even on first term alone. Similarely x %e x x %e+ (%e + 1)Ei(%e ) (16) x %e + 1 with first term handled by Ei routine and second by pattern matcher. But (17) - integrate((x*exp(x)+2)*exp(exp(x)), x) x %A ++%A %e (17) | (%A %e + 2)%ed%A ++ Because this time Ei routine left elementary part intact and pattern matcher can not handle it. Actually, the method used in transcendental case should also work in algebraic case (the method is somewhat different than one used by Cherry). I did not work out all details, but is seems that the hardest part is elementary (that is implementing currently unimplemented part of Bronstein-Risch algorithm). In fact, it seems that method used for Ei will lead to simpler algorithm for elementary functions than the method proposed (but only partially implemented) by Bronstein. BTW: This is first part. There is other part which is going to handle erf, gamma incomplete and missing case above. However the second part requires some work to finish (it is in quite rough state now). At least the work has started. So thanks again. With erf, we probably get Fresnel and related Function too? Yes. More precisely: (23) - integrate((2*x+1)*sin(x^4+2*x^3+x^2) + exp(x), x) 2 +-+ 2 +---+ (x + x)\|2 +---+ 2x + 2x +-+ x \|%pi fresnelS() + \|%pi fresnelS(--) + 2\|2 %e +---+ +-+ +---+ \|%pi \|2 \|%pi (23) +-+ 2\|2 Type: Union(Expression(Integer),...) (2*x+1)*sin(x^4+2*x^3+x^2) alone is expressed in terms of tangents and does not go to Ei/erf/gamma handler. Derivative of fresnelS(x^2+x) currently has trouble during final processing: ker2trigs routine is unable to simplify roots of complex numbers and gives up. Complex version gives: (24) - complexIntegrate(D(fresnelS(x^2+x), x), x) +-+ +---+2 |+---+ +---+ +-+ | +---+ +---+(x + x)\|%pi\|- 1 \|- 1 \|2 \|- %pi\|- 1 \|%pi erf() +-+ \|2 + +---+ +-+ 2 | +---+ +---+ +-+ +---+ |+---+ (x + x)\|- %pi\|- 1 - \|- 1 \|2 \|%pi \|%pi\|- 1 erf(--) +-+ \|2 / +---+ +-+ | +---+ |+---+ 4\|- %pi\|- 1 \|%pi\|- 1 Both examples using code from my developement version. -- Waldek Hebisch hebi...@math.uni.wroc.pl -- 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+unsubscr...@googlegroups.com. To post to this group, send email to
Re: [fricas-devel] Integration in Terms of Logarithmic Integrals
someone wrote: I tried Fricas on the examples from the paper: INTEGRATION IN FINITE TERMS WITH SPECIAL FUNCTIONS: THE LOGARITHMIC INTEGRAL which was written by CHERRY in 1986. FYI: I am now working on integration in terms of Ei. Currently the procedure is still fairly incomplete, but can do all Cherry examples except for the following: -- Page 18 -- Example 5.4 i := ((2*x^3-x^2-6*x)/(x^2+3*x+2) + (2*x-3)/(log(x)+1)) * exp(x*log(x)+x) I := integrate(i, x) Ic := -3/exp(1)*li(exp(x*log(x)+x+log(x)+1)) + 2/exp(2)*li(exp(x*log(x)+x+2*log(x)+2)) -- Waldek Hebisch hebi...@math.uni.wroc.pl -- 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+unsubscr...@googlegroups.com. To post to this group, send email to fricas-devel@googlegroups.com. Visit this group at http://groups.google.com/group/fricas-devel?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: [fricas-devel] Integration in Terms of Logarithmic Integrals
someone wrote: I tried Fricas on the examples from the paper: INTEGRATION IN FINITE TERMS WITH SPECIAL FUNCTIONS: THE LOGARITHMIC INTEGRAL which was written by CHERRY in 1986. I just wanted to share my findings in case this is useful. Thanks for examples -- the result are as expected: li cases seem to work quite well, Ei cases are mostly unhandled. The Ei cases will be useful when implementing Ei branch... -- Waldek Hebisch hebi...@math.uni.wroc.pl -- You received this message because you are subscribed to the Google Groups FriCAS - computer algebra system group. To post to this group, send email to fricas-devel@googlegroups.com. To unsubscribe from this group, send email to fricas-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en.
[fricas-devel] Integration in Terms of Logarithmic Integrals
I tried Fricas on the examples from the paper: INTEGRATION IN FINITE TERMS WITH SPECIAL FUNCTIONS: THE LOGARITHMIC INTEGRAL which was written by CHERRY in 1986. I just wanted to share my findings in case this is useful. INPUT --- -- Examples taken from: -- INTEGRATION IN FINITE TERMS WITH SPECIAL FUNCTIONS: THE LOGARITHMIC INTEGRAL -- written by G. W. CHERRY -- published in SIAM J. COMPUT. Vol. 15, No. 1, February 1986 -- Page 1 -- Example 1.1 i := x/log(x)^2 I := integrate(i, x) Ic := 2*li(x^2) - x^2/log(x) D(Ic, x) -- Page 16 -- Example 5.1 i := x^3 / log(x^2-1) I := integrate(i, x) Ic := li(x^4-2*x^2+1)/2 + li(x^2-1)/2 D(Ic, x) -- Example 5.2 i := x^2 / log(x^2-1) I := integrate(i, x) -- No closed form -- Page 17 -- Example 5.3 i := (2*x+3)/(3*log(x)+2*x) * exp(log(x)/2+x) + 1/(x+1)*(exp(log(x)/2+x))^2 I := integrate(i, x) -- Example 5.3a i := (2*x+3)/(3*log(x)+2*x) * exp(log(x)/2+x) I := integrate(i, x) Ic := li(x*exp(log(x)/2+x)) D(Ic, x) -- Example 5.3b i := 1/(x+1)*(exp(log(x)/2+x))^2 I := integrate(i, x) i := x/(x+1)*exp(2*x) I := integrate(i, x) Ic := exp(2*x)/2 - exp(-2)*li(exp(2*x+2)) D(Ic, x) -- Page 18 -- Example 5.4 i := ((2*x^3-x^2-6*x)/(x^2+3*x+2) + (2*x-3)/(log(x)+1)) * exp(x*log(x)+x) I := integrate(i, x) Ic := -3/exp(1)*li(exp(x*log(x)+x+log(x)+1)) + 2/exp(2)*li(exp(x*log(x)+x+2*log(x)+2)) D(Ic, x) -- Page 19 -- Example 6 i := cos(x)^2 / x^3 I := integrate(i, x) Ic := -Ci(2*x) + sin(2*x)/(2*x) - cos(2*x)/(4*x^2) - 1/(4*x^2) D(Ic, x) -- Appendix -- Example d1 (same as 1.1) i := x/log(x)^2 I := integrate(i, x) -- Example d2 i := 1/(log(x)+3) I := integrate(i, x) Ic := exp(-3)*li(exp(3)*x) D(Ic, x) -- Example d3 i := x^2 / log(x+1) I := integrate(i, x) Ic := li(x^3+3*x^2+3*x+1) - 2*li(x^2+2*x+1) + li(x+1) D(Ic, x) -- Example d4 i := (log(x)^2+3)/(log(x)^2+3*log(x)+2) I := integrate(i, x) Ic := -7*exp(-2)*li(exp(2)*x)+4*exp(-1)*li(exp(1)*x)+x D(Ic, x) -- Example d5, d6, d7 I := li(x*exp(x)/log(x)) i := D(I, x) I := integrate(i, x) -- Example d8 i := exp(x)/(x+1)^2 I := integrate(i, x) Ic := exp(-1)*Ei(x+1) - exp(x)/(x+1) D(Ic, x) -- Example d9 i := sin(x)/x I := integrate(i, x) -- Example d10 (same as 6) i := cos(x)^2/x^3 I := integrate(i, x) -- Example d11 i := (x^2+3)*exp(x)/(x^2+3*x+2) I := integrate(i, x) Ic := -7*exp(-2)*Ei(x+2) + 4*exp(-1)*Ei(x+1) + exp(x) D(Ic, x) -- Example d12 i := (x^2+1)*exp(x)/(x^2+x+1) I := integrate(i, x) --- OUTPUT --- (1) - )read li.input -- Examples taken from: -- INTEGRATION IN FINITE TERMS WITH SPECIAL FUNCTIONS: THE LOGARITHMIC INTEGRAL -- written by G. W. CHERRY -- published in SIAM J. COMPUT. Vol. 15, No. 1, February 1986 -- Page 1 -- Example 1.1 i := x/log(x)^2 x (1) --- 2 log(x) Type: Expression(Integer) I := integrate(i, x) 2 2 2li(x )log(x) - x (2) -- log(x) Type: Union(Expression(Integer),...) Ic := 2*li(x^2) - x^2/log(x) 2 2 2li(x )log(x) - x (3) -- log(x) Type: Expression(Integer) D(Ic, x) 2 2 (- 2x log(x) + x)log(x ) + 4x log(x) (4) - 2 2 log(x) log(x ) Type: Expression(Integer) -- Page 16 -- Example 5.1 i := x^3 / log(x^2-1) 3 x (5) --- 2 log(x - 1) Type: Expression(Integer) I := integrate(i, x) 4 22 li(x - 2x + 1) + li(x - 1) (6) - 2 Type: Union(Expression(Integer),...) Ic := li(x^4-2*x^2+1)/2 + li(x^2-1)/2 4 22 li(x - 2x + 1) + li(x - 1) (7) - 2 Type: Expression(Integer) D(Ic, x) 4 2 3 2 x log(x - 2x + 1) + (2x - 2x)log(x - 1) (8) --- 2 4 2 log(x - 1)log(x - 2x + 1) Type: Expression(Integer) -- Example 5.2 i := x^2 / log(x^2-1) 2 x (9) --- 2 log(x - 1) Type: Expression(Integer) I := integrate(i, x)
Re: [fricas-devel] Integration by rules
someone wrote: Predicates -- In the examples above we see that the results are sometimes only valid under certain conditions. For example here: r := { x^n, x^(n+1)/(n+1) } we have to assure that n is not -1. We need a general way to incorporate such conditions on parameters into the integration rule. Hence we extend the definition to: rule := { pattern, result, predicates } The third part called 'predicates' is an expression that can be evaluated to a boolean value after substitution of placeholder values. It is in general build up by boolean and, or, not operations from simpler predicates. predicates := boolean combinations of one or more single predicate predicate := function: parameters - Boolean value A simple predicate for example is: p := n ~= -1 p := not( n = -1 ) or: p := m n/3 An example of a composite predicate would be: p1 := integer? n p2 := even? m p3 := n 2 p4 := m = n/2 p := p1 and p2 or p3 and p4 written out we find: p := n integer and m even or n2 and m=n/2 There can be couplings between all the input parameters describing complex relations. Note that we can not express p1 and p2 this way in Axiom right now. Hmm, the 'suchThat' construct in 'RewriteRule' allows you to attach to a rule arbitrary function as a predicate. So, you should be able to express _any_ predicate you want. AFAICS the only drawback of function as a predicate is that once you create a predicate function it is opaque and can not be transformed/optimized. -- Waldek Hebisch hebi...@math.uni.wroc.pl -- You received this message because you are subscribed to the Google Groups FriCAS - computer algebra system group. To post to this group, send email to fricas-devel@googlegroups.com. To unsubscribe from this group, send email to fricas-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en.
Re: [fricas-devel] Integration by rules
someone wrote: Today I tried writing my own little integrator. I put the code here: http://github.com/raoulb/fricas_code This includes some updates and experiments. I tried to improve the coarse structure a bit. I am not sure why you want your rule and ruleset domains. What is wrong with FriCAS 'RewriteRule' and 'Ruleset' domains? How good or bad is the matcher in Fricas? I did not looks at details of matchers in other systems. After quick look at Mathematica guide I think that Mathematica patterns are more general (they allow alternatives in the pattern). However, for matching expressions FriCAS matcher should be reasonably good -- I do not see how to take advantage of Mathematica features when matching expressions (OTOH Mathematica features are quite useful if you want to use pattern matching on general data). After quick look at Maple help it seems that capabilities of Maple and FriCAS pattern matchers are quite similar. So you probably need special domain for unexpanded expressions. There is the Factored domain for polynomials. I imagine this new domain to be something similar, right? It depends. I think that historically first representation of expressions was as trees, with operator as the root and arguments as childern. Rather unlike 'Factored'. OTOH Derive used representation as sums of rational (possibly negative) powers of products, each term beeing a kernel (variable or function applied to arguments) or recursively an expression. Using existing FriCAS machinery it is quite easy to create one, just create a domain like Integer, but without most its properties: -cut here-- )abbrev domain IBT IntegerAsComparable IntegerAsComparable : Join(BasicType, Comparable, ConvertibleTo Pattern Integer, PatternMatchable(Integer)) with 0 : () - % 1 : () - % _- : % - % coerce : Integer - % coerce : % - Integer == Integer add coerce(n : Integer) : % == n pretend % coerce(x : %) : Integer == x pretend Integer cut here and then use 'Expression(IntegerAsComparable)'. How do I have to use this? (108) - cos((x+1$IBT)^2) 2 (108) cos(x + 2x + 1) Type: Expression(Integer) Probably I miss the obvious. Not so obvious: (1) - ET := Expression(IntegerAsComparable) (1) Expression(IntegerAsComparable) Type: Type (2) - cos := operator 'cos (2) cos Type: BasicOperator (3) - cos(1::ET) (3) cos(1) Type: Expression(IntegerAsComparable) (4) - plus := operator '+ (4) + Type: BasicOperator (5) - plus(x::ET, 1::ET) (5) +(x,1) Type: Expression(IntegerAsComparable) (6) - cos(plus(x::ET, 1::ET)) (6) cos(+(x,1)) Type: Expression(IntegerAsComparable) Note: we need to define '+' for ET in orfer to be able to use normal notation instead of 'plus'. Also, in more complicated situation we may be forced to define other functions. Unfortunately, pattern matcher directly can not work with such expressions, so some work is needed. Hmm. I have created an experimantal modification to pattern matcher that allows (at least simple cases of) pattern for such expressions. If you are interested I will post the code. Of course I'm interested. The question rather is if I can understand the code. Please post it. I'll have to dig into the PM code a little bit anyway. I have now put a tarball at: http://www.math.uni.wroc.pl/~hebisch/fricas/et.tar.gz In the tarball you will find 6 Spad files (3 modified ones and 3 new), and some examples. -- Waldek Hebisch hebi...@math.uni.wroc.pl -- You received this message because you are subscribed to the Google Groups FriCAS - computer algebra system group. To post to this group, send email to fricas-devel@googlegroups.com. To unsubscribe from this group, send email to fricas-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en.
Re: [fricas-devel] Integration by rules
Today I tried writing my own little integrator. I put the code here: http://github.com/raoulb/fricas_code This includes some updates and experiments. I tried to improve the coarse structure a bit. I'd like to do some further work on this topic as time permits. The long term goal is to improve the integration of various more or less special functions in Axiom/Fricas. Do you think it worth it? It is interesting project. ATM I can not predict how good the result will be. Ok. In this case I'll continue working on it. It seems not to be a total waste of time. I hope that I can learn SPAD and increase my understanding of the internals while working on this project. I think the biggest problem is that in Rubi testsuite functions are neatly factored to make their structure apparent. I am not sure how likely are such functions in real life. Hmm, I don't know too. But they tested with about 18'000 functions from well known tables used by many people. If people use the tables, they probably have to put their real life functions into a suitable form too. Maybe there is an additional factoring step necessary before the user can hand the function over to RUBI. Worse, FriCAS automatically expands expressions so if you work with Expression(Integer) FriCAS will destroy structure present in the input. That's bad. AFAICS after expansion most Rubi patterns will no longer match (at least using FriCAS pattern matcher, but I doubt that other matchers cope better with this problem). How good or bad is the matcher in Fricas? So you probably need special domain for unexpanded expressions. There is the Factored domain for polynomials. I imagine this new domain to be something similar, right? Using existing FriCAS machinery it is quite easy to create one, just create a domain like Integer, but without most its properties: -cut here-- )abbrev domain IBT IntegerAsComparable IntegerAsComparable : Join(BasicType, Comparable, ConvertibleTo Pattern Integer, PatternMatchable(Integer)) with 0 : () - % 1 : () - % _- : % - % coerce : Integer - % coerce : % - Integer == Integer add coerce(n : Integer) : % == n pretend % coerce(x : %) : Integer == x pretend Integer cut here and then use 'Expression(IntegerAsComparable)'. How do I have to use this? (108) - cos((x+1$IBT)^2) 2 (108) cos(x + 2x + 1) Type: Expression(Integer) Probably I miss the obvious. You think we can use this as a work-around to build on? I'm fine with it but I doubt I can see all the consequences now. I hope you don't mind if I upload this and similar snippets to my repository. Unfortunately, pattern matcher directly can not work with such expressions, so some work is needed. Hmm. I have created an experimantal modification to pattern matcher that allows (at least simple cases of) pattern for such expressions. If you are interested I will post the code. Of course I'm interested. The question rather is if I can understand the code. Please post it. I'll have to dig into the PM code a little bit anyway. One attraction of rules is that they are much shorther than equvalent procedural code performing the same transformation. OTOH one is frequently forced to essentially duplicate rules to handle minor syntactic variations -- with code is easier to share common parts. So I do not know how much shorter large collection of rules really is... This is probably an open question. Duplication of rules could to some extent be reduced by piecewise expressions for the results, f.e.: x^n - [ x^(n+1)/(n+1) | n != -1 [ log(x) | otherwise could fit into one rule. The condition on n is now built into the result and not into the rule. Let me add that I looked at Rubi, and decided that currently I will get more effect from my work extending Rich integrator. Sure. Whenever there is a strict algorithm Axiom/Fricas should implement and use it. But how far can one get? If I remember correctly, there is a result showing that there can not be an algorithm for some cases. And what about the rather large number of special functions? How much work does it take? I see the value of pattern matching and table lookup to fix rough edges, branches of algorithmd lacking an implementation and so on. For me, algorithms vs. rules is not an either-or but rather a combined strategy. (This is already the case in Axiom as far as I see.) You may get some idea how patterns compare to algorithms looking at 'intden.spad.pamphlet'. Code handling similar functions in Rubi probably has 50-70 lines, so is much shorter. However, I think that FriCAS can handle much more functions of this kind -- increasing Rubi coverage can easily increase size of ruleset to size of FriCAS code. Maybe. But still rules /can/ be more
Re: [fricas-devel] Integration by rules
someone wrote: Today I tried writing my own little integrator. I started this project to understand better the whole pattern matching stuff. You can find the first code as well as some examples attached to this posting. It is nothing fancy, but I see some potential ... I think that the program given in [1] shows how powerful this approach can be. Maybe we should port (some parts) of RUBI to the Axiom world. [1]: http://www.apmaths.uwo.ca/~arich/ At least where there is no full algorithm like Risch, this kind of optimized table lookup can give good results. Additionally it's much easier to implement and extend than, for example, code based on the Meijer-G approach. I'd like to do some further work on this topic as time permits. The long term goal is to improve the integration of various more or less special functions in Axiom/Fricas. Do you think it worth it? It is interesting project. ATM I can not predict how good the result will be. I think the biggest problem is that in Rubi testsuite functions are neatly factored to make their structure apparent. I am not sure how likely are such functions in real life. Worse, FriCAS automatically expands expressions so if you work with Expression(Integer) FriCAS will destroy structure present in the input. AFAICS after expansion most Rubi patterns will no longer match (at least using FriCAS pattern matcher, but I doubt that other matchers cope better with this problem). So you probably need special domain for unexpanded expressions. Using existing FriCAS machinery it is quite easy to create one, just create a domain like Integer, but without most its properties: -cut here-- )abbrev domain IBT IntegerAsComparable IntegerAsComparable : Join(BasicType, Comparable, ConvertibleTo Pattern Integer, PatternMatchable(Integer)) with 0 : () - % 1 : () - % _- : % - % coerce : Integer - % coerce : % - Integer == Integer add coerce(n : Integer) : % == n pretend % coerce(x : %) : Integer == x pretend Integer cut here and then use 'Expression(IntegerAsComparable)'. Unfortunately, pattern matcher directly can not work with such expressions, so some work is needed. I have created an experimantal modification to pattern matcher that allows (at least simple cases of) pattern for such expressions. If you are interested I will post the code. One attraction of rules is that they are much shorther than equvalent procedural code performing the same transformation. OTOH one is frequently forced to essentially duplicate rules to handle minor syntactic variations -- with code is easier to share common parts. So I do not know how much shorter large collection of rules really is... Let me add that I looked at Rubi, and decided that currently I will get more effect from my work extending Rich integrator. You may get some idea how patterns compare to algorithms looking at 'intden.spad.pamphlet'. Code handling similar functions in Rubi probably has 50-70 lines, so is much shorter. However, I think that FriCAS can handle much more functions of this kind -- increasing Rubi coverage can easily increase size of ruleset to size of FriCAS code. And FriCAS handles some cases which IMHO are not feasible for pattern matchers. -- Waldek Hebisch hebi...@math.uni.wroc.pl -- You received this message because you are subscribed to the Google Groups FriCAS - computer algebra system group. To post to this group, send email to fricas-devel@googlegroups.com. To unsubscribe from this group, send email to fricas-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en.
[fricas-devel] Integration by rules
Today I tried writing my own little integrator. I started this project to understand better the whole pattern matching stuff. You can find the first code as well as some examples attached to this posting. It is nothing fancy, but I see some potential ... I think that the program given in [1] shows how powerful this approach can be. Maybe we should port (some parts) of RUBI to the Axiom world. [1]: http://www.apmaths.uwo.ca/~arich/ At least where there is no full algorithm like Risch, this kind of optimized table lookup can give good results. Additionally it's much easier to implement and extend than, for example, code based on the Meijer-G approach. I'd like to do some further work on this topic as time permits. The long term goal is to improve the integration of various more or less special functions in Axiom/Fricas. Do you think it worth it? -- You received this message because you are subscribed to the Google Groups FriCAS - computer algebra system group. To post to this group, send email to fricas-devel@googlegroups.com. To unsubscribe from this group, send email to fricas-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en. rubi.input Description: Binary data rubi.spad Description: Binary data
Re: [fricas-devel] Integration in terms of special functions.
Hi Waldek, I looked a bit though your code, but I'm unable to check anything in a reasonable amount of time. Without your email, I wouldn't have any clue what the code is supposed to do. Although I appreciate your work very much and now if it can beat the big M's even better, but without good documentation, your code is only half as valuable as it could be. At least some links to the literature should be written into comments. I'm still a fan of literate programming. ;-) Ralf -- You received this message because you are subscribed to the Google Groups FriCAS - computer algebra system group. To post to this group, send email to fricas-devel@googlegroups.com. To unsubscribe from this group, send email to fricas-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en.
[fricas-devel] Integration in terms of special functions.
I have just commited new routines which generate logarithmic integrals and polylogs when function is not integrable in terms of elementary functions. Current procedure is incomplete. More precisely, I have implemented part of decision procedure for integration in terms of logarithmic integrals, skipping one (big) branch and a few problematic subcases in implemented branch. AFAIK for polylog no complete algorithm is known, but some case can be handled in similar way as logarithmic integrals. While incomplete, the new procedure seem to be more powerful compared to what Maxima, Maple or Mathematica have, for example none of the M-s can handle: integrate(((-4*x-8)*log(x)+(-2*x^2-4*x))/(3*x*exp(2*log(x)+x)^2-1*x), x) which is handled by the new procedure. You can see more examples in the 'integ' test file. One technical remark: there are two typical ways in which logarithmic integrals or polylogs appear in integration results. One is due to terms in denominators, like: (1) - integrate(1/(log(x) + 2), x) 2 li(x %e ) (1) - 2 %e Type: Union(Expression(Integer),...) (2) - integrate(x/(exp(x) + 2), x) x x %e + 2 %e + 2 2 - 2x log(---) - 2dilog(---) + x 2 2 (2) 4 Type: Union(Expression(Integer),...) Another one is due to polynomial type terms, like 'exp(x)/x' (giving 'li(exp(x))') or 'log(x)^3/(1 - x)' (leading to polylog). Current procedure only handles denominator case (or rather large part of it), and makes no attempt to handle polynomial case. -- Waldek Hebisch hebi...@math.uni.wroc.pl -- You received this message because you are subscribed to the Google Groups FriCAS - computer algebra system group. To post to this group, send email to fricas-devel@googlegroups.com. To unsubscribe from this group, send email to fricas-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en.