Re: Basic conditional statement question.

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

```In article <ca6iep\$itr\$1 at smc.vnet.net>, jujio77 at yahoo.com (Scott)
wrote:

> 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

Do[Print[i^2],{i,10}]

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

http://physics.uwa.edu.au/pub/Mathematica/Calculus/

A search at

http://library.wolfram.com/infocenter/MathSource/

on tensor or Christoffel turns up several useful packages.

Cheers,
Paul

--
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 physics.uwa.edu.au
AUSTRALIA                            http://physics.uwa.edu.au/~paul

```

• 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