Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

In Mathematica 9 If I write:

f[x_] = (x - 1)/(x - 1)

I get

1

And if then I write:

f[1] 

I get

1

But if I write:

(1 - 1)/(1 - 1)

I get:

Indeterminate

Why am I not getting Indeterminate for f[1] when f[x_] = (x - 1)/(x - 1) ?

What am I doing wrong?

share|improve this question
add comment

closed as too localized by Yves Klett, Simon Woods, Artes, rm -rf Jan 3 '13 at 14:18

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

Thanks to @Nasser comment, I found my mistake, I was using = instead of :=. The basic difference between these forms is when the expression is evaluated. = is an immediate assignment, which is evaluated at the time when the assignment is made. := on the other hand, is a delayed assignment, which is not evaluated when the assignment is made, but is instead evaluated each time its value is requested, more info here: http://reference.wolfram.com/mathematica/tutorial/ImmediateAndDelayedDefinitions.html

share|improve this answer
1  
By the way, if you had typed ?f following the original definition of f, you would have seen why it was returning 1. –  David Skulsky Jan 3 '13 at 14:12
add comment

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