[Integrate] Why two results of same eq. are different?

• To: mathgroup at smc.vnet.net
• Subject: [mg44655] [Integrate] Why two results of same eq. are different?
• From: "Sung Jin Kim" <kimsj at mobile.snu.ac.kr>
• Date: Thu, 20 Nov 2003 03:16:22 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Dear all,

I got very extraordinary results today from below two same integrals
except one is symbolic one and the other is numeric one:
A. In[1]= N[Integrate[ Log[2, 1 + 10*x]*Exp[-x]*x, {x, 0, Infinity}]]
Out[1]= -3.77002
B. In[2]= NIntegrate[ Log[2, 1 + 10*x]*Exp[-x]*x, {x, 0, Infinity}]
Out[2]= 4.05856

Why did I got the different results of these, surprisingly?

---
Sung Jin Kim
A member of MCL in SNU: kimsj at mobile.snu.ac.kr,
A MTS of i-Networking Lab in SAIT: communication at samsung.com

-----Original Message-----
From: Wolf, Hartmut [mailto:Hartmut.Wolf at t-systems.com]
To: mathgroup at smc.vnet.net
Subject: [mg44655] [mg44622] RE: [mg44599] filled plot on part of x-interval

>-----Original Message-----
>From: Murray Eisenberg [mailto:murray at math.umass.edu]
To: mathgroup at smc.vnet.net
>Sent: Monday, November 17, 2003 9:39 AM
>To: mathgroup at smc.vnet.net
>Subject: [mg44655] [mg44622] [mg44599] filled plot on part of x-interval
>
>
>How do I use a FilledPlot that fills the region under the
>graph of f[x]
>only, say, for x from 2 to 10 but still graphs the function
>itself from
>0 to 10?
>
>--
>Murray Eisenberg                     murray at math.umass.edu
>Mathematics & Statistics Dept.
>Lederle Graduate Research Tower      phone 413 549-1020 (H)
>University of Massachusetts                413 545-2859 (W)
>710 North Pleasant Street            fax   413 545-1801
>Amherst, MA 01003-9305
>

A simple trick would be:

In[1]:= << Graphics`FilledPlot`

In[3]:= f[t_] := (t/7.5)^2 + Sin[t]

In[4]:= g[t_] := f[t] /; t < 2 || t > 9
In[5]:= g[t_] := 0  /; 2 <= t <= 9

In[6]:= FilledPlot[{f[t], g[t]}, {t, 0, 10}]

The result is not quite perfect, as below and above the shaded region,
the
function is plotted twice (at different sampling), and vertical lines
are
visible at the borders of the shaded region.

In[7]:= filled = FilledPlot[f[t], {t, 2, 9}, Fills -> {Hue[2/3, .5, 1]},

DisplayFunction -> Identity]
In[8]:=
Plot[f[t], {t, 0, 10}, Prolog -> filled[[1, 2, 1, 1]],
PlotStyle -> {GrayLevel[0]}, DisplayFunction -> \$DisplayFunction]

Here only the polygon for the shading is retained from filled, but again
at
different sampling (such you may see some small open gaps, or the line
blurred over). Furthermore, the abscissa got partially hidden.

In[9]:= pl = Plot[f[t], {t, 0, 10}, DisplayFunction -> Identity]
In[10]:=
Show[pl, Graphics[filled[[1, 2, 1, 1]]], pl,
DisplayFunction -> \$DisplayFunction, AxesFront -> True]

This makes the axis visible in full, but shares the remaining defects.

With simple means, this was most satisfying to me:

In[11]:= plow = Plot[f[t], {t, 0, 2}, DisplayFunction -> Identity]
In[12]:= plhi = Plot[f[t], {t, 9, 10}, DisplayFunction -> Identity]
In[13]:=
Show[plow, filled, plhi, DisplayFunction -> \$DisplayFunction,
AxesFront -> True]

If you don't mind switching off an error message, you may do

In[20]:= g1[t_] := f[t] /; t < 2 || t > 9
In[21]:= g2[t_] := f[t]  /; 2 <= t <= 9
In[22]:=
Off[Plot::"plnr"]
In[23]:=
FilledPlot[{g1[t], g2[t]}, {t, 0, 10},
Fills -> {{{2, Axis}, Hue[1/3, .5, 1]}}]

You may seperate concerns a bit:

In[31]:= \[Theta]1[t_, {min_, max_}] := 1 /; t < min || t > max
In[32]:= \[Theta]2[t_, {min_, max_}] := 1 /; min <= t <= max
In[33]:= \[Theta][t_, {min_, max_}] := Through[{\[Theta]1, \[Theta]2}[t,
{min, max}]]

(a strange "partition of unity")

In[34]:= Off[Plot::"plnr"]

In[35]:=
FilledPlot[f[t]*\[Theta][t, {2, 9}], {t, 0, 10},
Fills -> {{{2, Axis}, Hue[1/3, .5, 1]}}]

If you want to have shading between several curves, just do e.g.

In[36]:=
FilledPlot[Append[Cos[t] \[Theta][t, {2, 9}], Sin[t]], {t, 0, 10},
Fills -> {{{2, 3}, Hue[1/6, .5, 1]}}]

In[38]:= On[Plot::"plnr"]

--
Hartmut Wolf

```

• Prev by Date: Re: Improper integral
• Next by Date: Membrane arbitray shape
• Previous by thread: Re: IO-Performance of Mathematica 4.1
• Next by thread: Re: [Integrate] Why two results of same eq. are different?