Adept Scientific - English
The world's best software and hardware for research, science and engineering.
flag arrow
clearclear

 Adept Store | register Join My Adept | Flags  
Adept Scientific | Amor Way | Letchworth Garden City | Herts | SG6 1ZA | Tel: +44 (0)1462 480055  
UKdedksvnofi
Home
Products
Training
Events
 Buy Online
Downloads
Academic Discounts
Support
My Adept
International |  About Us |  Adept Scientific Blog |  Contact Us |  Press Room |  Jobs
Adept Scientific on Facebook Adept Scientific on Twitter Adept Scientific on YouBube Adept Scientific on LinkedIn


The Next Steps

• Ask us a question
• Watch Maple Video Demonstrations
• Buy Maple Now
• View Maple Pricing
• Download a Brochure
• Request an Evaluation
• Meet Our Team
• Read our RSS Feeds

Learn More

Maple Home
Maple 17 Overview
Maple 17 Professional
Maple 17 Academic
Maple 17 Student Use
Maple 17 Personal Edition
What's New in Maple 17
Maple Features
Maple History
Recorded Online Seminars

MapleSim
MapleNet
Maple T.A.
BlockImporter™
Maple Toolboxes
The Möbius Project

Maple Rave Reviews
Maple Study Guides
Books about Maple
System Requirements

Latest Information

New Features: Professional
New Features: Academic
Maple Features
The Maple Reporter Online

Service & Support

Maple Primes
blogs, forums etc

Elite Maintenance Program
Application Centre
Powertools
Search the Knowledge Base
Technical Support request

List Archives >  Maple User Group List Archive >  Archive by date >  This Month By Date >  This Month By Topic

[MUG] Re: about the instruction define and forall

Search email archive for  

[MUG] Re: about the instruction define and forall
Author: Maple Group    Posted: 21/06/2001 20:49:02 GDT
>> From: Maple Group

On Thu, 14 Jun 2001, Alsina, Montse wrote:
> The following sentence (belonging to a long procedure)
> used to work when I ran MapleV in Europe:
>
> define(`&s`, associative, forall([x,y],x &s y = 'smul(x,y)'));

-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Tue, 19 Jun 2001 21:45:38 -0500
From: Rafal Ablamowicz
To:
Subject: about the instruction 'define' and 'forall'


Just try this:

`&s`:=proc() smul(args) end:

and define it in the initialization procedure of your package, that is,

packagename[init]:=proc( ) global `&s`;
`&s`:=proc() smul(args) end:
end:

For more examples, see my package CLIFFORD or file clifford8.mws available from
http://math.tntech.edu/rafal/cliff4/index.html. By the way, the above
construction works in Maple V Rel. 5.0 and 5.1.

Rafal Ablamowicz

--
Department of Mathematics, Box 5054
Tennessee Technological University
Cookeville, TN 38505
(931)372-3441 (phone)
(931)372-6353 (fax)
http://www.math.tntech.edu/





-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Sat, 16 Jun 2001 12:57:58 +0200 (MEST)
From: Bertfried Fauser
To:
Subject: about the instruction 'define' and 'forall'


Dear Alsina,

from my own experience I can only warn you NOT to uses 'define' in Maple
V rel 5.1. It has tremendous bugs and they are tricky to be resolved.
If you really need a define which is 'flat' I can provide you with some
code. This code is part of the BIGEBRA package (for tensor products of
Grassmann and Clifford algebras mainly) which you can download also from
Rafal Ablamowic's web server at : http://math.tntech.edu/rafal/
he is also an author of BIGEBRA and of CLIFFORD needed for BIGEBRA.

That my version of define works pretty good, can be checked at my web-page
where you can interactively test the BIGEBRA package, url is:
http://clifford.physik.uni-konstanz.de/~fauser/
and follow the link : maple-> mapel interactive

I am not sure that I understand what you want to do with the 'forall'
option? in define. The code of define does NOT recognise such an option.

best
BF.

% Bertfried Fauser Fachbereich Physik Fach M 678
% Universit"at Konstanz 78457 Konstanz Germany
% Phone : +49 7531 883786 FAX : +49 7531 884266
% E-mail:
% Web : http://kaluza.physik.uni-konstanz.de/~fauser



-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-

Date: Tue, 19 Jun 2001 00:35:16 +0200
From: Helmut Kahovec
To:
Subject: about the instruction 'define' and 'forall'


The following is Maple6. It may be converted to MapleV/R5 by
substituting 'end' for 'end proc' and 'fi' for 'end if' as well as the
statement error "..."; by the function call ERROR("...");.

Your problem arises from the changes made to define() in MapleV/R5 (and
later) compared to define() in MapleV/R4. Presumably, you used the
latter in Europe and the former in the US. The following will clarify
some finer points of defining binary operators as flat etc..

Section 1
=========

Neutral operators are left associative binary operators in Maple, i.e.,
Maple knows how to evaluate expressions that contain such operators.
Whether a neutral operator is flat or not is up to its actual
definition. Cf. the following two examples:

> restart;
> s1:=proc(x::set,y::set) `intersect`(x,y) end proc:
> `&s1`:=proc() eval(subs('procname'='s1','procname'(args))) end proc:

> s2:=proc(x::set,y::set) `minus`(x,y) end proc:
> `&s2`:=proc() eval(subs('procname'='s2','procname'(args))) end proc:

&s1 is flat as can be seen from the properties of the procedure s1(),
i.e., from the set operator `intersect`. Since &s1 is left associative,
the first two expressions are identical:

> {a,b} &s1 {a,c} &s1 {b,c};

{}

> ({a,b} &s1 {a,c}) &s1 {b,c};

