MathGroup Archive 2006

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

Search the Archive

Re: Plus Behavior Inside a Notation Box?

  • To: mathgroup at
  • Subject: [mg64956] Re: Plus Behavior Inside a Notation Box?
  • From: Paul Abbott <paul at>
  • Date: Fri, 10 Mar 2006 05:14:47 -0500 (EST)
  • Organization: The University of Western Australia
  • References: <duh39s$5ui$> <duls4s$35u$>
  • Sender: owner-wri-mathgroup at

In article <duls4s$35u$1 at>, "Josh" <josh at> 

> Thanks, that was the insight I was looking for.  I did find that a
> single underscore worked better than the double and triple underscore.
> Not sure I understand why, the double or triple underscore should work
> better.  

This is an issue with understanding how pattern-matching works. It 
really has nothing to do with the Notation package.

> The motivation for this was to map the built in BesselJ[n,z] and
> BesselK[n,z] functions to J_n[z] and Y_n[z].  

If you use TraditionalForm (at least for output -- if you've followed 
some other recent threads on this topic) by doing

  Cell | Default Output FormatType | TraditionalForm

then special functions such as the Bessel function are typeset 

(Note one potential problem: the Notation package expects that you are 
using the same FormatType for Input and Output. If these are different 
you will encounter problems using Notation.)

> This works quite nicely,
> with the subscript properly denoting the order of the Bessel function
> after differentiation and all the rules for simplification and such are
> still implemented.  The subscripts tend to come out backwards, -1+n
> instead of n-1, but I can live with that.

That is also an issue with StandardForm. If you enter

  n - 1

in StandardForm you get

  -1 + n

TraditionalForm gives you

  n - 1

> Notation[ J_n_ [z_] <=> BesselJ[n_, z_] ]
> Notation[ Y_n_ [z_] <=> BesselY[n_, z_] ]
> One alternative was to create the symbols J_n and Y_n, but I lose a lot
> of the built-in functionality that way.  The other possibility was
> creating a function J_n_[z_] := BesselJ[n,z], which preserves all the
> built-in functions, but the output is in the BesselJ[n,z] format.
> I started running into trouble when I tried implementing the Hankel
> functions in a similiar manner.  My understanding is that there is no
> built-in function for them yet, so I tried the following.
> Notation[H_n_ ^(1) [z_] <=> Plus[ J_n[z_], Complex[0,1] Y_n[z_] ] ]
> Notation[H_n_ ^(2) [z_] <=> Plus[ J_n[z_], Complex[0,-1] Y_n[z_] ] ]
> Again, this was working reasonably well.  The symbols for H_n ^(1) and
> H_n ^(2) rendered properly and I was getting good results.  Until I
> tried adding another number in, prompting my first post.

Since Mathematica only knows how to operate on BesselJ or BesselY, there 
will be issues in "recognising" Hankel functions in expressions. Again, 
this is really a pattern-matching issue, rather than an Notation package 
one. If you operate on Hankel functions then you expect the result to 
also be expressed in terms of Hankel functions. One way to achieve this 
is to input expressions using the notation package (which can convert 
Hankel functions on input to combinations of BesselJ and BesselY), 
operate on this result and then use the patterns

  {BesselJ[n_, z_] -> (Hankel[1][n,z] + Hankel[2][n,z])/2,
   BesselY[n_, z_] -> (Hankel[1][n,z] - Hankel[2][n,z])/(2 I)}

(note that Hankel[1,2][n,z] is not [yet] defined) to express the answer 
as Hankel functions.

Beware of automatic simplification/transformation. For example, entering




will cause problems if your rules are expecting such combinations to be 
left untouched.
> I've made some progress on this, but there are considerably more cases
> that need to be defined.  If you want I'll post what I have so far
> (what's the best way of doing so?) for you to look at.

The easiest way is to put Notebooks in a publicly accessible location 
(for download via http, ftp, afp, ...)


Paul Abbott                                      Phone:  61 8 6488 2734
School of Physics, M013                            Fax: +61 8 6488 1014
The University of Western Australia         (CRICOS Provider No 00126G)    

  • Prev by Date: Re: Mathematica and Education
  • Next by Date: Re: Mathematica and Education
  • Previous by thread: Re: Plus Behavior Inside a Notation Box?
  • Next by thread: Compile Fourier (2)