       Re: Plot works in Mathematca 7 but not in Mathematica 8

• To: mathgroup at smc.vnet.net
• Subject: [mg115866] Re: Plot works in Mathematca 7 but not in Mathematica 8
• From: DrMajorBob <btreat1 at austin.rr.com>
• Date: Sun, 23 Jan 2011 05:36:25 -0500 (EST)

```Right you are. It's still a version 8 bug, I think, either way!

Bobby

On Sat, 22 Jan 2011 20:37:16 -0600, 1.156 <rob at piovere.com> wrote:

> Bobby, I'm not yet convinced you're right about that. Please consider:
>
> f := 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) 2/kn NIntegrate[
>        Exp[I (kr + ki I) y] Sin[kn y]/y, {y, 0, 2}])]
> h = 1; a = 0.0001; kn = \[Pi]/h; kr = 3.088;
> Plot[f, {ki, -0.105, -.085}]
>
> This has no _?NumericQ in it and works in M8 here.
> \$Version
> "8.0 for Microsoft Windows (32-bit) (November 7, 2010)"
>
> Rob
>
> On 11/01/22 19:20 PM, DrMajorBob wrote:
>> It's not SetDelayed that fixed the Plot (though it's necessary for other
>> reasons)... it's _?NumericQ that does it.
>>
>> Bobby
>>
>> On Sat, 22 Jan 2011 16:32:50 -0600, 1.156 <rob at piovere.com> wrote:
>>
>>> Sir, the plot looks right. It appears that the scheme of using set
>>> delayed for the plotted function allows it to work on M8. Why, I have
>>> no idea. Thank you for your help.
>>> Regards, Rob
>>>
>>> On 11/01/22 15:28 PM, DrMajorBob wrote:
>>>> 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

```

• Prev by Date: Re: Compilation options question
• Next by Date: Re: Simple n-tuple problem - with no simple solution
• Previous by thread: Re: Plot works in Mathematca 7 but not in Mathematica 8
• Next by thread: Re: Plot works in Mathematca 7 but not in Mathematica 8