Re: Different results with ReplaceAll and direct substitution
- To: mathgroup at smc.vnet.net
- Subject: [mg108973] Re: Different results with ReplaceAll and direct substitution
- From: dh <dh at metrohm.com>
- Date: Thu, 8 Apr 2010 08:04:43 -0400 (EDT)
- References: <hphq4e$1gd$1@smc.vnet.net>
On 07.04.2010 13:26, Alessio Giberti wrote: > Hi all. A vector function of one variable, defined as follows, > > Y=expA[z].(Y0+Integrate[expA[-s].b[s],{s,0,z}]) > > give me different results if I use ReplaceAll instead of writing > directly the value of z: > > Y /. z -> 0 > Out[41]= > {0.207031, 0.408203, 0.50293, 0.40625, 0.206543, 0., -0.00195313, > 0.00195313, 0., 0.} > > expA[0].(Y0 + Integrate[expA[-s].b[s], {s, 0, 0}]) > Out[42]= > {0.206431, 0.408134, 0.503139, 0.405617, 0.206019, 0., 0., 0., 0., 0.} > > > Where expA[z] is a matrix (10x10 in this case), Y0 is a vector of > constants and b is a vector of functions. Since the last 5 components of > Y0 are all zero, the first result cannot be correct! > Why these 2 different results? > Hi Alessio, in the first case, the integral is calculated symbolically and afterwards numerical values are substituted. My guess is that during the evaluation of this expression we will have truncation errors. On the other hand, the integral is evaluated numerically and the algorithmus cares about the precision. cheers, Daniel -- Daniel Huber Metrohm Ltd. Oberdorfstr. 68 CH-9100 Herisau Tel. +41 71 353 8585, Fax +41 71 353 8907 E-Mail:<mailto:dh at metrohm.com> Internet:<http://www.metrohm.com>