Re: [fricas-devel] Re: My first package (PSLQ algorithm)

2015-10-26 Thread Thomas Baruchel
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.


[fricas-devel] automatic factorization in Factored

2015-10-26 Thread Ralf Hemmecke
Hi Waldek,

Did you change anything in Factored?

As far as I remember (and a very old FriCAS form 2011 that I still have
around confirms this), there was no automatic factorization in (3). I
thought this was deliberate, because factorization costs time and (2)
and (3) might only be intermediate operations.

Honestly, I'm not decided whether this is good or bad.

Ralf

(1) -> p: Factored(Polynomial Integer) := (x-1)^2*(x+1)

   2
   (1)  (x - 1) (x + 1)
  Type:
Factored(Polynomial(Integer))
(2) -> q :=p+1

 32
   (2)  x  - x  - x + 2
  Type:
Factored(Polynomial(Integer))
(3) -> q-1

   2
   (3)  (x - 1) (x + 1)
  Type:
Factored(Polynomial(Integer))

-- 
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)

2015-10-26 Thread Waldek Hebisch
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] Linking (lisp) libraries to FriCAS?

2015-10-26 Thread Kurt Pagani

That's very "ok" :)
Unfortunately I have little time to contribute to this topic, but you
know much more about these things anyway. I also had a glance over the
FFI of OpenAxiom which Alfredo Portes posted recently here. Looks quite
interesting but here too, I have to avoid frittering ;)

I'll keep an eye on the repo :)

Many thanks
Kurt




Am 26.10.2015 um 17:34 schrieb Bill Page:
> I just dropped this "proof-of-concept" level code into a repository at:
> 
>   https://github.com/billpage/gsla
> 
> Title: GNU Scientific Library for Axiom (and FriCAS and OpenAxiom)
> 
> I hope there are no objections or let me know.
> 
> Please check it out and test it. Feel free to fork it, make changes, etc.
> 
> For now I have included Kurt, Alasdair and myself as "authors" though
> really so far only Kurt has written any significant code.
> 
> OK?
> 
> Bill.
> 

-- 
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] Linking (lisp) libraries to FriCAS?

2015-10-26 Thread Kurt Pagani

Hello Bill,

that's great. There is a lot in Lisp which is a "black spot" to me,
especially this "multiple value" stuff. Since this also seems to be
solved I think this could be a starting point.

Thank you and
best regards
Kurt


Am 26.10.2015 um 05:14 schrieb Bill Page:
> Alasdair and Kurt,
> 
> Here is one way to deal with multiple return values:
> 
> (1) -> )co gsl
>Compiling FriCAS source code from file /home/wspage/gsl.spad using
>   old system compiler.
> 
>gsl is now explicitly exposed in frame frame1
>gsl will be automatically loaded when needed from
>   /home/wspage/GSL.NRLIB/GSL
> 
> (1) -> )r gsl-test
> DF ==> DoubleFloat
> 
>Type: Void
> f:=(x:DF):DF+->exp(-x^2)
> 
> 
>(2)  theMap(*1;anonymousFunction;0;frame1;internal)
>Type: (DoubleFloat -> DoubleFloat)
> gslIntegrationQng(f,0.0::DF,1.0::DF)
> 
> 
>(3)  [result= 0.7468241328124271,abserr= 8.291413475940725e-15,neval= 21]
>  Type: Record(result: DoubleFloat,abserr: DoubleFloat,neval: Integer)
> (4) ->
> 
> ---
> 
> In the revised files attached 'integration-qng-list' is a wrapper
> routine that just returns the multiple values as a list of values.
> Since lists are homogeneous in FriCAS we then have to sort out the
> actual types of the result for SPAD in gslIntegrationQng and in this
> example return it as a record.
> 
> ---
> 
> Yes, adding other routines should be easy. The hard part of passing
> FriCAS functions was done by Kurt (he just made it look easy! :)
> 
> I agree that arbitrary precision is indeed another issue and in my
> opinion, in general not so interesting.
> 
> More tomorrow when I get a chance. I am wondering now about how best
> to make GSL a permanent addition to FriCAS. Perhaps Waldek can advise.
> 
> Bill.
> 
> On 25 October 2015 at 23:10, Alasdair McAndrew  wrote:
>> Sweet!  Works beautifully (once I set my SBCL_HOME variable); one line will
>> do it:
>>
>> (2) -> gslIntegrationQng(x+->exp(-x^2),0.0,1.0)
>>
>>  And I suppose adding other routines is just a matter of more (include ...)
>> lines in gsl.input and corresponding lines in gsl.spad?
>>
>> With regard to arbitrary precision, that might be another issue.  However, I
>> was recommended that it may be better to "roll our own" in which case the
>> method of choice is probably tanh-sinh integration, which has all of the
>> advantages of Gauss Kronrod (nested rules for error analysis) and is far
>> easier to implement.  See
>> http://crd-legacy.lbl.gov/~dhbailey/dhbpapers/dhb-tanh-sinh.pdf for some
>> details.
>>
>> On Mon, Oct 26, 2015 at 1:54 PM, Bill Page 
>> wrote:
>>>
>>> You are FAST!  That's amazing. Works exactly as advertised.
>>>
>>> Re qng:
>>>
>>> "The function returns the final approximation, result, an estimate of
>>> the absolute error, abserr and the number of function evaluations
>>> used, neval."
>>>
>>>
>>> https://www.gnu.org/software/gsl/manual/html_node/QNG-non_002dadaptive-Gauss_002dKronrod-integration.html
>>>
>>> This is great.
>>>
>>> Bill.
>>>
> 

