axiom-mail
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Axiom-mail] [fricas-devel] Using a polynomial inside a function


From: Bill Page
Subject: Re: [Axiom-mail] [fricas-devel] Using a polynomial inside a function
Date: Mon, 16 Nov 2015 21:46:01 -0500

Alasdair,

Here is one solution:

(1) -> )r alas1.input

mult(xs:List _expression_ Integer):_expression_ Integer == reduce(*,[x-z for z in xs])
 
   Function declaration mult : List(_expression_(Integer)) -> _expression_(
      Integer) has been added to workspace.
                                                                   Type: Void

intm(xs,a,b) == integrate(mult(xs),x=a..b)
 
                                                                   Type: Void
(3) -> mult([x1,x2])

   Compiling function mult with type List(_expression_(Integer)) ->
      _expression_(Integer)

                             2
   (3)  (x1 - x)x2 - x x1 + x
                                                    Type: _expression_(Integer)
(4) -> intm([x1,x2,x3],1,2)

   Compiling function intm with type (List(OrderedVariableList([x1,x2,
      x3])),PositiveInteger,PositiveInteger) -> Union(f1:
      OrderedCompletion(_expression_(Integer)),f2: List(OrderedCompletion
      (_expression_(Integer))),fail: failed,pole: potentialPole)

        ((- 12x1 + 18)x2 + 18x1 - 28)x3 + (18x1 - 28)x2 - 28x1 + 45
   (4)  -----------------------------------------------------------
                                     12
                  Type: Union(f1: OrderedCompletion(_expression_(Integer)),...)

Bill Page.


On 16 November 2015 at 19:39, Alasdair McAndrew <address@hidden> wrote:
Here's a minimum (non)-working example: I have a function which returns a polynomial:

mult(xs)==
  return(reduce(*,[x-z for z in xs]))

and I have another function which needs such a polynomial:

intm(xs,a,b)==
  g:=(x:Float):Float+->mult(xs)
  return(numeric(integrate(g(x),x=a..b)))

which doesn't work.  I've tried replacing the second line with

  function(mult(xs),g,x)

which works on the command line, but not in a function.  Any ideas as to how I can get over this hump?

ever confused,
Alasdair

--
http://www.facebook.com/alasdair.mcandrew https://plus.google.com/+AlasdairMcAndrew/posts https://www.linkedin.com/pub/alasdair-mcandrew/a/178/108 https://twitter.com/amca01 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 address@hidden.
To post to this group, send email to address@hidden.
Visit this group at http://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]