{}

> {a,b} &s1 ({a,c} &s1 {b,c});

{}

&s2 is not flat as can be seen from the properties of the procedure
s2(), i.e., from the set operator `minus`. Since &s2 is left
associative, the first two expressions are identical:


> {a,b} &s2 {a,c} &s2 {b,c};

{}

> ({a,b} &s2 {a,c}) &s2 {b,c};

{}

> {a,b} &s2 ({a,c} &s2 {b,c});

{b}

Section 2
=========

IMO the following should solve your problem and give you the same
results that you got with MapleV/R4 using `define/forall`. Actually, you
have to supply your own procedure definition of smul(), which is
supposed to be flat. Since &s is left associative, the first two
expressions are identical:

> restart;
> smul:=proc() 'procname'(args) end proc:
> `&s`:=smul:

Now you get:

> x &s y &s z; eval(subs(smul=`&*`,%));

smul(smul(x, y), z)
(x &* y) &* z

> (x &s y) &s z; eval(subs(smul=`&*`,%));

smul(smul(x, y), z)
(x &* y) &* z

> x &s (y &s z); eval(subs(smul=`&*`,%));

smul(x, smul(y, z))
x &* (y &* z)

As an example I have added the results when smul() is equal to the
non-commutative multiplication operator &*.

Section 3
=========

We may also define &s as a true flat binary operator. Then we must also
define how to evaluate function calls like smul(x,y,z). If smul() is
again equal to the non-commutative multiplication operator &* then Maple
does not know how to evaluate function calls like &*(x,y,z). In this
case we must tell Maple how to evaluate such function calls.

A true flat binary operator cannot be defined via Maple's define()
facility since there is no way of using an arbitrary expression sequence
as an argument of define().

> restart;
> smul:=proc() 'procname'(args) end proc:
> `&s`:=proc()
> if hastype([args],specfunc(anything,{procname,smul})) then
> smul(
> op(
> map(
> eval,
> subs(
> procname=proc() args end,
> smul=proc() args end,
> [args]
> )
> )
> )
> )
> else
> smul(args)
> end if
> end proc:

> x &s y &s z; eval(subs(smul=`&*`,%));

smul(x, y, z)
&*(x, y, z)

> (x &s y) &s z; eval(subs(smul=`&*`,%));

smul(x, y, z)
&*(x, y, z)

> x &s (y &s z); eval(subs(smul=`&*`,%));

smul(x, y, z)
&*(x, y, z)

Note that in this case all three expressions are identical since &s as
well as &* are supposed to be true flat binary operators.

Section 4
=========

We may reproduce the same results as in Section 2 above if we first
define &s as a true flat binary operator and tell Maple how to evaluate
expressions like _smul(x,y,z) afterwards. However, our programming
effort is much greater than it was in Section 2.

> restart;
> `&s`:=proc()
> if hastype([args],specfunc(anything,{procname,_smul})) then
> _smul(
> op(
> map(
> eval,
> subs(
> procname=proc() args end,
> _smul=proc() args end,
> [args]
> )
> )
> )
> )
> else
> _smul(args)
> end if
> end proc:

> _smul:=proc()
> if nargs>2 then
> procname(procname(args[1]..args[-2]),args[-1])
> elif nargs=2 then
> smul(args)
> else
> error "procedure expects at least two arguments"
> end if
> end proc:

> x &s y &s z; eval(subs(smul=`&*`,%));

smul(smul(x, y), z)
(x &* y) &* z

> (x &s y) &s z; eval(subs(smul=`&*`,%));

smul(smul(x, y), z)
(x &* y) &* z

> x &s (y &s z); eval(subs(smul=`&*`,%));

smul(x, smul(y, z))
x &* (y &* z)


With kind regards,

Helmut

[View Complete Thread]



Previous by date: [MUG] Character Sequences,  Nathan Sokalski
Next by date: [MUG] Re: inequalities, Maple Group
Previous thread: [MUG] A difficult plotting problem.,  Jacob Lalonde
Next thread: [MUG] Re: inequalities,  Greg Nash



Ready to buy?

For more pricing information:
Visit our webstore, call us on +44 (0) 1462 480055 or email us at sales@adeptscience.co.uk

Product Reviews

"Without the Maple software, we would have to spend weeks generating the equations of motion for every experiment. Then the chances that we did it right would basically be near zero. There would always be a mistake somewhere. It is very difficult to set up a dynamic motion model by hand."
- Jean-Claude PiedBeouf, Ph.D Manager of Robotics, Canadian Space Agency

"Its very good - highly accurate and easy to use. The speed of Maple allows me to change equations and quickly reintegrate them into the application, so more possibilities can be explored to achieve the precise effect desired."
Shawn Neely, Senior R & D Director for PDI/Dreamworks

Latest News

Global Optimization Toolbox: Better Optimization to Solve More Problems, Faster
Global Optimization Toolbox: Better Optimization to Solve More Problems, Faster
New MapleSim release delivers advanced model development and analysis, extended toolchain connectivity and quicker results
Maple 17 offers advanced solving and application development capabilities
New release of Maple advances teaching and research
adept

Top of the Page

Popular Links: ChemDraw | ChemOffice | Data Acquisition | Data Analysis | EndNote | Mathcad | MathType | Quality Analyst | Reference Manager | VisSim

EU ePrivacy Directive | Our Privacy and Terms and Conditions Statement
All Trademarks Recognised. Copyright © 2013, Adept Scientific Ltd.
Site designed and maintained by Lyndon Ash

Adept Scientific | Amor Way | Letchworth Garden City | Herts | SG6 1ZA | Tel: +44 (0)1462 480055