MathGroup Archive 2006

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

Search the Archive

Re: Beginner--getting rid of dot products with zero

  • To: mathgroup at smc.vnet.net
  • Subject: [mg66946] Re: Beginner--getting rid of dot products with zero
  • From: Peter Pein <petsie at dordos.net>
  • Date: Sun, 4 Jun 2006 02:01:32 -0400 (EDT)
  • References: <e5ot50$i6t$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

smanky at gmx.de schrieb:
> sorry that my question was apparently not clear.
> 
> i have no problem with computing the derivatives. the expressions with Total[] etc all make sense. 
> 
> however, the derivatives include ugly terms that are simply zero. there are terms of the following form
> 
> 0.{exp, exp, exp}
> 
> or 
> 
> {exp, exp, exp}.0
> 
> in both cases the whole thing is zero and they should drop out...
> 
> i am surprised that mathematica is not getting rid of them by itself, or at least when i use Simplify[]. so i am looking for a clever way to tell mathematica that it should disregard those terms.
> 
> thanks,
> 
> ~s
> 
> p.s. if it is still not clear, or you just want to see for yourself, run:
> 
> finish = 2;
> i = Table[i, {i, finish}];
> 
> d1[k1_, k2_] = Exp[k1*i + k2*i^2];
> d2[k1_, k2_] = Total[Exp[k1*i + k2*i^2]];
> 
> w[k1_, k2_, i] = d1[k1, k2]/d2[k1, k2];
> 
> q[k1_, k2_] = x.w[k1, k2, i];
> 
> 
> L[k1_, k2_, alpha_, beta_ ] = Total[Log[q[k1, k2]]] + Total[(y - alpha - beta*q[k1, k2])^2/q[k1, k2]];
> 
> \!\(Simplify[&#8706;\_beta\ L[k1, \ k2, \ alpha, \ beta]]\)   
> 
> Link to the forum page for this post:
> http://www.mathematica-users.org/webMathematica/wiki/wiki.jsp?pageName=Special:Forum_ViewTopic&pid=10811#p10811
> Posted through http://www.mathematica-users.org [[postId=10811]]
> 
> 
Hello Stephan,

I don't know what you expect when applying a dot-product to a scalar (x) and a vector, but one of the following should do what you want:

either define x,y as vectors:
x = {x1, x2}; y = {y1, y2};
Simplify[D[L[k1, k2, a, b], a]]
-->
{(2*E^(-k1 - 3*k2)*(a*(1 + E^(k1 + 3*k2))^2 + 2*b*E^(k1 + 3*k2)*x1 -
      (1 + E^(k1 + 3*k2))^2*y1))/x1,
   (2*E^(-k1 - 3*k2)*(a*(1 + E^(k1 + 3*k2))^2 + 2*b*E^(k1 + 3*k2)*x2 -
      (1 + E^(k1 + 3*k2))^2*y2))/x2}

or use scalar multiplication in the definition of q[]:
q[k1_, k2_] = x*w[k1, k2, i];
Simplify[D[L[k1, k2, a, b], a]]
-->
(2*E^(-k1 - 3*k2)*(a*(1 + E^(k1 + 3*k2))^2 + 2*b*E^(k1 + 3*k2)*x -
     (1 + E^(k1 + 3*k2))^2*y))/x

hth,
  Peter


  • Prev by Date: Re: New Analytical Functions - Mathematica Verified
  • Next by Date: RE: Colored Tick Labels?
  • Previous by thread: Re: RE:Beginner--getting rid of dot products with zero
  • Next by thread: Re: Problem with a limit.