Message Boards Message Boards

0
|
26647 Views
|
41 Replies
|
8 Total Likes
View groups...
Share
Share this post:

Runing a FoxH code in Mathematica

Posted 11 years ago
I would like to ask if I have a Mathematica code of a specific function and I need to use this code in Mathematica to get some values of this function, How Can I do this? I tried to copy the code into new notebook file but unfortunatelly it did not work
Please help me to solve this problem, because I am new in using Mathematica
Thanks in advanced 
POSTED BY: Hosam rh
41 Replies
Posted 11 years ago
CAREFULLY type the Mathematica code from Appendix A of the paper you linked to into a new empty Mathematica notebook page, or perhaps find the author has a .nb file on the net with this already done. Every character in this must be exactly correct.

Then save the notebook for later use using File Save.

Then on a new separate line type  FoxH[ a,b,z ] where you replace those a,b,z with appropriate numbers and then hold down the shift key while pressing the Enter key. It should calculate for a while and display the result. Choose numbers where you can check the result at first.

This is a very simple example
FoxH[a_,b_,z_]:=2*a-b+z;
FoxH[3,7,12]
If I enter that into a notebook and press <shift><enter> it will evaluate the definition of the FoxH function and then use that function to calculate the value 11. But you must substitute the actual FoxH code from the Appendix A.
POSTED BY: Bill Simpson
Posted 11 years ago
Thank you very much Mr. Simpson for your great suppurt, I attached the code below
Thanks again
Attachments:
POSTED BY: Hosam rh
Posted 11 years ago
Ah, thank you. I apologize for not seeing your post with the attached notebook.

If I open that notebook and evaluate the large cell containing the definition of FoxH and then evaluate your cell trying to use FoxH I get the same result that you do.
In[9]:= FoxH[{{{-2,1}}},{{{0,1}}},-0.5,
OptionsPattern[{FoxHFractionTolerance,FoxHDuplicationLimit,FoxHWorkingPrecision}]]

Out[9]= FoxH[{{{-2,1}}},{{{0,1}}},-0.5,OptionsPattern[{FoxHFractionTolerance,FoxHDuplicationLimit,FoxHWorkingPrecision}]]
When Mathematica returns the expression you just evaluated and does not change it that usually means that Mathematica does not understand how to do that. Many new users are confused when it does this and does not print a message explaining.I am very puzzled by this and spend time trying to find what mistake I might have made. I carefully check spelling and capitalization and {} and find nothing.

I find and read this
https://reference.wolfram.com/mathematica/ref/character/RightArrow.html
and I change the seven "right arrow" unicode characters in the code to the two characters -> which Mathematica will understand as a "Rule" construct.

I read this and look at the examples
http://reference.wolfram.com/mathematica/ref/OptionsPattern.html
I then try this, also using -> which Mathematica will understand as a "Rule" construct.
FoxH[{{{-2,1}}},{{{0,1}}},-0.5,{FoxHFractionTolerance->0.001,
FoxHDuplicationLimit->50,FoxHWorkingPrecision->$MachinePrecision}]
and it gives a variety of errors, but I suspect those are "good" errors and reflect the very simple example data that you used.

Please make these changes and see if you get the same results. Then try using data which will give a result that you can verify and see if this works.

There are more things about the Options which I think may need further changes, but you should be able to get started using the code.
I believe it is possible, if you wish to use the default values for options, to do this
FoxH[{{{-2, 1}}}, {{{0, 1}}}, -0.5]
POSTED BY: Bill Simpson
Posted 11 years ago
Dear Hosam rh,
Would you mind sending me your final version of this Fox H function? I am also facing the same problem with you in typing the code in that paper.
Please help me for overcoming this problem.
Thanks in advance.
POSTED BY: Thanh Tu
Posted 11 years ago
Dear Hosam rh,
I am working a project that contains the calculation of the Fox H function. Could you please send a copy of your final version to me ?

