[Date Index]
[Thread Index]
[Author Index]
Re: Re: record intermediate steps
*To*: mathgroup at smc.vnet.net
*Subject*: [mg73446] Re: [mg73126] Re: [mg73095] record intermediate steps
*From*: "Chris Chiasson" <chris at chiasson.name>
*Date*: Fri, 16 Feb 2007 05:21:45 -0500 (EST)
*References*: <200702030847.DAA02930@smc.vnet.net>
A small update: the trap method a little better when HoldPattern is
used to prevent evaluation of symb on the lhs of the new rule. Also,
it should be noted that the new DownValue isn't always specific enough
to be executed before built-in rules.
On 2/4/07, Chris Chiasson <chris at chiasson.name> wrote:
> Dimitris,
> I tried using Robby Villegas' trap method in an automated fashion on
> most of the functions in the System` context to see if I could figure
> out what is being called. Unfortunately, it breaks FullSimplify and
> doesn't reveal what functions were called. However, I am not yet ready
> to give up on this method.
>
> Also, it is possible to get 1/8 by using
> RootReduce@TrigFactor@tr
>
> Anyway, here is the automated trapping code:
> In[1]:=
> nameTrapBin={};
> In[2]:=
> nameTrap[symb_Symbol]/;FreeQ[Attributes@symb,Locked]:=
> Module[{trap=True},Unprotect@Unevaluated@symb;
> g_symb/;trap:=
> Block[{trap=False},
> If[nameTrapCount>0,nameTrapCount--;
> nameTrapBin={nameTrapBin,HoldForm@g}];g]]
> In[3]:=
> nameTrap[str_String]:=ToExpression[str,InputForm,nameTrap]
> In[4]:=
> nameSet=DeleteCases[Names["System`*"],
> Alternatives@@
> Union[Join[
> ToString/@
> Cases[DownValues@nameTrap,_Symbol,{0,Infinity},
> Heads\[Rule]True],Names["System`*Packet*"],
> Names["System`*Box*"],Names["System`*Abort*"],
> Names["System`*Trace*"],Names["System`*Dialog*"],
> Names["System`*Message*"],Names["System`*$*"],
> Names["System`*Link*"],Names["System`*Set*"],
> Names["System`*Message*"],{"Apply"}]]];
> In[5]:=
> ((*Print@#;*)nameTrap@#)&/@nameSet;
> In[6]:=
> Block[{nameTrapCount=10},tr=Cos[2*Pi/7]*Cos[4*Pi/7]*Cos[8*Pi/7]]
> In[7]:=
> FullSimplify@tr
> In[8]:=
> Block[{nameTrapCount=10},BetaRegularized[1,2,3]]
> In[9]:=
> Flatten@nameTrapBin
>
> On 2/3/07, dimitris <dimmechan at yahoo.com> wrote:
> > I know that Mathematica's implementated algorithms in most cases (for
> > e.g. indefinite integration) do not follow the "human way" (e.g.
> > integration by parts, substitution etc).
> >
> > But sometimes it is quite interesting to "record on the side" the
> > intermediate tranformations
> > rules followed in the course of arriving in the result.
> >
> > So, consider the following expression:
> >
> > In[6]:=
> > tr = Cos[2*Pi/7]*Cos[4*Pi/7]*Cos[8*Pi/7]
> >
> > Out[6]=
> > Cos[(2*Pi)/7]*Cos[(4*Pi)/7]*Cos[(8*Pi)/7]
> >
> > It is very easy to show that tr is actually equal to 1/8.
> >
> > In Mathematica you can demonstrate this with the command
> >
> > In[7]:=
> > FullSimplify[tr]
> >
> > Out[7]=
> > 1/8
> >
> > I believe (but I am not sure!) that Mathematica more or less in this
> > example follow the "human way" of applying the transformation rules.
> >
> > So, I would like to see/know them (i.e. the transformation rules)
> > applied by mathematica to reach this result and further record on the
> > side (regardless if they actually have any resemblence with the way a
> > human will work in this example!).
> >
> > I personally tried
> >
> > In[8]:=
> > Trace[FullSimplify[tr], TraceInternal -> True]
> >
> > but this is not the case here!
> >
> > Thanks in advance for any kind of response.
> >
> > Dimitris
> >
> >
>
>
> --
> http://chris.chiasson.name/
>
>
--
http://chris.chiasson.name/
Prev by Date:
**Re: Re: Removing constant multiples from polynomials**
Next by Date:
**Re: Wolfram Workbench with remote kernel**
Previous by thread:
**Re: record intermediate steps**
Next by thread:
**Re: Re: Re: record intermediate steps**
| |