List Archives > 
Maple User Group List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[MUG] differental operators
| [MUG] differental operators |
|
Author: Richard Patterson
Posted: Tue, 11 Feb 2003 10:26:00 -0500
|
>> From: Richard Patterson "rpatters"
I want to define differential operators and test them on
a polynomial f(x,y):
f:=(x,y)->a*x^2+b*x*y+d*y^2;
2 2
f := (x, y) -> a x + b x y + d y
If the differential operator has constant coefficients
> op1:=2*D[1]+3*D[2];
op1 := 2 D[1] + 3 D[2]
then everything works fine:
> op1(f)(x,y);
4 a x + 2 b y + 3 b x + 6 d y
How do I accomplish the same thing if the coefficients are
unspecified constants?
> op2:=c*D[1]+d*D[2];
op2 := c D[1] + d D[2]
> op2(f)(x,y);
c(f)(x, y) (2 a x + b y) + d(f)(x, y) (b x + 2 d y)
It was no help to include
> assume(c,constant): assume(d,constant):
> op2(f)(x,y);
c~(f)(x, y) (2 a x + b y) + d~(f)(x, y) (b x + 2 d~ y)
|
| [MUG] differental operators |
|
Author: Maple User Group
Posted: Mon, 17 Feb 2003 22:05:23 -0500
|
>> From: Maple User Group "maple_gr"
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Thu, 13 Feb 2003 09:41:53 -0500 (EST)
From: Fred Chapman "fwchapma"
To: "maple-list"
Subject: differental operators
On Tue, 11 Feb 2003, Richard Patterson wrote:
> >> From: Richard Patterson "rpatters"
>
> I want to define differential operators and test them on
> a polynomial f(x,y):
>
> f:=(x,y)->a*x^2+b*x*y+d*y^2;
> 2 2
> f := (x, y) -> a x + b x y + d y
>
> If the differential operator has constant coefficients
>
> > op1:=2*D[1]+3*D[2];
>
> op1 := 2 D[1] + 3 D[2]
>
> then everything works fine:
>
> > op1(f)(x,y);
>
> 4 a x + 2 b y + 3 b x + 6 d y
>
> How do I accomplish the same thing if the coefficients are
> unspecified constants?
The simplest reliable solution that I found for your problem is to define
`c` and `d` to be constant functions:
> f:=(x,y)->a*x^2+b*x*y+d*y^2;
2 2
f := (x, y) -> a x + b x y + d y
> op2:=c*D[1]+d*D[2];
op2 := c D[1] + d D[2]
> op2(f)(x,y);
c(f)(x, y) (2 a x + b y) + d(f)(x, y) (b x + 2 d y)
> c := (f::anything) -> c;
c := f::anything -> c
> d := (f::anything) -> d;
d := f::anything -> d
> op2(f)(x,y);
c (2 a x + b y) + d (b x + 2 d y)
If you like, you can assign numerical values to `c` and `d` afterwards:
> c := 2: d := 3: op2(f)(x,y);
4 a x + 2 b y + 3 b x + 18 y
With best wishes,
Fred Chapman
NOTE: In anticipation of obtaining my Ph.D. this June, I'm now using my
new, permanent, lifetime e-mail address: "fwchapman"
---------------- http://www.scg.uwaterloo.ca/~fwchapma/ ----------------
Frederick W. Chapman, Ph.D. Student UW Office: Math & Computer 5162
Department of Applied Mathematics UW Phone: (519) 888-4567 x6672
University of Waterloo
Waterloo, Ontario, N2L 3G1, Canada Curriculum Vitae: see homepage
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Thu, 13 Feb 2003 22:02:23 +0100
From: Helmut Kahovec "helmut.kahovec"
To: "maple-list"
Subject: differental operators
Richard Patterson wrote:
>| I want to define differential operators and test them on
>| a polynomial f(x,y):
>|
>| f:=(x,y)->a*x^2+b*x*y+d*y^2;
>| 2 2
>| f := (x, y) -> a x + b x y + d y
>|
>| If the differential operator has constant coefficients
>|
>| > op1:=2*D[1]+3*D[2];
>|
>| op1 := 2 D[1] + 3 D[2]
>|
>| then everything works fine:
>|
>| > op1(f)(x,y);
>|
>| 4 a x + 2 b y + 3 b x + 6 d y
>|
>| How do I accomplish the same thing if the coefficients are
>| unspecified constants?
>|
>| > op2:=c*D[1]+d*D[2];
>|
>| op2 := c D[1] + d D[2]
>|
>| > op2(f)(x,y);
>|
>| c(f)(x, y) (2 a x + b y) + d(f)(x, y) (b x + 2 d y)
Well, you may use an extension to evalapply() as shown below.
> restart;
> type(1,procedure);
false
> 1(f);
1
> 1(f)(x,y);
1
> type(u,procedure),type(v,procedure);
false, false
> u(f),v(f);
u(f), v(f)
> u(f)(x,y),v(f)(x,y);
u(f)(x, y), v(f)(x, y)
> ConstOperator:=proc() op(0,args[1]) end proc:
> `evalapply/u`:=eval(ConstOperator):
> `evalapply/v`:=eval(ConstOperator):
> type(u,procedure),type(v,procedure);
false, false
> u(f),v(f);
u(f), v(f)
> u(f)(x,y),v(f)(x,y);
u, v <===!!!===
> f:=(x,y)->a*x^2+b*x*y+c*y^2;
2 2
f := (x, y) -> a x + b x y + c y
> op1:=2*D[1]+3*D[2];
op1 := 2 D[1] + 3 D[2]
> op1(f)(x,y);
4 a x + 2 b y + 3 b x + 6 c y
> op2:=u*D[1]+v*D[2];
op2 := u D[1] + v D[2]
> op2(f)(x,y);
u (2 a x + b y) + v (b x + 2 c y)
> eval(%,{u=2,v=3});
4 a x + 2 b y + 3 b x + 6 c y
Kind regards,
Helmut
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Sat, 15 Feb 2003 04:25:19 -0500 (EST)
From: Carl Devore "devore"
To: "maple-list"
Subject: differental operators
On Tue, 11 Feb 2003, Richard Patterson wrote:
> I want to define differential operators and test them on
> a polynomial f(x,y):
> f:=(x,y)->a*x^2+b*x*y+d*y^2;
> If the differential operator has constant coefficients
> > op1:=2*D[1]+3*D[2];
> then everything works fine:
> > op1(f)(x,y);
> 4 a x + 2 b y + 3 b x + 6 d y
>
> How do I accomplish the same thing if the coefficients are
> unspecified constants?
> > op2:=c*D[1]+d*D[2];
> > op2(f)(x,y);
> c(f)(x, y) (2 a x + b y) + d(f)(x, y) (b x + 2 d y)
You need to make the coefficients operators at the same level as the D's.
Numbers are automatically operators, but names are not.
> op2:= (()->()->c)*D[1] + (()->()->d)*D[2];
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
From: "Dr Francis J. Wright" "F.J.Wright"
To: "rpatters"
Subject: differental operators
Date: Sat, 15 Feb 2003 18:43:50 -0000
From: "Richard Patterson" "rpatters"
To: "maple_gr"
Sent: Tuesday, February 11, 2003 3:26 PM
Subject: [MUG] differental operators
> I want to define differential operators and test them on
> a polynomial f(x,y):
>
> f:=(x,y)->a*x^2+b*x*y+d*y^2;
> 2 2
> f := (x, y) -> a x + b x y + d y
>
> If the differential operator has constant coefficients
>
> > op1:=2*D[1]+3*D[2];
>
> op1 := 2 D[1] + 3 D[2]
>
> then everything works fine:
>
> > op1(f)(x,y);
>
> 4 a x + 2 b y + 3 b x + 6 d y
>
> How do I accomplish the same thing if the coefficients are
> unspecified constants?
>
> > op2:=c*D[1]+d*D[2];
>
> op2 := c D[1] + d D[2]
>
> > op2(f)(x,y);
>
> c(f)(x, y) (2 a x + b y) + d(f)(x, y) (b x + 2 d y)
Maple is treating c and d as mappings, so one solution is explicitly to
define them to be constant mappings, i.e. mappings that evaluate to their
own names when they are applied, regardless of their arguments. This is
essentially what Maple does automatically for numbers, which is why your
explicit example worked.
> c := proc() 'procname' end proc;
c := proc() 'procname' end proc
> d := eval(c);
d := proc() 'procname' end proc
> op2(f)(x,y);
c (2 a x + b y) + d (b x + 2 d y)
Francis
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Mon, 17 Feb 2003 17:01:43 -0500 (EST)
From: Carl Devore "devore"
To: "maple-list"
Subject: differential operators
Please CC all articles to the mailing-list. If that is unacceptable to
you, then this is my last article on this subject. Let others benefit
from these writings.
On Mon, 17 Feb 2003, Richard Patterson wrote:
> > f:=(x,y)->a*x^2+b*x*y+c*y^2;
> > g:=(x,y)->p*x^3+q*x^2*y+r*x*y^2+s*y^3;
>
> Procedure to change the coefficients of polynomials to constant functions.
>
> > Change:=proc(f) local C:
> > for C in coeffs(f(x,y),[x,y]) do assign(C,unapply(C,f)) end do;
> > end proc;
>
> This leaves me uneasy as it affects f even though the procedure returns
> nothing.
Worse than that, it affects the coefficients. Here is how to get it to
returned the modified polynomial without any side effects:
Change:= (f, V)->
unapply(subsindets(f(V[]), name, N-> `if`(N in V, N, unapply(N))), V[])
;
And the call becomes
F:= change(f, [x,y]);
I chose to use a different name, F, but you re-use f if you want.
It is best not to rely on there being 2 variables, so I pass in the
variable names. We can get around that if you insist on not passing in
the variable names.
The above uses the Maple 8 feature `in`. You can retrofit it to Maple 7
by using member. susbindets is a feature of Maple 7. We can go back
further than that if you need.
> However the Changed polynomials can still be multiplied,
> evaluated, differentiated just like ordinary polynomials.
diff works on them, but there is a bug that prevents D from working on
them. The coefficient functions are changed to simply t. This affects at
least Maple 6 and Maple 8.
|
Previous by date: [MUG] Re: DegreeReverseLexicographic Monomial ordering, Allan Wittkopf
Next by date: [MUG] Re: Generating a compound poission process in Maple, Robert Israel
Previous thread: [MUG] simple question: numbering equations and/or lines in worksheet?, Clearthink
Next thread: [MUG] Generating a compound poission process in Maple, Theo H S Boafo
|