|
[Date Index]
[Thread Index]
[Author Index]
No Error in Mathematica!
- To: mathgroup at yoda.physics.unc.edu
- Subject: No Error in Mathematica!
- From: puglisi at settimo.italtel.it
- Date: Mon, 8 Nov 93 16:43:25 MST
John Writes:
I just starting playing with Mathematica and I cannot seem to
resolve the following output.
In[1]:= x=b
Out[1]= b
In[2]:= x^2
Out[2]= b^2 (* as I would expect)
In[3]:= x^2/.x->a
Out[3]= a^2
In[4]:= x=2
Out[4]= 2
In[5]:= x^2/.x->7
Out[5]= 4
What is going on? considering output %3 I would have thought that
%5 would be 49
-----------------------------------------------------
The behavior observed is no error,it is the expected one from Mathematica.
What happens here is that x=2, and x^2/.x->7 tries to replace x with the value 7
in the constant function 2^2==4.
Another way to put it is that Mathematica does symbolic computation,
but when it sees a number understand it as a number.
Hint: Type ?x after each new input line.
Ciao
Alberto Puglisi
ITALTEL
Central Research Laboratories, DRSC-IS CLTB
20019 Castelletto di Settimo Milanese (Milano)
Italy
phone: (+39)(2)4388-8299
fax: (+39)(2)4388-7989
e-mail: puglisi at settimo.italtel.it
Prev by Date:
Re: Error in Mathematica?
Next by Date:
BigSeriesExpansion
Previous by thread:
Re: Error in Mathematica?
Next by thread:
BigSeriesExpansion
|