Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

## Re: [Reduce-algebra-developers] problem with depend that seems erroneous

 Re: [Reduce-algebra-developers] problem with depend that seems erroneous From: Rainer Schöpf - 2013-05-15 19:27:52 ```On Wed, 15 May 2013 at 08:10 +0930, Tony Roberts wrote: > the following code causes me grief with derivatives and dependencies, > and looks like an error that needs fixing. > operator x; operator pp; > % for j:=1:2 do depend pp,x(j); % why is this not needed? > let df(pp,x(~j))=>pp(j); > thisIsOK:=df(pp^2,x(1)); > shouldBeZero:=df(pp^2,t); > end; > > On my Reduce it generates > thisisok := 2*pp(1)*pp > shouldbezero := 2*df(pp,t)*pp > and the second is certainly not what I want, and causes me grief. > Further, why is the "depend pp,x(j)" statement not needed? When you add a rule for differentiation, a suitable dependency is added automatically, ie. let df(pp,x) => something; effectively adds depend pp,x; The exception is the case of differentiation w.r.t. a free variable, eg., let df(pp,~y) => x(y); since a dependency on a free variable doesn't make sense. What happens here is that your rule defines differentation w.r.t. an expression containing a free variable. Unfortunately, this general case is not checked, and you end up with a dependency of pp on x(~j). Now, when you enter df(pp,t); Reduce checks whether x depends on t; if that happens to be the case, the correct answer would either be df(pp,t); (if the switch expanddf is off), or df(pp,x)*df(x,t); if the switch expanddf is on. In your case it checks whether x(~j) depends on t. A free variable may be replaced by an arbitrary expression, and therefore x(~j) is treated as being dependent on anything. I'll test a correction in the next few days. Rainer ```

 [Reduce-algebra-developers] problem with depend that seems erroneous From: Tony Roberts - 2013-05-14 22:40:26 ```-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all, the following code causes me grief with derivatives and dependencies, and looks like an error that needs fixing. operator x; operator pp; % for j:=1:2 do depend pp,x(j); % why is this not needed? let df(pp,x(~j))=>pp(j); thisIsOK:=df(pp^2,x(1)); shouldBeZero:=df(pp^2,t); end; On my Reduce it generates thisisok := 2*pp(1)*pp shouldbezero := 2*df(pp,t)*pp and the second is certainly not what I want, and causes me grief. Further, why is the "depend pp,x(j)" statement not needed? I have reduce running as pslbuild/x86_64-mac_10.6_snowleopard-darwin10.6.0/red/reduce.img Reduce (Free PSL version), 6-Jan-2012 ... Tony - -- - --------------------------------------------------------------------- Professor A.J. Roberts School of Mathematical Sciences phone: +61 8 8313 3035 University of Adelaide fax: +61 8 8313 3696 South Australia 5005. mailto:anthony.roberts@... http://www.maths.adelaide.edu.au/anthony.roberts/ ==.0000001000000100000110001000011010001111110010111011101000010000== -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAlGSvVEACgkQ7TX8dTbro1ukCgCdEloE0FuAtTgQ1OYqk+/abK/l me4AmwbNXKONPKA9TeUEA7GtuDdo35Ha =nzmO -----END PGP SIGNATURE----- ```
 Re: [Reduce-algebra-developers] problem with depend that seems erroneous From: Rainer Schöpf - 2013-05-15 19:27:52 ```On Wed, 15 May 2013 at 08:10 +0930, Tony Roberts wrote: > the following code causes me grief with derivatives and dependencies, > and looks like an error that needs fixing. > operator x; operator pp; > % for j:=1:2 do depend pp,x(j); % why is this not needed? > let df(pp,x(~j))=>pp(j); > thisIsOK:=df(pp^2,x(1)); > shouldBeZero:=df(pp^2,t); > end; > > On my Reduce it generates > thisisok := 2*pp(1)*pp > shouldbezero := 2*df(pp,t)*pp > and the second is certainly not what I want, and causes me grief. > Further, why is the "depend pp,x(j)" statement not needed? When you add a rule for differentiation, a suitable dependency is added automatically, ie. let df(pp,x) => something; effectively adds depend pp,x; The exception is the case of differentiation w.r.t. a free variable, eg., let df(pp,~y) => x(y); since a dependency on a free variable doesn't make sense. What happens here is that your rule defines differentation w.r.t. an expression containing a free variable. Unfortunately, this general case is not checked, and you end up with a dependency of pp on x(~j). Now, when you enter df(pp,t); Reduce checks whether x depends on t; if that happens to be the case, the correct answer would either be df(pp,t); (if the switch expanddf is off), or df(pp,x)*df(x,t); if the switch expanddf is on. In your case it checks whether x(~j) depends on t. A free variable may be replaced by an arbitrary expression, and therefore x(~j) is treated as being dependent on anything. I'll test a correction in the next few days. Rainer ```
 Re: [Reduce-algebra-developers] problem with depend that seems erroneous From: Tony Roberts - 2013-05-16 02:03:36 ```-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, thanks for the explanation. I also tried, without success, df(pp,x(~j))=>pp(j) when fixp(j) It seems the generic nature of the ~j still affects other derivatives. In the interim I have switched to using mkid() which is OK for my purposes, at the expense of more let rules (one for each). Tony On 16/05/13 4:57 AM, Rainer Schöpf wrote: > On Wed, 15 May 2013 at 08:10 +0930, Tony Roberts wrote: > >> the following code causes me grief with derivatives and >> dependencies, and looks like an error that needs fixing. operator >> x; operator pp; % for j:=1:2 do depend pp,x(j); % why is this not >> needed? let df(pp,x(~j))=>pp(j); thisIsOK:=df(pp^2,x(1)); >> shouldBeZero:=df(pp^2,t); end; >> >> On my Reduce it generates thisisok := 2*pp(1)*pp shouldbezero := >> 2*df(pp,t)*pp and the second is certainly not what I want, and >> causes me grief. Further, why is the "depend pp,x(j)" statement >> not needed? > > When you add a rule for differentiation, a suitable dependency is > added automatically, ie. > > let df(pp,x) => something; > > effectively adds > > depend pp,x; > > The exception is the case of differentiation w.r.t. a free > variable, eg., > > let df(pp,~y) => x(y); > > since a dependency on a free variable doesn't make sense. > > What happens here is that your rule defines differentation w.r.t. > an expression containing a free variable. Unfortunately, this > general case is not checked, and you end up with a dependency of pp > on x(~j). > > Now, when you enter > > df(pp,t); > > Reduce checks whether x depends on t; if that happens to be the > case, the correct answer would either be > > df(pp,t); > > (if the switch expanddf is off), or > > df(pp,x)*df(x,t); > > if the switch expanddf is on. > > In your case it checks whether x(~j) depends on t. A free variable > may be replaced by an arbitrary expression, and therefore x(~j) is > treated as being dependent on anything. > > I'll test a correction in the next few days. > > Rainer . > - -- - --------------------------------------------------------------------- Professor A.J. Roberts School of Mathematical Sciences phone: +61 8 8313 3035 University of Adelaide fax: +61 8 8313 3696 South Australia 5005. mailto:anthony.roberts@... http://www.maths.adelaide.edu.au/anthony.roberts/ ==.0000001000000100000110001000011010001111110010111011101000010000== -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAlGUPmkACgkQ7TX8dTbro1uVhACgjcZUmjWolIhvt55lYDEKicLj pG4AmwWLMJ+c3tKY1cdTIaL/By1Zu93s =qyvQ -----END PGP SIGNATURE----- ```