/usr/share/doc/maxima-doc/html/maxima_8.html is in maxima-doc 5.32.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html401/loose.dtd">
<html>
<!-- Created on January, 10 2014 by texi2html 1.76 -->
<!--
Written by: Lionel Cons <Lionel.Cons@cern.ch> (original author)
Karl Berry <karl@freefriends.org>
Olaf Bachmann <obachman@mathematik.uni-kl.de>
and many others.
Maintained by: Many creative people <dev@texi2html.cvshome.org>
Send bugs and suggestions to <users@texi2html.cvshome.org>
-->
<head>
<title>Maxima 5.32.1 Manual: 8. Evaluation</title>
<meta name="description" content="Maxima 5.32.1 Manual: 8. Evaluation">
<meta name="keywords" content="Maxima 5.32.1 Manual: 8. Evaluation">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="texi2html 1.76">
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
pre.display {font-family: serif}
pre.format {font-family: serif}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: serif; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: serif; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.sansserif {font-family:sans-serif; font-weight:normal;}
ul.toc {list-style: none}
body
{
color: black;
background: white;
margin-left: 8%;
margin-right: 13%;
}
h1
{
margin-left: +8%;
font-size: 150%;
font-family: sans-serif
}
h2
{
font-size: 125%;
font-family: sans-serif
}
h3
{
font-size: 100%;
font-family: sans-serif
}
h2,h3,h4,h5,h6 { margin-left: +4%; }
div.textbox
{
border: solid;
border-width: thin;
/* width: 100%; */
padding-top: 1em;
padding-bottom: 1em;
padding-left: 2em;
padding-right: 2em
}
div.titlebox
{
border: none;
padding-top: 1em;
padding-bottom: 1em;
padding-left: 2em;
padding-right: 2em;
background: rgb(200,255,255);
font-family: sans-serif
}
div.synopsisbox
{
border: none;
padding-top: 1em;
padding-bottom: 1em;
padding-left: 2em;
padding-right: 2em;
background: rgb(255,220,255);
/*background: rgb(200,255,255); */
/* font-family: fixed */
}
pre.example
{
border: 1px solid gray;
padding-top: 1em;
padding-bottom: 1em;
padding-left: 1em;
padding-right: 1em;
/* background: rgb(247,242,180); */ /* kind of sandy */
/* background: rgb(200,255,255); */ /* sky blue */
background-color: #F1F5F9; /* light blue-gray */
/* font-family: "Lucida Console", monospace */
}
div.spacerbox
{
border: none;
padding-top: 2em;
padding-bottom: 2em
}
div.image
{
margin: 0;
padding: 1em;
text-align: center;
}
div.categorybox
{
border: 1px solid gray;
padding-top: 0px;
padding-bottom: 0px;
padding-left: 1em;
padding-right: 1em;
background: rgb(247,242,220);
}
-->
</style>
<link rel="icon" href="http://maxima.sourceforge.net/favicon.ico"/>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Evaluation"></a>
<a name="SEC43"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="maxima_7.html#SEC42" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="#SEC44" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima_7.html#SEC35" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_9.html#SEC45" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_82.html#SEC380" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h1 class="chapter"> 8. Evaluation </h1>
<table class="menu" border="0" cellspacing="0">
<tr><td align="left" valign="top"><a href="#SEC44">8.1 Functions and Variables for Evaluation</a></td><td> </td><td align="left" valign="top">
</td></tr>
</table>
<p><a name="Item_003a-Functions-and-Variables-for-Evaluation"></a>
</p><hr size="6">
<a name="Functions-and-Variables-for-Evaluation"></a>
<a name="SEC44"></a>
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC43" title="Previous section in reading order"> < </a>]</td>
<td valign="middle" align="left">[<a href="maxima_9.html#SEC45" title="Next section in reading order"> > </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="#SEC43" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="#SEC43" title="Up section"> Up </a>]</td>
<td valign="middle" align="left">[<a href="maxima_9.html#SEC45" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_82.html#SEC380" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<h2 class="section"> 8.1 Functions and Variables for Evaluation </h2>
<p><a name="quote"></a>
<a name="Item_003a-_0027"></a>
</p><dl>
<dt><u>Operator:</u> <b>'</b>
<a name="IDX279"></a>
</dt>
<dd><p>The single quote operator <code>'</code> prevents evaluation.
</p>
<p>Applied to a symbol, the single quote prevents evaluation of the symbol.
</p>
<p>Applied to a function call, the single quote prevents evaluation of the function
call, although the arguments of the function are still evaluated (if evaluation
is not otherwise prevented). The result is the noun form of the function call.
</p>
<p>Applied to a parenthesized expression, the single quote prevents evaluation of
all symbols and function calls in the expression.
E.g., <code>'(f(x))</code> means do not evaluate the expression <code>f(x)</code>.
<code>'f(x)</code> (with the single quote applied to <code>f</code> instead of <code>f(x)</code>)
means return the noun form of <code>f</code> applied to <code>[x]</code>.
</p>
<p>The single quote does not prevent simplification.
</p>
<p>When the global flag <code><a href="maxima_6.html#noundisp">noundisp</a></code> is <code>true</code>, nouns display with a single
quote. This switch is always <code>true</code> when displaying function definitions.
</p>
<p>See also the quote-quote operator <code><a href="#quote_002dquote">''</a></code> and <code><a href="#nouns">nouns</a></code>.
</p>
<p>Examples:
</p>
<p>Applied to a symbol,
the single quote prevents evaluation of the symbol.
</p>
<pre class="example">(%i1) aa: 1024;
(%o1) 1024
(%i2) aa^2;
(%o2) 1048576
(%i3) 'aa^2;
2
(%o3) aa
(%i4) ''%;
(%o4) 1048576
</pre>
<p>Applied to a function call, the single quote prevents evaluation of the function
call. The result is the noun form of the function call.
</p>
<pre class="example">(%i1) x0: 5;
(%o1) 5
(%i2) x1: 7;
(%o2) 7
(%i3) integrate (x^2, x, x0, x1);
218
(%o3) ---
3
(%i4) 'integrate (x^2, x, x0, x1);
7
/
[ 2
(%o4) I x dx
]
/
5
(%i5) %, nouns;
218
(%o5) ---
3
</pre>
<p>Applied to a parenthesized expression, the single quote prevents evaluation of
all symbols and function calls in the expression.
</p>
<pre class="example">(%i1) aa: 1024;
(%o1) 1024
(%i2) bb: 19;
(%o2) 19
(%i3) sqrt(aa) + bb;
(%o3) 51
(%i4) '(sqrt(aa) + bb);
(%o4) bb + sqrt(aa)
(%i5) ''%;
(%o5) 51
</pre>
<p>The single quote does not prevent simplification.
</p>
<pre class="example">(%i1) sin (17 * %pi) + cos (17 * %pi);
(%o1) - 1
(%i2) '(sin (17 * %pi) + cos (17 * %pi));
(%o2) - 1
</pre>
<p>Maxima considers floating point operations by its in-built mathematical
functions to be a simplification.
</p>
<pre class="example">(%i1) sin(1.0);
(%o1) .8414709848078965
(%i2) '(sin(1.0));
(%o2) .8414709848078965
</pre>
<div class=categorybox>
·
<p>@ref{Category: Evaluation} ·
@ref{Category: Operators}
</div>
</p></dd></dl>
<p><a name="quote_002dquote"></a>
<a name="Item_003a-_0027_0027"></a>
</p><dl>
<dt><u>Operator:</u> <b>"</b>
<a name="IDX280"></a>
</dt>
<dd><p>The quote-quote operator <code>''</code> (two single quote marks) modifies
evaluation in input expressions.
</p>
<p>Applied to a general expression <var>expr</var>, quote-quote causes the value of
<var>expr</var> to be substituted for <var>expr</var> in the input expression.
</p>
<p>Applied to the operator of an expression, quote-quote changes the operator from
a noun to a verb (if it is not already a verb).
</p>
<p>The quote-quote operator is applied by the input parser; it is not stored as
part of a parsed input expression. The quote-quote operator is always applied
as soon as it is parsed, and cannot be quoted. Thus quote-quote causes
evaluation when evaluation is otherwise suppressed, such as in function
definitions, lambda expressions, and expressions quoted by single quote
<code>'</code>.
</p>
<p>Quote-quote is recognized by <code><a href="maxima_13.html#batch">batch</a></code> and <code><a href="maxima_13.html#load">load</a></code>.
</p>
<p>See also the single-quote operator <code><a href="#quote">'</a></code> and <code><a href="#nouns">nouns</a></code>.
</p>
<p>Examples:
</p>
<p>Applied to a general expression <var>expr</var>, quote-quote causes the value of
<var>expr</var> to be substituted for <var>expr</var> in the input expression.
</p>
<pre class="example">(%i1) expand ((a + b)^3);
3 2 2 3
(%o1) b + 3 a b + 3 a b + a
(%i2) [_, ''_];
3 3 2 2 3
(%o2) [expand((b + a) ), b + 3 a b + 3 a b + a ]
(%i3) [%i1, ''%i1];
3 3 2 2 3
(%o3) [expand((b + a) ), b + 3 a b + 3 a b + a ]
(%i4) [aa : cc, bb : dd, cc : 17, dd : 29];
(%o4) [cc, dd, 17, 29]
(%i5) foo_1 (x) := aa - bb * x;
(%o5) foo_1(x) := aa - bb x
(%i6) foo_1 (10);
(%o6) cc - 10 dd
(%i7) ''%;
(%o7) - 273
(%i8) ''(foo_1 (10));
(%o8) - 273
(%i9) foo_2 (x) := ''aa - ''bb * x;
(%o9) foo_2(x) := cc - dd x
(%i10) foo_2 (10);
(%o10) - 273
(%i11) [x0 : x1, x1 : x2, x2 : x3];
(%o11) [x1, x2, x3]
(%i12) x0;
(%o12) x1
(%i13) ''x0;
(%o13) x2
(%i14) '' ''x0;
(%o14) x3
</pre>
<p>Applied to the operator of an expression, quote-quote changes the operator from
a noun to a verb (if it is not already a verb).
</p>
<pre class="example">(%i1) declare (foo, noun);
(%o1) done
(%i2) foo (x) := x - 1729;
(%o2) ''foo(x) := x - 1729
(%i3) foo (100);
(%o3) foo(100)
(%i4) ''foo (100);
(%o4) - 1629
</pre>
<p>The quote-quote operator is applied by the input parser; it is not stored as
part of a parsed input expression.
</p>
<pre class="example">(%i1) [aa : bb, cc : dd, bb : 1234, dd : 5678];
(%o1) [bb, dd, 1234, 5678]
(%i2) aa + cc;
(%o2) dd + bb
(%i3) display (_, op (_), args (_));
_ = cc + aa
op(cc + aa) = +
args(cc + aa) = [cc, aa]
(%o3) done
(%i4) ''(aa + cc);
(%o4) 6912
(%i5) display (_, op (_), args (_));
_ = dd + bb
op(dd + bb) = +
args(dd + bb) = [dd, bb]
(%o5) done
</pre>
<p>Quote-quote causes evaluation when evaluation is otherwise suppressed, such as
in function definitions, lambda expressions, and expressions quoted by single
quote <code>'</code>.
</p>
<pre class="example">(%i1) foo_1a (x) := ''(integrate (log (x), x));
(%o1) foo_1a(x) := x log(x) - x
(%i2) foo_1b (x) := integrate (log (x), x);
(%o2) foo_1b(x) := integrate(log(x), x)
(%i3) dispfun (foo_1a, foo_1b);
(%t3) foo_1a(x) := x log(x) - x
(%t4) foo_1b(x) := integrate(log(x), x)
(%o4) [%t3, %t4]
(%i5) integrate (log (x), x);
(%o5) x log(x) - x
(%i6) foo_2a (x) := ''%;
(%o6) foo_2a(x) := x log(x) - x
(%i7) foo_2b (x) := %;
(%o7) foo_2b(x) := %
(%i8) dispfun (foo_2a, foo_2b);
(%t8) foo_2a(x) := x log(x) - x
(%t9) foo_2b(x) := %
(%o9) [%t7, %t8]
(%i10) F : lambda ([u], diff (sin (u), u));
(%o10) lambda([u], diff(sin(u), u))
(%i11) G : lambda ([u], ''(diff (sin (u), u)));
(%o11) lambda([u], cos(u))
(%i12) '(sum (a[k], k, 1, 3) + sum (b[k], k, 1, 3));
(%o12) sum(b , k, 1, 3) + sum(a , k, 1, 3)
k k
(%i13) '(''(sum (a[k], k, 1, 3)) + ''(sum (b[k], k, 1, 3)));
(%o13) b + a + b + a + b + a
3 3 2 2 1 1
</pre>
<div class=categorybox>
·
<p>@ref{Category: Evaluation} ·
@ref{Category: Operators}
</div>
</p></dd></dl>
<p><a name="ev"></a>
<a name="Item_003a-ev"></a>
</p><dl>
<dt><u>Function:</u> <b>ev</b><i> (<var>expr</var>, <var>arg_1</var>, …, <var>arg_n</var>)</i>
<a name="IDX281"></a>
</dt>
<dd><p>Evaluates the expression <var>expr</var> in the environment specified by the
arguments <var>arg_1</var>, …, <var>arg_n</var>. The arguments are switches
(Boolean flags), assignments, equations, and functions. <code>ev</code> returns the
result (another expression) of the evaluation.
</p>
<p>The evaluation is carried out in steps, as follows.
</p>
<ol>
<li>
First the environment is set up by scanning the arguments which may
be any or all of the following.
<ul>
<li>
<code><a href="maxima_9.html#simp">simp</a></code> causes <var>expr</var> to be simplified regardless of the setting of the
switch <code>simp</code> which inhibits simplification if <code>false</code>.
</li><li>
<code><a href="#noeval">noeval</a></code> suppresses the evaluation phase of <code>ev</code> (see step (4) below).
This is useful in conjunction with the other switches and in causing
<var>expr</var> to be resimplified without being reevaluated.
</li><li>
<code><a href="#nouns">nouns</a></code> causes the evaluation of noun forms (typically unevaluated
functions such as <code>'integrate</code> or <code>'diff</code>) in <var>expr</var>.
</li><li>
<code><a href="maxima_9.html#expand">expand</a></code> causes expansion.
</li><li>
<code>expand (<var>m</var>, <var>n</var>)</code> causes expansion, setting the values of
<code><a href="maxima_9.html#maxposex">maxposex</a></code> and <code><a href="maxima_9.html#maxnegex">maxnegex</a></code> to <var>m</var> and <var>n</var> respectively.
</li><li>
<code><a href="maxima_23.html#detout">detout</a></code> causes any matrix inverses computed in <var>expr</var> to have their
determinant kept outside of the inverse rather than dividing through
each element.
</li><li>
<code><a href="maxima_18.html#diff">diff</a></code> causes all differentiations indicated in <var>expr</var> to be performed.
</li><li>
<code>derivlist (<var>x</var>, <var>y</var>, <var>z</var>, ...)</code> causes only differentiations
with respect to the indicated variables. See also <code><a href="maxima_18.html#derivlist">derivlist</a></code>.
</li><li>
<code>risch</code> causes integrals in <var>expr</var> to be evaluated using the Risch
algorithm. See <code><a href="maxima_19.html#risch">risch</a></code>. The standard integration routine is invoked
when using the special symbol <code><a href="#nouns">nouns</a></code>.
</li><li>
<code><a href="maxima_5.html#float">float</a></code> causes non-integral rational numbers to be converted to floating
point.
</li><li>
<code><a href="maxima_5.html#numer">numer</a></code> causes some mathematical functions (including exponentiation)
with numerical arguments to be evaluated in floating point. It causes
variables in <var>expr</var> which have been given numervals to be replaced by
their values. It also sets the <code><a href="maxima_5.html#float">float</a></code> switch on.
</li><li>
<code><a href="#pred">pred</a></code> causes predicates (expressions which evaluate to <code>true</code> or
<code>false</code>) to be evaluated.
</li><li>
<code><a href="#eval">eval</a></code> causes an extra post-evaluation of <var>expr</var> to occur.
(See step (5) below.)
<code>eval</code> may occur multiple times. For each instance of <code>eval</code>, the
expression is evaluated again.
</li><li>
<code>A</code> where <code>A</code> is an atom declared to be an evaluation flag
<code><a href="#evflag">evflag</a></code> causes <code>A</code> to be bound to <code>true</code> during the evaluation
of <var>expr</var>.
</li><li>
<code>V: expression</code> (or alternately <code>V=expression</code>) causes <code>V</code> to be
bound to the value of <code>expression</code> during the evaluation of <var>expr</var>.
Note that if <code>V</code> is a Maxima option, then <code>expression</code> is used for
its value during the evaluation of <var>expr</var>. If more than one argument to
<code>ev</code> is of this type then the binding is done in parallel. If <code>V</code> is
a non-atomic expression then a substitution rather than a binding is performed.
</li><li>
<code>F</code> where <code>F</code>, a function name, has been declared to be an evaluation
function <code><a href="#evfun">evfun</a></code> causes <code>F</code> to be applied to <var>expr</var>.
</li><li>
Any other function names, e.g. <code><a href="maxima_28.html#sum">sum</a></code>, cause evaluation of occurrences
of those names in <var>expr</var> as though they were verbs.
</li><li>
In addition a function occurring in <var>expr</var> (say <code>F(x)</code>) may be defined
locally for the purpose of this evaluation of <var>expr</var> by giving
<code>F(x) := expression</code> as an argument to <code>ev</code>.
</li><li>
If an atom not mentioned above or a subscripted variable or subscripted
expression was given as an argument, it is evaluated and if the result is an
equation or assignment then the indicated binding or substitution is performed.
If the result is a list then the members of the list are treated as if they were
additional arguments given to <code>ev</code>. This permits a list of equations to be
given (e.g. <code>[X=1, Y=A**2]</code>) or a list of names of equations (e.g.,
<code>[%t1, %t2]</code> where <code>%t1</code> and <code>%t2</code> are equations) such as that
returned by <code><a href="maxima_20.html#solve">solve</a></code>.
</li></ul>
<p>The arguments of <code>ev</code> may be given in any order with the exception of
substitution equations which are handled in sequence, left to right, and
evaluation functions which are composed, e.g., <code>ev (<var>expr</var>, ratsimp,
realpart)</code> is handled as <code>realpart (ratsimp (<var>expr</var>))</code>.
</p>
<p>The <code><a href="maxima_9.html#simp">simp</a></code>, <code><a href="maxima_5.html#numer">numer</a></code>, and <code><a href="maxima_5.html#float">float</a></code> switches may also be set
locally in a block, or globally in Maxima so that they will remain in effect
until being reset.
</p>
<p>If <var>expr</var> is a canonical rational expression (CRE), then the expression
returned by <code>ev</code> is also a CRE, provided the <code>numer</code> and <code>float</code>
switches are not both <code>true</code>.
</p>
</li><li>
During step (1), a list is made of the non-subscripted variables appearing on
the left side of equations in the arguments or in the value of some arguments
if the value is an equation. The variables (subscripted variables which do not
have associated array functions as well as non-subscripted variables) in the
expression <var>expr</var> are replaced by their global values, except for those
appearing in this list. Usually, <var>expr</var> is just a label or <code>%</code> (as in
<code>%i2</code> in the example below), so this step simply retrieves the expression
named by the label, so that <code>ev</code> may work on it.
</li><li>
If any substitutions are indicated by the arguments, they are carried out now.
</li><li>
The resulting expression is then re-evaluated (unless one of the arguments was
<code><a href="#noeval">noeval</a></code>) and simplified according to the arguments. Note that any
function calls in <var>expr</var> will be carried out after the variables in it are
evaluated and that <code>ev(F(x))</code> thus may behave like <code>F(ev(x))</code>.
</li><li>
For each instance of <code><a href="#eval">eval</a></code> in the arguments, steps (3) and (4) are
repeated.
</li></ol>
<p>Examples:
</p>
<pre class="example">(%i1) sin(x) + cos(y) + (w+1)^2 + 'diff (sin(w), w);
d 2
(%o1) cos(y) + sin(x) + -- (sin(w)) + (w + 1)
dw
(%i2) ev (%, numer, expand, diff, x=2, y=1);
2
(%o2) cos(w) + w + 2 w + 2.449599732693821
</pre>
<p>An alternate top level syntax has been provided for <code>ev</code>, whereby one
may just type in its arguments, without the <code>ev()</code>. That is, one may
write simply
</p>
<pre class="example"><var>expr</var>, <var>arg_1</var>, ..., <var>arg_n</var>
</pre>
<p>This is not permitted as part of another expression, e.g., in functions,
blocks, etc.
</p>
<p>Notice the parallel binding process in the following example.
</p>
<pre class="example">(%i3) programmode: false;
(%o3) false
(%i4) x+y, x: a+y, y: 2;
(%o4) y + a + 2
(%i5) 2*x - 3*y = 3$
(%i6) -3*x + 2*y = -4$
(%i7) solve ([%o5, %o6]);
Solution
1
(%t7) y = - -
5
6
(%t8) x = -
5
(%o8) [[%t7, %t8]]
(%i8) %o6, %o8;
(%o8) - 4 = - 4
(%i9) x + 1/x > gamma (1/2);
1
(%o9) x + - > sqrt(%pi)
x
(%i10) %, numer, x=1/2;
(%o10) 2.5 > 1.772453850905516
(%i11) %, pred;
(%o11) true
</pre>
<div class=categorybox>
·
<p>@ref{Category: Evaluation}
</div>
</p></dd></dl>
<p><a name="eval"></a>
<a name="Item_003a-eval"></a>
</p><dl>
<dt><u>Special symbol:</u> <b>eval</b>
<a name="IDX282"></a>
</dt>
<dd><p>As an argument in a call to <code>ev (<var>expr</var>)</code>, <code>eval</code> causes an extra
evaluation of <var>expr</var>. See <code><a href="#ev">ev</a></code>.
</p>
<p>Example:
</p>
<pre class="example">(%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
</pre>
<div class=categorybox>
·
<p>@ref{Category: Evaluation flags}
</div>
</p></dd></dl>
<p><a name="evflag"></a>
<a name="Item_003a-evflag"></a>
</p><dl>
<dt><u>Property:</u> <b>evflag</b>
<a name="IDX283"></a>
</dt>
<dd><p>When a symbol <var>x</var> has the <code>evflag</code> property, the expressions
<code>ev(<var>expr</var>, <var>x</var>)</code> and <code><var>expr</var>, <var>x</var></code> (at the
interactive prompt) are equivalent to <code>ev(<var>expr</var>, <var>x</var> = true)</code>.
That is, <var>x</var> is bound to <code>true</code> while <var>expr</var> is evaluated.
</p>
<p>The expression <code>declare(<var>x</var>, evflag)</code> gives the <code>evflag</code> property
to the variable <var>x</var>.
</p>
<p>The flags which have the <code>evflag</code> property by default are the following:
</p>
<pre class="verbatim"> 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
</pre>
<p>Examples:
</p>
<pre class="example">(%i1) sin (1/2);
1
(%o1) sin(-)
2
(%i2) sin (1/2), float;
(%o2) 0.479425538604203
(%i3) sin (1/2), float=true;
(%o3) 0.479425538604203
(%i4) simp : false;
(%o4) false
(%i5) 1 + 1;
(%o5) 1 + 1
(%i6) 1 + 1, simp;
(%o6) 2
(%i7) simp : true;
(%o7) true
(%i8) sum (1/k^2, k, 1, inf);
inf
====
\ 1
(%o8) > --
/ 2
==== k
k = 1
(%i9) sum (1/k^2, k, 1, inf), simpsum;
2
%pi
(%o9) ----
6
(%i10) declare (aa, evflag);
(%o10) done
(%i11) if aa = true then YES else NO;
(%o11) NO
(%i12) if aa = true then YES else NO, aa;
(%o12) YES
</pre>
<div class=categorybox>
·
<p>@ref{Category: Evaluation flags} ·
@ref{Category: Simplification flags and variables}
</div>
</p></dd></dl>
<p><a name="evfun"></a>
<a name="Item_003a-evfun"></a>
</p><dl>
<dt><u>Property:</u> <b>evfun</b>
<a name="IDX284"></a>
</dt>
<dd><p>When a function <var>F</var> has the <code>evfun</code> property, the expressions
<code>ev(<var>expr</var>, <var>F</var>)</code> and <code><var>expr</var>, <var>F</var></code> (at the
interactive prompt) are equivalent to <code><var>F</var>(ev(<var>expr</var>))</code>.
</p>
<p>If two or more <code>evfun</code> functions <var>F</var>, <var>G</var>, etc., are specified,
the functions are applied in the order that they are specified.
</p>
<p>The expression <code>declare(<var>F</var>, evfun)</code> gives the <code>evfun</code> property
to the function <var>F</var>. The functions which have the <code>evfun</code> property by
default are the following:
</p>
<pre class="verbatim"> bfloat factor fullratsimp
logcontract polarform radcan
ratexpand ratsimp rectform
rootscontract trigexpand trigreduce
</pre>
<p>Examples:
</p>
<pre class="example">(%i1) x^3 - 1;
3
(%o1) x - 1
(%i2) x^3 - 1, factor;
2
(%o2) (x - 1) (x + x + 1)
(%i3) factor (x^3 - 1);
2
(%o3) (x - 1) (x + x + 1)
(%i4) cos(4 * x) / sin(x)^4;
cos(4 x)
(%o4) --------
4
sin (x)
(%i5) cos(4 * x) / sin(x)^4, trigexpand;
4 2 2 4
sin (x) - 6 cos (x) sin (x) + cos (x)
(%o5) -------------------------------------
4
sin (x)
(%i6) cos(4 * x) / sin(x)^4, trigexpand, ratexpand;
2 4
6 cos (x) cos (x)
(%o6) - --------- + ------- + 1
2 4
sin (x) sin (x)
(%i7) ratexpand (trigexpand (cos(4 * x) / sin(x)^4));
2 4
6 cos (x) cos (x)
(%o7) - --------- + ------- + 1
2 4
sin (x) sin (x)
(%i8) declare ([F, G], evfun);
(%o8) done
(%i9) (aa : bb, bb : cc, cc : dd);
(%o9) dd
(%i10) aa;
(%o10) bb
(%i11) aa, F;
(%o11) F(cc)
(%i12) F (aa);
(%o12) F(bb)
(%i13) F (ev (aa));
(%o13) F(cc)
(%i14) aa, F, G;
(%o14) G(F(cc))
(%i15) G (F (ev (aa)));
(%o15) G(F(cc))
</pre>
<div class=categorybox>
·
<p>@ref{Category: Evaluation flags}
</div>
</p></dd></dl>
<p><a name="infeval"></a>
<a name="Item_003a-infeval"></a>
</p><dl>
<dt><u>Option variable:</u> <b>infeval</b>
<a name="IDX285"></a>
</dt>
<dd><p>Enables "infinite evaluation" mode. <code><a href="#ev">ev</a></code> repeatedly evaluates an
expression until it stops changing. To prevent a variable, say <code>X</code>, from
being evaluated away in this mode, simply include <code>X='X</code> as an argument to
<code>ev</code>. Of course expressions such as <code>ev (X, X=X+1, infeval)</code> will
generate an infinite loop.
</p>
<div class=categorybox>
·
<p>@ref{Category: Evaluation flags}
</div>
</p></dd></dl>
<p><a name="noeval"></a>
<a name="Item_003a-noeval"></a>
</p><dl>
<dt><u>Special symbol:</u> <b>noeval</b>
<a name="IDX286"></a>
</dt>
<dd><p><code>noeval</code> suppresses the evaluation phase of <code><a href="#ev">ev</a></code>. This is useful in
conjunction with other switches and in causing expressions
to be resimplified without being reevaluated.
</p>
<div class=categorybox>
·
<p>@ref{Category: Evaluation flags}
</div>
</p></dd></dl>
<p><a name="nouns"></a>
<a name="Item_003a-nouns"></a>
</p><dl>
<dt><u>Special symbol:</u> <b>nouns</b>
<a name="IDX287"></a>
</dt>
<dd><p><code>nouns</code> is an <code><a href="#evflag">evflag</a></code>. When used as an option to the <code><a href="#ev">ev</a></code>
command, <code>nouns</code> converts all "noun" forms occurring in the expression
being <code>ev</code>'d to "verbs", i.e., evaluates them. See also
<code><a href="maxima_6.html#noun">noun</a></code>, <code><a href="maxima_6.html#nounify">nounify</a></code>, <code>verb</code>, and <code><a href="maxima_6.html#verbify">verbify</a></code>.
</p>
<div class=categorybox>
·
<p>@ref{Category: Evaluation flags} ·
@ref{Category: Nouns and verbs}
</div>
</p></dd></dl>
<p><a name="pred"></a>
<a name="Item_003a-pred"></a>
</p><dl>
<dt><u>Special symbol:</u> <b>pred</b>
<a name="IDX288"></a>
</dt>
<dd><p>As an argument in a call to <code>ev (<var>expr</var>)</code>, <code>pred</code> causes
predicates (expressions which evaluate to <code>true</code> or <code>false</code>) to be
evaluated. See <code><a href="#ev">ev</a></code>.
</p>
<p>Example:
</p>
<pre class="example">(%i1) 1<2;
(%o1) 1 < 2
(%i2) 1<2,pred;
(%o2) true
</pre>
<div class=categorybox>
·
<p>@ref{Category: Evaluation flags}
</div>
</p></dd></dl>
<p><a name="Item_003a-Simplification"></a>
</p><hr size="6">
<table cellpadding="1" cellspacing="1" border="0">
<tr><td valign="middle" align="left">[<a href="#SEC43" title="Beginning of this chapter or previous chapter"> << </a>]</td>
<td valign="middle" align="left">[<a href="maxima_9.html#SEC45" title="Next chapter"> >> </a>]</td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left"> </td>
<td valign="middle" align="left">[<a href="maxima.html#SEC_Top" title="Cover (top) of document">Top</a>]</td>
<td valign="middle" align="left">[<a href="maxima_toc.html#SEC_Contents" title="Table of contents">Contents</a>]</td>
<td valign="middle" align="left">[<a href="maxima_82.html#SEC380" title="Index">Index</a>]</td>
<td valign="middle" align="left">[<a href="maxima_abt.html#SEC_About" title="About (help)"> ? </a>]</td>
</tr></table>
<p>
<font size="-1">
This document was generated by <em>root</em> on <em>January, 10 2014</em> using <a href="http://texi2html.cvshome.org/"><em>texi2html 1.76</em></a>.
</font>
<br>
</p>
</body>
</html>
|