Re: [fricas-devel] Using a polynomial inside a function
Bill Page <[email protected]> Mon, 16 Nov 2015 21:46:01 -0500
| Newsgroups | gmane.comp.mathematics.axiom.user |
|---|---|
| Message-ID | <CAC6x94Q0fFK2KwhzAEV3xKRx3DmJs_HYpPphPjdMq5jQz9a3xA@mail.gmail.com> |
--===============6620227352051146419==
Content-Type: multipart/alternative; boundary=001a114e3e66b49d850524b386fc
--001a114e3e66b49d850524b386fc
Content-Type: text/plain; charset=UTF-8
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 <[email protected]> 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
>
> --
> [image: http://www.facebook.com/alasdair.mcandrew]
> <http://www.facebook.com/alasdair.mcandrew> [image:
> https://plus.google.com/+AlasdairMcAndrew/posts]
> <https://plus.google.com/+AlasdairMcAndrew/posts> [image:
> https://www.linkedin.com/pub/alasdair-mcandrew/a/178/108]
> <https://www.linkedin.com/pub/alasdair-mcandrew/a/178/108> [image:
> https://twitter.com/amca01] <https://twitter.com/amca01> [image:
> http://numbersandshapes.net] <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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/fricas-devel.
> For more options, visit https://groups.google.com/d/optout.
>
--001a114e3e66b49d850524b386fc
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Alasdair,<br><br>Here is one solution:<br><br>(1) -&g=
t; )r alas1.input<br><br>mult(xs:List Expression Integer):Expression Intege=
r =3D=3D reduce(*,[x-z for z in xs])<br>=C2=A0<br>=C2=A0=C2=A0 Function dec=
laration mult : List(Expression(Integer)) -> Expression(<br>=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0 Integer) has been added to workspace.<br>=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0 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=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
Type: Expression(Integer)<br>(4) -> intm([x1,x2,x3],1,2)<br><br>=C2=A0=
=C2=A0 Compiling function intm with type (List(OrderedVariableList([x1,x2,<=
br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 x3])),PositiveInteger,PositiveInteger) -&=
gt; Union(f1: <br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 OrderedCompletion(Expressi=
on(Integer)),f2: List(OrderedCompletion<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (=
Expression(Integer))),fail: failed,pole: potentialPole) <br><br>=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ((- 12x1 + 18)x2 + 18x1 - 28)x3 + (18x1 -=
28)x2 - 28x1 + 45<br>=C2=A0=C2=A0 (4)=C2=A0 ------------------------------=
-----------------------------<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0 12<br>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Type: Union(f1=
: OrderedCompletion(Expression(Integer)),...)<br><br></div>Bill Page.<br><b=
r></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On 16 Nov=
ember 2015 at 19:39, Alasdair McAndrew <span dir=3D"ltr"><<a href=3D"mai=
lto:[email protected]" target=3D"_blank">[email protected]</a>></span> wro=
te:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-=
left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><div><div><div>=
<div><div><div><div><div><div><div>Here's a minimum (non)-working examp=
le: I have a function which returns a polynomial:<br><br></div>mult(xs)=3D=
=3D<br></div>=C2=A0 return(reduce(*,[x-z for z in xs]))<br><br></div>and I =
have another function which needs such a polynomial:<br><br></div>intm(xs,a=
,b)=3D=3D<br></div>=C2=A0 g:=3D(x:Float):Float+->mult(xs)<br></div>=C2=
=A0 return(numeric(integrate(g(x),x=3Da..b)))<br><br></div>which doesn'=
t work.=C2=A0 I've tried replacing the second line with<br><br></div>=
=C2=A0 function(mult(xs),g,x)<br><br></div>which works on the command line,=
but not in a function.=C2=A0 Any ideas as to how I can get over this hump?=
<br><br></div>ever confused,<br></div>Alasdair<span class=3D"HOEnZb"><font =
color=3D"#888888"><br clear=3D"all"><div><div><div><div><div><div><div><div=
><div><div><div><div><br>-- <br><div><div dir=3D"ltr"><a href=3D"http://www=
.facebook.com/alasdair.mcandrew" target=3D"_blank"><img alt=3D"http://www.f=
acebook.com/alasdair.mcandrew" src=3D"https://dl.dropboxusercontent.com/u/2=
796170/facebook.png"></a> <a href=3D"https://plus.google.com/+AlasdairMcAnd=
rew/posts" target=3D"_blank"><img alt=3D"https://plus.google.com/+AlasdairM=
cAndrew/posts" src=3D"https://dl.dropboxusercontent.com/u/2796170/f-gplus_2=
56-48.png"></a> <a href=3D"https://www.linkedin.com/pub/alasdair-mcandrew/a=
/178/108" target=3D"_blank"><img alt=3D"https://www.linkedin.com/pub/alasda=
ir-mcandrew/a/178/108" src=3D"https://dl.dropboxusercontent.com/u/2796170/l=
inkedin.png"></a> <a href=3D"https://twitter.com/amca01" target=3D"_blank">=
<img alt=3D"https://twitter.com/amca01" src=3D"https://dl.dropboxuserconten=
t.com/u/2796170/twitter.png"></a> <a href=3D"http://numbersandshapes.net" t=
arget=3D"_blank"><img alt=3D"http://numbersandshapes.net" src=3D"https://dl=
.dropboxusercontent.com/u/2796170/wordpress.png"></a><br></div></div>
</div></div></div></div></div></div></div></div></div></div></div></div></f=
ont></span></div><span class=3D"HOEnZb"><font color=3D"#888888">
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;FriCAS - computer algebra system" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]" target=
=3D"_blank">[email protected]</a>.<br>
To post to this group, send email to <a href=3D"mailto:fricas-devel@googleg=
roups.com" target=3D"_blank">[email protected]</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/group/fricas-devel"=
target=3D"_blank">http://groups.google.com/group/fricas-devel</a>.<br>
For more options, visit <a href=3D"https://groups.google.com/d/optout" targ=
et=3D"_blank">https://groups.google.com/d/optout</a>.<br>
</font></span></blockquote></div><br></div>
--001a114e3e66b49d850524b386fc--
--===============6620227352051146419==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Axiom-mail mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/axiom-mail
--===============6620227352051146419==--