Thanks a lot.
POSTED BY: Fulu Zheng
Posted 11 years ago
Dear Hosam rh,
I am working a project that contains the calculation of the Fox H function. Could you please send a copy of your final version to me ?
Thanks a lot.
POSTED BY: Fulu Zheng
Posted 11 years ago

Dear Hosam rh, I am very interested in Fox H function, I hope that you can share me the final version of the implementation code. Thank you and regards,

POSTED BY: Ti Ho
Posted 11 years ago

Dear Hosam rh, I am working on a research paper that requires the calculation of the Fox's H function. I would appreciate it if you could you please send a copy of your final version of your code sequence to me. The H Function is a very very complex contour integration. Numerical methods is the right approach to solving it.

Thank you. T. Hassett

POSTED BY: Thomas Hassett
For example, I define a function and setup the tool to table some values. I hope this is what you wish. Otherwise please post an example. Thank you.
(* iabraham, Mathematica 7.0.1.0, Win-7-64b *)
Clear["Global`*"]; (* Clear memory *)

f[x_] := Sin[x] x; (* Define the function *)
Table[ f[x],{x, 0, Pi, Pi/4}] (* Tabulate some values *)
POSTED BY: Isaac Abraham
Posted 11 years ago
Thank you very much for your reply Mr. Abraham,
the code have too many steps to implement the function that I need, It is the Fox-H function if you know it,
I attached the paper that includes the code (in its appendix), I would like to know how to use any written code in Mathematica.
Thanks in advanced 
Attachments:
POSTED BY: Hosam rh
Posted 11 years ago
Thank you Mr. Hardesty for this link, the problem that I face is how to run such codes in Mathematica, is it to copy the code to a file.nb and just define the variables, or there is something to do with these codes
Thanks again
POSTED BY: Hosam rh
Posted 11 years ago
Thank you very much Mr. Simpson for your comment, I try this:
FoxH[{{{1 , 1/2}}, {{1/2 , 3}}}, {{{0, 1}}, {{1/2 , 2}}}, 0.1]
but the output is 
FoxH(({1,1/2}{1/2,3} ),({0,1} {1/2,2}),0.1)
so the function does nothing !!!!!! 
Do you have any idea about that?
Thanks in advance.
POSTED BY: Hosam rh
Posted 11 years ago
I must tell Mathematica the definition of FoxH and evaluate this and then use the definition of FoxH.

Here is what I see when I evaluate each line of my notebook with <shift><enter>
In[1]:= FoxH[a_, b_, z_] := 2*a - b + z;

In[2]:= FoxH[{{{1, 1/2}}, {{1/2, 3}}}, {{{0, 1}}, {{1/2, 2}}}, 0.1]

Out[2]= {{{2.1, 0.1}}, {{0.6, 4.1}}}

Perhaps this tutorial can help you better understand how to use functions in Mathematica.

http://reference.wolfram.com/mathematica/tutorial/DefiningFunctions.html

Attached is a copy of my notebook which you can download and also try
Attachments:
POSTED BY: Bill Simpson
Posted 11 years ago
Thanks again for your quick reply, 
I understood your example and I used it, so I got the idea of using such a function,
but I think there is something that I have not understand when I used the code in the paper specifically how to define the input variables, where the function do nothing when I define its variables, so I am trying now hoping there will some results 
Thanks again,
I appreciate your help
POSTED BY: Hosam rh
Posted 11 years ago
If you can make a post and attach a small notebook containing your code and explain what is not working then perhaps someone can help.
POSTED BY: Bill Simpson
Posted 11 years ago
I made what you had suggested, and the results appear better than the first time, I think there may some mistakes in writing this code, because I copied every line from the paper and put it into the notebook file, the 'right row" problem is one of that, I am going to rewrite it again without copying from the paper hoping it will do better and try to solve the errors that appear.
Thank you very very much Mr. Simpson for all of your help.
POSTED BY: Hosam rh
Posted 11 years ago
This is the latest version of this code, if anyone need to have a look on it 
Thanks in advanced
Attachments:
POSTED BY: Hosam rh
Posted 11 years ago
In the Foxh.nb attached to the previous message I find the following.

