1

I am using Spherical Hankel Functions, and making a tabulated form like this :

Table[SHF[n, z ] = FunctionExpand[SphericalHankelH1[n, z]], {n, 1, 5, 
   1}] // TableForm

Now, I need to use the z as different variables, keeping it as function expansion; meaning I need SHF[n , k] now. Instead of calculating again, I am trying :

Replace[SHF[1, k], SHF[1, z] :-> z]

or

Replace[SHF[1, z], SHF[1, z] -> SHF[1, k]]

Above both just gives me SHF [1, k] and not full expansion (replacing z by k after the expansion from table)

So, I try :

SHF[1, z] /. z -> k

which gives me this error :

Syntax::sntxi: Incomplete expression; more input is needed .

I need to calculate/expand it several times keeping it k, or some other variables, so am wondering if there is a better way to do this. Also, am new at this, so might be missing something obvious!

I am using Wolfram Mathematica 12.2 Please ask me if any necessary detail is missing

ZeroTwo
  • 307
  • 1
  • 3
  • 12
  • 1
    I believe that `//TableForm` turns any expression into something formatted and cute to look at, BUT that you can't use for any further calculations. Next: `t=Table[SHF[n,z ]=FunctionExpand[ SphericalHankelH1[n,z]],{n,1,5,1}];t[[1]]/.z->k` will calculate your table of functions once and then replace the z with k in the first of those five functions. Perhaps most helpful might be for you to try to simply explain what you are REALLY trying to accomplish. – Bill Jun 15 '21 at 01:08
  • I need Table Form only for visualization of these functions. I just tried removing `//Table Form` and it works fine with `SHF[1, z] /. z -> k ` now. I didn't know the issue was with formatting due to the `//Table Form,` thanks for figuring it out for me. I will maybe assign them to other variable to visualize and continue calculations with one without being used in `//Table Form.` Not sure if that's the best way, but am not sure. – ZeroTwo Jun 15 '21 at 06:02
  • @Bill What I am really trying to do is.. I use SHF[1, z], SHF [1,k], and other variables like z and k to expand these functions, and then, I plug them in my physical equations, where I want to expand those complex equations for different variables : sometimes it's not just z or k, but a mix of variables, and I also use their derivative. Hope that clears it up more! – ZeroTwo Jun 15 '21 at 06:03
  • People who have to have `TableForm` sometimes do `(x=complicatedstuff)//TableForm` where the `()` will force the ordinary assignment to happen first and then the displayed result will be changed into `TableForm` I'm guessing you are trying to force Mathematica to evaluate things the way you want and not the way it wants. That is almost always a situation where Mathematica will fight you to the death to do it their way while you try to make it do it your way. Often succeeding at that requires WAY more knowledge and skill in the deep dark art of understanding the details of evaluation. – Bill Jun 15 '21 at 06:17

1 Answers1

1

Various manipulations shown

Clear[SHF]

Table[SHF[n, z] = FunctionExpand[SphericalHankelH1[n, z]], {n, 1, 5, 1}];

DownValues[SHF]

shows down values

Change definition, replacing z with k

SHF[1, z] = ReplaceAll[SHF[1, z], z :> k]

or equivalently

SHF[1, z] = SHF[1, z] /. z :> k

DownValues[SHF]

shows change to down values

Add new definition and remove old one

SHF[1, k] = SHF[1, z]

DownValues[SHF] = DeleteCases[DownValues[SHF, Sort -> False],
  HoldPattern[Verbatim[HoldPattern][SHF[1, z]] :> _]]

DownValues[SHF]

shows change to down values

DownValues deletion thanks to Oleksandr R..

Chris Degnen
  • 8,443
  • 2
  • 23
  • 40