# Ways to change an explicit function into a pure function

I'm trying to use FixedPoint to solve a transcendental equations, but the first argument of the FixedPoint should be a pure function, But the function I have to use is an explicit function from a lot of preceeding symbolic calculations and is very complicated, e.g.,

func=-HankelH1[1, 0.6 Sqrt[27.415568 - \[Beta]^2]] ((1/(
57.641231 - \[Beta]^2))
1.6666667 \[Beta] BesselJ[1,
0.6 Sqrt[57.641231 - \[Beta]^2]] ((
1.6666667 \[Beta] BesselJ[1,
0.6 Sqrt[57.641231 - \[Beta]^2]] HankelH1[1,
0.6 Sqrt[27.415568 - \[Beta]^2]])/(27.415568 - \[Beta]^2) - (
1.6666667 \[Beta] BesselJ[1,
0.6 Sqrt[57.641231 - \[Beta]^2]] HankelH1[1,
0.6 Sqrt[27.415568 - \[Beta]^2]])/(57.641231 - \[Beta]^2))


My failed effort is to use Function[\[Beta],func]&, but it seems the value of func doesn't get into the Function, because of scoping problem I think.

Is there any clever way to change functions like this to be a pure function??

-

If you use explicit Function, you don't need &. That would be Function@Function...

Try Function[\[Beta], Evaluate@func]. The Evaluate is because otherwise func would only get evaluated AFTER replacing \[Beta] with the values when doing, e.g, Function[\[Beta], func][3.], so they just wont be replaced because they are not there.

-

I don't think you need to worry about Function in this question at all. Instead, you could just take your expression func with the parameter \[Beta] and define a new function as follows:

f[\[Beta]_] = func


Here I used a = instead of an := to get the evaluated expression func as the replacement for the pattern f[\[Beta]_], where \[Beta]_ with an underscore names the pattern that is then used as the value for \[Beta] on the righthand side.

Now you should be able to use f in the FixedPoint like this

FixedPoint[f, startingValue]


All that is really needed for FixedPoint is that the first argument has to have a "slot" into which the iterated results can be inserted. You can define that "slot" using Function, using #...& or by the means I chose. The latter is the simplest in this case where an expression already exists that has the desired variable as a parameter.

-

I've found a way to cope with this problem, albeit not so elegant.

    func=-HankelH1[1, 0.6 Sqrt[27.415568 - \[Beta]^2]] ((1/(
57.641231 - \[Beta]^2))
1.6666667 \[Beta] BesselJ[1,
0.6 Sqrt[57.641231 - \[Beta]^2]] ((
1.6666667 \[Beta] BesselJ[1,
0.6 Sqrt[57.641231 - \[Beta]^2]] HankelH1[1,
0.6 Sqrt[27.415568 - \[Beta]^2]])/(27.415568 - \[Beta]^2) - (
1.6666667 \[Beta] BesselJ[1,
0.6 Sqrt[57.641231 - \[Beta]^2]] HankelH1[1,
0.6 Sqrt[27.415568 - \[Beta]^2]])/(57.641231 - \[Beta]^2));

f=(Evaluate[func/.\[Beta]->#])&;


But I'm still waiting for a more clever way.

-
Maybe you are misunderstanding something. You do not need to use a pure function in FixedPoint. That's just something people do for convenience when they don't want to give a function a separate name. Now you are giving a function a separate name (f), but trying hard to make it look like a pure function, which is completely unnecessary. All you need to do is to define a "function" with a slot from the expression func that you have. Note that func is not an "explicit function" as you call it. It has no function slots. – Jens Jun 20 '12 at 6:41
Is just defining func[\[Beta]_] = ... and then using FixedPoint[func,x0]` not an option ? – b.gatessucks Jun 20 '12 at 21:01
@b.gatessucks, thank you.+1 – yulinlinyu Jun 21 '12 at 1:14