1
$\begingroup$

When placing Terms in several lines for better readability it comes to a strange behavior:

(* this works ==> fx1[1, 3,5,7,11,13] = -25 *)
fx1[pa1_, pa2_, pa3_, pb1_, pb2_, pb3_] :=
  (pa1*pb1) + (pa2*pb2) - (pa3*pb3);

(* this works, too ==> fx2[1, 3,5,7,11,13] = -25 *)
fx2[pa1_, pa2_, pa3_, pb1_, pb2_, pb3_] :=
  (pa1*pb1) +
   (pa2*pb2) -
   (pa3*pb3);

(* this does not ==> fx3[1, 3,5,7,11,13] = -7 *)
fx3[pa1_, pa2_, pa3_, pb1_, pb2_, pb3_] :=
  (pa1*pb1)
   + (pa2*pb2)
   - (pa3*pb3);

This happens in M8 as well as in M10 so I guess it's not a bug... but why? and can I avoid this?

$\endgroup$
  • 6
    $\begingroup$ related $\endgroup$ – happy fish Dec 14 '15 at 7:45
  • 1
    $\begingroup$ note if you wrap the whole thing in ( ) or other constructs such as Module, you can break the lines as you please. I always do so if the expression is big enough to need breaks. $\endgroup$ – george2079 Dec 14 '15 at 12:59

Browse other questions tagged or ask your own question.