MathGroup Archive 2005

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

Search the Archive

Effect of Simplify on numeric vs symbolic

  • To: mathgroup at
  • Subject: [mg55971] Effect of Simplify on numeric vs symbolic
  • From: carlos at
  • Date: Tue, 12 Apr 2005 05:26:32 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

In my previous example of FEM symbolic vs numeric speed all
computations were with numbers.  No variables were involved.
The difference (minutes vs seconds) due largely due to Simplify.

Here is a simpler example that illustrates the point, also taken from
the same course.  LineGaussRuleInfo returns weights and abcissae of 1D
Gauss-Legendre quadrature rules of 1 to 5 points. Argument numer asks
for exact information if False; if True it returns N[information].
All computations involve nunbers only.

Results of calls (at end of post) on a Mac laptop:

numer rule   n  Eval time  Simplify time
True    4   50   0.00 sec     0.00 sec
False   4   50   0.00 sec    78.01 sec  (* Note: FullSimplify needed *)
False   4   50   0.00 sec     0.00 sec  (* found result in cache *)

LineGaussRuleInfo[{rule_,numer_},point_]:= Module[
   w4={(1/2)-Sqrt[5/6]/6, (1/2)+Sqrt[5/6]/6,
       (1/2)+Sqrt[5/6]/6, (1/2)-Sqrt[5/6]/6},
        Sqrt[(3-2*Sqrt[6/5])/7], Sqrt[(3+2*Sqrt[6/5])/7]},
        Sqrt[5-2*Sqrt[10/7]], Sqrt[5+2*Sqrt[10/7]]}/3,
  If [p==1, info={0,2}];
  If [p==2, info={g2[[i]],1}];
  If [p==3, info={g3[[i]],w3[[i]]}];
  If [p==4, info={g4[[i]],w4[[i]]}];
  If [p==5, info={g5[[i]],w5[[i]]}];
  If [numer, Return[N[info]], Return[info] ];


Print[PerverseExpression[4,50,True ]];
Print[PerverseExpression[4,50,False]]; (* Cached *)

  • Prev by Date: Re: Mathematica graphs in WORD
  • Next by Date: Re: cannot evaluate in HelpBrowser (Win XP)
  • Previous by thread: Re: Re: Numerical Optimization involving equation solving
  • Next by thread: Re: Effect of Simplify on numeric vs symbolic