If I have not introduced any errors in opening your notebook on my system

Inside the next to last Do loop you have Z=ZPower and that should be Z=Z  Power (with a space or even * between those)
Inside the next to last Do loop you have G=GSqrt and that should be G=G  Sqrt (same)
Inside the last Do loop you have Z=ZPower and that should be Z=Z Power (same)

I do not see any additional differences between your code and the pdf paper, but I might have missed some.

I assume you are working on the rest of the code in the Module from the paper.
POSTED BY: Bill Simpson
Posted 11 years ago
Thank you Mr. Simpson,
I checked it again and corrected some mistakes which similar to what you had mentioned in you last reply.
The code still not runing correctly, but I am trying to see some solution hoping it will run better.
Thank you again for all helps and supports
Attachments:
POSTED BY: Hosam rh
Posted 11 years ago
I am very glad you are making progress on your problem. I am impressed.

Do you know of a set of very simple inputs to FoxH where you know what the result should be?
Or perhaps even know what some of the subcalculations inside FoxH should be?

If you are able to provide that then perhaps it will be possible to help track down and fix more problems.
POSTED BY: Bill Simpson
Posted 11 years ago
I have a reference about H-function which I used in my works, there are many simple cases of H function that can be solved with some calculations like eq.1.43 in the reference [16 in case of H_{1,1}^{1,1}=[-0.5|{-2,1};{0,1}] ]. The authors of the paper that includes the Mathematica H-function code are expert in their field and I am sure that this code is totally true, but the main problem is how to use it correctly, as you saw there was some mistakes when I wrote the code, and may be there are some others, I am trying to understand each step in the code, hoping I will get something interesting.
Thank your again Mr. Simpson

Reference:
https://www.google.com.eg/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=0CEUQFjAC&url=http%3A%2F%2Fbib.tiera.ru%2Fb%2F91087&ei=DdIyU5zKN9OGswaQ-oGYDg&usg=AFQjCNEoc43d7Rir_eRguLVBNPafXOfcWQ
POSTED BY: Hosam rh
Posted 11 years ago
Good news, 
The code is working well now, and I tested some H-function and I got true results,
I would like to thank every one who helped me to solved some problems, especially Mr. Bill Simpson for his great help and supports
POSTED BY: Hosam rh
Posted 11 years ago

Hi, has anyone have a working copy of this implementation of the H function that wouldn't mind sharing? I will be forever grateful.

thanks in advance

POSTED BY: Germán C
Posted 8 years ago

Hello, Just finding out if anyone can send me a working copy of the implementation of the H function. thanks in advance.

POSTED BY: Kapo Cossy
Posted 7 years ago

The codes in Foxh.nb are true. The correct usage of FoxH is enter image description here

Example: enter image description here

The results of MMA : enter image description here

POSTED BY: Yulong Fu
Posted 7 years ago

Hi Yulong,

Could you please send me a working copy of the H function code?

Thanks, Assad

POSTED BY: Assad Akhlaq
Posted 7 years ago

Dear Assad Akhlaq,

The H function code in the "Attachments: Foxh.nb" posted by Hosam rh is true. In the "Attachments: FoxH and Example.nb", I just added an example. I hope this is what you wish.

Attachments:
POSTED BY: Yulong Fu
Posted 7 years ago

Dear Yulong Fu,

Yes, I was able to run (yesterday) the FoxH function in the attached notebook. Now I am stuck with the FoxHbar function that is provided in the appendix B of the paper "New Results on the Sum of Gamma random Variates With Application to the Performance of Wireless Communication Systems over Nakagami-m Fading Channels". I am not quite familiar with FoxH functions (just started looking at them 2 days ago). For FoxHBar function I am having trouble in calling the function. Some problem in the use of curly brackets. Could you please help me in its correct usage (if possible for you). FoxHBar is attached.

Thanks, Assad

Attachments:
POSTED BY: Assad Akhlaq
Posted 7 years ago

