MathGroup Archive 1998

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

Search the Archive

Re: Plotting alogrithm question..



Christopher W Ruhl wrote:
> 
> When I use Mathematica 3.0 to plot:
> 
> Plot[Integrate[1/(1-t), {t, 0, x}], {x, -5, 5}]
> 
> I get the plot that I expect on [-5, 1) but then wild occilationS on (1,
> Inf).
> 
> I expected the plot to be the same as:
> 
> Plot[-Ln[1 - x], {x, -5, 5}].
> 
> Anyone know why the occilations after x=1 ?
> 
> any input would be appriciated!
> 
> :)
> 
> thanks,
> chris.
> 
> --
> *********************************************** Chris Ruhl
> (cruhl@u.arizona.edu)
> I think i'll do laundry tomorrow.


	The routine Integrate sometimes calls upon the routine NIntegrate.  One
of the triggers is a singularity in the integrand.  Any interval on
1/(1-x) that includes 1 has a singularity in it, the Numerical
integration routine is called and has trouble getting it to converge. 
It sounds like what you wanted was a SYMBOLIC integration and then a
plot.  
	I also bet that you had to wait a long time even to get your
unsatisfactory plot.  That is because the plot routine evaluates the
argument function for each and every point.  It does this by keeping
its first argument in a HOLD state.  The plot routine also tries to
generate a smooth looking plot and so will subdivide intervals that
have large changes in slope.  Your method involved evaluating hundreds
of symbolic and numerical integrals.  The way around this is Evaluate.

Integrate[1/(1-t), {t, 0, x}]

returns

I Pi-Log[-1+x]

We see that Mathematica put an imaginary constant on the indefinite
integral that you probably don't want to graph.  So you want to plot:

Plot[Evaluate[Re[Integrate[1/(1-t), {t, 0, x}]]],{x,-3,3}]


This generates a relatively smooth curve, handles the discontinuity and
evaluates in less than a second.
-- 
Remove the _nospam_ in the return address to respond.



  • Prev by Date: Re: exponential rule application
  • Next by Date: Re: combine two vectors to form matrix
  • Prev by thread: Plotting alogrithm question..
  • Next by thread: Simple question