 |
|
List Archives > 
Maple User Group List Archive > 
Archive by date > 
This Month By Date > 
This Month By Topic
[MUG] yp := (t) -> %;
| [MUG] yp := (t) -> %; |
|
Author: Colin Campbell - IST
Posted: Mon, 05 Aug 2002 15:12:01 -0400
|
>> From: Colin Campbell - IST "campbell"
Could people vote on the following proposal for Maple 9? 10?
BACKGROUND:
^^^^^^^^^^^
You define a function:
f := (t) -> sin(t^2); # ( ) on t not needed
You differentiate it and get a result:
diff( f(t), t );
You want to use the result to define a function. You'd like to type:
fp := (t) -> %; # Method 1 Mmm ... pretty!
but you have to type:
fp := unapply(%, t); # Method 2 Mmm ... not pretty!
QUESTION:
^^^^^^^^^
Would you support the idea of Maple 9? 10? permitting "Method 1"?
NOTE: This would likely mean %, %%, ... could no longer be used in
procedures. Some like Greg Fee would say that would be a good
thing as using them tends to reduce readability!
Please vote "yes" or "no" or suggest a better scheme for avoinding unapply.
Colin
-----------------------------------------------------------------------------
Colin Campbell U n i v e r s i t y o f W a t e r l o o
Academic Computing Waterloo, Ontario, Canada N2L 3G1
Math & Computer 2048 www.ist.uwaterloo.ca/~campbell
Electronic Workplace Group Voice: (519) 888-4567 x5327
Information Systems & Technology FAX: (519) 884-4398
"Across the country, computers are usually not used effectively in under-
graduate ... courses. Often, they are not used at all. Problem-solving
approaches and calculation methods are little influenced by ... computers."
---> http://www.asee.org/jee/papers/00220.PDF
-----------------------------------------------------------------------------
|
| [MUG] Re: yp := (t) -> %; |
|
Author: Maple User Group
Posted: Wed, 7 Aug 2002 16:28:15 -0400 (
|
>> From: Maple User Group "maple_gr"
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Wed, 07 Aug 2002 02:07:47 +0200
From: Helmut Kahovec "helmut.kahovec"
To: "maple-list"
Subject: yp := (t) -> %;
Well, I do not like your idea, sorry! BTW, I think that the following is
pretty well legible:
> restart;
> f:=t->sin(t^2):
> fp:=D(f);
2
fp := t -> 2 cos(t ) t
Kind regards,
Helmut
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Tue, 6 Aug 2002 17:29:55 -0700 (PDT)
From: Robert Israel "israel"
To: "maple-list"
Subject: yp := (t) -> %;
My vote would be an emphatic NO.
The fundamental issue is this: when you define
a function with proc or ->, the definition is not evaluated. Any
variables occurring in that definition (including %) are evaluated only
when the function is called, not when it is defined. So for example:
> c:= 1;
f:= x -> c*x;
c:= 2;
f(x);
results in 2*x, not x. It's a clear, simple rule, and making an exception
for % would mess it up.
Another serious problem is that any existing code which used % inside
procedures would be broken. Backwards compatibility is important.
Whether % promotes or reduces readability is a side issue.
Robert Israel "israel"
Department of Mathematics http://www.math.ubc.ca/~israel
University of British Columbia
Vancouver, BC, Canada V6T 1Z2
On Mon, 5 Aug 2002, Colin Campbell - IST wrote:
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Wed, 07 Aug 2002 08:49:38
To: "maple-list"
From: Bruce M Hartley "hartley"
Subject: yp := (t) -> %;
Colin,
I have been using "unapply" to convert expressions to procedures and then
to C subroutines.
I can see little advantage in changing to a differnt method of "unapply"ing.
Bruce Hartley
Bruce Hartley
Senior Research Associate
Department of Exploration Geophysics
Curtin University of Technology
+61 8 9266 2297 Ph. +61 8 9266 3407 Fax.
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Tue, 6 Aug 2002 19:12:44 -0700 (MST)
From: Matthias Kawski "kawski"
To: "maple-list"
Subject: yp := (t) -> %;
I prefer 2 (use "unapply')
I see this as part of a larger need to help clarify when
two identical symbols (on the screen) represent the same
quantity. I have had my fair share of trouble w/ escaped
local variables etc. -- and would like to have a consistent
and transparent scheme implemented throughout.
Exceptions that "locally" facilitate / speed up the work
make life harder as now one has to memorize when special
tricks/shortcuts are no longer allowed.
Method 1 reminds me of situations where I stumbled over
that were similar in spirit, e.g. to whether the t in
unapply(....,t) is the same as the t in
unapply( diff(g(t),t)),...).
Matthias
**********************************************************
Matthias Kawski http://math.asu.edu/~kawski
Dept. of Mathematics and Statistics "kawski"
Arizona State University office: (480) 965 3376
Tempe, Arizona 85287-1804 home: (480) 893 0107
**********************************************************
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
From: Stanley J Houghton "S.J.Houghton"
Date: Wed, 7 Aug 2002 13:33:40 +0100
To: "maple-list"
Subject: yp := (t) -> %;
As a user of % in procedures (where it does not obscure readability), I
would vote a definite "no" to this. However, my response deserves an
explanation .. it is not just that I don't like change!
The current %, %%, %%% nullary operators are very precisely defined in
Maple (see the help pages). It is a shorthand notation and is there
for a specific purpose. It is deliberately restricted to the current
execution level (ignoring for loop variables and NULL) to avoid
ambiguity. Computational results in calls to sub-procedures are
ignored at the higher level as are computational results before entry
to the current execution level.
Changing the operator functions would introduce incompatibility and
would need much more careful thought, design and definition than is
given here. Forgive me but I consider the suggestion a bit of a "knee
jerk" reaction to the notation. It is certainly not worth changing an
existing useful definition simply for the ease of writing t->% instead
of unapply(%,t), i.e. for a prettier notation.
Nvertheless, I take your point about the readability of 'unapply'
notation. Perhaps an acceptable alternative is to provide a new
unapply operator (albeit different from '->') acting like unapply to
construct a proc from evaluated arguments (at the same level) and
provide the notation you want, e.g. (t) ->> %; (eqivalent to
'unapply(%,t);').
If you follow your approach, you have problems with
> g(x);f(x);h(%%);
i.e. does the %% now refer to the results of computing g(x) or does it
refer to the penultimate computed expression in f(x)?
and note also that using your approach
> t^2; f:=(t)->%;
the first t would be global and different from the formal argument t.
Hence my preference and I hope the explanation helps.
I await others' comments.
Regards
Stan Houghton
| >> From: Colin Campbell - IST "campbell"
|
| Could people vote on the following proposal for Maple 9? 10?
| You define a function:
|
| f := (t) -> sin(t^2); # ( ) on t not needed
|
| You differentiate it and get a result:
|
| diff( f(t), t );
|
| You want to use the result to define a function. You'd like to type:
|
| fp := (t) -> %; # Method 1 Mmm ... pretty!
|
| but you have to type:
|
| fp := unapply(%, t); # Method 2 Mmm ... not pretty!
|
| Would you support the idea of Maple 9? 10? permitting "Method 1"?
|
| [MUG] Re: yp := (t) -> %; |
|
Author: Maple User Group
Posted: Wed, 7 Aug 2002 16:27:47 -0400 (
|
>> From: Maple User Group "maple_gr"
| >> From: Colin Campbell - IST "campbell"
|
| Could people vote on the following proposal for Maple 9? 10?
| You define a function:
|
| f := (t) -> sin(t^2); # ( ) on t not needed
|
| You differentiate it and get a result:
|
| diff( f(t), t );
|
| You want to use the result to define a function. You'd like to type:
|
| fp := (t) -> %; # Method 1 Mmm ... pretty!
|
| but you have to type:
|
| fp := unapply(%, t); # Method 2 Mmm ... not pretty!
|
| Would you support the idea of Maple 9? 10? permitting "Method 1"?
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Tue, 06 Aug 2002 11:13:22 -0700
From: Allan Wittkopf "wittkopf"
Subject: yp := (t) -> %;
To: "maple-list"
Even prettier:
> f := (t) -> sin(t^2);
2
f := t -> sin(t )
> fp := D(f);
2
fp := t -> 2 cos(t ) t
- Allan Wittkopf
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Tue, 6 Aug 2002 14:30:43 -0400 (EDT)
From: Fred Chapman "fwchapma"
To: "maple-list"
Subject: yp := (t) -> %;
Yes, I vote in favor of Method 1.
In this particular example, you could just do fp := D(f), which is much
simpler. In general, however, I think it would be very convenient and
desirable for t -> % to mean the same thing as unapply(%, t).
---------------- 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 E-Mail: "fwchapman"
Waterloo, Ontario, N2L 3G1, Canada Curriculum Vitae: see home page
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
From: "Richard Quint" "rquint"
To: "maple-list"
Subject: yp := (t) -> %;
Date: Tue, 6 Aug 2002 11:44:08 -0700
You can already do this
> f:=x->sin(x^2);
2
f := x -> sin(x )
> fp:=D(f);
2
fp := x -> 2 cos(x ) x
> fp(t);
2
2 cos(t ) t
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
From: Joe Riel "joer"
To: "maple-list"
Date: Tue, 06 Aug 2002 11:40:17 -0700
Subject: yp := (t) -> %;
I'm inclined to vote against it, though I haven't given it much thought.
Here is an operator that does what you want.
> `&->` := proc() unapply(args[-1],args[1..-2]) end:
> f := t &-> sin(t^2):
> diff(f(t),t);
2
2 cos(t ) t
> fp := t &-> %;
2
fp := t -> 2 cos(t ) t
Joe Riel
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Tue, 6 Aug 2002 14:41:35 -0500
From: Phil Mendelsohn "mend0070"
To: "maple-list" "campbell"
Subject: yp := (t) -> %;
Yes, as long as it doesn't break any multivariable combinations.
I.e., you can still specify the mapped symbols arbitrarily, i.e.,
fp:= (z, t) -> %
should work, even if t doesn't show up in the expression. Why?
'cause if you make a mistake, you don't want the value of % to have
changed underneath you and do all the calculations over again.
(Why % is slippery in the first place.)
Cheers,
Phil Mendelsohn
--
www.rephil.org / University of Minnesota
"To misattribute a quote is unforgivable" -- Anonymous
-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-=*=-
Date: Tue, 6 Aug 2002 13:50:36 -0700 (PDT)
From: John Kurtzke "kurtzke"
To: "maple-list"
Subject: yp := (t) -> %;
Colin,
Maybe I am missing something, but what about D?
f := t -> sin(t^2);
g := D(f);
Maple responds with;
g := t -> 2 cos(t^2) t
Ask Maple what g(t is and you get:
g(t);
2*cos(t^2)*t (except Maple doesn't put in the asterisks).
g(sqrt(Pi));
-2 sqrt(Pi)
Is this what you want?
(I'm using Maple 7, but this works on Maple 6, ...)
john
--
John F. Kurtzke, C.S.C.
Department of Mathematics
278 Buckley Center
University of Portland
Portland, OR 97203
503-943-7377
"kurtzke"
|
Previous by date: [MUG] Re: A bug?, Maple User Group
Next by date: [MUG] AW: A solution, Thomas Richard
Previous thread: [MUG] gradient of a vector field, Rob Scott
Next thread: [MUG] A solution, C W
|
|
|