2
$\begingroup$

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

Thanks in advance

$\endgroup$
  • $\begingroup$ What is the answer you are looking for Mathematica to produce? You can try FunctionExpand on the left hand side. $\endgroup$ – QuantumDot Aug 29 '16 at 16:48
  • $\begingroup$ @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. $\endgroup$ – EngDavid Aug 29 '16 at 16:57
  • $\begingroup$ @QuantumDot How will FunctionExpand help finding the value of x? $\endgroup$ – EngDavid Aug 29 '16 at 17:03
  • $\begingroup$ Please include your Mathematica code. In this case a minimal non-working example will do. $\endgroup$ – JimB Aug 29 '16 at 17:11
  • $\begingroup$ ...and with the non-working example, give the result you want/expect (explicitly). $\endgroup$ – QuantumDot Aug 29 '16 at 17:14
2
$\begingroup$

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
             ]

Mathematica graphics

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

$\endgroup$
  • $\begingroup$ 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? $\endgroup$ – EngDavid Aug 29 '16 at 19:53
  • $\begingroup$ 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. $\endgroup$ – Jack LaVigne Aug 29 '16 at 20:01
  • $\begingroup$ 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. $\endgroup$ – Jack LaVigne Aug 29 '16 at 20:03
  • $\begingroup$ 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). $\endgroup$ – Sjoerd C. de Vries Aug 29 '16 at 20:12
  • $\begingroup$ Thanks all. I appreciate your help. I will look into the symbols above. $\endgroup$ – EngDavid Aug 30 '16 at 1:00
2
$\begingroup$
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"})]

enter image description here

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

enter image description here

$\endgroup$
  • $\begingroup$ 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? $\endgroup$ – EngDavid Aug 29 '16 at 19:58
  • $\begingroup$ @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). $\endgroup$ – Bob Hanlon Aug 29 '16 at 20:14
  • $\begingroup$ OK. I will. Thanks for your help $\endgroup$ – EngDavid Aug 30 '16 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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