[Maxima] part of equation as function
Javier Arantegui
javier.arantegui at gmail.com
Tue Mar 13 05:58:04 CDT 2012
Hi!
The difference between ":=" and "define" is a topic that has been
discussed several times. It's one of those things that separate
newbies (like me) and experts. For experts, the difference seems to be
very clear, but most of the new users think that := is the way to
define functions in Maxima. And, frankly the difference is very hard
to tell if you just read the documentation.
Let's see what the Maxima Manual says about := :
http://maxima.sourceforge.net/docs/manual/en/maxima_7.html#IDX264
And, what about define:
http://maxima.sourceforge.net/docs/manual/en/maxima_36.html#IDX1469
There is only (I think) one small difference between them:
"The function definition operator. f(x_1, ..., x_n) := expr defines a
function named f with arguments x_1, …, x_n and function body expr. :=
never evaluates the function body (unless explicitly evaluated by
quote-quote '')."
"Defines a function named f with arguments x_1, …, x_n and function
body expr. define always evaluates its second argument (unless
explicitly quoted). "
Because it's a FAQ, maybe a new sentence should be added to explain
the consequences of that difference, and a new example should be added
showing the different behaviour. Now, the set of examples is the same
in both cases.
Javier
On Tue, Mar 13, 2012 at 10:04 AM, Jaime Villate <villate at fe.up.pt> wrote:
> On 03/13/2012 07:53 AM, Jan Hendrik Müller wrote:
>>
>> Hi all,
>> how can I use parts of an equation as a function, e.g.
>> o% z = x*y
>> and I would like to define f(x,y):=x*y by using the output.
>> f(x,y):=rhs(eq) doesn't work if I want to evaluate e.g. f(1,2)
>
> Use:
>
> define (f(x,y), rhs(eq));
>
> for mathematical functions use always define() instead of :=. Think of := as
> a way to define a small program, rather than defining a function.
> Cheers,
> Jaime
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
--
Lee mi blog: "Un pequeño paso para Neil" http://up3n.wordpress.com/
¡Ahora también en Twitter! http://twitter.com/javierarantegui
More information about the Maxima
mailing list