MathGroup Archive 1997

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

Search the Archive

Re: plot variation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg9605] Re: plot variation
  • From: tburton at cts.com (Tom Burton)
  • Date: Thu, 13 Nov 1997 23:24:15 -0500
  • Sender: owner-wri-mathgroup at wolfram.com

On 13 Nov 1997 18:36:05 GMT, in comp.soft-sys.math.mathematica you
wrote:

>Hello!
>
>My name is Saeed, I have problem that i hope somebody can help me. 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=20
>
>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.
>
>Thanks
>
>
This seems to be a fairly difficult problem. I don't think that
Mathematica can find a general solution as a function of lambda. Here is
a specific solution for

gamma==7/5; lambda==1;

Here are your definitions of f and g, put into Mathematical form:

f[u_]==u^(4/(gamma+1))*(1/2+1/((gamma-1)*u^2));
g[x_]==x^(4*(gamma-1)/(gamma+1))/(gamma-1)+x^(-(5-3*gamma)/(gamma+1));

I could not get solutions with Solve or NSolve, so I used FindRoot. By a
bit of trial and error, I found that I could get a solution for x====.1
by starting at u====-.2:

In[150]:==
FindRoot[f[u]====lambda^(-2(gamma-1)/(gamma+1))*g[.1],{u,-2}] Out[150]==
{u->0.896558 -0.614002 I}

When I want a series of such solutions, I usually like to creep along
the x-axis, using the result at the current value of x as the starting
guess for the next value of x. The NestList function is just right for
this. Here is a range of X's for which I want U's:

In[163]:== Xs==Range[.1,1,.05];

Here are the corresponding solutions:

In[164]:== Us==Rest at FoldList[
      u/.FindRoot[f[u]====lambda^(-2(gamma-1)/(gamma+1))*g[#2],{u,#1}]&,
    -2,Xs];

If you are like me, you'll need to study the Help on FoldList a while to
understand what is going on here. Time well spent. I'll just point out
that "Rest@" discards the initial condition "-2" from the list of
results.

The following command will plot the real and imaginary parts of u vs x:

ListPlot[Transpose[{Xs,Re[Us]}],PlotJoined->True];
ListPlot[Transpose[{Xs,Im[Us]}],PlotJoined->True];

Hope this helps.
Tom Burton


  • Prev by Date: Re: LaTeX Save?
  • Next by Date: Programming Challenge
  • Previous by thread: Re:
  • Next by thread: Re: plot variation