Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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??

share|improve this question
add comment

3 Answers 3

up vote 4 down vote accepted

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 won`t be replaced because they are not there.

share|improve this answer
add comment

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.

share|improve this answer
4  
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
1  
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
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.