# Inverse Function in Mathematica

How to find bConst in the following code

For[QdB = -10, QdB <= 15, QdB++;
QConst = 10^(QdB/10);
Solve[1 - (bConst - 2/QConst )*Beta[1, 2]*
Hypergeometric2F1[2, 1, 3, 1 - bConst] == 0.8, bConst];
Print[bConst]
]


I need to find bConst that makes the above expression equivalent to 0.8. I used Solve function, but it didn't work!!

• What is the answer you are looking for Mathematica to produce? You can try FunctionExpand on the left hand side. Aug 29, 2016 at 16:48
• @QuantumDot Actually, the function is inside a for loop, where the left hand side is multiplied by the variable of the for loop. This implies that x must change with each loop. What I get is that x is a constant over all the loops!! This doesn't make sense. Aug 29, 2016 at 16:57
• @QuantumDot How will FunctionExpand help finding the value of x? Aug 29, 2016 at 17:03
• Please include your Mathematica code. In this case a minimal non-working example will do.
– JimB
Aug 29, 2016 at 17:11
• ...and with the non-working example, give the result you want/expect (explicitly). Aug 29, 2016 at 17:14

FindRoot with a good starting value does the job.

For[
QdB = -10,
QdB <= 15,
QdB++;
QConst = 10^(QdB/10);
bConst /.  FindRoot[
1 - (bConst - 2/QConst)*Beta[1, 2]*
Hypergeometric2F1[2, 1, 3, 1 - bConst] == 0.8,
{bConst, 2.1/QConst}] // Echo
]


If you want to gather a list of bConst values, Table will work better for you.

• The values make sense now, but I didn't understand what you did. Why did you write bConst/. before FindRoot? In {bConst, 2.1/QConst}, why did you choose this starting point 2.1/QConst? Aug 29, 2016 at 19:53
• The output from FindRoot looks like {bConst -> 20.5017}. So when he writes bConst /. before FindRoot it is like writing bConst /. {bConst -> 20.5017}. This is a rule that says replace occurrences of bConst with the value 20.5017. Try cutting and pasting it in a fresh notebook. Aug 29, 2016 at 20:01
• FindRoot is happiest when it has a reasonable starting point for the solution. Some functions have multiple minimums and FindRoot only finds a local minimum. The value 2.1/QConst approximates the numerical solution and so provides a good starting point. Aug 29, 2016 at 20:03
• Thanks Jack for further explanations. @EngDavid: questions about /. here and about /@ and & (below the other answer) can be easily answered by selecting these characters and hitting F1 (help). Aug 29, 2016 at 20:12
• Thanks all. I appreciate your help. I will look into the symbols above. Aug 30, 2016 at 1:00
QdB = Range[-10, 15];

QConst = 10^(QdB/10);

Clear[bConst];

bConst = N[bConst /.
Solve[
1 - (bConst - 2/#)*Beta[1, 2]*
Hypergeometric2F1[2, 1, 3, 1 - bConst] == 8/10,
bConst, Reals][[1]]] & /@ QConst

(*  {25.6843, 20.5017, 16.3782, 13.0965, 10.4836, 8.40259, 6.74435, \
5.42232, 4.36775, 3.52598, 2.8536, 2.31611, 1.88608, 1.54172, \
1.26569, 1.0442, 0.866294, 0.72324, 0.608089, 0.515304, 0.440473, \
0.380073, 0.331294, 0.291885, 0.260043, 0.234322}  *)

ListLinePlot[bConst,
DataRange -> QdB[[{1, -1}]],
Frame -> True, Axes -> False,
FrameLabel -> (Style[#, 14, Bold] & /@
{"QdB", "bConst"})]


ListLogPlot[bConst,
Joined -> True,
DataRange -> QdB[[{1, -1}]],
Frame -> True, Axes -> False,
FrameLabel -> (Style[#, 14, Bold] & /@
{"QdB", "bConst"})]


• Thank you. The values make sense. bConst should decay as QdB gets larger. But why did you write bConst/. before Solve? What does &/@ do in the code? Aug 29, 2016 at 19:58
• @EngDavid - Read the documentation for Solve, Rule, ReplaceAll, Function, and Map. You need to read these to understand some of the basics of Mathematica. In general, highlight unknown symbols or operators and press F1 (Help). Aug 29, 2016 at 20:14
• OK. I will. Thanks for your help Aug 30, 2016 at 1:00