-- 
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] automatic factorization in Factored

2015-10-26 Thread Ralf Hemmecke
> Nothing changed in Factored, but now Polynomial(Integer) has
> UniqueFactorizationDomain.  Now coercion to Factored is
> performing factorization:
> 
> (1) -> (x^2 - 1)::Factored(?)
> 
>(1)  (x - 1)(x + 1)
>   Type: Factored(Polynomial(Integer))
> 
> This coercion is performed after subtraction.

Yes. I understand your example and don't have a problem with it.
Coercion is an operation and is allowed to do something.

Now, in my original posting I used p+1 and who knows, why type the
interpreter give to + and 1 and what magic coercions happen in between
even though the result finally is Factored Polynomial Integer.

But where is the coercion in the session below? Everything happens
inside F, so there shouldn't be need for a coercion, and, in fact, I
cannot see from the code of Factored, where there is a coercion or
anything that produces a factored form in (5).

Ralf

(1) -> F ==> Factored Polynomial Integer
   Type:
Void
(2) -> e: F := 1

   (2)  1
  Type:
Factored(Polynomial(Integer))
(3) -> p: F := (x-1)^2*(x+1)

   2
   (3)  (x - 1) (x + 1)
  Type:
Factored(Polynomial(Integer))
(4) -> q: F := p + e

 32
   (4)  x  - x  - x + 2
  Type:
Factored(Polynomial(Integer))
(5) -> r: F := q - e

   2
   (5)  (x - 1) (x + 1)
  Type:
Factored(Polynomial(Integer))

-- 
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] Linking (lisp) libraries to FriCAS?

2015-10-26 Thread Alasdair McAndrew
Now that Karl has provided a fantastic working template for an integration
routine from QUADPACK/GSL/GSLL it should be possible to extend those files
to incorporate some of the other routines.   For the next few days I'll not
have much time, but I'll aim to fiddle later in the week.  And I might even
learn a little Lisp in the process!

On Tue, Oct 27, 2015 at 6:32 AM, Kurt Pagani  wrote:

