Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1996

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

Search the Archive

Re: Bug??

  • To: mathgroup at smc.vnet.net
  • Subject: [mg3841] Re: Bug??
  • From: Stephen P Luttrell <luttrell at signal.dra.hmg.gb>
  • Date: Mon, 29 Apr 1996 00:32:09 -0400
  • Organization: Defence Research Agency, Malvern
  • Sender: owner-wri-mathgroup at wolfram.com

Theo Pillay wrote:
> 
> Hi all,
> 
> I came across the following strange (and highly frustrating) behaviour while
> using MMA to do some simple substitutions. The relevant parts of the text
> file I was using are reproduced below.
> 
> f[x,y] = a[x] y + b[x];
> 
> F1 = f[x,y];
> 
> F2 = y2 (D[f[x,y], y]  - D[r[x], x]) + D[f[x,y],x];
> 
> F3 = r[x];
> 
> eight = -y2 A[x,y] D[F2,y] - 2 y2 B[x,y,y2] D[F3,y] +
>         2 y2 D[F2,y,x] + y2^2 D[F2,{y,2}] - A[x,y] D[F2,x] +
>         B[x,y,y2] D[F2,y2] -
>         2 B[x,y,y2] D[F3,x] - D[B[x,y,y2], y] F1 - D[B[x,y,y2], y2] F2
>         - D[B[x,y,y2],x] F3 + D[F2, {x,2}];  (* 1 *)
> 
> I get different answers for eight depending on the position of line (1). As
> shown I get the wrong answer, but it works if I move (1) up to the previous
> line (i.e next to F2). This is worse than irritating - anybody know what's
> happening here?

When the Mathematica parser reaches the end of the line above (1) it thinks it has a complete 
input statement, i.e. all pending brackets (etc) have been closed, so it doesn't look any further.

If, on the other hand, you move the minus sign (which appears at the start of (1)) to the end of 
the line above (1), so that your input appears like this

eight = -y2 A[x,y] D[F2,y] - 2 y2 B[x,y,y2] D[F3,y] +
         2 y2 D[F2,y,x] + y2^2 D[F2,{y,2}] - A[x,y] D[F2,x] +
         B[x,y,y2] D[F2,y2] -
         2 B[x,y,y2] D[F3,x] - D[B[x,y,y2], y] F1 - D[B[x,y,y2], y2] F2 -
         D[B[x,y,y2],x] F3 + D[F2, {x,2}];  (* 1 *)

then the parser is forced to look at line (1) to find whatever is supposed to come after the minus 
sign, and it will thus do what you intended.

You can also achieve the same effect by moving the whole of line (1) to the end of the previous 
line (as you have already noted).

-- 
Dr Stephen P Luttrell                  luttrell at signal.dra.hmg.gb
Adaptive Systems Theory                01684-894046 (phone)
Room EX21, Defence Research Agency     01684-894384 (fax)           
Malvern, Worcs, WR14 3PS, U.K.         http://www.dra.hmg.gb/cis5pip/Welcome.html

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: Help on Function
  • Next by Date: DUO2300C and Mathematica
  • Previous by thread: Re: Bug??
  • Next by thread: Re: Evaluation of Expression in Do