Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2011

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

Search the Archive

Re: Plot works in Mathematca 7 but not in Mathematica 8 [CORRECTION]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg115873] Re: Plot works in Mathematca 7 but not in Mathematica 8 [CORRECTION]
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sun, 23 Jan 2011 05:37:51 -0500 (EST)

I left off the definition of a in my previous response. Use this

f[ki_?NumericQ, h_, a_, kn_?NumericQ, kr_?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}])]

h = 1; a = 0.0001; kn = Pi/h; kr = 3.050;

Plot[f[ki, h, a, kn, kr], {ki, -0.23, -.10}]


Bob Hanlon


---- Bob Hanlon <hanlonr at cox.net> wrote: 

=============

Works if you pull the function out of the Plot.

$Version

"8.0 for Mac OS X x86 (64-bit) (November 6, 2010)"

f[ki_?NumericQ, h_, kn_?NumericQ, kr_?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}])]

h = 1; kn = Pi/h; kr = 3.050;

Plot[f[ki, h, kn, kr], {ki, -0.23, -.10}]


Bob Hanlon

---- "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}]
-- 



  • Prev by Date: Re: a bug in Mathematica 7.0?
  • Next by Date: Re: Do I need MathLink to run finite-difference fast enough for
  • Previous by thread: Re: Wavelet and histogram
  • Next by thread: Mathematica 20x slower than Java at arithmetic/special functions, is