>
> That's very "ok" :)
> Unfortunately I have little time to contribute to this topic, but you
> know much more about these things anyway. I also had a glance over the
> FFI of OpenAxiom which Alfredo Portes posted recently here. Looks quite
> interesting but here too, I have to avoid frittering ;)
>
> I'll keep an eye on the repo :)
>
> Many thanks
> Kurt
>
>
>
>
> Am 26.10.2015 um 17:34 schrieb Bill Page:
> > I just dropped this "proof-of-concept" level code into a repository at:
> >
> >   https://github.com/billpage/gsla
> >
> > Title: GNU Scientific Library for Axiom (and FriCAS and OpenAxiom)
> >
> > I hope there are no objections or let me know.
> >
> > Please check it out and test it. Feel free to fork it, make changes, etc.
> >
> > For now I have included Kurt, Alasdair and myself as "authors" though
> > really so far only Kurt has written any significant code.
> >
> > OK?
> >
> > Bill.
> >
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "FriCAS - computer algebra system" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/fricas-devel/q18Av7P3jnM/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>



-- 
[image: http://www.facebook.com/alasdair.mcandrew]
 [image:
https://plus.google.com/+AlasdairMcAndrew/posts]
 [image:
https://www.linkedin.com/pub/alasdair-mcandrew/a/178/108]
 [image:
https://twitter.com/amca01]  [image:
http://numbersandshapes.net] 

-- 
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] automatic factorization in Factored

2015-10-26 Thread Waldek Hebisch
Ralf Hemmecke wrote:
> 
> > Nothing changed in Factored, but now Polynomial(Integer) has
> > UniqueFactorizationDomain.  Now coercion to Factored is
> > performing factorization:
> > 
> > (1) -> (x^2 - 1)::Factored(?)
> > 
> >(1)  (x - 1)(x + 1)
> >   Type: 
> > Factored(Polynomial(Integer))
> > 
> > This coercion is performed after subtraction.
> 
> Yes. I understand your example and don't have a problem with it.
> Coercion is an operation and is allowed to do something.
> 
> Now, in my original posting I used p+1 and who knows, why type the
> interpreter give to + and 1 and what magic coercions happen in between
> even though the result finally is Factored Polynomial Integer.
> 
> But where is the coercion in the session below? Everything happens
> inside F, so there shouldn't be need for a coercion, and, in fact, I
> cannot see from the code of Factored, where there is a coercion or
> anything that produces a factored form in (5).

Look at '+' in Factored, when base domain R is GCD domain as last
step it performs multiplication of expanded sum by gcd.
Expanded sum is in R, and we need multiplication of type (R, %) -> %,
If you look at this multiplication you will see that as first
step it performs coercion from R to %...

This is a bit tricky but

)trace Factored )math 

will tell you that '+' calls '*' and '*' calls 'coerce'.

-- 
  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] Linking (lisp) libraries to FriCAS?

2015-10-26 Thread Bill Page
Here is a little design issue concerning names.

Right now we have the example of 'gslIntegrationQng' and I have
started to fill in some miscellaneous functions such as

gslLookup: String -> Symbol
  ++ \spad{\gslLookup} finds GSLL function by GSL name and
  ++ displays some documentation.
gslIsNaN?: DF -> Boolean
  ++ \spad{\gslIsNaN?} returns true if x is not-a-number.
gslIsInf: DF -> SingleInteger
  ++ \spad{\gslIsInf} returns +1 if x is positive infinity,
  ++ -1 if x is negative infinity and 0 otherwise. On
  ++ some platforms 1 is returned for negative infinity.
gslFinite?: DF -> Boolean
  ++ \spad{\gslFinite?} returns true if x is a real number,
  ++ and false if it is infinite or not-a-number.
gslFcmp: (DF,DF,DF) -> SingleInteger
  ++ \spad{\gslFcmp} determines whether x and y are approximately
  ++ equal to a relative accuracy epsilon.
gslIntegrationQng :  (DF -> DF,DF,DF) -> Record(result:DF,
abserr:DF, neval:Integer)
  ++ \spad{\gslIntegrationQng}  applies the Gauss-Kronrod 10-point,
  ++ 21-point, 43-point and 87-point integration rules in succession

but before going further it occurs to me to wonder if we really should
continue to use the prefix 'gsl' in all these function names?  In
Axiom/FriCAS it is common to overload names and rely on package names
and types for disambiguation.  It seems unnecessarily redundant to
write:

gslIntegrationQng$gsl

Also, the names that appear at the GSLL (lisp) level omit the gsl
prefix for a similar reason - Common Lisp packaging.

