MathGroup Archive 2004

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Basic conditional statement question.

  • To: mathgroup at
  • Subject: [mg48662] Re: Basic conditional statement question.
  • From: Paul Abbott <paul at>
  • Date: Thu, 10 Jun 2004 02:42:54 -0400 (EDT)
  • Organization: The University of Western Australia
  • References: <ca6iep$itr$>
  • Sender: owner-wri-mathgroup at

In article <ca6iep$itr$1 at>, jujio77 at (Scott) 

> Here is a question I would think has a simple solution.  Let's say I
> have some variable "a" which is an integer, but I haven't defined it
> in Mathematica.  I want to run a conditional statement on it. 
> Basically
> If[a!=0,Print["such and such"]]
> When I do something like this, Mathematica I asume is spitting out a
> null statement, because it doesn't do anything.  So, how can I define
> "a" such that Mathematica knows it isn't =0 yet, still some integer.

In Mathematica the use of Print statements should be avoided (IMHO). 
There are nearly always better ways of producing formatted output, with 
the added advantage that the output can be re-used as input. For example


is not as useful as

   Table[i^2, {i, 10}]

because the Table command generates output that can be re-used as input.
> The reason I ask is I am calculating Christophel symbols (and such)
> and many of them =0, so I want to only output those that are not equal
> to zero.

I assume that you are aware that there are already packages that compute 
Christoffel symbols, e.g., the Symbolic Vector Analysis package 
developed by Hong Qin, which deals with arbitrary vector objects, 
available at

A search at

on tensor or Christoffel turns up several useful packages.


Paul Abbott                                   Phone: +61 8 9380 2734
School of Physics, M013                         Fax: +61 8 9380 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at 

  • Prev by Date: Re: Energy content of a mathematical result.
  • Next by Date: Re: seruous solve bug? only when used with simplifying
  • Previous by thread: Re: Basic conditional statement question.
  • Next by thread: ListContourPlot and missing data