Maxima – 51 – Valutazione – funzioni e variabili per la valutazione – 3

Continuo da qui, copio dal Reference Manual, PDF scaricabile da qui, sono a p.152.

eval
As an argument in a call to ev(expr), eval causes an extra evaluation of expr.

(%i1) [a:b, b:c, c:d, d:e];
(%o1)                            [b, c, d, e]
(%i2) a;
(%o2)                                  b
(%i3) ev(a);
(%o3)                                  c
(%i4) ev(a),eval;
(%o4)                                  e
(%i5) a,eval,eval;
(%o5)                                  e

evflag
When a symbol x has the evflag property, the expressions ev(expr, x) and expr, x (at the interactive prompt) are equivalent to ev(expr, x = true). That is, x is bound to true while expr is evaluated.

The expression declare(x, evflag) gives the evflag property to the variable x.

The flags which have the evflag property by default are the following:

algebraic          cauchysum       demoivre
dotscrules         %emode          %enumer
exponentialize     exptisolate     factorflag
float              halfangles      infeval
isolate_wrt_times  keepfloat       letrat
listarith          logabs          logarc
logexpand          lognegint
m1pbranch          numer_pbranch   programmode
radexpand          ratalgdenom     ratfac
ratmx              ratsimpexpons   simp
simpproduct        simpsum         sumexpand
trigexpand
(%i6) sin (1/2);
                                        1
(%o6)                               sin(-)
                                        2
(%i7) sin (1/2), float;
(%o7)                          0.479425538604203
(%i8) sin (1/2), float=true;
(%o8)                          0.479425538604203
(%i9) simp : false;
(%o9)                                false
(%i10) 1 + 1;
(%o10)                               1 + 1
(%i11) 1 + 1, simp;
(%o11)                                 2
(%i12) simp : true;
(%o12)                               true
(%i13) sum (1/k^2, k, 1, inf);
                                   inf
                                   ====
                                   \     1
(%o13)                              >    --
                                   /      2
                                   ====  k
                                   k = 1
(%i14) sum (1/k^2, k, 1, inf), simpsum;
                                        2
                                     %pi
(%o14)                               ----
                                      6
(%i15) declare (aa, evflag);
(%o15)                               done
(%i16) if aa = true then YES else NO;
(%o16)                                NO
(%i17) if aa = true then YES else NO, aa;
(%o17)                                YES

evfun
When a function F has the evfun property, the expressions ev(expr, F) and expr, F (at the interactive prompt) are equivalent to F(ev(expr)).

If two or more evfun functions F, G, etc., are specified, the functions are applied in the order that they are specified.

The expression declare(F, evfun) gives the evfun property to the function F. The functions which have the evfun property by default are the following:

bfloat          factor       fullratsimp
logcontract     polarform    radcan
ratexpand       ratsimp      rectform
rootscontract   trigexpand   trigreduce
(%i18) x^3 - 1;
                                     3
(%o18)                              x  - 1
(%i19) x^3 - 1, factor;
                                       2
(%o19)                       (x - 1) (x  + x + 1)
(%i20) factor (x^3 - 1);
                                       2
(%o20)                       (x - 1) (x  + x + 1)
(%i21) cos(4 * x) / sin(x)^4;
                                   cos(4 x)
(%o21)                             --------
                                      4
                                   sin (x)
(%i22) cos(4 * x) / sin(x)^4, trigexpand;
                        4           2       2         4
                     sin (x) - 6 cos (x) sin (x) + cos (x)
(%o22)               -------------------------------------
                                       4
                                    sin (x)
(%i23) cos(4 * x) / sin(x)^4, trigexpand, ratexpand;
                                  2          4
                             6 cos (x)    cos (x)
(%o23)                    (- ---------) + ------- + 1
                                 2           4
                              sin (x)     sin (x)
(%i24) ratexpand (trigexpand (cos(4 * x) / sin(x)^4));
                                  2          4
                             6 cos (x)    cos (x)
(%o24)                    (- ---------) + ------- + 1
                                 2           4
                              sin (x)     sin (x)
(%i25) declare ([F, G], evfun);
(%o25)                               done
(%i26) (aa : bb, bb : cc, cc : dd);
(%o26)                                dd
(%i27) aa;
(%o27)                                bb
(%i28) aa, F;
(%o28)                               F(cc)
(%i29) F (aa);
(%o29)                               F(bb)
(%i30) F (ev (aa));
(%o30)                               F(cc)
(%i31) aa, F, G;
(%o31)                             G(F(cc))
(%i32) G (F (ev (aa)));
(%o32)                             G(F(cc))

infeval
Enables “infinite evaluation” mode. ev repeatedly evaluates an expression until it stops changing. To prevent a variable, say X, from being evaluated away in this mode, simply include X='X as an argument to ev. Of course expressions such as ev(X, X=X+1, infeval) will generate an infinite loop.

noeval
noeval suppresses the evaluation phase of ev. This is useful in conjunction with other switches and in causing expressions to be resimplified without being reevaluated.

nouns
nouns is an evflag. When used as an option to the ev command, nouns converts all “noun” forms occurring in the expression being ev’d to “verbs”, i.e., evaluates them.

See also noun, nounify, verb, and verbify.

pred
As an argument in a call to ev(expr), pred causes predicates (expressions which evaluate to true or false) to be evaluated.

(%i33) 1<2;
(%o33)                               1 < 2
(%i34) 1<2,pred;
(%o34)                               true

Posta un commento o usa questo indirizzo per il trackback.

Trackback

Rispondi

Inserisci i tuoi dati qui sotto o clicca su un'icona per effettuare l'accesso:

Logo di WordPress.com

Stai commentando usando il tuo account WordPress.com. Chiudi sessione /  Modifica )

Google photo

Stai commentando usando il tuo account Google. Chiudi sessione /  Modifica )

Foto Twitter

Stai commentando usando il tuo account Twitter. Chiudi sessione /  Modifica )

Foto di Facebook

Stai commentando usando il tuo account Facebook. Chiudi sessione /  Modifica )

Connessione a %s...

Questo sito utilizza Akismet per ridurre lo spam. Scopri come vengono elaborati i dati derivati dai commenti.

%d blogger hanno fatto clic su Mi Piace per questo: