That's just the way Maple works. It automatically distributes multiplication of numerics over sums. You can fake the output using the empty function (``):
x := a/2+b/3:
makefrac := (``@numer)/(``@denom):
makefrac(x);
(3 a + 2 b)
------------
(6)
expand(%);
a/2 + b/3
Haven't come across how to use an empty function (` `) yet and I haven't used the @ symbol. Still have lots to learn. Can't find any help on how to use the empty function but thanks for the reply.
The empty function is an inert function whose name is `` and so appears as empty (invisible). For example,
``(a);
(a)
It can be used to group quantities that would otherwise be combined by Maple. It's primary use is in ifactor, where it prevents the terms from being recombined:
ifactor(6);
(2)*(3)
The @ symbol is used for function composition (it is the closest non-letter ascii symbol corresponding to the usual mathematical symbol for function composition, the open centered circle). Thus
(f@g)(x)
f(g(x))
Similary, (``@denom)(x) is equivalent to ``(denom(x)), which visually encloses the denominator of x in parentheses. Somewhat more elaborate is
makefrac := (``@numer)/(``@denom):
This works (as described herein) because with Maple one can apply an algebraic expression to arguments, the arguments are then passed to each of the algebraic terms. For example (f/g)(x) evaluates to f(x)/g(x). So makefrac(x) evaluates to ``(numer(x))/``(denom(x)) which then displays the numerator and denominator of x as a fraction, with no automatic recombination (numer and denom are designed to give the appropriate answer even if their arguments are not of type `*`).
I agree, I have found the documentation to be a little sparse in some areas.
And thanks for the explanation, that was quite helpful. By the way how did you learn how to do this? Was it from a separate book or just from the maple help documentation?
Most of my knowledge of Maple has been acquired by practice (i.e. using Maple, and trying stuff), reading the help pages, reading the programming manuals, inspecting existing code, and following this and other/previous Maple forums.
se la vi
That's just the way Maple works. It automatically distributes multiplication of numerics over sums. You can fake the output using the empty function (``):
x := a/2+b/3: makefrac := (``@numer)/(``@denom): makefrac(x); (3 a + 2 b) ------------ (6) expand(%); a/2 + b/3c'est la vie
Okay, yes that works.
Haven't come across how to use an empty function (` `) yet and I haven't used the @ symbol. Still have lots to learn. Can't find any help on how to use the empty function but thanks for the reply.
emptysymbol
Look under ?emptysymbol for help on the empty symbol function.
Thanks for correcting my gibberish francaise.
empty symbol
Nice little trick to force maple to give a common denom by the way.
?empty symbol, I'll check it out. Thanks
Can you give a few more examples?
Can you give a few examples using the empty function ' ' and the @ symbol so I can understand how it works a little better.
explanation
The empty function is an inert function whose name is `` and so appears as empty (invisible). For example,
``(a);
(a)
It can be used to group quantities that would otherwise be combined by Maple. It's primary use is in ifactor, where it prevents the terms from being recombined:
ifactor(6);
(2)*(3)
The @ symbol is used for function composition (it is the closest non-letter ascii symbol corresponding to the usual mathematical symbol for function composition, the open centered circle). Thus
(f@g)(x)
f(g(x))
Similary, (``@denom)(x) is equivalent to ``(denom(x)), which visually encloses the denominator of x in parentheses. Somewhat more elaborate is
makefrac := (``@numer)/(``@denom):
This works (as described herein) because with Maple one can apply an algebraic expression to arguments, the arguments are then passed to each of the algebraic terms. For example (f/g)(x) evaluates to f(x)/g(x). So makefrac(x) evaluates to ``(numer(x))/``(denom(x)) which then displays the numerator and denominator of x as a fraction, with no automatic recombination (numer and denom are designed to give the appropriate answer even if their arguments are not of type `*`).
functional programming documentation
I find that this latter issue on functional style programming is barely mentioned in the documentation. In ?examples,functionaloperators :
and may be not much more elsewhere.
By the way, I would call this property as distributive.
evalapply
Examples of applying the common base types to arguments are give in the help page for evalapply.
not an obvious place
for those examples. And only one example for 'evalapply' itself...
Thanks for the explanation
I agree, I have found the documentation to be a little sparse in some areas.
And thanks for the explanation, that was quite helpful. By the way how did you learn how to do this? Was it from a separate book or just from the maple help documentation?
Learning Maple
Most of my knowledge of Maple has been acquired by practice (i.e. using Maple, and trying stuff), reading the help pages, reading the programming manuals, inspecting existing code, and following this and other/previous Maple forums.
Wiki
It is a recurrent theme, but I think that a wiki could help a lot with deficiencies of documentation in some areas like this one.
Unofficial Wiki
It seems pretty rough and pretty out of date, but there is a Maple project at WikiBooks for any aspiring Wikinauts:
http://en.wikibooks.org/wiki/Maple
John
I will look at it
Thank you for this link.