Dear Assad Akhlaq,

According to the Eq.(4) in the "New Results on the Sum of Gamma random Variates With Application to the Performance of Wireless Communication Systems over Nakagami-m Fading Channels" and the Fox's Hbar definition Eq.(A.2), I think the use of FoxHBar is correct in the "Attachments: FoxHBar(1).nb", but I do not know why the output is imaginary. I hope it helps you.

Attachments:
POSTED BY: Yulong Fu
Posted 7 years ago

Dear Yulong Fu,

Thank you very much for your help. It is indeed very helpful for me. But I don't understand how the brackets in the call to FoxHBar correspond to Eq.(4). Could you please help me understand it (i.e. could you please elaborate it)? I also want to use Eq. (27) of this paper now and without this understanding I can use Eq. (27).

Many thanks, Assad

POSTED BY: Assad Akhlaq
Posted 7 years ago

Dear Yulong Fu,

After giving it a bit of thought I understand that how these brackets are used during the call to FoxHBar. But when I used the same concept to use Eq.(27) I am not getting correct results. Am I right in defining 'a' and 'b' as below

a = { {1-m1/Omega1, 1, m1}, {1-m2/Omega2, 1, m2}, {1-m3/Omega3, 1, m3}, {1,1,1} } b = { {-m1/Omega1, 1, m1}, {-m2/Omega2, 1, m2}, {-m3/Omega3, 1, m3}, {0,1,1} } z = Exp[2];

and call FoxHBar as

1 + (m1/Omega1)^m1(m2/Omega2)^m2FoxHBar[ { a, {} }, { {}, b }, z ]

Please tell me if I am doing it wrong?

Thanks, Assad

POSTED BY: Assad Akhlaq
Posted 7 years ago

Runing a FoxH code in Mathematica

POSTED BY: Yulong Fu
Posted 7 years ago

Dear Assad Akhlaq,

I think the result is very sensitive to R. R depends on numerator argument i.e.it must be at least half of the least valued gamma arguments (the annotation in the FoxH function codes). When you set R=-1/2, the output is correct.

POSTED BY: Yulong Fu
Posted 7 years ago

Dear Yulong Fu,

What are the numerator arguments here (for example for L = 5)?

Thanks, Assad

POSTED BY: Assad Akhlaq
Posted 7 years ago

So numerator arguments are -m/Omega values and R should be least half of the least valued gamma arguments?

POSTED BY: Assad Akhlaq
Posted 7 years ago

Dear Assad Akhlaq,

I hope the " Attachments: FoxHBar (2).nb" helps you.

Attachments:
POSTED BY: Yulong Fu
Posted 7 years ago

Dear Yulong Fu,

Thank you very much. Very well explained. You are great!

Regards, Assad

POSTED BY: Assad Akhlaq

Dear Sir I am using the code but not able to get the correct results for example for this FoxH[{{{-2, 1}}, {{}}}, {{{0, 1}}, {{}}}, -0.5] result is showing as 3. I am confused how to provide input arguments.

POSTED BY: RUPENDER SINGH
Posted 6 years ago

Respected Sir, I hope you are all fine. Recently, during our research work, we have encountered the FoxH to solve some numerical integration consisting of three MeijerG functions. Therefore to solve this, I have used your codes.
and its working fine for a single variable. But I am in trouble in writing for two variableFoxH functions.

So my heartily request, please help me out to solve two variableFoxH functions using MATHEMATICA.
(We are using Wolfram Mathematica-11.0).

Attachments:
POSTED BY: Banibrata Bag
Posted 6 years ago

k1 = {{{1, 1}, {1, 1}}, {}} ; k11 = {{{1, 1}}, {{0, 1}}}; g = (1 + 10^(15/10)); out = Abs[Hfunction[k1, k11, g, 2000] ]; Print[out]; (** gives 3.5152 **) (**************)

and N[Log[1 + 10^(15/10)]]
(** gives 3.48501 **)

POSTED BY: Banibrata Bag
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract