List Archives > 
Maple User Group List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[MUG] Kronecker delta
| [MUG] Kronecker delta |
|
Author: Willard, Daniel Dr DUSA-OR
Posted: 10/11/2000 13:50:52 GMT
|
>> From: "Willard, Daniel Dr DUSA-OR"
Does Maple V know how to give you a fast Kronecker delta (discrete form of
Dirac delta)?
Sample:
>kron:= proc(i::integer, j::integer, x)
>if i <> j then
>x:=0 else
>x=1 fi end;
Daniel Willard
Special Assistant for Air and Missile Defense
Office, Deputy Under Secretary of the Army (Operations Research)
102 Army Pentagon ATTN: SAUS-OR Washington, DC 20310-0102
Phone: 703-697-6742 (DSN 227) Fax: 703-693-3897 (DSN 223)
E-mail:
|
| [MUG] Re: Kronecker delta |
|
Author: Maple Group
Posted: 15/11/2000 20:58:20 GMT
|
>> From: Maple Group
| >> From: "Willard, Daniel Dr DUSA-OR"
| Does Maple V know how to give you a fast Kronecker delta (discrete
| form of Dirac delta)?
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Mon, 13 Nov 2000 19:32:14 -0500 (EST)
From: Carl DeVore
To:
Subject: Kronecker delta
I'm not sure what you mean by fast when it comes to Maple. But, anyway,
here's the fastest that I could come up with:
> kron:= proc(x,y) option inline; `if`(x=y, 1, 0) end;
I did 100,000 evaluations in 1.1 seconds on a Sparc Ultra 1 (not a
particularly fast computer). About half of that time is just incrementing
the loop counter.
Carl Devore
University of Delaware
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
From: "Dr. Ferdinand Gleisberg"
To:
Subject: Kronecker delta
Date: Tue, 14 Nov 2000 09:37:31 +0100
Hello, I'm always using BesselJ(i-j,0) for Kronecker(i,j) .
Ferdinand Gleisberg
--
Dr. Ferdinand Gleisberg
Abteilung fuer Mathematische Physik
Universitaet Ulm
D-89069 Ulm
Tel. +49-731-50-23000
Fax +49-731-50-23003
e-mail:
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Tue, 14 Nov 2000 10:46:34 -0800 (PST)
From: Robert Israel
To:
Subject: Kronecker delta
This came up about 5 years ago in MUG. It's easy to do if i and j
are to be integers: I would just say
delta:= proc(i::integer, j::integer) if i=j then 1 else 0 fi end;
The tricky part is that you usually want to give delta symbolic
arguments and use it in sums. Here's one version from Holger
Friedrich's posting of 10 Nov 1995:
> delta := proc(j, k)
> option `Workaround avoiding sum/hgpossib2 suggested by Michael
Monagan`;
> if type([j, k], [numeric, numeric])
> then if j = k then 1 else 0 fi
> else 'delta'(args)
> fi end: `sum/delta` := proc()
> local x, s;
> if isdelta(args[1]) then
> x := solve(op(1, args[1]) = op(2, args[1]), args[2]);
> RETURN(Heaviside(args[2] - x - 1))
> fi;
> if isproductwithdelta(args[1], 's') then
> x := solve(op(1, op(s, args[1])) = op(2, op(s, args[1])),
args[2]);
> RETURN(Heaviside(args[2] - x - 1) * subs(args[2]=x, args[1]))
> fi;
> ERROR(`sorry, input expression too complicated :-(`) end: isdelta
> := proc(expr)
> local i;
> if not has(expr, delta) then RETURN(false) fi;
> for i to nops(expr) do if has(op(i, expr), delta) then RETURN(false)
fi od;
> true; end: isproductwithdelta := proc(expr, j)
> local i;
> j := `nowhere`;
> if not type(expr, `*`) then RETURN(false) fi;
> for i to nops(expr) do if isdelta(op(i, expr)) then j := i;
RETURN(true) fi od;
> false end:
I would make one change to this: the test in line 3 should not be
if type([j, k], [numeric, numeric])
but rather
if type(j-k, numeric)
Robert Israel
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2
|
| [MUG] Re: Kronecker delta |
|
Author: Willard, Daniel Dr DUSA-OR
Posted: 23/11/2000 13:38:57 GMT
|
>> From: "Willard, Daniel Dr DUSA-OR"
Thanks. But how about: > kron:=proc(i::integer,j::integer)`if`(i<>j, 0, 1)
end:
With Windows 98 and Maple V rel 5.1 "inline" is defined only for plotting.
And since mostly i<>j no branching would then occur.
Dan Willard
>> From: Maple Group
| >> From: "Willard, Daniel Dr DUSA-OR"
| Does Maple V know how to give you a fast Kronecker delta (discrete
| form of Dirac delta)?
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=
-
Date: Mon, 13 Nov 2000 19:32:14 -0500 (EST)
From: Carl DeVore
To:
Subject: Kronecker delta
I'm not sure what you mean by fast when it comes to Maple. But, anyway,
here's the fastest that I could come up with:
> kron:= proc(x,y) option inline; `if`(x=y, 1, 0) end;
I did 100,000 evaluations in 1.1 seconds on a Sparc Ultra 1 (not a
particularly fast computer). About half of that time is just incrementing
the loop counter.
Carl Devore
University of Delaware
|
Previous by date: [MUG] syntax for mpl and mhp files and .m files, William S Price
Next by date: [MUG] Question on implicitplot colors, Sol X Rochman
Previous thread: [MUG] Radius of Convergence and Power Series, Chuck Baker
Next thread: [MUG] Question on implicitplot colors, Sol X Rochman
|