Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

function definition

1 view
Skip to first unread message

schmitz

unread,
Oct 12, 2009, 12:30:09 PM10/12/09
to
Hello colleagues !

I was used to define functions in the following manner in Maple
Classic ( Version 13 and lower ), e.g.

f:=(i,j)-> if i<=j then 0 else i+j;

In the Classic Version this definition is accepted.

Now I like to use ( because of some ExcelExport application ) the
Maple Standard work sheet.

A function definition implying the if-statement is in Maple Standard
rejected.
How can I define such functions in Maple Standard ?

Wim

Rainer Rosenthal

unread,
Oct 12, 2009, 1:41:06 PM10/12/09
to
schmitz wrote:

> I was used to define functions in the following manner in Maple
> Classic ( Version 13 and lower ), e.g.
>
> f:=(i,j)-> if i<=j then 0 else i+j;
>
> In the Classic Version this definition is accepted.

I doubt that. At least my Maple 6 needs a closing "fi" for the "if"
construction.

f:=(i,j)-> if i<=j then 0 else i+j fi;
f(3,4) ... yields 0
f(4,3) ... yields 7

You could try the ` quotes as follows:

g := (i,j) -> `if`(i <= j,0,i+j);
g(3,4) ... yields 0
g(4,3) ... yields 7

Cheers,
Rainer

G. A. Edgar

unread,
Oct 12, 2009, 2:09:11 PM10/12/09
to
In article
<063f7f90-c85f-4621...@11g2000yqp.googlegroups.com>,
schmitz <schm...@hccnet.nl> wrote:

Use "piecewise"

f := (i,j) -> piecewise(i<=j,0,i+j);

f(1,2);
0
f(3,2);
5

--
G. A. Edgar http://www.math.ohio-state.edu/~edgar/

schmitz

unread,
Oct 13, 2009, 3:01:19 AM10/13/09
to
On 12 okt, 20:09, "G. A. Edgar" <ed...@math.ohio-state.edu.invalid>
wrote:
> In article
> <063f7f90-c85f-4621-9dc4-f5f1f6fdf...@11g2000yqp.googlegroups.com>,

>
>
>
> schmitz <schmit...@hccnet.nl> wrote:
> > Hello colleagues !
>
> > I was used to define functions in the following manner in Maple
> > Classic (  Version 13 and lower  ), e.g.
>
> > f:=(i,j)-> if i<=j then 0 else i+j;
>
> > In the Classic Version this definition is accepted.
>
> > Now I like to use ( because of some ExcelExport application )  the
> > Maple Standard work sheet.
>
> > A function definition implying the if-statement is in Maple Standard
> > rejected.
> > How can I define such functions in Maple Standard ?
>
> > Wim
>
> Use "piecewise"
>
> f := (i,j) -> piecewise(i<=j,0,i+j);
>
> f(1,2);
>                                       0
> f(3,2);
>                                       5
>
> --
> G. A. Edgar                              http://www.math.ohio-state.edu/~edgar/

Nice solution. I knew "piecewise" but did not realize that I could use
this command as an escape.
Wim

schmitz

unread,
Oct 13, 2009, 3:04:41 AM10/13/09
to

Thank you. I forgot the "end if". Your solution is a shorthand
notation for Edgar's solution. I like yours too.
Is there a secret Maple Handbook ?

Wim

A. van der Meer

unread,
Oct 13, 2009, 6:48:16 AM10/13/09
to
schmitz wrote:

in dutch:
http://www.math.utwente.nl/maple/2006/

Adri van der Meer

Ray Vickson

unread,
Oct 14, 2009, 12:06:22 PM10/14/09
to

It would be helpful to buy a book about Maple. My favourite is the
one by Andre Heck, called "Introduction to Maple". Don't be fooled by
the word "introduction": it has plenty of advanced material.

R.G. Vickson

>
> Wim

jfh

unread,
Oct 14, 2009, 5:34:45 PM10/14/09
to

I have its 2nd ed. (1996). My main problems were things new since
Maple V.4 and things omitted from the index. The additions below to
the index may help others who have that edition. A page number in ( )
below means an addition to a list of page numbers already there.

{ } for sets, 296
[ ] for lists, 298
for,
from, 14,21,126
while, 121,123
with lists, 308
forget,
see also unapply,unassign
fsolve,
assigning solutions, 71
if, 196
integration,
dependence on parameters, 76
interface
text-based 37,96
worksheet 30-32,35,37,96
list
see lists
loops,
finite, see for
Newton-Cotes method, for numerical integration, (242)
polynomials,
converting series to, 272,275,276
premature evaluation, 76
printing messages, 98-99,130,254, see also infolevel
proc, 202
quadrature, 242
unapply, see also forget
while, 121,123
worksheet interface, (35,37,96) and that heading ought not to be
indented: it isn't a subheading under word size.

-- John Harper

Ray Vickson

unread,
Oct 14, 2009, 8:44:24 PM10/14/09
to

I updated my edition of the book when I updated software to to much
newer versions of Maple. My current edition of Heck is the 3rd,
published in 2003. I have not checked all the material you give
above. Still, I am sure the OP would be glad to know of better books
if we could supply the titles.

R.G. Vickson

schmitz

unread,
Nov 6, 2009, 7:18:33 AM11/6/09
to

Dear Ray,

1) The reference ( an electronic Maple book in dutch ) given by Adri
van der Meer was also helpful.
Choose " Maple Input" in the "Input Display". Then I can use ( in the
Standard Worksheet ) the function definition ( with "if" ) I am used
to.
2) I have a lot of Maple books, also Heck's book ( third edition ).
But I could not find a quotation about my problem in it.

Wim ( Schmitz )

0 new messages