MathGroup Archive 2000

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

Search the Archive

Re: Problem with Integration

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22524] Re: Problem with Integration
  • From: Hendrik van Hees <h.vanhees at gsi.de>
  • Date: Thu, 9 Mar 2000 03:24:15 -0500 (EST)
  • Organization: GSI Darmstadt
  • References: <8a53ai$dln@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hans Friedrich Steffani wrote:
> 
> In[1]:= U[f_]:=1.0*Integrate[Cos[(f*Pi)/(180*2) + alpha],{alpha,-(Pi/3), Pi/3}]
> 
> In[2]:= U[60]
> 
>                         -16
> Out[2]= 1.5 - 6.08617 10    I
> 
> In[3]:= Integrate[Cos[(f*Pi)/(180*2) + alpha],{alpha, -(Pi/3), Pi/3}]
> 
>                     f Pi
> Out[3]= Sqrt[3] Cos[----]
>                     360
> 
> Cos[f Pi/360] should be real vor any real f. How can I avoid results
> like Out[2] (exepct using Chop[] or Re[])?

Why don't you use In[3] as definition? This calculates your integral
exactly while In[1] uses machine precision numbers (due to the 1.0 in
front of the expression). Doing so you get exactly 3/2 as you like.

If you want numerical output you should use N around the whole
expression. Calculate as many as possible exactly with Mathematica.

I hope I'm not too naughty if I say here that nevertheless for numerical
calculations which are more "number crunching" other tools like C, C++
or Fortran are much faster than Mathematica even Wolfram claims that not
to be true, at least if you want to program procedural for which task
Mathematica is not designed for. 

Not to be misunderstood: Using built in numerics like NIntegrate,
NDSolve etc. of course has enhanced in speed dramatically from version
3.0 to 4.0. I'm not familiar with MathLink but perhaps this would be a
nice alternative to use the great analytical features of Mathematica
together with own numerics.



-- 
Hendrik van Hees		Phone:  ++49 06159 71-2755
c/o GSI-Darmstadt THE		Fax:    ++49 06159 71-2990
Planckstr. 1			mailto:h.vanhees at gsi.de
D-64291 Darmstadt		http://www.gsi.de/~vanhees/vanhees.html


  • Prev by Date: Re: Graphing Functions
  • Next by Date: Re: string-variable-Set-snarl
  • Previous by thread: Re: Problem with Integration
  • Next by thread: Re: Problem with Integration