Re: Plot works in Mathematca 7 but not in Mathematica 8
- To: mathgroup at smc.vnet.net
- Subject: [mg115855] Re: Plot works in Mathematca 7 but not in Mathematica 8
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Sun, 23 Jan 2011 05:34:16 -0500 (EST)
I also got an empty Plot in version 8, but I found two solutions.
First, the awkward one:
h = 1; a = 0.0001; kn = Pi/h; kr = 3.050;
ListPlot[pts =
Table[{ki,
Abs[((kn^2 - (kr + ki I)^2)*(4 h (Log[4 h/a] -
NIntegrate[(1 - Exp[I (kr + ki I) y Cos[kn y]])/y, {y, 0,
2}]) +
I/((kr + ki I) + kn) (Exp[I 2 ((kr + ki I) + kn) h] - 1) +
I/((kr + ki I) - kn) (Exp[I 2 ((kr + ki I) - kn) h] -
1)) - (kn^2 + (kr + ki I)^2)*
NIntegrate[
Exp[I (kr + ki I) y] Sin[kn y]/y, {y, 0,
2}])]}, {ki, -0.23, -.10, .001}], Joined -> True]
Is that what the plot should look like?
If it is, you get a good approximation to the function with
f = Interpolation@pts;
Plot[f@ki, {ki, -.23, -.1}]
Finally, the simple solution:
h = 1; a = 0.0001 // Rationalize; kn = Pi/h; kr = 3.050 // Rationalize;
g[ki_?NumericQ] :=
Abs[((kn^2 - (kr + ki I)^2)*(4 h (Log[4 h/a] -
NIntegrate[(1 - Exp[I (kr + ki I) y Cos[kn y]])/y, {y, 0,
2}]) + I/((kr + ki I) + kn) (Exp[
I 2 ((kr + ki I) + kn) h] - 1) +
I/((kr + ki I) - kn) (Exp[I 2 ((kr + ki I) - kn) h] -
1)) - (kn^2 + (kr + ki I)^2)*
NIntegrate[Exp[I (kr + ki I) y] Sin[kn y]/y, {y, 0, 2}])]
Plot[g@ki, {ki, -0.23, -.10}]
Bobby
On Sat, 22 Jan 2011 02:24:31 -0600, 1.156 <rob at piovere.com> wrote:
> I've found very little to complain about using Mathematica 8 but I just
> ran into a
> Plot which only displays the two plot axes, no graph. Fortunately I
> still have Mathematica 7 installed and found that Mathematica 7 Plots
> this same code nicely.
> Can anyone give me clues on what may make this work correctly in
> Mathematica 8?
> Code below, thanks.
>
> ***************
> h = 1; a = 0.0001; kn = Pi/h; kr = 3.050;
> Plot[Abs[((kn^2 - (kr + ki I)^2)*
> (4 h (Log[4 h/a] -
> NIntegrate[(1 - Exp[I (kr + ki I) y Cos[kn y]])/y, {y, 0, 2}]) +
> I/((kr + ki I) + kn) (Exp[I 2 ((kr + ki I) + kn) h] - 1) +
> I/((kr + ki I) - kn) (Exp[I 2 ((kr + ki I) - kn) h] - 1) ) -
> (kn^2 + (kr + ki I)^2)*
> NIntegrate[
> Exp[I (kr + ki I) y] Sin[kn y]/y, {y, 0, 2}])], {ki, -0.23, -.10}]
--
DrMajorBob at yahoo.com