[Date Index] [Thread Index] [Author Index]
Re: Plus Behavior Inside a Notation Box?
Paul, 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. For example, here's what I found... ClearNotations Notation[a + n_ <=> Plus[b, c, n_] ] b + c + d b + c + d + e a + d a + (d + e) ClearNotations Notation[a + n__ <=> Plus[b, c, n__] ] b + c + d b + c + d + e a + d a + d, e ClearNotations Notation[a + n__ <=> Plus[b, c, n___] ] b + c + d b + c + d + e a + d a + d,e 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]. 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. 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. 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. Thanks, Josh