MathGroup Archive 1997

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: numerical inverse functions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg9617] Re: numerical inverse functions
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Fri, 14 Nov 1997 21:39:57 -0500
  • Organization: University of Western Australia
  • Sender: owner-wri-mathgroup at wolfram.com

Saeed Esmaily Rashid wrote:

> > The problem consists of two functions
> >
> > f(u):=u^(4/(gamma+1))*(1/2+1/((gamma-1)*u^2))
> >
> > and
> >
> > g(x):=x^(4*(gamma-1)/(gamma+1))/(gamma-1)+x^(-(5-3*gamma)/(gamma+1))
> >
> > they are related to each other by the
> >
> > f(u)=\lambda^(-2(gamma-1)/(gamma+1))*g(x)
> >
> > where lambda is some constant, the value of gamma=7/5. I want to plot a
> > graph which shows the variation of u as a function of x. I have tried
> > for many hours but i can't find the way doing it in Mathematica 3.0.0.
> > Any help appriciated.

See the attached Mathematica 3.0 Notebook which obtains the numerical
inverse of f by plotting it and then produces the relation u(x).

Cheers,
	Paul 

____________________________________________________________________ 
Paul Abbott                                   Phone: +61-8-9380-2734
Department of Physics                           Fax: +61-8-9380-1014
The University of Western Australia            Nedlands WA  6907       
mailto:paul at physics.uwa.edu.au  AUSTRALIA                            
http://www.pd.uwa.edu.au/~paul

            God IS a weakly left-handed dice player
____________________________________________________________________


Notebook[{
Cell["The functions can be written:", "Text"],

Cell[BoxData[
    \(TraditionalForm
    \`\(f\_\[Gamma]_\)(u_) := 
      u\^\(4\/\(\[Gamma] + 1\)\)\ 
        \((1\/2 + 1\/\(\((\[Gamma] - 1)\)\ u\^2\))\)\)], "Input"],

Cell[BoxData[
    \(TraditionalForm
    \`\(g\_\[Gamma]_\)(x_) := 
      x\^\(-\(\(5 - 3\ \[Gamma]\)\/\(\[Gamma] + 1\)\)\) + 
        x\^\(\(4\ \((\[Gamma] - 1)\)\)\/\(\[Gamma] + 1\)\)\/\(\[Gamma] -
1
            \)\)], "Input"],

Cell[TextData[{
  "Since you want to plot a graph which shows the variation of u as a \
function of ",
  Cell[BoxData[
      \(TraditionalForm\`x\)]],
  ", ",
  Cell[BoxData[
      \(TraditionalForm\`u \((x)\)\)]],
  " can be determined from the relation ",
  Cell[BoxData[
      \(TraditionalForm
      \`f \((u)\) = 
        \[Lambda]\^\(-\(\(2\ \((\[Gamma] - 1)\)\)\/\(\[Gamma] + 1\)\)\)\
g 
          \((x)\)\)]],
  " if we can determine the inverse function (relation) for ",
  Cell[BoxData[
      \(TraditionalForm\`f\)]],
  ". "
}], "Text"],

Cell["Obtaining the plotpoints from the plot", "Text"],

Cell[BoxData[
    \(TraditionalForm\`\(Plot[\(f\_\(7/5\)\)(u), {u, 0.01, 1}]; \)\)], 
  "Input"],

Cell[BoxData[
    \(TraditionalForm\`\(p = Cases[%, Line[{x__}] \[Rule] x,
\[Infinity]]; 
    \)\)], "Input"],

Cell[TextData[{
  "we can use interpolation to obtain a numerical inverse function (the
\
inverse is not unique so we have to chose the appropriate branch when we
plot \
",
  Cell[BoxData[
      \(TraditionalForm\`\(f\_\(7/5\)\)(u)\)]],
  "):"
}], "Text"],

Cell[CellGroupData[{

Cell[BoxData[
    \(TraditionalForm\`invf1 = Interpolation[Reverse/@p]\)], "Input"],

Cell[BoxData[
    FormBox[
      TagBox[
        RowBox[{"InterpolatingFunction", "(", 
          RowBox[{
            RowBox[{"(", GridBox[{
                  {"3.00000000000000088`", "11.6041882096514403`"}
                  },
                ColumnAlignments->{Decimal}], ")"}], ",",
"\<\"<>\"\>"}], 
          ")"}],
        False,
        Editable->False], TraditionalForm]], "Output"] }, Open  ]],

Cell["As a check, this is what this inverse branch looks like:",
"Text"],

Cell[BoxData[
    \(TraditionalForm\`\(Plot[invf1[t], {t, 3, 11}]; \)\)], "Input"],

Cell["Introducing", "Text"],

Cell[BoxData[
    \(TraditionalForm
    \`\(k\_\(\[Gamma]_, \[Lambda]_\)\)(x_) := 
      \(\[Lambda]\^\(-\(\(2\ \((\[Gamma] - 1)\)\)\/\(\[Gamma] +
1\)\)\)\) 
        \(\(g\_\[Gamma]\)(x)\)\)], "Input"],

Cell[TextData[{
  "then, for ",
  Cell[BoxData[
      \(TraditionalForm\`\[Lambda]( = 1)\)]],
  " constant, here is one branch of the ",
  Cell[BoxData[
      \(TraditionalForm\`u(x)\)]],
  ". "
}], "Text"],

Cell[BoxData[
    \(TraditionalForm\`\(p1 = Plot[invf[\(k\_\(7/5, 1\)\)(x)], {x, 0.7,
8}]; 
    \)\)], "Input"],

Cell["Here is the other branch:", "Text"],

Cell[BoxData[
    \(TraditionalForm\`\(Plot[\(f\_\(7/5\)\)(u), {u, 1, 10}]; \)\)], 
  "Input"],

Cell[BoxData[
    \(TraditionalForm\`\(p = Cases[%, Line[{x__}] \[Rule] x,
\[Infinity]]; 
    \)\)], "Input"],

Cell[CellGroupData[{

Cell[BoxData[
    \(TraditionalForm\`invf2 = Interpolation[Reverse/@p]\)], "Input"],

Cell[BoxData[
    FormBox[
      TagBox[
        RowBox[{"InterpolatingFunction", "(", 
          RowBox[{
            RowBox[{"(", GridBox[{
                  {"3.00000000000011723`", "24.3683399404755629`"}
                  },
                ColumnAlignments->{Decimal}], ")"}], ",",
"\<\"<>\"\>"}], 
          ")"}],
        False,
        Editable->False], TraditionalForm]], "Output"] }, Closed]],

Cell[BoxData[
    \(TraditionalForm\`\(p2 = Plot[invf2[\(k\_\(7/5, 1\)\)(x)], {x, 0.7,
8}]; 
    \)\)], "Input"],

Cell["and we can show both branches together:", "Text"],

Cell[BoxData[
    \(TraditionalForm\`\(Show[p1, p2]; \)\)], "Input"] }
]


  • Prev by Date: Re: Finance Pack ListPlot3D
  • Next by Date: Re: How to solve 2D geometry problem in Mathematica
  • Previous by thread: (Newbie) Replace without Evaluation
  • Next by thread: Re: Book recommendation for Mathematica