Re: [fricas-devel] Re: My first package (PSLQ algorithm)
Added the 'algdep' function; I will have a look at the automatical control of precision and finish cleaning the code. Regards. Le lundi 26 octobre 2015 11:29:47 UTC+1, Waldek Hebisch a écrit : > > Thomas Baruchel wrote: > > > > I would be very happy to have this package included in Fricas; I began > to > > clean the code according to your comments. > > I also added a maximum number of iterations (in order to avoid infinite > > loops when requested precision is higher than current > > number of digits). > > A nice to have featue would be automatic control of precision, > so that computations use adequate number of digits (not too > much and not too little). > > > Would you like me to include in my package an "algdep" function for > > guessing a polynomial from a numerical root (if any)? > > Yes, it makes sense to add such function. > > > I encounter some problems while tring to convert some matrices to > > Matrix(Integer) type because I need to mix > > floats and integers in the computations, and I couldn't manage to coerce > a > > rounded float to an integer type! > > How can I round a float to an integer in a compiled spad code? > > Like > > retract(round(nf))@Integer > > FriCAS interpreter when given '::' will also try to use 'retract', > but in Spad code 'retract' have to be explicit. > > -- > 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 http://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
Re: [fricas-devel] Re: My first package (PSLQ algorithm)
Thomas Baruchel wrote: > > I would be very happy to have this package included in Fricas; I began to > clean the code according to your comments. > I also added a maximum number of iterations (in order to avoid infinite > loops when requested precision is higher than current > number of digits). A nice to have featue would be automatic control of precision, so that computations use adequate number of digits (not too much and not too little). > Would you like me to include in my package an "algdep" function for > guessing a polynomial from a numerical root (if any)? Yes, it makes sense to add such function. > I encounter some problems while tring to convert some matrices to > Matrix(Integer) type because I need to mix > floats and integers in the computations, and I couldn't manage to coerce a > rounded float to an integer type! > How can I round a float to an integer in a compiled spad code? Like retract(round(nf))@Integer FriCAS interpreter when given '::' will also try to use 'retract', but in Spad code 'retract' have to be explicit. -- 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 http://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
Re: [fricas-devel] Re: My first package (PSLQ algorithm)
Le dimanche 25 octobre 2015 04:51:06 UTC+1, Waldek Hebisch a écrit : > > Thomas Baruchel wrote: > > > > I think the package is ready now; > > > > https://github.com/baruchel/numerical-routines/tree/master/spad > > > > The PSLQ (which was once selected as one of the "Top Ten Algorithms of > the > > Century) (see: https://en.wikipedia.org/wiki/Integer_relation_algorithm > ) > > is an algorithm useful for detecting integer relations between numerical > > values. Thus it is a very useful algorithm for "experimental > mathematics". > > Some comments: > > - we do not have PSLQ, so will be happy to include your routine > - I have unfinished version of LLL routine which can be > I would be very happy to have this package included in Fricas; I began to clean the code according to your comments. I also added a maximum number of iterations (in order to avoid infinite loops when requested precision is higher than current number of digits). Would you like me to include in my package an "algdep" function for guessing a polynomial from a numerical root (if any)? I encounter some problems while tring to convert some matrices to Matrix(Integer) type because I need to mix floats and integers in the computations, and I couldn't manage to coerce a rounded float to an integer type! How can I round a float to an integer in a compiled spad code? Best regards, tb. -- 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] Re: My first package (PSLQ algorithm)
Thomas Baruchel wrote: > > I think the package is ready now; > > https://github.com/baruchel/numerical-routines/tree/master/spad > > The PSLQ (which was once selected as one of the "Top Ten Algorithms of the > Century) (see: https://en.wikipedia.org/wiki/Integer_relation_algorithm ) > is an algorithm useful for detecting integer relations between numerical > values. Thus it is a very useful algorithm for "experimental mathematics". Some comments: - we do not have PSLQ, so will be happy to include your routine - I have unfinished version of LLL routine which can be used for similar purpose, I will try to cross-check PSLQ and LLL - concerning style: - in Spad 0 and 1 give you floating point zero or one in context we floating point number is expected. Usually in FriCAS this is used instead of version with dot - IMO Vector and Matrix are more natural here than OneDimensionalArray and TwoDimensionalArray - for one dimensioninal arrray/vector indexing on can use both 'v.i' and 'v(i)'. I personally find the second form more readible (I prefer to use dot only for record fields). - instead of '(n-1) pretend PositiveInteger' please use '(n-1)::PositiveInteger' or 'qcoerce(n-1)@PositiveInteger' The first form perform runtime checking, so is slower but safe. The second one generates the same code as 'pretend' but still give some compile time checking (only check for positive value is skipped). - in FriCAS Float has unlimited exponent range and settable accuracy so 1.0E-308 looks very suspicious. - IIRC in PSLQ one of arrays is purely integer, it would be much better to make so in the code -- 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 http://groups.google.com/group/fricas-devel. For more options, visit https://groups.google.com/d/optout.
Re: [fricas-devel] Re: My first package (PSLQ algorithm)
On Fri, 23 Oct 2015, Thomas Baruchel wrote: (4) -> pslq(v, 1.0E-36) (4) [- 2.0,8.0,3.0,- 2.0] Type: OneDimensionalArray(Float) Why does it return a OneDimensionalArray(Float)? I thought it should return a OneDimensionalArray(Integer). Andrey -- 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] Re: My first package (PSLQ algorithm)
> I think the package is ready now; Small comment. (I didn't yet go through it in full detail.) There is a difference in SPAD between ++ and -- comments. In fact, -- introduces ordinary language comments which are ignored by the compiler. The ++ comments are more like docstrings in python or java. They can only appear at certain places (before the package/domain/category starts) or after function signatures. (See my previous mail.) So the first two usages of your ++ docstrings are fine while any ++ comment that comes after the "add" should be changed into a --. The ++ docstrings are part of the compiled source code. The -- comments are not in compiled code. Hope that helps. Ralf PS: Maybe I should have pointed you to http://axiom-wiki.newsynthesis.org/ProgrammingSPAD in the first place. PPS: For learning SPAD, I usually refer to the Aldor User Guide. Aldor is not exactly SPAD, but, in fact, it was invented as the (future) Axiom Library compiler. (But history is a bit involved here.) Nevertheless, the Aldor User Guide is a good source to understand important notions of the language. Nearly all of them are identical to SPAD. See http://fricas.github.io/ for more documentation, in particular the link to "Language Diferences". PPPS: Well, I should not forget to say: Welcome to 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 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] Re: My first package (PSLQ algorithm)
Please subscribe to the email list: 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. On 23 October 2015 at 11:59, Thomas Baruchel wrote: > I think the package is ready now; > > https://github.com/baruchel/numerical-routines/tree/master/spad > > The PSLQ (which was once selected as one of the "Top Ten Algorithms of the > Century) (see: https://en.wikipedia.org/wiki/Integer_relation_algorithm ) is > an algorithm useful for detecting integer relations between numerical > values. Thus it is a very useful algorithm for "experimental mathematics". > > See some example below: > * computing a numerical value with three other constants and then find > back the coefficients; > * finding the coefficients for the relation [gamma(11/2),1,sqrt(Pi)] > * detecting the algebreaic equation for which the golden number is a > solution (ie. detecting that phi actually is an algebraic number) > > The session below shows these three examples: > > (1) -> )lib PSLQ >Pslq is now explicitly exposed in frame initial >Pslq will be automatically loaded when needed from > /home/pi/docs/maths/numerical-routines/spad/PSLQ.NRLIB/PSLQ > (1) -> digits(64) > >(1) 20 > Type: > PositiveInteger > (2) -> z := numeric( 4 + 3/2*%pi - %e) > >(2) >5.9941071519_2564462233_3677603566_5918285385_0700536269_9156495449_261 > Type: > Float > (3) -> v := oneDimensionalArray([z, 1.0, %pi, %e]) > >(3) >[5.9941071519_2564462233_3677603566_5918285385_0700536269_9156495449_261, > 1.0, > 3.1415926535_8979323846_2643383279_5028841971_6939937510_5820974944_592, > 2.7182818284_5904523536_0287471352_6624977572_4709369995_9574966967_628] > Type: > OneDimensionalArray(Expression(Float)) > (4) -> pslq(v, 1.0E-36) > >(4) [- 2.0,8.0,3.0,- 2.0] > Type: > OneDimensionalArray(Float) > (5) -> g := Gamma(11/2)$DoubleFloatSpecialFunctions > >(5) 52.34284553526 > Type: > DoubleFloat > (6) -> w := oneDimensionalArray([g :: Float, 1.0, sqrt(%pi)]) > >(6) >[52.342845_5352603259_5982542261_4812850952_1484375, 1.0, > 1.7724538509_0551602729_8167483341_1451827975_4945612238_7128213807_79] > Type: > OneDimensionalArray(Expression(Float)) > (7) -> pslq(w, 1.0E-10) > >(7) [- 32.0,0.0,945.0] > Type: > OneDimensionalArray(Float) > (8) -> phi := numeric( (1+sqrt(5))/2 ) > >(8) >1.6180339887_4989484820_4586834365_6381177203_0917980576_2862135448_623 > Type: > Float > (9) -> x := oneDimensionalArray([1,phi,phi^2]) > >(9) >[1.0, > 1.6180339887_4989484820_4586834365_6381177203_0917980576_2862135448_623, > 2.6180339887_4989484820_4586834365_6381177203_0917980576_2862135448_623] > Type: > OneDimensionalArray(Float) > (10) -> pslq(x, 1.0E-24) > >(10) [1.0,1.0,- 1.0] > Type: > OneDimensionalArray(Float) > (11) -> > > > -- > 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. -- 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] Re: My first package (PSLQ algorithm)
I think the package is ready now; https://github.com/baruchel/numerical-routines/tree/master/spad The PSLQ (which was once selected as one of the "Top Ten Algorithms of the Century) (see: https://en.wikipedia.org/wiki/Integer_relation_algorithm ) is an algorithm useful for detecting integer relations between numerical values. Thus it is a very useful algorithm for "experimental mathematics". See some example below: * computing a numerical value with three other constants and then find back the coefficients; * finding the coefficients for the relation [gamma(11/2),1,sqrt(Pi)] * detecting the algebreaic equation for which the golden number is a solution (ie. detecting that phi actually is an algebraic number) The session below shows these three examples: (1) -> )lib PSLQ Pslq is now explicitly exposed in frame initial Pslq will be automatically loaded when needed from /home/pi/docs/maths/numerical-routines/spad/PSLQ.NRLIB/PSLQ (1) -> digits(64) (1) 20 Type: PositiveInteger (2) -> z := numeric( 4 + 3/2*%pi - %e) (2) 5.9941071519_2564462233_3677603566_5918285385_0700536269_9156495449_261 Type: Float (3) -> v := oneDimensionalArray([z, 1.0, %pi, %e]) (3) [5.9941071519_2564462233_3677603566_5918285385_0700536269_9156495449_261, 1.0, 3.1415926535_8979323846_2643383279_5028841971_6939937510_5820974944_592, 2.7182818284_5904523536_0287471352_6624977572_4709369995_9574966967_628] Type: OneDimensionalArray(Expression(Float)) (4) -> pslq(v, 1.0E-36) (4) [- 2.0,8.0,3.0,- 2.0] Type: OneDimensionalArray(Float) (5) -> g := Gamma(11/2)$DoubleFloatSpecialFunctions (5) 52.34284553526 Type: DoubleFloat (6) -> w := oneDimensionalArray([g :: Float, 1.0, sqrt(%pi)]) (6) [52.342845_5352603259_5982542261_4812850952_1484375, 1.0, 1.7724538509_0551602729_8167483341_1451827975_4945612238_7128213807_79] Type: OneDimensionalArray(Expression(Float)) (7) -> pslq(w, 1.0E-10) (7) [- 32.0,0.0,945.0] Type: OneDimensionalArray(Float) (8) -> phi := numeric( (1+sqrt(5))/2 ) (8) 1.6180339887_4989484820_4586834365_6381177203_0917980576_2862135448_623 Type: Float (9) -> x := oneDimensionalArray([1,phi,phi^2]) (9) [1.0, 1.6180339887_4989484820_4586834365_6381177203_0917980576_2862135448_623, 2.6180339887_4989484820_4586834365_6381177203_0917980576_2862135448_623] Type: OneDimensionalArray(Float) (10) -> pslq(x, 1.0E-24) (10) [1.0,1.0,- 1.0] Type: OneDimensionalArray(Float) (11) -> -- 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.