So I propose that we drop the 'gsl' part of the name and lowercase the
first letter, as is the Axiom custom.

lookup: String -> Symbol
  ++ \spad{\lookup} finds GSLL function by GSL name and
  ++ displays some documentation.
isNaN?: DF -> Boolean
  ++ \spad{\isNaN?} returns true if x is not-a-number.
isInf: DF -> SingleInteger
  ++ \spad{\isInf} returns +1 if x is positive infinity,
  ++ -1 if x is negative infinity and 0 otherwise. On
  ++ some platforms 1 is returned for negative infinity.
finite?: DF -> Boolean
  ++ \spad{\finite?} returns true if x is a real number,
  ++ and false if it is infinite or not-a-number.
fcmp: (DF,DF,DF) -> SingleInteger
  ++ \spad{\fcmp} determines whether x and y are approximately
  ++ equal to a relative accuracy epsilon.
integrationQng :  (DF -> DF,DF,DF) -> Record(result:DF, abserr:DF,
neval:Integer)
  ++ \spad{\integrationQng}  applies the Gauss-Kronrod 10-point,
  ++ 21-point, 43-point and 87-point integration rules in succession

What do you think?

On 26 October 2015 at 20:44, Alasdair McAndrew  wrote:
>
> Now that Karl has provided a fantastic working template for an integration
> routine from QUADPACK/GSL/GSLL it should be possible to extend those
> files to incorporate some of the other routines.   For the next few days I'll
> not have much time, but I'll aim to fiddle later in the week.  And I might
> even learn a little Lisp in the process!
>

My plan is to chip away at adding new routines as time permits.  If
there is something in particular you would like to tackle, just let me
know.

Besides GSL are there some other libraries that might be interesting
and amenable to the QuickLisp approach?

>
>>
>> Am 26.10.2015 um 17:34 schrieb Bill Page:
>> > I just dropped this "proof-of-concept" level code into a repository at:
>> >
>> >   https://github.com/billpage/gsla
>> >
>> > Title: GNU Scientific Library for Axiom (and FriCAS and OpenAxiom)
>> >

-- 
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)

2015-10-26 Thread Thomas Baruchel
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] automatic factorization in Factored

2015-10-26 Thread Waldek Hebisch
Ralf Hemmecke wrote:
> 
> Hi Waldek,
> 
> Did you change anything in Factored?
> 
> As far as I remember (and a very old FriCAS form 2011 that I still have
> around confirms this), there was no automatic factorization in (3). I
> thought this was deliberate, because factorization costs time and (2)
> and (3) might only be intermediate operations.
> 
> Honestly, I'm not decided whether this is good or bad.
> 
> Ralf
> 
> (1) -> p: Factored(Polynomial Integer) := (x-1)^2*(x+1)
> 
>2
>(1)  (x - 1) (x + 1)
>   Type:
> Factored(Polynomial(Integer))
> (2) -> q :=p+1
> 
>  32
>(2)  x  - x  - x + 2
>   Type:
> Factored(Polynomial(Integer))
> (3) -> q-1
> 
>2
>(3)  (x - 1) (x + 1)
>   Type:
> Factored(Polynomial(Integer))
> 

Nothing changed in Factored, but now Polynomial(Integer) has
UniqueFactorizationDomain.  Now coercion to Factored is
performing factorization:

(1) -> (x^2 - 1)::Factored(?)

   (1)  (x - 1)(x + 1)
  Type: Factored(Polynomial(Integer))

This coercion is performed after subtraction.

-- 
  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] Linking (lisp) libraries to FriCAS?

2015-10-26 Thread Bill Page
I just dropped this "proof-of-concept" level code into a repository at:

  https://github.com/billpage/gsla

Title: GNU Scientific Library for Axiom (and FriCAS and OpenAxiom)

I hope there are no objections or let me know.

Please check it out and test it. Feel free to fork it, make changes, etc.

For now I have included Kurt, Alasdair and myself as "authors" though
really so far only Kurt has written any significant code.

OK?

Bill.

-- 
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.