Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

RE: Re: NIntegrate and Plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30442] RE: [mg30430] Re: [mg30408] NIntegrate and Plot
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sun, 19 Aug 2001 02:01:36 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

I think this might be a faster method for making the plots. Use NDSolve to
create an InterpolatingFunction for the plotted function.

f[x_, n_:2, betaN_:121.643] := Sech[betaN*x^n]^2;

Clear[F];
F[x_] = F[x] /. NDSolve[{Derivative[1][F][x] == f[x],
      F[-0.4] == 0}, F, {x, -0.4, 0.4}][[1,1]]
InterpolatingFunction[{{-0.4, 0.4}}, "<>"][x]

Plot[F[x],
    {x, -0.4, 0.4},
    PlotStyle -> RGBColor[1, 0, 0]];

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/

> From: BobHanlon at aol.com [mailto:BobHanlon at aol.com]
To: mathgroup at smc.vnet.net
>
>
> In a message dated 2001/8/17 3:45:32 AM, y.tesiram at pgrad.unimelb.edu.au
> writes:
>
> >I would like to plot the integral of,
> >
> >(Sech[betaN * x^n])^2 ,
> >
> >where beatN=121.643 and n=2 say. I have started by making a table of x
> >values as
> >
> >np=100;
> >x1 = Table[(-0.5 + ((i -1)/(np-1)), {i,1,np}];
> >x2 = t1^n;
> >x3 = (Sech[betaN * x^n])^2;
> >
> >I have tried NIntegrate but of course that just returns the total area
> >of
> >x3.
> >
>
> f[x_, n_:2, betaN_:121.643] := Sech[betaN*x^n]^2;
>
> Plot[f[x], {x, -0.5, 0.5},
>     PlotRange -> All,
>     PlotStyle -> RGBColor[0, 0, 1]];
>
> Plot[NIntegrate[f[t], {t, -0.5, x}],
>     {x, -0.5, 0.5},
>     PlotStyle -> RGBColor[1, 0, 0]];
>
> To combine these plots into one, you would probably want to use separate
> scales for the curves.  See:
>
> http://support.wolfram.com/Graphics/Axes/TwoAxisGraph.html
>
>
> Bob Hanlon
> Chantilly, VA  USA
>



  • Prev by Date: Re: Polynomial Reduction with Mod
  • Next by Date: Re: Polynomial Reduction with Mod
  • Previous by thread: Re: NIntegrate and Plot
  • Next by thread: Re: NIntegrate and Plot