I wanted to know the difference between two operators:

= and :=

I couldn't find the ":=" operator on the list at https://reference.wolfram.com/language/tutorial/Operators.html

Can someone help?



marked as duplicate by corey979, Feyre, Leonid Shifrin, Michael E2, halirutan Oct 30 '16 at 15:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You need to understand the difference of "Set" and "Set Delay" :

Let's make an example which illustrates this clearly. I have a function:

f[x1_,x2_]:= x1+x1*x2

and I want to find it's derivative according to x2 at specific locations of x1 and x2.

m[x1_,x2_] = D[f[x1,x2],x2]
  1. If you use use ":" before the "=", (Set Delay), it evaluates the function when it is needed, hence it will evaluate the function only when values for x1 and x2 are given.

  2. The function definition without ":" before the "=" (Set) evaluates the function before it is used and the output is assigned to m[x1_,x2_], so if you input values in m[x1_,x2_] they are put into the already-differentiated equation.

If now, you would decide to put a ":" in front of the "=" for m[x1_,m2_],it will not work, since one cannot differentiate a function with respect to a numerical value (5 for example).

I hope that this helps you.

P.S. I encountered the same question once: How To First Evaluate A Differential Equation And Then To Input The Function Parameters?

  • $\begingroup$ Thank you very much for the quick response! $\endgroup$ – André Oct 30 '16 at 15:57
  • $\begingroup$ Your welcome ! Glad I could help. :) $\endgroup$ – henry Oct 30 '16 at 17:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.