1This is maxima.info, produced by makeinfo version 6.6 from maxima.texi. 2 3Das ist ein Texinfo Maxima Manual 4 5 Copyright 1994,2001 William F. Schelter 6 7START-INFO-DIR-ENTRY 8* Maxima: (maxima). Ein Computer Algebra System. 9END-INFO-DIR-ENTRY 10 11 12File: maxima.info, Node: draw, Next: drawdf, Prev: Package distrib, Up: Top 13 1442 draw 15******* 16 17* Menu: 18 19* Introduction to draw:: 20* Functions and Variables for draw:: 21* Functions and Variables for pictures:: 22* Functions and Variables for worldmap:: 23 24 25File: maxima.info, Node: Introduction to draw, Next: Functions and Variables for draw, Prev: draw, Up: draw 26 2742.1 Introduction to draw 28========================= 29 30'draw' is a Maxima-Gnuplot interface. 31 32There are three main functions to be used at Maxima level: 'draw2d', 33'draw3d' and 'draw'. 34 35Follow this link for more elaborated examples of this package: 36 37<http://riotorto.users.sourceforge.net/gnuplot> 38 39You need Gnuplot 4.2 or newer to run this program. 40 41 42File: maxima.info, Node: Functions and Variables for draw, Next: Functions and Variables for pictures, Prev: Introduction to draw, Up: draw 43 4442.2 Functions and Variables for draw 45===================================== 46 4742.2.1 Scenes 48------------- 49 50 -- Scene constructor: gr2d (<graphic option>, ..., <graphic object>, 51 ...) 52 53 Function 'gr2d' builds an object describing a 2D scene. Arguments 54 are graphic options, graphic objects, or lists containing both 55 graphic options and objects. This scene is interpreted 56 sequentially: graphic options affect those graphic objects placed 57 on its right. Some graphic options affect the global appearence of 58 the scene. 59 60 This is the list of graphic objects available for scenes in two 61 dimensions: 62 'bars', 63 'ellipse', 64 'explicit', 65 'image', 66 'implicit', 67 'label', 68 'parametric', 69 'points', 70 'polar', 71 'polygon', 72 'quadrilateral', 73 'rectangle', 74 'triangle', 75 'vector', and 76 'geomap' (this one defined in package 'worldmap'). 77 78 See also 'draw' and 'draw2d'. To make use of this object, write 79 first 'load(draw)'. 80 81 -- Scene constructor: gr3d (<graphic option>, ..., <graphic object>, 82 ...) 83 84 Function 'gr3d' builds an object describing a 3d scene. Arguments 85 are graphic options, graphic objects, or lists containing both 86 graphic options and objects. This scene is interpreted 87 sequentially: graphic options affect those graphic objects placed 88 on its right. Some graphic options affect the global appearence of 89 the scene. 90 91 This is the list of graphic objects available for scenes in three 92 dimensions: 93 'cylindrical', 94 'elevation_grid', 95 'explicit', 96 'implicit', 97 'label', 98 'mesh', 99 'parametric', 100 'parametric_surface', 101 'points', 102 'quadrilateral', 103 'spherical', 104 'triangle', 105 'tube', 106 'vector', and 107 'geomap' (this one defined in package 'worldmap'). 108 109 See also 'draw' and 'draw3d'. To make use of this object, write 110 first 'load(draw)'. 111 11242.2.2 Functions 113---------------- 114 115 -- Function: draw (<gr2d>, ..., <gr3d>, ..., <options>, ...) 116 117 Plots a series of scenes; its arguments are 'gr2d' and/or 'gr3d' 118 objects, together with some options, or lists of scenes and 119 options. By default, the scenes are put together in one column. 120 121 Function 'draw' accepts the following global options: 'terminal', 122 'columns', 'dimensions', 'file_name' and 'delay'. 123 124 Functions 'draw2d' and 'draw3d' are short cuts to be used when only 125 one scene is required, in two or three dimensions, respectively. 126 127 See also 'gr2d' and 'gr3d'. To make use of this function, write 128 first 'load(draw)'. 129 130 Example: 131 132 (%i1) load(draw)$ 133 (%i2) scene1: gr2d(title="Ellipse", 134 nticks=30, 135 parametric(2*cos(t),5*sin(t),t,0,2*%pi))$ 136 (%i3) scene2: gr2d(title="Triangle", 137 polygon([4,5,7],[6,4,2]))$ 138 (%i4) draw(scene1, scene2, columns = 2)$ 139 140 The two draw sentences are equivalent: 141 142 (%i1) load(draw)$ 143 (%i2) draw(gr3d(explicit(x^2+y^2,x,-1,1,y,-1,1))); 144 (%o2) [gr3d(explicit)] 145 (%i3) draw3d(explicit(x^2+y^2,x,-1,1,y,-1,1)); 146 (%o3) [gr3d(explicit)] 147 148 An animated gif file: 149 150 (%i1) load(draw)$ 151 (%i2) draw( 152 delay = 100, 153 file_name = "zzz", 154 terminal = 'animated_gif, 155 gr2d(explicit(x^2,x,-1,1)), 156 gr2d(explicit(x^3,x,-1,1)), 157 gr2d(explicit(x^4,x,-1,1))); 158 End of animation sequence 159 (%o2) [gr2d(explicit), gr2d(explicit), gr2d(explicit)] 160 161 See also 'gr2d', 'gr3d', 'draw2d' and 'draw3d'. 162 163 -- Function: draw2d (<option>, <graphic_object>, ...) 164 165 This function is a short cut for 'draw(gr2d(<options>, ..., 166 <graphic_object>, ...))'. 167 168 It can be used to plot a unique scene in 2d. 169 170 To make use of this function, write first 'load(draw)'. 171 172 See also 'draw' and 'gr2d'. 173 174 -- Function: draw3d (<option>, <graphic_object>, ...) 175 176 This function is a short cut for 'draw(gr3d(<options>, ..., 177 <graphic_object>, ...))'. 178 179 It can be used to plot a unique scene in 3d. 180 181 To make use of this function, write first 'load(draw)'. 182 183 See also 'draw' and 'gr3d'. 184 185 -- Function: draw_file (<graphic option>, ..., <graphic object>, ...) 186 187 Saves the current plot into a file. Accepted graphics options are: 188 'terminal', 'dimensions', 'file_name' and 'background_color'. 189 190 Example: 191 192 (%i1) load(draw)$ 193 (%i2) /* screen plot */ 194 draw(gr3d(explicit(x^2+y^2,x,-1,1,y,-1,1)))$ 195 (%i3) /* same plot in eps format */ 196 draw_file(terminal = eps, 197 dimensions = [5,5]) $ 198 199 -- Function: multiplot_mode (<term>) 200 201 This function enables Maxima to work in one-window multiplot mode 202 with terminal <term>; accepted arguments for this function are 203 'screen', 'wxt', 'aquaterm' and 'none'. 204 205 When multiplot mode is enabled, each call to 'draw' sends a new 206 plot to the same window, without erasing the previous ones. To 207 disable the multiplot mode, write 'multiplot_mode(none)'. 208 209 When multiplot mode is enabled, global option 'terminal' is blocked 210 and you have to disable this working mode before changing to 211 another terminal. 212 213 This feature does not work in Windows platforms. 214 215 Example: 216 217 (%i1) load(draw)$ 218 (%i2) set_draw_defaults( 219 xrange = [-1,1], 220 yrange = [-1,1], 221 grid = true, 222 title = "Step by step plot" )$ 223 (%i3) multiplot_mode(screen)$ 224 (%i4) draw2d(color=blue, explicit(x^2,x,-1,1))$ 225 (%i5) draw2d(color=red, explicit(x^3,x,-1,1))$ 226 (%i6) draw2d(color=brown, explicit(x^4,x,-1,1))$ 227 (%i7) multiplot_mode(none)$ 228 229 -- Function: set_draw_defaults (<graphic option>, ..., <graphic 230 object>, ...) 231 232 Sets user graphics options. This function is useful for plotting a 233 sequence of graphics with common graphics options. Calling this 234 function without arguments removes user defaults. 235 236 Example: 237 238 (%i1) load(draw)$ 239 (%i2) set_draw_defaults( 240 xrange = [-10,10], 241 yrange = [-2, 2], 242 color = blue, 243 grid = true)$ 244 (%i3) /* plot with user defaults */ 245 draw2d(explicit(((1+x)**2/(1+x*x))-1,x,-10,10))$ 246 (%i4) set_draw_defaults()$ 247 (%i5) /* plot with standard defaults */ 248 draw2d(explicit(((1+x)**2/(1+x*x))-1,x,-10,10))$ 249 250 To make use of this function, write first 'load(draw)'. 251 25242.2.3 Graphics options 253----------------------- 254 255 -- Graphic option: adapt_depth 256 Default value: 10 257 258 'adapt_depth' is the maximum number of splittings used by the 259 adaptive plotting routine. 260 261 This option is relevant only for 2d 'explicit' functions. 262 263 -- Graphic option: axis_3d 264 Default value: 'true' 265 266 If 'axis_3d' is 'true', the <x>, <y> and <z> axis are shown in 3d 267 scenes. 268 269 Since this is a global graphics option, its position in the scene 270 description does not matter. 271 272 Example: 273 274 (%i1) load(draw)$ 275 (%i2) draw3d(axis_3d = false, 276 explicit(sin(x^2+y^2),x,-2,2,y,-2,2) )$ 277 278 See also 'axis_bottom', 'axis_left', 'axis_top', and 'axis_right' 279 for axis in 2d. 280 281 -- Graphic option: axis_bottom 282 Default value: 'true' 283 284 If 'axis_bottom' is 'true', the bottom axis is shown in 2d scenes. 285 286 Since this is a global graphics option, its position in the scene 287 description does not matter. 288 289 Example: 290 291 (%i1) load(draw)$ 292 (%i2) draw2d(axis_bottom = false, 293 explicit(x^3,x,-1,1))$ 294 295 See also 'axis_left', 'axis_top', 'axis_right', and 'axis_3d'. 296 297 -- Graphic option: axis_left 298 Default value: 'true' 299 300 If 'axis_left' is 'true', the left axis is shown in 2d scenes. 301 302 Since this is a global graphics option, its position in the scene 303 description does not matter. 304 305 Example: 306 307 (%i1) load(draw)$ 308 (%i2) draw2d(axis_left = false, 309 explicit(x^3,x,-1,1))$ 310 311 See also 'axis_bottom', 'axis_top', 'axis_right', and 'axis_3d'. 312 313 -- Graphic option: axis_right 314 Default value: 'true' 315 316 If 'axis_right' is 'true', the right axis is shown in 2d scenes. 317 318 Since this is a global graphics option, its position in the scene 319 description does not matter. 320 321 Example: 322 323 (%i1) load(draw)$ 324 (%i2) draw2d(axis_right = false, 325 explicit(x^3,x,-1,1))$ 326 327 See also 'axis_bottom', 'axis_left', 'axis_top', and 'axis_3d'. 328 329 -- Graphic option: axis_top 330 Default value: 'true' 331 332 If 'axis_top' is 'true', the top axis is shown in 2d scenes. 333 334 Since this is a global graphics option, its position in the scene 335 description does not matter. 336 337 Example: 338 339 (%i1) load(draw)$ 340 (%i2) draw2d(axis_top = false, 341 explicit(x^3,x,-1,1))$ 342 343 See also 'axis_bottom', 'axis_left', 'axis_right', and 'axis_3d'. 344 345 -- Graphic option: background_color 346 Default value: 'white' 347 348 Sets the background color for terminals 'gif', 'png', 'jpg', and 349 'gif'. Default background color is white. 350 351 This option das not work with terminals 'epslatex' and 352 'epslatex_standalone'. 353 354 See also 'color'. 355 356 -- Graphic option: border 357 Default value: 'true' 358 359 If 'border' is 'true', borders of polygons are painted according to 360 'line_type' and 'line_width'. 361 362 This option affects the following graphic objects: 363 * 'gr2d': 'polygon', 'rectangle', and 'ellipse'. 364 365 Example: 366 367 (%i1) load(draw)$ 368 (%i2) draw2d(color = brown, 369 line_width = 8, 370 polygon([[3,2],[7,2],[5,5]]), 371 border = false, 372 fill_color = blue, 373 polygon([[5,2],[9,2],[7,5]]) )$ 374 375 -- Graphic option: cbrange 376 Default value: 'auto' 377 378 If 'cbrange' is 'auto', the range for the values which are colored 379 when 'enhanced3d' is not 'false' is computed automatically. Values 380 outside of the color range use color of the nearest extreme. 381 382 When 'enhanced3d' or 'colorbox' is 'false', option 'cbrange' has no 383 effect. 384 385 If the user wants a specific interval for the colored values, it 386 must be given as a Maxima list, as in 'cbrange=[-2, 3]'. 387 388 Since this is a global graphics option, its position in the scene 389 description does not matter. 390 391 Example: 392 393 (%i1) load(draw)$ 394 (%i2) draw3d ( 395 enhanced3d = true, 396 color = green, 397 cbrange = [-3,10], 398 explicit(x^2+y^2, x,-2,2,y,-2,2)) $ 399 400 See also 'enhanced3d', 'colorbox' and 'cbtics'. 401 402 -- Graphic option: cbtics 403 Default value: 'auto' 404 405 This graphic option controls the way tic marks are drawn on the 406 colorbox when option 'enhanced3d' is not 'false'. 407 408 When 'enhanced3d' or 'colorbox' is 'false', option 'cbtics' has no 409 effect. 410 411 See 'xtics' for a complete description. 412 413 Example : 414 415 (%i1) load(draw)$ 416 (%i2) draw3d ( 417 enhanced3d = true, 418 color = green, 419 cbtics = {["High",10],["Medium",05],["Low",0]}, 420 cbrange = [0, 10], 421 explicit(x^2+y^2, x,-2,2,y,-2,2)) $ 422 423 See also 'enhanced3d', 'colorbox' and 'cbrange'. 424 425 -- Graphic option: color 426 Default value: 'blue' 427 428 'color' specifies the color for plotting lines, points, borders of 429 polygons and labels. 430 431 Colors can be given as names or in hexadecimal rgb code. 432 433 Available color names are: 434 white black gray0 grey0 435 gray10 grey10 gray20 grey20 436 gray30 grey30 gray40 grey40 437 gray50 grey50 gray60 grey60 438 gray70 grey70 gray80 grey80 439 gray90 grey90 gray100 grey100 440 gray grey light_gray light_grey 441 dark_gray dark_grey red light_red 442 dark_red yellow light_yellow dark_yellow 443 green light_green dark_green spring_green 444 forest_green sea_green blue light_blue 445 dark_blue midnight_blue navy medium_blue 446 royalblue skyblue cyan light_cyan 447 dark_cyan magenta light_magenta dark_magenta 448 turquoise light_turquoise dark_turquoise pink 449 light_pink dark_pink coral light_coral 450 orange_red salmon light_salmon dark_salmon 451 aquamarine khaki dark_khaki goldenrod 452 light_goldenrod dark_goldenrod gold beige 453 brown orange dark_orange violet 454 dark_violet plum purple 455 456 Cromatic componentes in hexadecimal code are introduced in the form 457 '"#rrggbb"'. 458 459 Example: 460 461 (%i1) load(draw)$ 462 (%i2) draw2d(explicit(x^2,x,_1,1), /* default is black */ 463 color = red, 464 explicit(0.5 + x^2,x,-1,1), 465 color = blue, 466 explicit(1 + x^2,x,-1,1), 467 color = light_blue, 468 explicit(1.5 + x^2,x,-1,1), 469 color = "#23ab0f", 470 label(["This is a label",0,1.2]) )$ 471 472 See also 'fill_color'. 473 474 -- Graphic option: colorbox 475 Default value: 'true' 476 477 If 'colorbox' is 'true', a color scale without label is drawn 478 together with 'image' 2D objects, or coloured 3d objects. If 479 'colorbox' is 'false', no color scale is shown. If 'colorbox' is a 480 string, a color scale with label is drawn. 481 482 Since this is a global graphics option, its position in the scene 483 description does not matter. 484 485 Example: 486 487 Color scale and images. 488 489 (%i1) load(draw)$ 490 (%i2) im: apply('matrix, 491 makelist(makelist(random(200),i,1,30),i,1,30))$ 492 (%i3) draw2d(image(im,0,0,30,30))$ 493 (%i4) draw2d(colorbox = false, image(im,0,0,30,30))$ 494 495 Color scale and 3D coloured object. 496 497 (%i1) load(draw)$ 498 (%i2) draw3d( 499 colorbox = "Magnitude", 500 enhanced3d = true, 501 explicit(x^2+y^2,x,-1,1,y,-1,1))$ 502 503 See also 'palette'. 504 505 -- Graphic option: columns 506 Default value: 1 507 508 'columns' is the number of columns in multiple plots. 509 510 Since this is a global graphics option, its position in the scene 511 description does not matter. It can be also used as an argument of 512 function 'draw'. 513 514 Example: 515 516 (%i1) load(draw)$ 517 (%i2) scene1: gr2d(title="Ellipse", 518 nticks=30, 519 parametric(2*cos(t),5*sin(t),t,0,2*%pi))$ 520 (%i3) scene2: gr2d(title="Triangle", 521 polygon([4,5,7],[6,4,2]))$ 522 (%i4) draw(scene1, scene2, columns = 2)$ 523 524 -- Graphic option: contour 525 Default value: 'none' 526 527 Option 'contour' enables the user to select where to plot contour 528 lines. Possible values are: 529 530 * 'none': no contour lines are plotted. 531 532 * 'base': contour lines are projected on the xy plane. 533 534 * 'surface': contour lines are plotted on the surface. 535 536 * 'both': two contour lines are plotted: on the xy plane and on 537 the surface. 538 539 * 'map': contour lines are projected on the xy plane, and the 540 view point is set just in the vertical. 541 542 Since this is a global graphics option, its position in the scene 543 description does not matter. 544 545 Example: 546 547 (%i1) load(draw)$ 548 (%i2) draw3d(explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3), 549 contour_levels = 15, 550 contour = both, 551 surface_hide = true) $ 552 553 -- Graphic option: contour_levels 554 Default value: 5 555 556 This graphic option controls the way contours are drawn. 557 'contour_levels' can be set to a positive integer number, a list of 558 three numbers or an arbitrary set of numbers: 559 560 * When option 'contour_levels' is bounded to positive integer 561 <n>, <n> contour lines will be drawn at equal intervals. By 562 default, five equally spaced contours are plotted. 563 564 * When option 'contour_levels' is bounded to a list of length 565 three of the form '[lowest,s,highest]', contour lines are 566 plotted from 'lowest' to 'highest' in steps of 's'. 567 568 * When option 'contour_levels' is bounded to a set of numbers of 569 the form '{n1, n2, ...}', contour lines are plotted at values 570 'n1', 'n2', ... 571 572 Since this is a global graphics option, its position in the scene 573 description does not matter. 574 575 Examples: 576 577 Ten equally spaced contour lines. The actual number of levels can 578 be adjusted to give simple labels. 579 580 (%i1) load(draw)$ 581 (%i2) draw3d(color = green, 582 explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3), 583 contour_levels = 10, 584 contour = both, 585 surface_hide = true) $ 586 587 From -8 to 8 in steps of 4. 588 589 (%i1) load(draw)$ 590 (%i2) draw3d(color = green, 591 explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3), 592 contour_levels = [-8,4,8], 593 contour = both, 594 surface_hide = true) $ 595 596 Isolines at levels -7, -6, 0.8 and 5. 597 598 (%i1) load(draw)$ 599 (%i2) draw3d(color = green, 600 explicit(20*exp(-x^2-y^2)-10,x,0,2,y,-3,3), 601 contour_levels = {-7, -6, 0.8, 5}, 602 contour = both, 603 surface_hide = true) $ 604 605 See also 'contour'. 606 607 -- Graphic option: data_file_name 608 Default value: '"data.gnuplot"' 609 610 This is the name of the file with the numeric data needed by 611 Gnuplot to build the requested plot. 612 613 Since this is a global graphics option, its position in the scene 614 description does not matter. It can be also used as an argument of 615 function 'draw'. 616 617 See example in 'gnuplot_file_name'. 618 619 -- Graphic option: delay 620 Default value: 5 621 622 This is the delay in 1/100 seconds of frames in animated gif files. 623 624 Since this is a global graphics option, its position in the scene 625 description does not matter. It can be also used as an argument of 626 function 'draw'. 627 628 Example: 629 630 (%i1) load(draw)$ 631 (%i2) draw( 632 delay = 100, 633 file_name = "zzz", 634 terminal = 'animated_gif, 635 gr2d(explicit(x^2,x,-1,1)), 636 gr2d(explicit(x^3,x,-1,1)), 637 gr2d(explicit(x^4,x,-1,1))); 638 End of animation sequence 639 (%o2) [gr2d(explicit), gr2d(explicit), gr2d(explicit)] 640 641 Option 'delay' is only active in animated gif's; it is ignored in 642 any other case. 643 644 See also 'terminal', 'dimensions'. 645 646 -- Graphic option: dimensions 647 Default value: '[600,500]' 648 649 Dimensions of the output terminal. Its value is a list formed by 650 the width and the height. The meaning of the two numbers depends 651 on the terminal you are working with. 652 653 With terminals 'gif', 'animated_gif', 'png', 'jpg', 'svg', 654 'screen', 'wxt', and 'aquaterm', the integers represent the number 655 of points in each direction. If they are not intergers, they are 656 rounded. 657 658 With terminals 'eps', 'eps_color', 'pdf', and 'pdfcairo', both 659 numbers represent hundredths of cm, which means that, by default, 660 pictures in these formats are 6 cm in width and 5 cm in height. 661 662 Since this is a global graphics option, its position in the scene 663 description does not matter. It can be also used as an argument of 664 function 'draw'. 665 666 Examples: 667 668 Option 'dimensions' applied to file output and to wxt canvas. 669 670 (%i1) load(draw)$ 671 (%i2) draw2d( 672 dimensions = [300,300], 673 terminal = 'png, 674 explicit(x^4,x,-1,1)) $ 675 (%i3) draw2d( 676 dimensions = [300,300], 677 terminal = 'wxt, 678 explicit(x^4,x,-1,1)) $ 679 680 Option 'dimensions' applied to eps output. We want an eps file 681 with A4 portrait dimensions. 682 683 (%i1) load(draw)$ 684 (%i2) A4portrait: 100*[21, 29.7]$ 685 (%i3) draw3d( 686 dimensions = A4portrait, 687 terminal = 'eps, 688 explicit(x^2-y^2,x,-2,2,y,-2,2)) $ 689 690 -- Graphic option: draw_realpart 691 Default value: 'true' 692 693 When 'true', functions to be drawn are considered as complex 694 functions whose real part value should be plotted; when 'false', 695 nothing will be plotted when the function does not give a real 696 value. 697 698 This option affects objects 'explicit' and 'parametric' in 2D and 699 3D, and 'parametric_surface'. 700 701 Example: 702 703 Option 'draw_realpart' affects objects 'explicit' and 'parametric'. 704 705 (%i1) load(draw)$ 706 (%i2) draw2d( 707 draw_realpart = false, 708 explicit(sqrt(x^2 - 4*x) - x, x, -1, 5), 709 color = red, 710 draw_realpart = true, 711 parametric(x,sqrt(x^2 - 4*x) - x + 1, x, -1, 5) ); 712 713 -- Graphic option: enhanced3d 714 Default value: 'none' 715 716 If 'enhanced3d' is 'none', surfaces are not colored in 3D plots. 717 In order to get a colored surface, a list must be assigned to 718 option 'enhanced3d', where the first element is an expression and 719 the rest are the names of the variables or parameters used in that 720 expression. A list such '[f(x,y,z), x, y, z]' means that point 721 '[x,y,z]' of the surface is assigned number 'f(x,y,z)', which will 722 be colored according to the actual 'palette'. For those 3D graphic 723 objects defined in terms of parameters, it is possible to define 724 the color number in terms of the parameters, as in '[f(u), u]', as 725 in objects 'parametric' and 'tube', or '[f(u,v), u, v]', as in 726 object 'parametric_surface'. While all 3D objects admit the model 727 based on absolute coordinates, '[f(x,y,z), x, y, z]', only two of 728 them, namely 'explicit' and 'elevation_grid', accept also models 729 defined on the '[x,y]' coordinates, '[f(x,y), x, y]'. 3D graphic 730 object 'implicit' accepts only the '[f(x,y,z), x, y, z]' model. 731 Object 'points' accepts also the '[f(x,y,z), x, y, z]' model, but 732 when points have a chronological nature, model '[f(k), k]' is also 733 valid, being 'k' an ordering parameter. 734 735 When 'enhanced3d' is assigned something different to 'none', 736 options 'color' and 'surface_hide' are ignored. 737 738 The names of the variables defined in the lists may be different to 739 those used in the definitions of the graphic objects. 740 741 In order to maintain back compatibility, 'enhanced3d = false' is 742 equivalent to 'enhanced3d = none', and 'enhanced3d = true' is 743 equivalent to 'enhanced3d = [z, x, y, z]'. If an expression is 744 given to 'enhanced3d', its variables must be the same used in the 745 surface definition. This is not necessary when using lists. 746 747 See option 'palette' to learn how palettes are specified. 748 749 Examples: 750 751 'explicit' object with coloring defined by the '[f(x,y,z), x, y, 752 z]' model. 753 754 (%i1) load(draw)$ 755 (%i2) draw3d( 756 enhanced3d = [x-z/10,x,y,z], 757 palette = gray, 758 explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3))$ 759 760 'explicit' object with coloring defined by the '[f(x,y), x, y]' 761 model. The names of the variables defined in the lists may be 762 different to those used in the definitions of the graphic objects; 763 in this case, 'r' corresponds to 'x', and 's' to 'y'. 764 765 (%i1) load(draw)$ 766 (%i2) draw3d( 767 enhanced3d = [sin(r*s),r,s], 768 explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3))$ 769 770 'parametric' object with coloring defined by the '[f(x,y,z), x, y, 771 z]' model. 772 773 (%i1) load(draw)$ 774 (%i2) draw3d( 775 nticks = 100, 776 line_width = 2, 777 enhanced3d = [if y>= 0 then 1 else 0, x, y, z], 778 parametric(sin(u)^2,cos(u),u,u,0,4*%pi)) $ 779 780 'parametric' object with coloring defined by the '[f(u), u]' model. 781 In this case, '(u-1)^2' is a shortcut for '[(u-1)^2,u]'. 782 783 (%i1) load(draw)$ 784 (%i2) draw3d( 785 nticks = 60, 786 line_width = 3, 787 enhanced3d = (u-1)^2, 788 parametric(cos(5*u)^2,sin(7*u),u-2,u,0,2))$ 789 790 'elevation_grid' object with coloring defined by the '[f(x,y), x, 791 y]' model. 792 793 (%i1) load(draw)$ 794 (%i2) m: apply( 795 matrix, 796 makelist(makelist(cos(i^2/80-k/30),k,1,30),i,1,20)) $ 797 (%i3) draw3d( 798 enhanced3d = [cos(x*y*10),x,y], 799 elevation_grid(m,-1,-1,2,2), 800 xlabel = "x", 801 ylabel = "y"); 802 803 'tube' object with coloring defined by the '[f(x,y,z), x, y, z]' 804 model. 805 806 (%i1) load(draw)$ 807 (%i2) draw3d( 808 enhanced3d = [cos(x-y),x,y,z], 809 palette = gray, 810 xu_grid = 50, 811 tube(cos(a), a, 0, 1, a, 0, 4*%pi) )$ 812 813 'tube' object with coloring defined by the '[f(u), u]' model. 814 Here, 'enhanced3d = -a' would be the shortcut for 'enhanced3d = 815 [-foo,foo]'. 816 817 (%i1) load(draw)$ 818 (%i2) draw3d( 819 tube_extremes = [open, closed], 820 palette = [26,15,-2], 821 enhanced3d = [-foo, foo], 822 tube(a, a, a^2, 1, a, -2, 2) )$ 823 824 'implicit' and 'points' objects with coloring defined by the 825 '[f(x,y,z), x, y, z]' model. 826 827 (%i1) load(draw)$ 828 (%i2) draw3d( 829 enhanced3d = [x-y,x,y,z], 830 implicit((x^2+y^2+z^2-1)*(x^2+(y-1.5)^2+z^2-0.5)=0.015, 831 x,-1,1,y,-1.2,2.3,z,-1,1)) $ 832 (%i3) m: makelist([random(1.0),random(1.0),random(1.0)],k,1,2000)$ 833 (%i4) draw3d( 834 point_type = filled_circle, 835 point_size = 2, 836 enhanced3d = [u+v-w,u,v,w], 837 points(m) ) $ 838 839 When points have a chronological nature, model '[f(k), k]' is also 840 valid, being 'k' an ordering parameter. 841 842 (%i1) load(draw)$ 843 (%i2) m:makelist([random(1.0), random(1.0), random(1.0)],k,1,5)$ 844 (%i3) draw3d( 845 enhanced3d = [sin(j), j], 846 point_size = 3, 847 point_type = filled_circle, 848 points_joined = true, 849 points(m)) $ 850 851 -- Graphic option: error_type 852 Default value: 'y' 853 854 Depending on its value, which can be 'x', 'y', or 'xy', graphic 855 object 'errors' will draw points with horizontal, vertical, or 856 both, error bars. When 'error_type=boxes', boxes will be drawn 857 instead of crosses. 858 859 See also 'errors'. 860 861 -- Graphic option: file_name 862 Default value: '"maxima_out"' 863 864 This is the name of the file where terminals 'png', 'jpg', 'gif', 865 'eps', 'eps_color', 'pdf', 'pdfcairo' and 'svg' will save the 866 graphic. 867 868 Since this is a global graphics option, its position in the scene 869 description does not matter. It can be also used as an argument of 870 function 'draw'. 871 872 Example: 873 874 (%i1) load(draw)$ 875 (%i2) draw2d(file_name = "myfile", 876 explicit(x^2,x,-1,1), 877 terminal = 'png)$ 878 879 See also 'terminal', 'dimensions'. 880 881 -- Graphic option: fill_color 882 Default value: '"red"' 883 884 'fill_color' specifies the color for filling polygons and 2d 885 'explicit' functions. 886 887 See 'color' to learn how colors are specified. 888 889 -- Graphic option: fill_density 890 Default value: 0 891 892 'fill_density' is a number between 0 and 1 that specifies the 893 intensity of the 'fill_color' in 'bars' objects. 894 895 See 'bars' for examples. 896 897 -- Graphic option: filled_func 898 Default value: 'false' 899 900 Option 'filled_func' controls how regions limited by functions 901 should be filled. When 'filled_func' is 'true', the region bounded 902 by the function defined with object 'explicit' and the bottom of 903 the graphic window is filled with 'fill_color'. When 'filled_func' 904 contains a function expression, then the region bounded by this 905 function and the function defined with object 'explicit' will be 906 filled. By default, explicit functions are not filled. 907 908 This option affects only the 2d graphic object 'explicit'. 909 910 Example: 911 912 Region bounded by an 'explicit' object and the bottom of the 913 graphic window. 914 (%i1) load(draw)$ 915 (%i2) draw2d(fill_color = red, 916 filled_func = true, 917 explicit(sin(x),x,0,10) )$ 918 919 Region bounded by an 'explicit' object and the function defined by 920 option 'filled_func'. Note that the variable in 'filled_func' must 921 be the same as that used in 'explicit'. 922 923 (%i1) load(draw)$ 924 (%i2) draw2d(fill_color = grey, 925 filled_func = sin(x), 926 explicit(-sin(x),x,0,%pi)); 927 928 See also 'fill_color' and 'explicit'. 929 930 -- Graphic option: font 931 Default value: '""' (empty string) 932 933 This option can be used to set the font face to be used by the 934 terminal. Only one font face and size can be used throughout the 935 plot. 936 937 Since this is a global graphics option, its position in the scene 938 description does not matter. 939 940 See also 'font_size' 941 942 Gnuplot doesn't handle fonts by itself, it leaves this task to the 943 support libraries of the different terminals, each one with its own 944 philosophy about it. A brief summary follows: 945 946 * x11: Uses the normal x11 font server mechanism. 947 948 Example: 949 (%i1) load(draw)$ 950 (%i2) draw2d(font = "Arial", 951 font_size = 20, 952 label(["Arial font, size 20",1,1]))$ 953 954 * windows: The windows terminal doesn't support changing of 955 fonts from inside the plot. Once the plot has been generated, 956 the font can be changed right-clicking on the menu of the 957 graph window. 958 959 * png, jpeg, gif: The libgd library uses the font path stored in 960 the environment variable 'GDFONTPATH'; in this case, it is 961 only necessary to set option 'font' to the font's name. It is 962 also possible to give the complete path to the font file. 963 964 Examples: 965 966 Option 'font' can be given the complete path to the font file: 967 (%i1) load(draw)$ 968 (%i2) path: "/usr/share/fonts/truetype/freefont/" $ 969 (%i3) file: "FreeSerifBoldItalic.ttf" $ 970 (%i4) draw2d( 971 font = concat(path, file), 972 font_size = 20, 973 color = red, 974 label(["FreeSerifBoldItalic font, size 20",1,1]), 975 terminal = png)$ 976 977 If environment variable 'GDFONTPATH' is set to the path where 978 font files are allocated, it is possible to set graphic option 979 'font' to the name of the font. 980 981 (%i1) load(draw)$ 982 (%i2) draw2d( 983 font = "FreeSerifBoldItalic", 984 font_size = 20, 985 color = red, 986 label(["FreeSerifBoldItalic font, size 20",1,1]), 987 terminal = png)$ 988 989 * Postscript: Standard Postscript fonts are: 990 '"Times-Roman"', 991 '"Times-Italic"', 992 '"Times-Bold"', 993 '"Times-BoldItalic"', 994 '"Helvetica"', 995 '"Helvetica-Oblique"', 996 '"Helvetica-Bold"', 997 '"Helvetic-BoldOblique"', 998 '"Courier"', 999 '"Courier-Oblique"', 1000 '"Courier-Bold"', and 1001 '"Courier-BoldOblique"'. 1002 1003 Example: 1004 1005 (%i1) load(draw)$ 1006 (%i2) draw2d( 1007 font = "Courier-Oblique", 1008 font_size = 15, 1009 label(["Courier-Oblique font, size 15",1,1]), 1010 terminal = eps)$ 1011 1012 * pdf: Uses same fonts as Postscript. 1013 1014 * pdfcairo: Uses same fonts as wxt. 1015 1016 * wxt: The pango library finds fonts via the 'fontconfig' 1017 utility. 1018 1019 * aqua: Default is '"Times-Roman"'. 1020 1021 The gnuplot documentation is an important source of information 1022 about terminals and fonts. 1023 1024 -- Graphic option: font_size 1025 Default value: 10 1026 1027 This option can be used to set the font size to be used by the 1028 terminal. Only one font face and size can be used throughout the 1029 plot. 'font_size' is active only when option 'font' is not equal 1030 to the empty string. 1031 1032 Since this is a global graphics option, its position in the scene 1033 description does not matter. 1034 1035 See also 'font'. 1036 1037 -- Graphic option: gnuplot_file_name 1038 Default value: '"maxout.gnuplot"' 1039 1040 This is the name of the file with the necessary commands to be 1041 processed by Gnuplot. 1042 1043 Since this is a global graphics option, its position in the scene 1044 description does not matter. It can be also used as an argument of 1045 function 'draw'. 1046 1047 Example: 1048 1049 (%i1) load(draw)$ 1050 (%i2) draw2d( 1051 file_name = "my_file", 1052 gnuplot_file_name = "my_commands_for_gnuplot", 1053 data_file_name = "my_data_for_gnuplot", 1054 terminal = png, 1055 explicit(x^2,x,-1,1)) $ 1056 1057 See also 'data_file_name'. 1058 1059 -- Graphic option: grid 1060 Default value: 'false' 1061 1062 If 'grid' is 'true', a grid will be drawn on the <xy> plane. 1063 1064 Since this is a global graphics option, its position in the scene 1065 description does not matter. 1066 1067 Example: 1068 1069 (%i1) load(draw)$ 1070 (%i2) draw2d(grid = true, 1071 explicit(exp(u),u,-2,2))$ 1072 1073 -- Graphic option: head_angle 1074 Default value: 45 1075 1076 'head_angle' indicates the angle, in degrees, between the arrow 1077 heads and the segment. 1078 1079 This option is relevant only for 'vector' objects. 1080 1081 Example: 1082 1083 (%i1) load(draw)$ 1084 (%i2) draw2d(xrange = [0,10], 1085 yrange = [0,9], 1086 head_length = 0.7, 1087 head_angle = 10, 1088 vector([1,1],[0,6]), 1089 head_angle = 20, 1090 vector([2,1],[0,6]), 1091 head_angle = 30, 1092 vector([3,1],[0,6]), 1093 head_angle = 40, 1094 vector([4,1],[0,6]), 1095 head_angle = 60, 1096 vector([5,1],[0,6]), 1097 head_angle = 90, 1098 vector([6,1],[0,6]), 1099 head_angle = 120, 1100 vector([7,1],[0,6]), 1101 head_angle = 160, 1102 vector([8,1],[0,6]), 1103 head_angle = 180, 1104 vector([9,1],[0,6]) )$ 1105 1106 See also 'head_both', 'head_length', and 'head_type'. 1107 1108 -- Graphic option: head_both 1109 Default value: 'false' 1110 1111 If 'head_both' is 'true', vectors are plotted with two arrow heads. 1112 If 'false', only one arrow is plotted. 1113 1114 This option is relevant only for 'vector' objects. 1115 1116 Example: 1117 1118 (%i1) load(draw)$ 1119 (%i2) draw2d(xrange = [0,8], 1120 yrange = [0,8], 1121 head_length = 0.7, 1122 vector([1,1],[6,0]), 1123 head_both = true, 1124 vector([1,7],[6,0]) )$ 1125 1126 See also 'head_length', 'head_angle', and 'head_type'. 1127 1128 -- Graphic option: head_length 1129 Default value: 2 1130 1131 'head_length' indicates, in <x>-axis units, the length of arrow 1132 heads. 1133 1134 This option is relevant only for 'vector' objects. 1135 1136 Example: 1137 1138 (%i1) load(draw)$ 1139 (%i2) draw2d(xrange = [0,12], 1140 yrange = [0,8], 1141 vector([0,1],[5,5]), 1142 head_length = 1, 1143 vector([2,1],[5,5]), 1144 head_length = 0.5, 1145 vector([4,1],[5,5]), 1146 head_length = 0.25, 1147 vector([6,1],[5,5]))$ 1148 1149 See also 'head_both', 'head_angle', and 'head_type'. 1150 1151 -- Graphic option: head_type 1152 Default value: 'filled' 1153 1154 'head_type' is used to specify how arrow heads are plotted. 1155 Possible values are: 'filled' (closed and filled arrow heads), 1156 'empty' (closed but not filled arrow heads), and 'nofilled' (open 1157 arrow heads). 1158 1159 This option is relevant only for 'vector' objects. 1160 1161 Example: 1162 1163 (%i1) load(draw)$ 1164 (%i2) draw2d(xrange = [0,12], 1165 yrange = [0,10], 1166 head_length = 1, 1167 vector([0,1],[5,5]), /* default type */ 1168 head_type = 'empty, 1169 vector([3,1],[5,5]), 1170 head_type = 'nofilled, 1171 vector([6,1],[5,5]))$ 1172 1173 See also 'head_both', 'head_angle', and 'head_length'. 1174 1175 -- Graphic option: ip_grid 1176 Default value: '[50, 50]' 1177 1178 'ip_grid' sets the grid for the first sampling in implicit plots. 1179 1180 This option is relevant only for 'implicit' objects. 1181 1182 -- Graphic option: ip_grid_in 1183 Default value: '[5, 5]' 1184 1185 'ip_grid_in' sets the grid for the second sampling in implicit 1186 plots. 1187 1188 This option is relevant only for 'implicit' objects. 1189 1190 -- Graphic option: key 1191 Default value: '""' (empty string) 1192 1193 'key' is the name of a function in the legend. If 'key' is an 1194 empty string, no key is assigned to the function. 1195 1196 This option affects the following graphic objects: 1197 * 'gr2d': 'points', 'polygon', 'rectangle', 'ellipse', 'vector', 1198 'explicit', 'implicit', 'parametric', and 'polar'. 1199 1200 * 'gr3d': 'points', 'explicit', 'parametric', and 1201 'parametric_surface'. 1202 1203 Example: 1204 1205 (%i1) load(draw)$ 1206 (%i2) draw2d(key = "Sinus", 1207 explicit(sin(x),x,0,10), 1208 key = "Cosinus", 1209 color = red, 1210 explicit(cos(x),x,0,10) )$ 1211 1212 -- Graphic option: label_alignment 1213 Default value: 'center' 1214 1215 'label_alignment' is used to specify where to write labels with 1216 respect to the given coordinates. Possible values are: 'center', 1217 'left', and 'right'. 1218 1219 This option is relevant only for 'label' objects. 1220 1221 Example: 1222 1223 (%i1) load(draw)$ 1224 (%i2) draw2d(xrange = [0,10], 1225 yrange = [0,10], 1226 points_joined = true, 1227 points([[5,0],[5,10]]), 1228 color = blue, 1229 label(["Centered alignment (default)",5,2]), 1230 label_alignment = 'left, 1231 label(["Left alignment",5,5]), 1232 label_alignment = 'right, 1233 label(["Right alignment",5,8]))$ 1234 1235 See also 'label_orientation', and 'color'. 1236 1237 -- Graphic option: label_orientation 1238 Default value: 'horizontal' 1239 1240 'label_orientation' is used to specify orientation of labels. 1241 Possible values are: 'horizontal', and 'vertical'. 1242 1243 This option is relevant only for 'label' objects. 1244 1245 Example: 1246 1247 In this example, a dummy point is added to get an image. Package 1248 'draw' needs always data to draw an scene. 1249 (%i1) load(draw)$ 1250 (%i2) draw2d(xrange = [0,10], 1251 yrange = [0,10], 1252 point_size = 0, 1253 points([[5,5]]), 1254 color = navy, 1255 label(["Horizontal orientation (default)",5,2]), 1256 label_orientation = 'vertical, 1257 color = "#654321", 1258 label(["Vertical orientation",1,5]))$ 1259 1260 See also 'label_alignment' and 'color'. 1261 1262 -- Graphic option: line_type 1263 Default value: 'solid' 1264 1265 'line_type' indicates how lines are displayed; possible values are 1266 'solid' and 'dots'. 1267 1268 This option affects the following graphic objects: 1269 * 'gr2d': 'points', 'polygon', 'rectangle', 'ellipse', 'vector', 1270 'explicit', 'implicit', 'parametric' and 'polar'. 1271 1272 * 'gr3d': 'points', 'explicit', 'parametric' and 1273 'parametric_surface'. 1274 1275 Example: 1276 1277 (%i1) load(draw)$ 1278 (%i2) draw2d(line_type = dots, 1279 explicit(1 + x^2,x,-1,1), 1280 line_type = solid, /* default */ 1281 explicit(2 + x^2,x,-1,1))$ 1282 1283 See also 'line_width'. 1284 1285 -- Graphic option: line_width 1286 Default value: 1 1287 1288 'line_width' is the width of plotted lines. Its value must be a 1289 positive number. 1290 1291 This option affects the following graphic objects: 1292 * 'gr2d': 'points', 'polygon', 'rectangle', 'ellipse', 'vector', 1293 'explicit', 'implicit', 'parametric' and 'polar'. 1294 1295 * 'gr3d': 'points' and 'parametric'. 1296 1297 Example: 1298 1299 (%i1) load(draw)$ 1300 (%i2) draw2d(explicit(x^2,x,-1,1), /* default width */ 1301 line_width = 5.5, 1302 explicit(1 + x^2,x,-1,1), 1303 line_width = 10, 1304 explicit(2 + x^2,x,-1,1))$ 1305 1306 See also 'line_type'. 1307 1308 -- Graphic option: logcb 1309 Default value: 'false' 1310 1311 If 'logcb' is 'true', the tics in the colorbox will be drawn in the 1312 logarithmic scale. 1313 1314 When 'enhanced3d' or 'colorbox' is 'false', option 'logcb' has no 1315 effect. 1316 1317 Since this is a global graphics option, its position in the scene 1318 description does not matter. 1319 1320 Example: 1321 1322 (%i1) load(draw)$ 1323 (%i2) draw3d ( 1324 enhanced3d = true, 1325 color = green, 1326 logcb = true, 1327 logz = true, 1328 palette = [-15,24,-9], 1329 explicit(exp(x^2-y^2), x,-2,2,y,-2,2)) $ 1330 1331 See also 'enhanced3d', 'colorbox' and 'cbrange'. 1332 1333 -- Graphic option: logx 1334 Default value: 'false' 1335 1336 If 'logx' is 'true', the <x> axis will be drawn in the logarithmic 1337 scale. 1338 1339 Since this is a global graphics option, its position in the scene 1340 description does not matter. 1341 1342 Example: 1343 1344 (%i1) load(draw)$ 1345 (%i2) draw2d(explicit(log(x),x,0.01,5), 1346 logx = true)$ 1347 1348 See also 'logy' and 'logz'. 1349 1350 -- Graphic option: logy 1351 Default value: 'false' 1352 1353 If 'logy' is 'true', the <y> axis will be drawn in the logarithmic 1354 scale. 1355 1356 Since this is a global graphics option, its position in the scene 1357 description does not matter. 1358 1359 Example: 1360 1361 (%i1) load(draw)$ 1362 (%i2) draw2d(logy = true, 1363 explicit(exp(x),x,0,5))$ 1364 1365 See also 'logx' and 'logz'. 1366 1367 -- Graphic option: logz 1368 Default value: 'false' 1369 1370 If 'logz' is 'true', the <z> axis will be drawn in the logarithmic 1371 scale. 1372 1373 Since this is a global graphics option, its position in the scene 1374 description does not matter. 1375 1376 Example: 1377 1378 (%i1) load(draw)$ 1379 (%i2) draw3d(logz = true, 1380 explicit(exp(u^2+v^2),u,-2,2,v,-2,2))$ 1381 1382 See also 'logx' and 'logy'. 1383 1384 -- Graphic option: nticks 1385 Default value: 29 1386 1387 In 2d, 'nticks' gives the initial number of points used by the 1388 adaptive plotting routine for explicit objects. It is also the 1389 number of points that will be shown in parametric and polar curves. 1390 1391 This option affects the following graphic objects: 1392 * 'gr2d': 'ellipse', 'explicit', 'parametric' and 'polar'. 1393 1394 * 'gr3d': 'parametric'. 1395 1396 Example: 1397 1398 (%i1) load(draw)$ 1399 (%i2) draw2d(transparent = true, 1400 ellipse(0,0,4,2,0,180), 1401 nticks = 5, 1402 ellipse(0,0,4,2,180,180) )$ 1403 1404 -- Graphic option: palette 1405 Default value: 'color' 1406 1407 'palette' indicates how to map gray levels onto color components. 1408 It works together with option 'enhanced3d' in 3D graphics, who 1409 associates every point of a surfaces to a real number or gray 1410 level. It also works with gray images. With 'palette', levels are 1411 transformed into colors. 1412 1413 There are two ways for defining these transformations. 1414 1415 First, 'palette' can be a vector of length three with components 1416 ranging from -36 to +36; each value is an index for a formula 1417 mapping the levels onto red, green and blue colors, respectively: 1418 1419 0: 0 1: 0.5 2: 1 1420 3: x 4: x^2 5: x^3 1421 6: x^4 7: sqrt(x) 8: sqrt(sqrt(x)) 1422 9: sin(90x) 10: cos(90x) 11: |x-0.5| 1423 12: (2x-1)^2 13: sin(180x) 14: |cos(180x)| 1424 15: sin(360x) 16: cos(360x) 17: |sin(360x)| 1425 18: |cos(360x)| 19: |sin(720x)| 20: |cos(720x)| 1426 21: 3x 22: 3x-1 23: 3x-2 1427 24: |3x-1| 25: |3x-2| 26: (3x-1)/2 1428 27: (3x-2)/2 28: |(3x-1)/2| 29: |(3x-2)/2| 1429 30: x/0.32-0.78125 31: 2*x-0.84 32: 4x;1;-2x+1.84;x/0.08-11.5 1430 33: |2*x - 0.5| 34: 2*x 35: 2*x - 0.5 1431 36: 2*x - 1 1432 1433 negative numbers mean negative colour component. 'palette = gray' 1434 and 'palette = color' are short cuts for 'palette = [3,3,3]' and 1435 'palette = [7,5,15]', respectively. 1436 1437 Second, 'palette' can be a user defined lookup table. In this 1438 case, the format for building a lookup table of length 'n' is 1439 'palette = [color_1, color_2, ..., color_n]', where 'color_i' is a 1440 well formed color (see option 'color'), such that 'color_1' is 1441 assigned to the lowest gray level and 'color_n' to the highest. 1442 The rest of colors are interpolated. 1443 1444 Since this is a global graphics option, its position in the scene 1445 description does not matter. 1446 1447 Examples: 1448 1449 It works together with option 'enhanced3d' in 3D graphics. 1450 1451 (%i1) load(draw)$ 1452 (%i2) draw3d( 1453 enhanced3d = [z-x+2*y,x,y,z], 1454 palette = [32, -8, 17], 1455 explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3))$ 1456 1457 It also works with gray images. 1458 1459 (%i1) load(draw)$ 1460 (%i2) im: apply( 1461 'matrix, 1462 makelist(makelist(random(200),i,1,30),i,1,30))$ 1463 (%i3) /* palette = color, default */ 1464 draw2d(image(im,0,0,30,30))$ 1465 (%i4) draw2d(palette = gray, image(im,0,0,30,30))$ 1466 (%i5) draw2d(palette = [15,20,-4], 1467 colorbox=false, 1468 image(im,0,0,30,30))$ 1469 1470 'palette' can be a user defined lookup table. In this example, low 1471 values of 'x' are colored in red, and higher values in yellow. 1472 1473 (%i1) load(draw)$ 1474 (%i2) draw3d( 1475 palette = [red, blue, yellow], 1476 enhanced3d = x, 1477 explicit(x^2+y^2,x,-1,1,y,-1,1)) $ 1478 1479 See also 'colorbox' and 'enhanced3d'. 1480 1481 -- Graphic option: point_size 1482 Default value: 1 1483 1484 'point_size' sets the size for plotted points. It must be a non 1485 negative number. 1486 1487 This option has no effect when graphic option 'point_type' is set 1488 to 'dot'. 1489 1490 This option affects the following graphic objects: 1491 * 'gr2d': 'points'. 1492 1493 * 'gr3d': 'points'. 1494 1495 Example: 1496 1497 (%i1) load(draw)$ 1498 (%i2) draw2d(points(makelist([random(20),random(50)],k,1,10)), 1499 point_size = 5, 1500 points(makelist(k,k,1,20),makelist(random(30),k,1,20)))$ 1501 1502 -- Graphic option: point_type 1503 Default value: 1 1504 1505 'point_type' indicates how isolated points are displayed; the value 1506 of this option can be any integer index greater or equal than -1, 1507 or the name of a point style: '$none' (-1), 'dot' (0), 'plus' (1), 1508 'multiply' (2), 'asterisk' (3), 'square' (4), 'filled_square' (5), 1509 'circle' (6), 'filled_circle' (7), 'up_triangle' (8), 1510 'filled_up_triangle' (9), 'down_triangle' (10), 1511 'filled_down_triangle' (11), 'diamant' (12) and 'filled_diamant' 1512 (13). 1513 1514 This option affects the following graphic objects: 1515 * 'gr2d': 'points'. 1516 1517 * 'gr3d': 'points'. 1518 1519 Example: 1520 1521 (%i1) load(draw)$ 1522 (%i2) draw2d(xrange = [0,10], 1523 yrange = [0,10], 1524 point_size = 3, 1525 point_type = diamant, 1526 points([[1,1],[5,1],[9,1]]), 1527 point_type = filled_down_triangle, 1528 points([[1,2],[5,2],[9,2]]), 1529 point_type = asterisk, 1530 points([[1,3],[5,3],[9,3]]), 1531 point_type = filled_diamant, 1532 points([[1,4],[5,4],[9,4]]), 1533 point_type = 5, 1534 points([[1,5],[5,5],[9,5]]), 1535 point_type = 6, 1536 points([[1,6],[5,6],[9,6]]), 1537 point_type = filled_circle, 1538 points([[1,7],[5,7],[9,7]]), 1539 point_type = 8, 1540 points([[1,8],[5,8],[9,8]]), 1541 point_type = filled_diamant, 1542 points([[1,9],[5,9],[9,9]]) )$ 1543 1544 -- Graphic option: points_joined 1545 Default value: 'false' 1546 1547 When 'points_joined' is 'true', points are joined by lines; when 1548 'false', isolated points are drawn. A third possible value for 1549 this graphic option is 'impulses'; in such case, vertical segments 1550 are drawn from points to the x-axis (2D) or to the xy-plane (3D). 1551 1552 This option affects the following graphic objects: 1553 * 'gr2d': 'points'. 1554 1555 * 'gr3d': 'points'. 1556 1557 Example: 1558 1559 (%i1) load(draw)$ 1560 (%i2) draw2d(xrange = [0,10], 1561 yrange = [0,4], 1562 point_size = 3, 1563 point_type = up_triangle, 1564 color = blue, 1565 points([[1,1],[5,1],[9,1]]), 1566 points_joined = true, 1567 point_type = square, 1568 line_type = dots, 1569 points([[1,2],[5,2],[9,2]]), 1570 point_type = circle, 1571 color = red, 1572 line_width = 7, 1573 points([[1,3],[5,3],[9,3]]) )$ 1574 1575 -- Graphic option: proportional_axes 1576 Default value: 'none' 1577 1578 When 'proportional_axes' is equal to 'xy' or 'xyz', a 2D or 3D 1579 scene will be drawn with axes proportional to their relative 1580 lengths. 1581 1582 Since this is a global graphics option, its position in the scene 1583 description does not matter. 1584 1585 This option works with Gnuplot version 4.2.6 or greater. 1586 1587 Examples: 1588 1589 Single 2D plot. 1590 1591 (%i1) load(draw)$ 1592 (%i2) draw2d( 1593 ellipse(0,0,1,1,0,360), 1594 transparent=true, 1595 color = blue, 1596 line_width = 4, 1597 ellipse(0,0,2,1/2,0,360), 1598 proportional_axes = xy) $ 1599 1600 Multiplot. 1601 1602 (%i1) load(draw)$ 1603 (%i2) draw( 1604 terminal = wxt, 1605 gr2d(proportional_axes = xy, 1606 explicit(x^2,x,0,1)), 1607 gr2d(explicit(x^2,x,0,1), 1608 xrange = [0,1], 1609 yrange = [0,2], 1610 proportional_axes=xy), 1611 gr2d(explicit(x^2,x,0,1)))$ 1612 1613 -- Graphic option: surface_hide 1614 Default value: 'false' 1615 1616 If 'surface_hide' is 'true', hidden parts are not plotted in 3d 1617 surfaces. 1618 1619 Since this is a global graphics option, its position in the scene 1620 description does not matter. 1621 1622 Example: 1623 1624 (%i1) load(draw)$ 1625 (%i2) draw(columns=2, 1626 gr3d(explicit(exp(sin(x)+cos(x^2)),x,-3,3,y,-3,3)), 1627 gr3d(surface_hide = true, 1628 explicit(exp(sin(x)+cos(x^2)),x,-3,3,y,-3,3)) )$ 1629 1630 -- Graphic option: terminal 1631 Default value: 'screen' 1632 1633 Selects the terminal to be used by Gnuplot; possible values are: 1634 'screen' (default), 'png', 'pngcairo', 'jpg', 'eps', 'eps_color', 1635 'pdf', 'pdfcairo', 'gif', 'animated_gif', 'wxt', 'svg', and 1636 'aquaterm'. 1637 1638 Terminals 'screen', 'wxt' and 'aquaterm' can be also defined as a 1639 list with two elements: the name of the terminal itself and a non 1640 negative integer number. In this form, multiple windows can be 1641 opened at the same time, each with its corresponding number. This 1642 feature does not work in Windows platforms. 1643 1644 Since this is a global graphics option, its position in the scene 1645 description does not matter. It can be also used as an argument of 1646 function 'draw'. 1647 1648 N.B. pdfcairo requires Gnuplot 4.3 or newer. 'pdf' requires 1649 Gnuplot to be compiled with the option '--enable-pdf' and libpdf 1650 must be installed. The pdf library is available from: 1651 <http://www.pdflib.com/en/download/pdflib-family/pdflib-lite/> 1652 1653 Examples: 1654 1655 (%i1) load(draw)$ 1656 (%i2) /* screen terminal (default) */ 1657 draw2d(explicit(x^2,x,-1,1))$ 1658 (%i3) /* png file */ 1659 draw2d(terminal = 'png, 1660 explicit(x^2,x,-1,1))$ 1661 (%i4) /* jpg file */ 1662 draw2d(terminal = 'jpg, 1663 dimensions = [300,300], 1664 explicit(x^2,x,-1,1))$ 1665 (%i5) /* eps file */ 1666 draw2d(file_name = "myfile", 1667 explicit(x^2,x,-1,1), 1668 terminal = 'eps)$ 1669 (%i6) /* pdf file */ 1670 draw2d(file_name = "mypdf", 1671 dimensions = 100*[12.0,8.0], 1672 explicit(x^2,x,-1,1), 1673 terminal = 'pdf)$ 1674 (%i7) /* wxwidgets window */ 1675 draw2d(explicit(x^2,x,-1,1), 1676 terminal = 'wxt)$ 1677 1678 Multiple windows. 1679 1680 (%i1) load(draw)$ 1681 (%i2) draw2d(explicit(x^5,x,-2,2), terminal=[screen, 3])$ 1682 (%i3) draw2d(explicit(x^2,x,-2,2), terminal=[screen, 0])$ 1683 1684 An animated gif file. 1685 1686 (%i1) load(draw)$ 1687 (%i2) draw( 1688 delay = 100, 1689 file_name = "zzz", 1690 terminal = 'animated_gif, 1691 gr2d(explicit(x^2,x,-1,1)), 1692 gr2d(explicit(x^3,x,-1,1)), 1693 gr2d(explicit(x^4,x,-1,1))); 1694 End of animation sequence 1695 (%o2) [gr2d(explicit), gr2d(explicit), gr2d(explicit)] 1696 1697 Option 'delay' is only active in animated gif's; it is ignored in 1698 any other case. 1699 1700 See also 'file_name', 'dimensions' and 'delay'. 1701 1702 -- Graphic option: title 1703 Default value: '""' (empty string) 1704 1705 Option 'title', a string, is the main title for the scene. By 1706 default, no title is written. 1707 1708 Since this is a global graphics option, its position in the scene 1709 description does not matter. 1710 1711 Example: 1712 1713 (%i1) load(draw)$ 1714 (%i2) draw2d(explicit(exp(u),u,-2,2), 1715 title = "Exponential function")$ 1716 1717 -- Graphic option: transform 1718 Default value: 'none' 1719 1720 If 'transform' is 'none', the space is not transformed and graphic 1721 objects are drawn as defined. When a space transformation is 1722 desired, a list must be assigned to option 'transform'. In case of 1723 a 2D scene, the list takes the form '[f1(x,y), f2(x,y), x, y]'. In 1724 case of a 3D scene, the list is of the form '[f1(x,y,z), f2(x,y,z), 1725 f3(x,y,z), x, y, z]'. 1726 1727 The names of the variables defined in the lists may be different to 1728 those used in the definitions of the graphic objects. 1729 1730 Examples: 1731 1732 Rotation in 2D. 1733 1734 (%i1) load(draw)$ 1735 (%i2) th : %pi / 4$ 1736 (%i3) draw2d( 1737 color = "#e245f0", 1738 proportional_axes = 'xy, 1739 line_width = 8, 1740 triangle([3,2],[7,2],[5,5]), 1741 border = false, 1742 fill_color = yellow, 1743 transform = [cos(th)*x - sin(th)*y, 1744 sin(th)*x + cos(th)*y, x, y], 1745 triangle([3,2],[7,2],[5,5]) )$ 1746 1747 Translation in 3D. 1748 1749 (%i1) load(draw)$ 1750 (%i2) draw3d( 1751 color = "#a02c00", 1752 explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3), 1753 transform = [x+10,y+10,z+10,x,y,z], 1754 color = blue, 1755 explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3) )$ 1756 1757 -- Graphic option: transparent 1758 Default value: 'false' 1759 1760 If 'transparent' is 'false', interior regions of polygons are 1761 filled according to 'fill_color'. 1762 1763 This option affects the following graphic objects: 1764 * 'gr2d': 'polygon', 'rectangle', and 'ellipse'. 1765 1766 Example: 1767 1768 (%i1) load(draw)$ 1769 (%i2) draw2d(polygon([[3,2],[7,2],[5,5]]), 1770 transparent = true, 1771 color = blue, 1772 polygon([[5,2],[9,2],[7,5]]) )$ 1773 1774 -- Graphic option: tube_extremes 1775 Default value: '[open, open]' 1776 1777 A list with two possible elements, 'open' and 'closed', indicating 1778 whether the extremes of a graphic object 'tube' remain open or must 1779 be closed. By default, both extremes are left open. 1780 1781 Example: 1782 1783 (%i1) load(draw)$ 1784 (%i2) draw3d( 1785 tube_extremes = [open, closed], 1786 tube(0, 0, a, 1, 1787 a, 0, 8) )$ 1788 1789 -- Graphic option: unit_vectors 1790 Default value: 'false' 1791 1792 If 'unit_vectors' is 'true', vectors are plotted with module 1. 1793 This is useful for plotting vector fields. If 'unit_vectors' is 1794 'false', vectors are plotted with its original length. 1795 1796 This option is relevant only for 'vector' objects. 1797 1798 Example: 1799 1800 (%i1) load(draw)$ 1801 (%i2) draw2d(xrange = [-1,6], 1802 yrange = [-1,6], 1803 head_length = 0.1, 1804 vector([0,0],[5,2]), 1805 unit_vectors = true, 1806 color = red, 1807 vector([0,3],[5,2]))$ 1808 1809 -- Graphic option: user_preamble 1810 Default value: '""' (empty string) 1811 1812 Expert Gnuplot users can make use of this option to fine tune 1813 Gnuplot's behaviour by writing settings to be sent before the 1814 'plot' or 'splot' command. 1815 1816 The value of this option must be a string or a list of strings (one 1817 per line). 1818 1819 Since this is a global graphics option, its position in the scene 1820 description does not matter. 1821 1822 Example: 1823 1824 The dumb terminal is not supported by package 'draw', but it is 1825 possible to set it by making use of option 'user_preamble', 1826 (%i1) load(draw)$ 1827 (%i2) draw2d(explicit(exp(x)-1,x,-1,1), 1828 parametric(cos(u),sin(u),u,0,2*%pi), 1829 user_preamble="set terminal dumb")$ 1830 1831 -- Graphic option: view 1832 Default value: '[60,30]' 1833 1834 A pair of angles, measured in degrees, indicating the view 1835 direction in a 3D scene. The first angle is the vertical rotation 1836 around the <x> axis, in the range [0, 180]. The second one is the 1837 horizontal rotation around the <z> axis, in the range [0, 360]. 1838 1839 Since this is a global graphics option, its position in the scene 1840 description does not matter. 1841 1842 Example: 1843 1844 (%i1) load(draw)$ 1845 (%i2) draw3d(view = [170, 360], 1846 explicit(sin(x^2+y^2),x,-2,2,y,-2,2) )$ 1847 1848 -- Graphic option: wired_surface 1849 Default value: 'false' 1850 1851 Indicates whether 3D surfaces in 'enhanced3d' mode show the grid 1852 joinning the points or not. 1853 1854 Since this is a global graphics option, its position in the scene 1855 description does not matter. 1856 1857 Example: 1858 1859 (%i1) load(draw)$ 1860 (%i2) draw3d( 1861 enhanced3d = [sin(x),x,y], 1862 wired_surface = true, 1863 explicit(x^2+y^2,x,-1,1,y,-1,1)) $ 1864 1865 -- Graphic option: x_voxel 1866 Default value: 10 1867 1868 'x_voxel' is the number of voxels in the x direction to be used by 1869 the marching cubes algorithm implemented by the 3d 'implicit' 1870 object. It is also used by graphic object 'region'. 1871 1872 -- Graphic option: xaxis 1873 Default value: 'false' 1874 1875 If 'xaxis' is 'true', the <x> axis is drawn. 1876 1877 Since this is a global graphics option, its position in the scene 1878 description does not matter. 1879 1880 Example: 1881 1882 (%i1) load(draw)$ 1883 (%i2) draw2d(explicit(x^3,x,-1,1), 1884 xaxis = true, 1885 xaxis_color = blue)$ 1886 1887 See also 'xaxis_width', 'xaxis_type' and 'xaxis_color'. 1888 1889 -- Graphic option: xaxis_color 1890 Default value: '"black"' 1891 1892 'xaxis_color' specifies the color for the <x> axis. See 'color' to 1893 know how colors are defined. 1894 1895 Since this is a global graphics option, its position in the scene 1896 description does not matter. 1897 1898 Example: 1899 1900 (%i1) load(draw)$ 1901 (%i2) draw2d(explicit(x^3,x,-1,1), 1902 xaxis = true, 1903 xaxis_color = red)$ 1904 1905 See also 'xaxis', 'xaxis_width' and 'xaxis_type'. 1906 1907 -- Graphic option: xaxis_secondary 1908 Default value: 'false' 1909 1910 If 'xaxis_secondary' is 'true', function values can be plotted with 1911 respect to the second <x> axis, which will be drawn on top of the 1912 scene. 1913 1914 Note that this is a local graphics option which only affects to 2d 1915 plots. 1916 1917 Example: 1918 1919 (%i1) load(draw)$ 1920 (%i2) draw2d( 1921 key = "Bottom x-axis", 1922 explicit(x+1,x,1,2), 1923 color = red, 1924 key = "Above x-axis", 1925 xtics_secondary = true, 1926 xaxis_secondary = true, 1927 explicit(x^2,x,-1,1)) $ 1928 1929 See also 'xrange_secondary', 'xtics_secondary', 1930 'xtics_rotate_secondary', 'xtics_axis_secondary' and 1931 'xaxis_secondary'. 1932 1933 -- Graphic option: xaxis_type 1934 Default value: 'dots' 1935 1936 'xaxis_type' indicates how the <x> axis is displayed; possible 1937 values are 'solid' and 'dots'. 1938 1939 Since this is a global graphics option, its position in the scene 1940 description does not matter. 1941 1942 Example: 1943 1944 (%i1) load(draw)$ 1945 (%i2) draw2d(explicit(x^3,x,-1,1), 1946 xaxis = true, 1947 xaxis_type = solid)$ 1948 1949 See also 'xaxis', 'xaxis_width' and 'xaxis_color'. 1950 1951 -- Graphic option: xaxis_width 1952 Default value: 1 1953 1954 'xaxis_width' is the width of the <x> axis. Its value must be a 1955 positive number. 1956 1957 Since this is a global graphics option, its position in the scene 1958 description does not matter. 1959 1960 Example: 1961 1962 (%i1) load(draw)$ 1963 (%i2) draw2d(explicit(x^3,x,-1,1), 1964 xaxis = true, 1965 xaxis_width = 3)$ 1966 1967 See also 'xaxis', 'xaxis_type' and 'xaxis_color'. 1968 1969 -- Graphic option: xlabel 1970 Default value: '""' (empty string) 1971 1972 Option 'xlabel', a string, is the label for the <x> axis. By 1973 default, no label is written. 1974 1975 Since this is a global graphics option, its position in the scene 1976 description does not matter. 1977 1978 Example: 1979 1980 (%i1) load(draw)$ 1981 (%i2) draw2d(xlabel = "Time", 1982 explicit(exp(u),u,-2,2), 1983 ylabel = "Population")$ 1984 1985 See also 'ylabel', and 'zlabel'. 1986 1987 -- Graphic option: xrange 1988 Default value: 'auto' 1989 1990 If 'xrange' is 'auto', the range for the <x> coordinate is computed 1991 automatically. 1992 1993 If the user wants a specific interval for <x>, it must be given as 1994 a Maxima list, as in 'xrange=[-2, 3]'. 1995 1996 Since this is a global graphics option, its position in the scene 1997 description does not matter. 1998 1999 Example: 2000 2001 (%i1) load(draw)$ 2002 (%i2) draw2d(xrange = [-3,5], 2003 explicit(x^2,x,-1,1))$ 2004 2005 See also 'yrange' and 'zrange'. 2006 2007 -- Graphic option: xrange_secondary 2008 Default value: 'auto' 2009 2010 If 'xrange_secondary' is 'auto', the range for the second <x> axis 2011 is computed automatically. 2012 2013 If the user wants a specific interval for the second <x> axis, it 2014 must be given as a Maxima list, as in 'xrange_secondary=[-2, 3]'. 2015 2016 Since this is a global graphics option, its position in the scene 2017 description does not matter. 2018 2019 See also 'xrange', 'yrange', 'zrange' and 'yrange_secondary'. 2020 2021 -- Graphic option: xtics 2022 Default value: 'auto' 2023 2024 This graphic option controls the way tic marks are drawn on the <x> 2025 axis. 2026 2027 * When option 'xtics' is bounded to symbol <auto>, tic marks are 2028 drawn automatically. 2029 2030 * When option 'xtics' is bounded to symbol <none>, tic marks are 2031 not drawn. 2032 2033 * When option 'xtics' is bounded to a positive number, this is 2034 the distance between two consecutive tic marks. 2035 2036 * When option 'xtics' is bounded to a list of length three of 2037 the form '[start,incr,end]', tic marks are plotted from 2038 'start' to 'end' at intervals of length 'incr'. 2039 2040 * When option 'xtics' is bounded to a set of numbers of the form 2041 '{n1, n2, ...}', tic marks are plotted at values 'n1', 'n2', 2042 ... 2043 2044 * When option 'xtics' is bounded to a set of pairs of the form 2045 '{["label1", n1], ["label2", n2], ...}', tic marks 2046 corresponding to values 'n1', 'n2', ... are labeled with 2047 '"label1"', '"label2"', ..., respectively. 2048 2049 Since this is a global graphics option, its position in the scene 2050 description does not matter. 2051 2052 Examples: 2053 2054 Disable tics. 2055 (%i1) load(draw)$ 2056 (%i2) draw2d(xtics = 'none, 2057 explicit(x^3,x,-1,1) )$ 2058 2059 Tics every 1/4 units. 2060 (%i1) load(draw)$ 2061 (%i2) draw2d(xtics = 1/4, 2062 explicit(x^3,x,-1,1) )$ 2063 2064 Tics from -3/4 to 3/4 in steps of 1/8. 2065 (%i1) load(draw)$ 2066 (%i2) draw2d(xtics = [-3/4,1/8,3/4], 2067 explicit(x^3,x,-1,1) )$ 2068 2069 Tics at points -1/2, -1/4 and 3/4. 2070 (%i1) load(draw)$ 2071 (%i2) draw2d(xtics = {-1/2,-1/4,3/4}, 2072 explicit(x^3,x,-1,1) )$ 2073 2074 Labeled tics. 2075 (%i1) load(draw)$ 2076 (%i2) draw2d(xtics = {["High",0.75],["Medium",0],["Low",-0.75]}, 2077 explicit(x^3,x,-1,1) )$ 2078 2079 See also 'ytics', and 'ztics'. 2080 2081 -- Graphic option: xtics_axis 2082 Default value: 'false' 2083 2084 If 'xtics_axis' is 'true', tic marks and their labels are plotted 2085 just along the <x> axis, if it is 'false' tics are plotted on the 2086 border. 2087 2088 Since this is a global graphics option, its position in the scene 2089 description does not matter. 2090 2091 -- Graphic option: xtics_rotate 2092 Default value: 'false' 2093 2094 If 'xtics_rotate' is 'true', tic marks on the <x> axis are rotated 2095 90 degrees. 2096 2097 Since this is a global graphics option, its position in the scene 2098 description does not matter. 2099 2100 -- Graphic option: xtics_rotate_secondary 2101 Default value: 'false' 2102 2103 If 'xtics_rotate_secondary' is 'true', tic marks on the secondary 2104 <x> axis are rotated 90 degrees. 2105 2106 Since this is a global graphics option, its position in the scene 2107 description does not matter. 2108 2109 -- Graphic option: xtics_secondary 2110 Default value: 'auto' 2111 2112 This graphic option controls the way tic marks are drawn on the 2113 second <x> axis. 2114 2115 See 'xtics' for a complete description. 2116 2117 -- Graphic option: xtics_secondary_axis 2118 Default value: 'false' 2119 2120 If 'xtics_secondary_axis' is 'true', tic marks and their labels are 2121 plotted just along the secondary <x> axis, if it is 'false' tics 2122 are plotted on the border. 2123 2124 Since this is a global graphics option, its position in the scene 2125 description does not matter. 2126 2127 -- Graphic option: xu_grid 2128 Default value: 30 2129 2130 'xu_grid' is the number of coordinates of the first variable ('x' 2131 in explicit and 'u' in parametric 3d surfaces) to build the grid of 2132 sample points. 2133 2134 This option affects the following graphic objects: 2135 * 'gr3d': 'explicit' and 'parametric_surface'. 2136 2137 Example: 2138 2139 (%i1) load(draw)$ 2140 (%i2) draw3d(xu_grid = 10, 2141 yv_grid = 50, 2142 explicit(x^2+y^2,x,-3,3,y,-3,3) )$ 2143 2144 See also 'yv_grid'. 2145 2146 -- Graphic option: xy_file 2147 Default value: '""' (empty string) 2148 2149 'xy_file' is the name of the file where the coordinates will be 2150 saved after clicking with the mouse button and hitting the 'x' key. 2151 By default, no coordinates are saved. 2152 2153 Since this is a global graphics option, its position in the scene 2154 description does not matter. 2155 2156 -- Graphic option: xyplane 2157 Default value: 'false' 2158 2159 Allocates the xy-plane in 3D scenes. When 'xyplane' is 'false', 2160 the xy-plane is placed automatically; when it is a real number, the 2161 xy-plane intersects the z-axis at this level. This option has no 2162 effect in 2D scenes. 2163 2164 Since this is a global graphics option, its position in the scene 2165 description does not matter. 2166 2167 Example: 2168 2169 (%i1) load(draw)$ 2170 (%i2) draw3d(xyplane = %e-2, 2171 explicit(x^2+y^2,x,-1,1,y,-1,1))$ 2172 2173 -- Graphic option: y_voxel 2174 Default value: 10 2175 2176 'y_voxel' is the number of voxels in the y direction to be used by 2177 the marching cubes algorithm implemented by the 3d 'implicit' 2178 object. It is also used by graphic object 'region'. 2179 2180 -- Graphic option: yaxis 2181 Default value: 'false' 2182 2183 If 'yaxis' is 'true', the <y> axis is drawn. 2184 2185 Since this is a global graphics option, its position in the scene 2186 description does not matter. 2187 2188 Example: 2189 2190 (%i1) load(draw)$ 2191 (%i2) draw2d(explicit(x^3,x,-1,1), 2192 yaxis = true, 2193 yaxis_color = blue)$ 2194 2195 See also 'yaxis_width', 'yaxis_type' and 'yaxis_color'. 2196 2197 -- Graphic option: yaxis_color 2198 Default value: '"black"' 2199 2200 'yaxis_color' specifies the color for the <y> axis. See 'color' to 2201 know how colors are defined. 2202 2203 Since this is a global graphics option, its position in the scene 2204 description does not matter. 2205 2206 Example: 2207 2208 (%i1) load(draw)$ 2209 (%i2) draw2d(explicit(x^3,x,-1,1), 2210 yaxis = true, 2211 yaxis_color = red)$ 2212 2213 See also 'yaxis', 'yaxis_width' and 'yaxis_type'. 2214 2215 -- Graphic option: yaxis_secondary 2216 Default value: 'false' 2217 2218 If 'yaxis_secondary' is 'true', function values can be plotted with 2219 respect to the second <y> axis, which will be drawn on the right 2220 side of the scene. 2221 2222 Note that this is a local graphics option which only affects to 2d 2223 plots. 2224 2225 Example: 2226 2227 (%i1) load(draw)$ 2228 (%i2) draw2d( 2229 explicit(sin(x),x,0,10), 2230 yaxis_secondary = true, 2231 ytics_secondary = true, 2232 color = blue, 2233 explicit(100*sin(x+0.1)+2,x,0,10)); 2234 2235 See also 'yrange_secondary', 'ytics_secondary', 2236 'ytics_rotate_secondary' and 'ytics_axis_secondary'. 2237 2238 -- Graphic option: yaxis_type 2239 Default value: 'dots' 2240 2241 'yaxis_type' indicates how the <y> axis is displayed; possible 2242 values are 'solid' and 'dots'. 2243 2244 Since this is a global graphics option, its position in the scene 2245 description does not matter. 2246 2247 Example: 2248 2249 (%i1) load(draw)$ 2250 (%i2) draw2d(explicit(x^3,x,-1,1), 2251 yaxis = true, 2252 yaxis_type = solid)$ 2253 2254 See also 'yaxis', 'yaxis_width' and 'yaxis_color'. 2255 2256 -- Graphic option: yaxis_width 2257 Default value: 1 2258 2259 'yaxis_width' is the width of the <y> axis. Its value must be a 2260 positive number. 2261 2262 Since this is a global graphics option, its position in the scene 2263 description does not matter. 2264 2265 Example: 2266 2267 (%i1) load(draw)$ 2268 (%i2) draw2d(explicit(x^3,x,-1,1), 2269 yaxis = true, 2270 yaxis_width = 3)$ 2271 2272 See also 'yaxis', 'yaxis_type' and 'yaxis_color'. 2273 2274 -- Graphic option: ylabel 2275 Default value: '""' (empty string) 2276 2277 Option 'ylabel', a string, is the label for the <y> axis. By 2278 default, no label is written. 2279 2280 Since this is a global graphics option, its position in the scene 2281 description does not matter. 2282 2283 Example: 2284 2285 (%i1) load(draw)$ 2286 (%i2) draw2d(xlabel = "Time", 2287 ylabel = "Population", 2288 explicit(exp(u),u,-2,2) )$ 2289 2290 See also 'xlabel', and 'zlabel'. 2291 2292 -- Graphic option: yrange 2293 Default value: 'auto' 2294 2295 If 'yrange' is 'auto', the range for the <y> coordinate is computed 2296 automatically. 2297 2298 If the user wants a specific interval for <y>, it must be given as 2299 a Maxima list, as in 'yrange=[-2, 3]'. 2300 2301 Since this is a global graphics option, its position in the scene 2302 description does not matter. 2303 2304 Example: 2305 2306 (%i1) load(draw)$ 2307 (%i2) draw2d(yrange = [-2,3], 2308 explicit(x^2,x,-1,1), 2309 xrange = [-3,3])$ 2310 2311 See also 'xrange', 'yrange_secondary' and 'zrange'. 2312 2313 -- Graphic option: yrange_secondary 2314 Default value: 'auto' 2315 2316 If 'yrange_secondary' is 'auto', the range for the second <y> axis 2317 is computed automatically. 2318 2319 If the user wants a specific interval for the second <y> axis, it 2320 must be given as a Maxima list, as in 'yrange_secondary=[-2, 3]'. 2321 2322 Since this is a global graphics option, its position in the scene 2323 description does not matter. 2324 2325 Example: 2326 2327 (%i1) load(draw)$ 2328 (%i2) draw2d( 2329 explicit(sin(x),x,0,10), 2330 yaxis_secondary = true, 2331 ytics_secondary = true, 2332 yrange = [-3, 3], 2333 yrange_secondary = [-20, 20], 2334 color = blue, 2335 explicit(100*sin(x+0.1)+2,x,0,10)) $ 2336 2337 See also 'xrange', 'yrange' and 'zrange'. 2338 2339 -- Graphic option: ytics 2340 Default value: 'auto' 2341 2342 This graphic option controls the way tic marks are drawn on the <y> 2343 axis. 2344 2345 See 'xtics' for a complete description. 2346 2347 -- Graphic option: ytics_axis 2348 Default value: 'false' 2349 2350 If 'ytics_axis' is 'true', tic marks and their labels are plotted 2351 just along the <y> axis, if it is 'false' tics are plotted on the 2352 border. 2353 2354 Since this is a global graphics option, its position in the scene 2355 description does not matter. 2356 2357 -- Graphic option: ytics_rotate 2358 Default value: 'false' 2359 2360 If 'ytics_rotate' is 'true', tic marks on the <y> axis are rotated 2361 90 degrees. 2362 2363 Since this is a global graphics option, its position in the scene 2364 description does not matter. 2365 2366 -- Graphic option: ytics_rotate_secondary 2367 Default value: 'false' 2368 2369 If 'ytics_rotate_secondary' is 'true', tic marks on the secondary 2370 <y> axis are rotated 90 degrees. 2371 2372 Since this is a global graphics option, its position in the scene 2373 description does not matter. 2374 2375 -- Graphic option: ytics_secondary 2376 Default value: 'auto' 2377 2378 This graphic option controls the way tic marks are drawn on the 2379 second <y> axis. 2380 2381 See 'xtics' for a complete description. 2382 2383 -- Graphic option: ytics_secondary_axis 2384 Default value: 'false' 2385 2386 If 'ytics_secondary_axis' is 'true', tic marks and their labels are 2387 plotted just along the secondary <y> axis, if it is 'false' tics 2388 are plotted on the border. 2389 2390 Since this is a global graphics option, its position in the scene 2391 description does not matter. 2392 2393 -- Graphic option: yv_grid 2394 Default value: 30 2395 2396 'yv_grid' is the number of coordinates of the second variable ('y' 2397 in explicit and 'v' in parametric 3d surfaces) to build the grid of 2398 sample points. 2399 2400 This option affects the following graphic objects: 2401 * 'gr3d': 'explicit' and 'parametric_surface'. 2402 2403 Example: 2404 2405 (%i1) load(draw)$ 2406 (%i2) draw3d(xu_grid = 10, 2407 yv_grid = 50, 2408 explicit(x^2+y^2,x,-3,3,y,-3,3) )$ 2409 2410 See also 'xu_grid'. 2411 2412 -- Graphic option: z_voxel 2413 Default value: 10 2414 2415 'z_voxel' is the number of voxels in the z direction to be used by 2416 the marching cubes algorithm implemented by the 3d 'implicit' 2417 object. 2418 2419 -- Graphic option: zaxis 2420 Default value: 'false' 2421 2422 If 'zaxis' is 'true', the <z> axis is drawn in 3D plots. This 2423 option has no effect in 2D scenes. 2424 2425 Since this is a global graphics option, its position in the scene 2426 description does not matter. 2427 2428 Example: 2429 2430 (%i1) load(draw)$ 2431 (%i2) draw3d(explicit(x^2+y^2,x,-1,1,y,-1,1), 2432 zaxis = true, 2433 zaxis_type = solid, 2434 zaxis_color = blue)$ 2435 2436 See also 'zaxis_width', 'zaxis_type' and 'zaxis_color'. 2437 2438 -- Graphic option: zaxis_color 2439 Default value: '"black"' 2440 2441 'zaxis_color' specifies the color for the <z> axis. See 'color' to 2442 know how colors are defined. This option has no effect in 2D 2443 scenes. 2444 2445 Since this is a global graphics option, its position in the scene 2446 description does not matter. 2447 2448 Example: 2449 2450 (%i1) load(draw)$ 2451 (%i2) draw3d(explicit(x^2+y^2,x,-1,1,y,-1,1), 2452 zaxis = true, 2453 zaxis_type = solid, 2454 zaxis_color = red)$ 2455 2456 See also 'zaxis', 'zaxis_width' and 'zaxis_type'. 2457 2458 -- Graphic option: zaxis_type 2459 Default value: 'dots' 2460 2461 'zaxis_type' indicates how the <z> axis is displayed; possible 2462 values are 'solid' and 'dots'. This option has no effect in 2D 2463 scenes. 2464 2465 Since this is a global graphics option, its position in the scene 2466 description does not matter. 2467 2468 Example: 2469 2470 (%i1) load(draw)$ 2471 (%i2) draw3d(explicit(x^2+y^2,x,-1,1,y,-1,1), 2472 zaxis = true, 2473 zaxis_type = solid)$ 2474 2475 See also 'zaxis', 'zaxis_width' and 'zaxis_color'. 2476 2477 -- Graphic option: zaxis_width 2478 Default value: 1 2479 2480 'zaxis_width' is the width of the <z> axis. Its value must be a 2481 positive number. This option has no effect in 2D scenes. 2482 2483 Since this is a global graphics option, its position in the scene 2484 description does not matter. 2485 2486 Example: 2487 2488 (%i1) load(draw)$ 2489 (%i2) draw3d(explicit(x^2+y^2,x,-1,1,y,-1,1), 2490 zaxis = true, 2491 zaxis_type = solid, 2492 zaxis_width = 3)$ 2493 2494 See also 'zaxis', 'zaxis_type' and 'zaxis_color'. 2495 2496 -- Graphic option: zlabel 2497 Default value: '""' (empty string) 2498 2499 Option 'zlabel', a string, is the label for the <z> axis. By 2500 default, no label is written. 2501 2502 Since this is a global graphics option, its position in the scene 2503 description does not matter. 2504 2505 Example: 2506 2507 (%i1) load(draw)$ 2508 (%i2) draw3d(zlabel = "Z variable", 2509 ylabel = "Y variable", 2510 explicit(sin(x^2+y^2),x,-2,2,y,-2,2), 2511 xlabel = "X variable" )$ 2512 2513 See also 'xlabel', and 'ylabel'. 2514 2515 -- Graphic option: zrange 2516 Default value: 'auto' 2517 2518 If 'zrange' is 'auto', the range for the <z> coordinate is computed 2519 automatically. 2520 2521 If the user wants a specific interval for <z>, it must be given as 2522 a Maxima list, as in 'zrange=[-2, 3]'. 2523 2524 Since this is a global graphics option, its position in the scene 2525 description does not matter. 2526 2527 Example: 2528 2529 (%i1) load(draw)$ 2530 (%i2) draw3d(yrange = [-3,3], 2531 zrange = [-2,5], 2532 explicit(x^2+y^2,x,-1,1,y,-1,1), 2533 xrange = [-3,3])$ 2534 2535 See also 'xrange' and 'yrange'. 2536 2537 -- Graphic option: ztics 2538 Default value: 'auto' 2539 2540 This graphic option controls the way tic marks are drawn on the <z> 2541 axis. 2542 2543 See 'xtics' for a complete description. 2544 2545 -- Graphic option: ztics_axis 2546 Default value: 'false' 2547 2548 If 'ztics_axis' is 'true', tic marks and their labels are plotted 2549 just along the <z> axis, if it is 'false' tics are plotted on the 2550 border. 2551 2552 Since this is a global graphics option, its position in the scene 2553 description does not matter. 2554 2555 -- Graphic option: ztics_rotate 2556 Default value: 'false' 2557 2558 If 'ztics_rotate' is 'true', tic marks on the <z> axis are rotated 2559 90 degrees. 2560 2561 Since this is a global graphics option, its position in the scene 2562 description does not matter. 2563 256442.2.4 Graphics objects 2565----------------------- 2566 2567 -- Graphic object: bars ([<x1>, <h1>, <w1>], [<x2>, <h2>, <w2>, ...]) 2568 2569 Draws vertical bars in 2D. 2570 2571 2D 2572 2573 'bars([<x1>, <h1>, <w1>], [<x2>, <h2>, <w2>, ...])' draws bars 2574 centered at values <x1>, <x2>, ... with heights <h1>, <h2>, ... and 2575 widths <w1>, <w2>, ... 2576 2577 This object is affected by the following graphic options: 'key', 2578 'fill_color', 'fill_density' and 'line_width'. 2579 2580 Example: 2581 2582 (%i1) load(draw)$ 2583 (%i2) draw2d( 2584 key = "Group A", 2585 fill_color = blue, 2586 fill_density = 0.2, 2587 bars([0.8,5,0.4],[1.8,7,0.4],[2.8,-4,0.4]), 2588 key = "Group B", 2589 fill_color = red, 2590 fill_density = 0.6, 2591 line_width = 4, 2592 bars([1.2,4,0.4],[2.2,-2,0.4],[3.2,5,0.4]), 2593 xaxis = true); 2594 2595 -- Graphic object: cylindrical (<radius>, <z>, <minz>, <maxz>, <azi>, 2596 <minazi>, <maxazi>) 2597 2598 Draws 3D functions defined in cylindrical coordinates. 2599 2600 3D 2601 2602 'cylindrical(<radius>, <z>, <minz>, <maxz>, <azi>, <minazi>, 2603 <maxazi>)' plots function '<radius>(<z>, <azi>)' defined in 2604 cylindrical coordinates, with variable <z> taking values from 2605 <minz> to <maxz> and azimuth <azi> taking values from <minazi> to 2606 <maxazi>. 2607 2608 This object is affected by the following graphic options: 2609 'xu_grid', 'yv_grid', 'line_type', 'key', 'wired_surface', 2610 'enhanced3d' and 'color'. 2611 2612 Example: 2613 2614 (%i1) load(draw)$ 2615 (%i2) draw3d(cylindrical(1,z,-2,2,az,0,2*%pi))$ 2616 2617 -- Graphic object: elevation_grid (<mat>, <x0>, <y0>, <width>, 2618 <height>) 2619 2620 Draws matrix <mat> in 3D space. <z> values are taken from <mat>, 2621 the abscissas range from <x0> to <x0> + <width> and ordinates from 2622 <y0> to <y0> + <height>. Element a(1,1) is projected on point 2623 (x0,y0+height), a(1,n) on (x0+width,y0+height), a(m,1) on (x0,y0), 2624 and a(m,n) on (x0+width,y0). 2625 2626 This object is affected by the following graphic options: 2627 'line_type', 'line_width', 'key', 'wired_surface', 'enhanced3d', 2628 and 'color'. 2629 2630 In older versions of Maxima, 'elevation_grid' was called 'mesh'. 2631 See also 'mesh'. 2632 2633 Example: 2634 2635 (%i1) load(draw)$ 2636 (%i2) m: apply( 2637 matrix, 2638 makelist(makelist(random(10.0),k,1,30),i,1,20)) $ 2639 (%i3) draw3d( 2640 color = blue, 2641 elevation_grid(m,0,0,3,2), 2642 xlabel = "x", 2643 ylabel = "y", 2644 surface_hide = true); 2645 2646 -- Graphic object: ellipse (<xc>, <yc>, <a>, <b>, <ang1>, <ang2>) 2647 2648 Draws ellipses and circles in 2D. 2649 2650 2D 2651 2652 'ellipse (<xc>, <yc>, <a>, <b>, <ang1>, <ang2>)' plots an ellipse 2653 centered at '[<xc>, <yc>]' with horizontal and vertical semi axis 2654 <a> and <b>, respectively, starting at angle <ang1> with an 2655 amplitude equal to angle <ang2>. 2656 2657 This object is affected by the following graphic options: 'nticks', 2658 'transparent', 'fill_color', 'border', 'line_width', 'line_type', 2659 'key' and 'color'. 2660 2661 Example: 2662 2663 (%i1) load(draw)$ 2664 (%i2) draw2d(transparent = false, 2665 fill_color = red, 2666 color = gray30, 2667 transparent = false, 2668 line_width = 5, 2669 ellipse(0,6,3,2,270,-270), 2670 /* center (x,y), a, b, start & end in degrees */ 2671 transparent = true, 2672 color = blue, 2673 line_width = 3, 2674 ellipse(2.5,6,2,3,30,-90), 2675 xrange = [-3,6], 2676 yrange = [2,9] )$ 2677 2678 -- Graphic object: errors ([<x1>, <x2>, ...], [<y1>, <y2>, ...]) 2679 2680 Draws points with error bars, horizontally, vertically or both, 2681 depending on the value of option 'error_type'. 2682 2683 2D 2684 2685 If 'error_type = x', arguments to 'errors' must be of the form '[x, 2686 y, xdelta]' or '[x, y, xlow, xhigh]'. If 'error_type = y', 2687 arguments must be of the form '[x, y, ydelta]' or '[x, y, ylow, 2688 yhigh]'. If 'error_type = xy' or 'error_type = boxes', arguments 2689 to 'errors' must be of the form '[x, y, xdelta, ydelta]' or '[x, y, 2690 xlow, xhigh, ylow, yhigh]'. 2691 2692 See also 'error_type'. 2693 2694 This object is affected by the following graphic options: 2695 'error_type', 'points_joined', 'line_width', 'key', 'line_type', 2696 'color', 'fill_density', 'xaxis_secondary', and 'yaxis_secondary'. 2697 2698 Option 'fill_density' is only relevant when 'error_type=boxes'. 2699 2700 Examples: 2701 2702 Horizontal error bars. 2703 2704 (%i1) load(draw)$ 2705 (%i2) draw2d( 2706 error_type = y, 2707 errors([[1,2,1], [3,5,3], [10,3,1], [17,6,2]]))$ 2708 2709 Vertical and horizontal error bars. 2710 2711 (%i1) load(draw)$ 2712 (%i2) draw2d( 2713 error_type = xy, 2714 points_joined = true, 2715 color = blue, 2716 errors([[1,2,1,2], [3,5,2,1], [10,3,1,1], [17,6,1/2,2]])); 2717 2718 -- Graphic object: explicit (<fcn>, <var>, <minval>, <maxval>) 2719 -- Graphic object: explicit (<fcn>, <var1>, <minval1>, <maxval1>, 2720 <var2>, <minval2>, <maxval2>) 2721 2722 Draws explicit functions in 2D and 3D. 2723 2724 2D 2725 2726 'explicit(<fcn>,<var>,<minval>,<maxval>)' plots explicit function 2727 <fcn>, with variable <var> taking values from <minval> to <maxval>. 2728 2729 This object is affected by the following graphic options: 'nticks', 2730 'adapt_depth', 'draw_realpart', 'line_width', 'line_type', 'key', 2731 'filled_func', 'fill_color' and 'color'. 2732 2733 Example: 2734 2735 (%i1) load(draw)$ 2736 (%i2) draw2d(line_width = 3, 2737 color = blue, 2738 explicit(x^2,x,-3,3) )$ 2739 (%i3) draw2d(fill_color = brown, 2740 filled_func = true, 2741 explicit(x^2,x,-3,3) )$ 2742 2743 3D 2744 2745 'explicit (<fcn>, <var1>, <minval1>, <maxval1>, <var2>, <minval2>, 2746 <maxval2>)' plots the explicit function <fcn>, with the variable 2747 <var1> taking values from <minval1> to <maxval1> and the variable 2748 <var2> taking values from <minval2> to <maxval2>. 2749 2750 This object is affected by the following graphic options: 2751 'draw_realpart', 'xu_grid', 'yv_grid', 'line_type', 'line_width', 2752 'key', 'wired_surface', 'enhanced3d', and 'color'. 2753 2754 Example: 2755 2756 (%i1) load(draw)$ 2757 (%i2) draw3d(key = "Gauss", 2758 color = "#a02c00", 2759 explicit(20*exp(-x^2-y^2)-10,x,-3,3,y,-3,3), 2760 yv_grid = 10, 2761 color = blue, 2762 key = "Plane", 2763 explicit(x+y,x,-5,5,y,-5,5), 2764 surface_hide = true)$ 2765 2766 See also 'filled_func' for filled functions. 2767 2768 -- Graphic object: image (<im>, <x0>, <y0>, <width>, <height>) 2769 2770 Renders images in 2D. 2771 2772 2D 2773 2774 'image(<im>, <x0>, <y0>, <width>, <height>)' plots image <im> in 2775 the rectangular region from vertex '(<x0>, <y0>)' to '(x0+<width>, 2776 y0+<height>)' on the real plane. Argument <im> must be a matrix of 2777 real numbers, a matrix of vectors of length three or a <picture> 2778 object. 2779 2780 If <im> is a matrix of real numbers or a <levels picture> object, 2781 pixel values are interpreted according to graphic option 'palette', 2782 which is a vector of length three with components ranging from -36 2783 to +36; each value is an index for a formula mapping the levels 2784 onto red, green and blue colors, respectively: 2785 0: 0 1: 0.5 2: 1 2786 3: x 4: x^2 5: x^3 2787 6: x^4 7: sqrt(x) 8: sqrt(sqrt(x)) 2788 9: sin(90x) 10: cos(90x) 11: |x-0.5| 2789 12: (2x-1)^2 13: sin(180x) 14: |cos(180x)| 2790 15: sin(360x) 16: cos(360x) 17: |sin(360x)| 2791 18: |cos(360x)| 19: |sin(720x)| 20: |cos(720x)| 2792 21: 3x 22: 3x-1 23: 3x-2 2793 24: |3x-1| 25: |3x-2| 26: (3x-1)/2 2794 27: (3x-2)/2 28: |(3x-1)/2| 29: |(3x-2)/2| 2795 30: x/0.32-0.78125 31: 2*x-0.84 2796 32: 4x;1;-2x+1.84;x/0.08-11.5 2797 33: |2*x - 0.5| 34: 2*x 35: 2*x - 0.5 2798 36: 2*x - 1 2799 negative numbers mean negative colour component. 2800 2801 'palette = gray' and 'palette = color' are short cuts for 'palette 2802 = [3,3,3]' and 'palette = [7,5,15]', respectively. 2803 2804 If <im> is a matrix of vectors of length three or an <rgb picture> 2805 object, they are interpreted as red, green and blue color 2806 components. 2807 2808 Examples: 2809 2810 If <im> is a matrix of real numbers, pixel values are interpreted 2811 according to graphic option 'palette'. 2812 2813 (%i1) load(draw)$ 2814 (%i2) im: apply( 2815 'matrix, 2816 makelist(makelist(random(200),i,1,30),i,1,30))$ 2817 (%i3) /* palette = color, default */ 2818 draw2d(image(im,0,0,30,30))$ 2819 (%i4) draw2d(palette = gray, image(im,0,0,30,30))$ 2820 (%i5) draw2d(palette = [15,20,-4], 2821 colorbox=false, 2822 image(im,0,0,30,30))$ 2823 2824 See also 'colorbox'. 2825 2826 If <im> is a matrix of vectors of length three, they are 2827 interpreted as red, green and blue color components. 2828 (%i1) load(draw)$ 2829 (%i2) im: apply( 2830 'matrix, 2831 makelist( 2832 makelist([random(300), 2833 random(300), 2834 random(300)],i,1,30),i,1,30))$ 2835 (%i3) draw2d(image(im,0,0,30,30))$ 2836 2837 Package 'draw' automatically loads package 'picture'. In this 2838 example, a level picture object is built by hand and then rendered. 2839 (%i1) load(draw)$ 2840 (%i2) im: make_level_picture([45,87,2,134,204,16],3,2); 2841 (%o2) picture(level, 3, 2, {Array: #(45 87 2 134 204 16)}) 2842 (%i3) /* default color palette */ 2843 draw2d(image(im,0,0,30,30))$ 2844 (%i4) /* gray palette */ 2845 draw2d(palette = gray, 2846 image(im,0,0,30,30))$ 2847 2848 An xpm file is read and then rendered. 2849 (%i1) load(draw)$ 2850 (%i2) im: read_xpm("myfile.xpm")$ 2851 (%i3) draw2d(image(im,0,0,10,7))$ 2852 2853 See also 'make_level_picture', 'make_rgb_picture' and 'read_xpm'. 2854 2855 <http://www.telefonica.net/web2/biomates/maxima/gpdraw/image> contains more 2856 elaborated examples. 2857 2858 -- Graphic object: implicit (<fcn>, <x>, <xmin>, <xmax>, <y>, <ymin>, 2859 <ymax>) 2860 -- Graphic object: implicit (<fcn>, <x>, <xmin>, <xmax>, <y>, <ymin>, 2861 <ymax>, <z>, <zmin>, <zmax>) 2862 2863 Draws implicit functions in 2D and 3D. 2864 2865 2D 2866 2867 'implicit(<fcn>, <x>, <xmin>, <xmax>, <y>, <ymin>, <ymax>)' plots 2868 the implicit function defined by <fcn>, with variable <x> taking 2869 values from <xmin> to <xmax>, and variable <y> taking values from 2870 <ymin> to <ymax>. 2871 2872 This object is affected by the following graphic options: 2873 'ip_grid', 'ip_grid_in', 'line_width', 'line_type', 'key' and 2874 'color'. 2875 2876 Example: 2877 2878 (%i1) load(draw)$ 2879 (%i2) draw2d(terminal = eps, 2880 grid = true, 2881 line_type = solid, 2882 key = "y^2=x^3-2*x+1", 2883 implicit(y^2=x^3-2*x+1, x, -4,4, y, -4,4), 2884 line_type = dots, 2885 key = "x^3+y^3 = 3*x*y^2-x-1", 2886 implicit(x^3+y^3 = 3*x*y^2-x-1, x,-4,4, y,-4,4), 2887 title = "Two implicit functions" )$ 2888 2889 3D 2890 2891 'implicit(<fcn>, <x>, <xmin>, <xmax>, <y>, <ymin>, <ymax>, <z>, 2892 <zmin>, <zmax>)' plots the implicit surface defined by <fcn>, with 2893 variable <x> taking values from <xmin> to <xmax>, variable <y> 2894 taking values from <ymin> to <ymax> and variable <z> taking values 2895 from <zmin> to <zmax>. This object implements the marching cubes 2896 algorithm. 2897 2898 This object is affected by the following graphic options: 2899 'x_voxel', 'y_voxel', 'z_voxel', 'line_width', 'line_type', 'key', 2900 'wired_surface', 'enhanced3d', and 'color'. 2901 2902 Example: 2903 2904 (%i1) load(draw)$ 2905 (%i2) draw3d( 2906 color=blue, 2907 implicit((x^2+y^2+z^2-1)*(x^2+(y-1.5)^2+z^2-0.5)=0.015, 2908 x,-1,1,y,-1.2,2.3,z,-1,1), 2909 surface_hide=true); 2910 2911 -- Graphic object: label ([<string>, <x>, <y>], ...) 2912 -- Graphic object: label ([<string>, <x>, <y>, <z>], ...) 2913 2914 Writes labels in 2D and 3D. 2915 2916 Colored labels work only with Gnuplot 4.3. This is a known bug in 2917 package 'draw'. 2918 2919 This object is affected by the following graphic options: 2920 'label_alignment', 'label_orientation' and 'color'. 2921 2922 2D 2923 2924 'label([<string>, <x>, <y>])' writes the <string> at point '[<x>, 2925 <y>]'. 2926 2927 Example: 2928 2929 (%i1) load(draw)$ 2930 (%i2) draw2d(yrange = [0.1,1.4], 2931 color = red, 2932 label(["Label in red",0,0.3]), 2933 color = "#0000ff", 2934 label(["Label in blue",0,0.6]), 2935 color = light_blue, 2936 label(["Label in light-blue",0,0.9], 2937 ["Another light-blue",0,1.2]) )$ 2938 2939 3D 2940 2941 'label([<string>, <x>, <y>, <z>])' writes the <string> at point 2942 '[<x>, <y>, <z>]'. 2943 2944 Example: 2945 2946 (%i1) load(draw)$ 2947 (%i2) draw3d(explicit(exp(sin(x)+cos(x^2)),x,-3,3,y,-3,3), 2948 color = red, 2949 label(["UP 1",-2,0,3], ["UP 2",1.5,0,4]), 2950 color = blue, 2951 label(["DOWN 1",2,0,-3]) )$ 2952 2953 -- Graphic object: mesh (<row_1>, <row_2>, ...) 2954 2955 Draws a quadrangular mesh in 3D. 2956 2957 3D 2958 2959 Argument <row_i> is a list of <n> 3D points of the form 2960 '[[x_i1,y_i1,z_i1], ...,[x_in,y_in,z_in]]', and all rows are of 2961 equal length. All these points define an arbitrary surface in 3D 2962 and in some sense it's a generalization of the 'elevation_grid' 2963 object. 2964 2965 This object is affected by the following graphic options: 2966 'line_type', 'line_width', 'color', 'key', 'wired_surface', 2967 'enhanced3d', and 'transform'. 2968 2969 Examples: 2970 2971 A simple example. 2972 2973 (%i1) load(draw)$ 2974 (%i2) draw3d( 2975 mesh([[1,1,3], [7,3,1],[12,-2,4],[15,0,5]], 2976 [[2,7,8], [4,3,1],[10,5,8], [12,7,1]], 2977 [[-2,11,10],[6,9,5],[6,15,1], [20,15,2]])) $ 2978 2979 Plotting a triangle in 3D. 2980 2981 (%i1) load(draw)$ 2982 (%i2) draw3d( 2983 line_width = 2, 2984 mesh([[1,0,0],[0,1,0]], 2985 [[0,0,1],[0,0,1]])) $ 2986 2987 Two quadrilaterals. 2988 2989 (%i1) load(draw)$ 2990 (%i2) draw3d( 2991 surface_hide = true, 2992 line_width = 3, 2993 color = red, 2994 mesh([[0,0,0], [0,1,0]], 2995 [[2,0,2], [2,2,2]]), 2996 color = blue, 2997 mesh([[0,0,2], [0,1,2]], 2998 [[2,0,4], [2,2,4]])) $ 2999 3000 -- Graphic object: parametric (<xfun>, <yfun>, <par>, <parmin>, 3001 <parmax>) 3002 -- Graphic object: parametric (<xfun>, <yfun>, <zfun>, <par>, <parmin>, 3003 <parmax>) 3004 3005 Draws parametric functions in 2D and 3D. 3006 3007 This object is affected by the following graphic options: 'nticks', 3008 'line_width', 'line_type', 'key', 'color' and 'enhanced3d'. 3009 3010 2D 3011 3012 'parametric(<xfun>, <yfun>, <par>, <parmin>, <parmax>)' plots the 3013 parametric function '[<xfun>, <yfun>]', with the parameter <par> 3014 taking values from <parmin> to <parmax>. 3015 3016 Example: 3017 3018 (%i1) load(draw)$ 3019 (%i2) draw2d(explicit(exp(x),x,-1,3), 3020 color = red, 3021 key = "This is the parametric one!!", 3022 parametric(2*cos(rrr),rrr^2,rrr,0,2*%pi))$ 3023 3024 3D 3025 3026 The command 'parametric(<xfun>, <yfun>, <zfun>, <par>, <parmin>, 3027 <parmax>)' plots the parametric curve '[<xfun>, <yfun>, <zfun>]', 3028 with the parameter <par> taking values from <parmin> to <parmax>. 3029 3030 Example: 3031 3032 (%i1) load(draw)$ 3033 (%i2) draw3d(explicit(exp(sin(x)+cos(x^2)),x,-3,3,y,-3,3), 3034 color = royalblue, 3035 parametric(cos(5*u)^2,sin(7*u),u-2,u,0,2), 3036 color = turquoise, 3037 line_width = 2, 3038 parametric(t^2,sin(t),2+t,t,0,2), 3039 surface_hide = true, 3040 title = "Surface & curves" )$ 3041 3042 -- Graphic object: parametric_surface (<xfun>, <yfun>, <zfun>, <par1>, 3043 <par1min>, <par1max>, <par2>, <par2min>, <par2max>) 3044 3045 Draws parametric surfaces in 3D. 3046 3047 3D 3048 3049 'parametric_surface(<xfun>, <yfun>, <zfun>, <par1>, <par1min>, 3050 <par1max>, <par2>, 3051 <par2min>, <par2max>)' plots the parametric surface '[<xfun>, 3052 <yfun>, <zfun>]', with the parameter <par1> taking values from 3053 <par1min> to <par1max> and the parameter <par2> taking values from 3054 <par2min> to <par2max>. 3055 3056 This object is affected by the following graphic options: 3057 'draw_realpart', 'xu_grid', 'yv_grid', 'line_type', 'line_width', 3058 'key', 'wired_surface', 'enhanced3d', and 'color'. 3059 3060 Example: 3061 3062 (%i1) load(draw)$ 3063 (%i2) draw3d(title = "Sea shell", 3064 xu_grid = 100, 3065 yv_grid = 25, 3066 view = [100,20], 3067 surface_hide = true, 3068 parametric_surface(0.5*u*cos(u)*(cos(v)+1), 3069 0.5*u*sin(u)*(cos(v)+1), 3070 u*sin(v) - ((u+3)/8*%pi)^2 - 20, 3071 u, 0, 13*%pi, v, -%pi, %pi) )$ 3072 3073 -- Graphic object: points ([[<x1>, <y1>], [<x2>, <y2>], ...]) 3074 -- Graphic object: points ([<x1>, <x2>, ...], [<y1>, <y2>, ...]) 3075 -- Graphic object: points ([<y1>, <y2>, ...]) 3076 -- Graphic object: points ([[<x1>, <y1>, <z1>], [<x2>, <y2>, <z2>], 3077 ...]) 3078 -- Graphic object: points ([<x1>, <x2>, ...], [<y1>, <y2>, ...], [<z1>, 3079 <z2>, ...]) 3080 -- Graphic object: points (<matrix>) 3081 -- Graphic object: points (<1d_y_array>) 3082 -- Graphic object: points (<1d_x_array>, <1d_y_array>) 3083 -- Graphic object: points (<1d_x_array>, <1d_y_array>, <1d_z_array>) 3084 -- Graphic object: points (<2d_xy_array>) 3085 -- Graphic object: points (<2d_xyz_array>) 3086 3087 Draws points in 2D and 3D. 3088 3089 This object is affected by the following graphic options: 3090 'point_size', 'point_type', 'points_joined', 'line_width', 'key', 3091 'line_type' and 'color'. In 3D mode, it is also affected by 3092 'enhanced3d'. 3093 3094 2D 3095 3096 'points([[<x1>, <y1>], [<x2>, <y2>], ...])' or 'points([<x1>, <x2>, 3097 ...], [<y1>, <y2>, ...])' plots points '[x1, y1]', '[x2, y2]', etc. 3098 If abscissas are not given, they are set to consecutive positive 3099 integers, so that 'points([<y1>, <y2>, ...])' draws points '[1, 3100 <y1>]', '[2, <y2>]', etc. If <matrix> is a two-column or two-row 3101 matrix, 'points (<matrix>)' draws the associated points. If 3102 <matrix> is a one-column or one-row matrix, abscissas are assigned 3103 automatically. 3104 3105 If <1d_y_array> is a 1D lisp array of numbers, 3106 'points(<1d_y_array>)' plots them setting abscissas to consecutive 3107 positive integers. 'points(<1d_x_array>, <1d_y_array>)' plots 3108 points with their coordinates taken from the two arrays passed as 3109 arguments. If <2d_xy_array> is a 2D array with two columns, or 3110 with two rows, 'points(<2d_xy_array>)' plots the corresponding 3111 points on the plane. 3112 3113 Examples: 3114 3115 Two types of arguments for 'points', a list of pairs and two lists 3116 of separate coordinates. 3117 (%i1) load(draw)$ 3118 (%i2) draw2d( 3119 key = "Small points", 3120 points(makelist([random(20),random(50)],k,1,10)), 3121 point_type = circle, 3122 point_size = 3, 3123 points_joined = true, 3124 key = "Great points", 3125 points(makelist(k,k,1,20),makelist(random(30),k,1,20)), 3126 point_type = filled_down_triangle, 3127 key = "Automatic abscissas", 3128 color = red, 3129 points([2,12,8]))$ 3130 3131 Drawing impulses. 3132 (%i1) load(draw)$ 3133 (%i2) draw2d( 3134 points_joined = impulses, 3135 line_width = 2, 3136 color = red, 3137 points(makelist([random(20),random(50)],k,1,10)))$ 3138 3139 Array with ordinates. 3140 (%i1) load(draw)$ 3141 (%i2) a: make_array (flonum, 100) $ 3142 (%i3) for i:0 thru 99 do a[i]: random(1.0) $ 3143 (%i4) draw2d(points(a)) $ 3144 3145 Two arrays with separate coordinates. 3146 (%i1) load(draw)$ 3147 (%i2) x: make_array (flonum, 100) $ 3148 (%i3) y: make_array (fixnum, 100) $ 3149 (%i4) for i:0 thru 99 do ( 3150 x[i]: float(i/100), 3151 y[i]: random(10) ) $ 3152 (%i5) draw2d(points(x, y)) $ 3153 3154 A two-column 2D array. 3155 (%i1) load(draw)$ 3156 (%i2) xy: make_array(flonum, 100, 2) $ 3157 (%i3) for i:0 thru 99 do ( 3158 xy[i, 0]: float(i/100), 3159 xy[i, 1]: random(10) ) $ 3160 (%i4) draw2d(points(xy)) $ 3161 3162 Drawing an array filled with function 'read_array'. 3163 (%i1) load(draw)$ 3164 (%i2) a: make_array(flonum,100) $ 3165 (%i3) read_array (file_search ("pidigits.data"), a) $ 3166 (%i4) draw2d(points(a)) $ 3167 3168 3D 3169 3170 'points([[<x1>, <y1>, <z1>], [<x2>, <y2>, <z2>], ...])' or 3171 'points([<x1>, <x2>, ...], [<y1>, <y2>, ...], [<z1>, <z2>, ...])' 3172 plots points '[<x1>, <y1>, <z1>]', '[<x2>, <y2>, <z2>]', etc. If 3173 <matrix> is a three-column or three-row matrix, 'points (<matrix>)' 3174 draws the associated points. 3175 3176 When arguments are lisp arrays, 'points(<1d_x_array>, <1d_y_array>, 3177 <1d_z_array>)' takes coordinates from the three 1D arrays. If 3178 <2d_xyz_array> is a 2D array with three columns, or with three 3179 rows, 'points(<2d_xyz_array>)' plots the corresponding points. 3180 3181 Examples: 3182 3183 One tridimensional sample, 3184 3185 (%i1) load(draw)$ 3186 (%i2) load (numericalio)$ 3187 (%i3) s2 : read_matrix (file_search ("wind.data"))$ 3188 (%i4) draw3d(title = "Daily average wind speeds", 3189 point_size = 2, 3190 points(args(submatrix (s2, 4, 5))) )$ 3191 3192 Two tridimensional samples, 3193 3194 (%i1) load(draw)$ 3195 (%i2) load (numericalio)$ 3196 (%i3) s2 : read_matrix (file_search ("wind.data"))$ 3197 (%i4) draw3d( 3198 title = "Daily average wind speeds. Two data sets", 3199 point_size = 2, 3200 key = "Sample from stations 1, 2 and 3", 3201 points(args(submatrix (s2, 4, 5))), 3202 point_type = 4, 3203 key = "Sample from stations 1, 4 and 5", 3204 points(args(submatrix (s2, 2, 3))) )$ 3205 3206 Unidimensional arrays, 3207 3208 (%i1) load(draw)$ 3209 (%i2) x: make_array (fixnum, 10) $ 3210 (%i3) y: make_array (fixnum, 10) $ 3211 (%i4) z: make_array (fixnum, 10) $ 3212 (%i5) for i:0 thru 9 do ( 3213 x[i]: random(10), 3214 y[i]: random(10), 3215 z[i]: random(10) ) $ 3216 (%i6) draw3d(points(x,y,z)) $ 3217 3218 Bidimensional colored array, 3219 3220 (%i1) load(draw)$ 3221 (%i2) xyz: make_array(fixnum, 10, 3) $ 3222 (%i3) for i:0 thru 9 do ( 3223 xyz[i, 0]: random(10), 3224 xyz[i, 1]: random(10), 3225 xyz[i, 2]: random(10) ) $ 3226 (%i4) draw3d( 3227 enhanced3d = true, 3228 points_joined = true, 3229 points(xyz)) $ 3230 3231 Color numbers explicitly specified by the user. 3232 3233 (%i1) load(draw)$ 3234 (%i2) pts: makelist([t,t^2,cos(t)], t, 0, 15)$ 3235 (%i3) col_num: makelist(k, k, 1, length(pts))$ 3236 (%i4) draw3d( 3237 enhanced3d = ['part(col_num,k),k], 3238 point_size = 3, 3239 point_type = filled_circle, 3240 points(pts))$ 3241 3242 -- Graphic object: polar (<radius>, <ang>, <minang>, <maxang>) 3243 3244 Draws 2D functions defined in polar coordinates. 3245 3246 2D 3247 3248 'polar(<radius>, <ang>, <minang>, <maxang>)' plots function 3249 '<radius>(<ang>)' defined in polar coordinates, with variable <ang> 3250 taking values from <minang> to <maxang>. 3251 3252 This object is affected by the following graphic options: 'nticks', 3253 'line_width', 'line_type', 'key' and 'color'. 3254 3255 Example: 3256 3257 (%i1) load(draw)$ 3258 (%i2) draw2d(user_preamble = "set grid polar", 3259 nticks = 200, 3260 xrange = [-5,5], 3261 yrange = [-5,5], 3262 color = blue, 3263 line_width = 3, 3264 title = "Hyperbolic Spiral", 3265 polar(10/theta,theta,1,10*%pi) )$ 3266 3267 -- Graphic object: polygon ([[<x1>, <y1>], [<x2>, <y2>], ...]) 3268 -- Graphic object: polygon ([<x1>, <x2>, ...], [<y1>, <y2>, ...]) 3269 3270 Draws polygons in 2D. 3271 3272 2D 3273 3274 'polygon([[<x1>, <y1>], [<x2>, <y2>], ...])' or 3275 'polygon([<x1>, <x2>, ...], [<y1>,<y2>, ...])': plots on the plane 3276 a polygon with vertices '[<x1>, <y1>]', '[<x2>, <y2>]', etc. 3277 3278 This object is affected by the following graphic options: 3279 'transparent', 'fill_color', 'border', 'line_width', 'key', 3280 'line_type' and 'color'. 3281 3282 Example: 3283 3284 (%i1) load(draw)$ 3285 (%i2) draw2d(color = "#e245f0", 3286 line_width = 8, 3287 polygon([[3,2],[7,2],[5,5]]), 3288 border = false, 3289 fill_color = yellow, 3290 polygon([[5,2],[9,2],[7,5]]) )$ 3291 3292 -- Graphic object: quadrilateral (<point_1>, <point_2>, <point_3>, 3293 <point_4>) 3294 3295 Draws a quadrilateral. 3296 3297 2D 3298 3299 'quadrilateral([<x1>, <y1>], [<x2>, <y2>], [<x3>, <y3>], [<x4>, 3300 <y4>])' draws a quadrilateral with vertices '[<x1>, <y1>]', '[<x2>, 3301 <y2>]', '[<x3>, <y3>]', and '[<x4>, <y4>]'. 3302 3303 This object is affected by the following graphic options: 3304 'transparent', 'fill_color', 'border', 'line_width', 3305 'key', 'xaxis_secondary', 'yaxis_secondary', 'line_type', 3306 'transform' and 'color'. 3307 3308 Example: 3309 3310 (%i1) load(draw)$ 3311 (%i2) draw2d( 3312 quadrilateral([1,1],[2,2],[3,-1],[2,-2]))$ 3313 3314 3D 3315 3316 'quadrilateral ([<x1>, <y1>, <z1>], [<x2>, <y2>, <z2>], [<x3>, 3317 <y3>, <z3>], [<x4>, <y4>, <z4>])' 3318 draws a quadrilateral with vertices '[<x1>, <y1>, <z1>]', '[<x2>, 3319 <y2>, <z2>]', '[<x3>, <y3>, <z3>]', and '[<x4>, <y4>, <z4>]'. 3320 3321 This object is affected by the following graphic options: 3322 'line_type', 'line_width', 'color', 'key', 'enhanced3d', and 3323 'transform'. 3324 3325 -- Graphic object: rectangle ([<x1>, <y1>], [<x2>, <y2>]) 3326 3327 Draws rectangles in 2D. 3328 3329 2D 3330 3331 'rectangle([<x1>, <y1>], [<x2>, <y2>])' draws a rectangle with 3332 opposite vertices '[<x1>, <y1>]' and '[<x2>, <y2>]'. 3333 3334 This object is affected by the following graphic options: 3335 'transparent', 'fill_color', 'border', 'line_width', 'key', 3336 'line_type' and 'color'. 3337 3338 Example: 3339 3340 (%i1) load(draw)$ 3341 (%i2) draw2d(fill_color = red, 3342 line_width = 6, 3343 line_type = dots, 3344 transparent = false, 3345 fill_color = blue, 3346 rectangle([-2,-2],[8,-1]), /* opposite vertices */ 3347 transparent = true, 3348 line_type = solid, 3349 line_width = 1, 3350 rectangle([9,4],[2,-1.5]), 3351 xrange = [-3,10], 3352 yrange = [-3,4.5] )$ 3353 3354 -- Graphic object: region (<expr>, <var1>, <minval1>, <maxval1>, 3355 <var2>, <minval2>, <maxval2>) 3356 3357 Plots a region on the plane defined by inequalities. 3358 3359 2D <expr> is an expression formed by inequalities and boolean 3360 operators 'and', 'or', and 'not'. The region is bounded by the 3361 rectangle defined by [<minval1>, <maxval1>] and [<minval2>, 3362 <maxval2>]. 3363 3364 This object is affected by the following graphic options: 3365 'fill_color', 'key', 'x_voxel', and 'y_voxel'. 3366 3367 Example: 3368 3369 (%i1) load(draw)$ 3370 (%i2) draw2d( 3371 x_voxel = 30, 3372 y_voxel = 30, 3373 region(x^2+y^2<1 and x^2+y^2 > 1/2, 3374 x, -1.5, 1.5, y, -1.5, 1.5)); 3375 3376 -- Graphic object: spherical (<radius>, <azi>, <minazi>, <maxazi>, 3377 <zen>, <minzen>, <maxzen>) 3378 3379 Draws 3D functions defined in spherical coordinates. 3380 3381 3D 3382 3383 'spherical(<radius>, <azi>, <minazi>, <maxazi>, <zen>, <minzen>, 3384 <maxzen>)' plots function '<radius>(<azi>, <zen>)' defined in 3385 spherical coordinates, with azimuth <azi> taking values from 3386 <minazi> to <maxazi> and zenith <zen> taking values from <minzen> 3387 to <maxzen>. 3388 3389 This object is affected by the following graphic options: 3390 'xu_grid', 'yv_grid', 'line_type', 'key', 'wired_surface', 3391 'enhanced3d', and 'color'. 3392 3393 Example: 3394 3395 (%i1) load(draw)$ 3396 (%i2) draw3d(spherical(1,a,0,2*%pi,z,0,%pi))$ 3397 3398 -- Graphic object: triangle (<point_1>, <point_2>, <point_3>) 3399 3400 Draws a triangle. 3401 3402 2D 3403 3404 'triangle([<x1>, <y1>], [<x2>, <y2>], [<x3>, <y3>])' draws a 3405 triangle with vertices '[<x1>, <y1>]', '[<x2>, <y2>]', and 3406 '[<x3>,<y3>]'. 3407 3408 This object is affected by the following graphic options: 3409 'transparent', 'fill_color', 'border', 'line_width', 3410 'key', 'xaxis_secondary', 'yaxis_secondary', 'line_type', 3411 'transform', and 'color'. 3412 3413 Example: 3414 3415 (%i1) load(draw)$ 3416 (%i2) draw2d( 3417 triangle([1,1],[2,2],[3,-1]))$ 3418 3419 3D 3420 3421 'triangle([<x1>, <y1>, <z1>], [<x2>, <y2>, <z2>], [<x3>, <y3>, 3422 <z3>])' draws a triangle with vertices '[<x1>, <y1>, <z1>]', 3423 '[<x2>, <y2>, <z2>]', and '[<x3>, <y3>, <z3>]'. 3424 3425 This object is affected by the following graphic options: 3426 'line_type', 'line_width', 'color', 'key', 'enhanced3d', and 3427 'transform'. 3428 3429 -- Graphic object: tube (<xfun>, <yfun>, <zfun>, <rfun>, <p>, <pmin>, 3430 <pmax>) 3431 3432 Draws a tube in 3D with varying diameter. 3433 3434 3D 3435 3436 '[<xfun>,<yfun>,<zfun>]' is the parametric curve with parameter <p> 3437 taking values from <pmin> to <pmax>. Circles of radius <rfun> are 3438 placed with their centers on the parametric curve and perpendicular 3439 to it. 3440 3441 This object is affected by the following graphic options: 3442 'xu_grid', 'yv_grid', 'line_type', 'line_width', 'key', 3443 'wired_surface', 'enhanced3d', 'color', and 'tube_extremes'. 3444 3445 Example: 3446 3447 (%i1) load(draw)$ 3448 (%i2) draw3d( 3449 enhanced3d = true, 3450 xu_grid = 50, 3451 tube(cos(a), a, 0, cos(a/10)^2, 3452 a, 0, 4*%pi) )$ 3453 3454 -- Graphic object: vector ([<x>, <y>], [<dx>, <dy>]) 3455 -- Graphic object: vector ([<x>, <y>, <z>], [<dx>, <dy>, <dz>]) 3456 3457 Draws vectors in 2D and 3D. 3458 3459 This object is affected by the following graphic options: 3460 'head_both', 'head_length', 'head_angle', 'head_type', 3461 'line_width', 'line_type', 'key' and 'color'. 3462 3463 2D 3464 3465 'vector([<x>, <y>], [<dx>,<dy>])' plots vector '[<dx>, <dy>]' with 3466 origin in '[<x>, <y>]'. 3467 3468 Example: 3469 3470 (%i1) load(draw)$ 3471 (%i2) draw2d(xrange = [0,12], 3472 yrange = [0,10], 3473 head_length = 1, 3474 vector([0,1],[5,5]), /* default type */ 3475 head_type = 'empty, 3476 vector([3,1],[5,5]), 3477 head_both = true, 3478 head_type = 'nofilled, 3479 line_type = dots, 3480 vector([6,1],[5,5]))$ 3481 3482 3D 3483 3484 'vector([<x>, <y>, <z>], [<dx>, <dy>, <dz>])' plots vector 3485 '[<dx>,<dy>,<dz>]' with origin in '[<x>, <y>, <z>]'. 3486 3487 Example: 3488 3489 (%i1) load(draw)$ 3490 (%i2) draw3d(color = cyan, 3491 vector([0,0,0],[1,1,1]/sqrt(3)), 3492 vector([0,0,0],[1,-1,0]/sqrt(2)), 3493 vector([0,0,0],[1,1,-2]/sqrt(6)) )$ 3494 3495 3496File: maxima.info, Node: Functions and Variables for pictures, Next: Functions and Variables for worldmap, Prev: Functions and Variables for draw, Up: draw 3497 349842.3 Functions and Variables for pictures 3499========================================= 3500 3501 -- Function: get_pixel (<pic>, <x>, <y>) 3502 3503 Returns pixel from picture. Coordinates <x> and <y> range from 0 3504 to 'width-1' and 'height-1', respectively. 3505 3506 -- Function: make_level_picture (<data>) 3507 -- Function: make_level_picture (<data>, <width>, <height>) 3508 3509 Returns a levels <picture> object. 'make_level_picture(<data>)' 3510 builds the <picture> object from matrix <data>. 3511 'make_level_picture(<data>, <width>, <height>)' builds the object 3512 from a list of numbers; in this case, both the <width> and the 3513 <height> must be given. 3514 3515 The returned <picture> object contains the following four parts: 3516 3517 1. symbol 'level' 3518 2. image width 3519 3. image height 3520 4. an integer array with pixel data ranging from 0 to 255. 3521 Argument <data> must contain only numbers ranged from 0 to 3522 255; negative numbers are substituted by 0, and those which 3523 are greater than 255 are set to 255. 3524 3525 Example: 3526 3527 Level picture from matrix. 3528 (%i1) load(draw)$ 3529 (%i2) make_level_picture(matrix([3,2,5],[7,-9,3000])); 3530 (%o2) picture(level, 3, 2, {Array: #(3 2 5 7 0 255)}) 3531 3532 Level picture from numeric list. 3533 (%i1) load(draw)$ 3534 (%i2) make_level_picture([-2,0,54,%pi],2,2); 3535 (%o2) picture(level, 2, 2, {Array: #(0 0 54 3)}) 3536 3537 -- Function: make_rgb_picture (<redlevel>, <greenlevel>, <bluelevel>) 3538 3539 Returns an rgb-coloured <picture> object. All three arguments must 3540 be levels picture; with red, green and blue levels. 3541 3542 The returned <picture> object contains the following four parts: 3543 3544 1. symbol 'rgb' 3545 2. image width 3546 3. image height 3547 4. an integer array of length <3*width*height> with pixel data 3548 ranging from 0 to 255. Each pixel is represented by three 3549 consecutive numbers (red, green, blue). 3550 3551 Example: 3552 3553 (%i1) load(draw)$ 3554 (%i2) red: make_level_picture(matrix([3,2],[7,260])); 3555 (%o2) picture(level, 2, 2, {Array: #(3 2 7 255)}) 3556 (%i3) green: make_level_picture(matrix([54,23],[73,-9])); 3557 (%o3) picture(level, 2, 2, {Array: #(54 23 73 0)}) 3558 (%i4) blue: make_level_picture(matrix([123,82],[45,32.5698])); 3559 (%o4) picture(level, 2, 2, {Array: #(123 82 45 33)}) 3560 (%i5) make_rgb_picture(red,green,blue); 3561 (%o5) picture(rgb, 2, 2, 3562 {Array: #(3 54 123 2 23 82 7 73 45 255 0 33)}) 3563 3564 -- Function: negative_picture (<pic>) 3565 3566 Returns the negative of a (<level> or <rgb>) picture. 3567 3568 -- Function: picture_equalp (<x>,<y>) 3569 3570 Returns 'true' in case of equal pictures, and 'false' otherwise. 3571 3572 -- Function: picturep (<x>) 3573 3574 Returns 'true' if the argument is a well formed image, and 'false' 3575 otherwise. 3576 3577 -- Function: read_xpm (<xpm_file>) 3578 3579 Reads a file in xpm and returns a picture object. 3580 3581 -- Function: rgb2level (<pic>) 3582 Transforms an <rgb> picture into a <level> one by averaging the 3583 red, green and blue channels. 3584 3585 -- Function: take_channel (<im>,<color>) 3586 3587 If argument <color> is 'red', 'green' or 'blue', function 3588 'take_channel' returns the corresponding color channel of picture 3589 <im>. 3590 3591 Example: 3592 3593 (%i1) load(draw)$ 3594 (%i2) red: make_level_picture(matrix([3,2],[7,260])); 3595 (%o2) picture(level, 2, 2, {Array: #(3 2 7 255)}) 3596 (%i3) green: make_level_picture(matrix([54,23],[73,-9])); 3597 (%o3) picture(level, 2, 2, {Array: #(54 23 73 0)}) 3598 (%i4) blue: make_level_picture(matrix([123,82],[45,32.5698])); 3599 (%o4) picture(level, 2, 2, {Array: #(123 82 45 33)}) 3600 (%i5) make_rgb_picture(red,green,blue); 3601 (%o5) picture(rgb, 2, 2, 3602 {Array: #(3 54 123 2 23 82 7 73 45 255 0 33)}) 3603 (%i6) take_channel(%,'green); /* simple quote!!! */ 3604 (%o6) picture(level, 2, 2, {Array: #(54 23 73 0)}) 3605 3606 3607File: maxima.info, Node: Functions and Variables for worldmap, Prev: Functions and Variables for pictures, Up: draw 3608 360942.4 Functions and Variables for worldmap 3610========================================= 3611 3612This package automatically loads package 'draw'. 3613 361442.4.1 Variables and Functions 3615------------------------------ 3616 3617 -- Global variable: boundaries_array 3618 Default value: 'false' 3619 3620 'boundaries_array' is where the graphic object 'geomap' looks for 3621 boundaries coordinates. 3622 3623 Each component of 'boundaries_array' is an array of floating point 3624 quantities, the coordinates of a polygonal segment or map boundary. 3625 3626 See also 'geomap'. 3627 3628 -- Function: numbered_boundaries (<nlist>) 3629 3630 Draws a list of polygonal segments (boundaries), labeled by its 3631 numbers ('boundaries_array' coordinates). This is of great help 3632 when building new geographical entities. 3633 3634 Example: 3635 3636 Map of Europe labeling borders with their component number in 3637 'boundaries_array'. 3638 (%i1) load(worldmap)$ 3639 (%i2) european_borders: 3640 region_boundaries(-31.81,74.92,49.84,32.06)$ 3641 (%i3) numbered_boundaries(european_borders)$ 3642 3643 -- Function: make_poly_continent (<continent_name>) 3644 -- Function: make_poly_continent (<country_list>) 3645 3646 Makes the necessary polygons to draw a colored continent or a list 3647 of countries. 3648 3649 Example: 3650 3651 (%i1) load(worldmap)$ 3652 (%i2) /* A continent */ 3653 make_poly_continent(Africa)$ 3654 (%i3) apply(draw2d, %)$ 3655 (%i4) /* A list of countries */ 3656 make_poly_continent([Germany,Denmark,Poland])$ 3657 (%i5) apply(draw2d, %)$ 3658 3659 -- Function: make_poly_country (<country_name>) 3660 3661 Makes the necessary polygons to draw a colored country. If islands 3662 exist, one country can be defined with more than just one polygon. 3663 3664 Example: 3665 3666 (%i1) load(worldmap)$ 3667 (%i2) make_poly_country(India)$ 3668 (%i3) apply(draw2d, %)$ 3669 3670 -- Function: make_polygon (<nlist>) 3671 3672 Returns a 'polygon' object from boundary indices. Argument <nlist> 3673 is a list of components of 'boundaries_array'. 3674 3675 Example: 3676 3677 Bhutan is defined by boundary numbers 171, 173 and 1143, so that 3678 'make_polygon([171,173,1143])' appends arrays of coordinates 3679 'boundaries_array[171]', 'boundaries_array[173]' and 3680 'boundaries_array[1143]' and returns a 'polygon' object suited to 3681 be plotted by 'draw'. To avoid an error message, arrays must be 3682 compatible in the sense that any two consecutive arrays have two 3683 coordinates in the extremes in common. In this example, the two 3684 first components of 'boundaries_array[171]' are equal to the last 3685 two coordinates of 'boundaries_array[173]', and the two first of 3686 'boundaries_array[173]' are equal to the two first of 3687 'boundaries_array[1143]'; in conclussion, boundary numbers 171, 173 3688 and 1143 (in this order) are compatible and the colored polygon can 3689 be drawn. 3690 3691 (%i1) load(worldmap)$ 3692 (%i2) Bhutan; 3693 (%o2) [[171, 173, 1143]] 3694 (%i3) boundaries_array[171]; 3695 (%o3) {Array: 3696 #(88.750549 27.14727 88.806351 27.25305 88.901367 27.282221 3697 88.917877 27.321039)} 3698 (%i4) boundaries_array[173]; 3699 (%o4) {Array: 3700 #(91.659554 27.76511 91.6008 27.66666 91.598022 27.62499 3701 91.631348 27.536381 91.765533 27.45694 91.775253 27.4161 3702 92.007751 27.471939 92.11441 27.28583 92.015259 27.168051 3703 92.015533 27.08083 92.083313 27.02277 92.112183 26.920271 3704 92.069977 26.86194 91.997192 26.85194 91.915253 26.893881 3705 91.916924 26.85416 91.8358 26.863331 91.712479 26.799999 3706 91.542191 26.80444 91.492188 26.87472 91.418854 26.873329 3707 91.371353 26.800831 91.307457 26.778049 90.682457 26.77417 3708 90.392197 26.903601 90.344131 26.894159 90.143044 26.75333 3709 89.98996 26.73583 89.841919 26.70138 89.618301 26.72694 3710 89.636093 26.771111 89.360786 26.859989 89.22081 26.81472 3711 89.110237 26.829161 88.921631 26.98777 88.873016 26.95499 3712 88.867737 27.080549 88.843307 27.108601 88.750549 3713 27.14727)} 3714 (%i5) boundaries_array[1143]; 3715 (%o5) {Array: 3716 #(91.659554 27.76511 91.666924 27.88888 91.65831 27.94805 3717 91.338028 28.05249 91.314972 28.096661 91.108856 27.971109 3718 91.015808 27.97777 90.896927 28.05055 90.382462 28.07972 3719 90.396088 28.23555 90.366074 28.257771 89.996353 28.32333 3720 89.83165 28.24888 89.58609 28.139999 89.35997 27.87166 3721 89.225517 27.795 89.125793 27.56749 88.971077 27.47361 3722 88.917877 27.321039)} 3723 (%i6) Bhutan_polygon: make_polygon([171,173,1143])$ 3724 (%i7) draw2d(Bhutan_polygon)$ 3725 3726 -- Function: region_boundaries (<x1>, <y1>, <x2>, <y2>) 3727 3728 Detects polygonal segments of global variable 'boundaries_array' 3729 fully contained in the rectangle with vertices (<x1>, <y1>) -upper 3730 left- and (<x2>, <y2>) -bottom right-. 3731 3732 Example: 3733 3734 Returns segment numbers for plotting southern Italy. 3735 (%i1) load(worldmap)$ 3736 (%i2) region_boundaries(10.4,41.5,20.7,35.4); 3737 (%o2) [1846, 1863, 1864, 1881, 1888, 1894] 3738 (%i3) draw2d(geomap(%))$ 3739 3740 -- Function: region_boundaries_plus (<x1>, <y1>, <x2>, <y2>) 3741 3742 Detects polygonal segments of global variable 'boundaries_array' 3743 containing at least one vertex in the rectangle defined by vertices 3744 (<x1>, <y1>) -upper left- and (<x2>, <y2>) -bottom right-. 3745 3746 Example: 3747 3748 (%i1) load(worldmap)$ 3749 (%i2) region_boundaries_plus(10.4,41.5,20.7,35.4); 3750 (%o2) [1060, 1062, 1076, 1835, 1839, 1844, 1846, 1858, 3751 1861, 1863, 1864, 1871, 1881, 1888, 1894, 1897] 3752 (%i3) draw2d(geomap(%))$ 3753 375442.4.2 Graphic objects 3755---------------------- 3756 3757 -- Graphic object: geomap (<numlist>) 3758 -- Graphic object: geomap (<numlist>, <3Dprojection>) 3759 3760 Draws cartographic maps in 2D and 3D. 3761 3762 2D 3763 3764 This function works together with global variable 3765 'boundaries_array'. 3766 3767 Argument <numlist> is a list containing numbers or lists of 3768 numbers. All these numbers must be integers greater or equal than 3769 zero, representing the components of global array 3770 'boundaries_array'. 3771 3772 Each component of 'boundaries_array' is an array of floating point 3773 quantities, the coordinates of a polygonal segment or map boundary. 3774 3775 'geomap (<numlist>)' flattens its arguments and draws the 3776 associated boundaries in 'boundaries_array'. 3777 3778 This object is affected by the following graphic options: 3779 'line_width', 'line_type' and 'color'. 3780 3781 Examples: 3782 3783 A simple map defined by hand: 3784 3785 (%i1) load(worldmap)$ 3786 (%i2) /* Vertices of boundary #0: {(1,1),(2,5),(4,3)} */ 3787 ( bnd0: make_array(flonum,6), 3788 bnd0[0]:1.0, bnd0[1]:1.0, bnd0[2]:2.0, 3789 bnd0[3]:5.0, bnd0[4]:4.0, bnd0[5]:3.0 )$ 3790 (%i3) /* Vertices of boundary #1: {(4,3),(5,4),(6,4),(5,1)} */ 3791 ( bnd1: make_array(flonum,8), 3792 bnd1[0]:4.0, bnd1[1]:3.0, bnd1[2]:5.0, bnd1[3]:4.0, 3793 bnd1[4]:6.0, bnd1[5]:4.0, bnd1[6]:5.0, bnd1[7]:1.0)$ 3794 (%i4) /* Vertices of boundary #2: {(5,1), (3,0), (1,1)} */ 3795 ( bnd2: make_array(flonum,6), 3796 bnd2[0]:5.0, bnd2[1]:1.0, bnd2[2]:3.0, 3797 bnd2[3]:0.0, bnd2[4]:1.0, bnd2[5]:1.0 )$ 3798 (%i5) /* Vertices of boundary #3: {(1,1), (4,3)} */ 3799 ( bnd3: make_array(flonum,4), 3800 bnd3[0]:1.0, bnd3[1]:1.0, bnd3[2]:4.0, bnd3[3]:3.0)$ 3801 (%i6) /* Vertices of boundary #4: {(4,3), (5,1)} */ 3802 ( bnd4: make_array(flonum,4), 3803 bnd4[0]:4.0, bnd4[1]:3.0, bnd4[2]:5.0, bnd4[3]:1.0)$ 3804 (%i7) /* Pack all together in boundaries_array */ 3805 ( boundaries_array: make_array(any,5), 3806 boundaries_array[0]: bnd0, boundaries_array[1]: bnd1, 3807 boundaries_array[2]: bnd2, boundaries_array[3]: bnd3, 3808 boundaries_array[4]: bnd4 )$ 3809 (%i8) draw2d(geomap([0,1,2,3,4]))$ 3810 3811 The auxiliary package 'worldmap' sets the global variable 3812 'boundaries_array' to the real world boundaries in coordinates. 3813 The data is in the public domain and come from 3814 <http://www-cger.nies.go.jp/grid-e/gridtxt/grid19.html>. The 3815 package 'worldmap' defines also boundaries for countries, 3816 continents and coastlines as lists with the necessary components of 3817 'boundaries_array' (see file 'share/draw/worldmap.mac' for more 3818 information). The package 'worldmap' automatically loads package 3819 'worldmap'. 3820 3821 (%i1) load(worldmap)$ 3822 (%i2) c1: gr2d(geomap([Canada,United_States, 3823 Mexico,Cuba]))$ 3824 (%i3) c2: gr2d(geomap(Africa))$ 3825 (%i4) c3: gr2d(geomap(Oceania,China,Japan))$ 3826 (%i5) c4: gr2d(geomap([France,Portugal,Spain, 3827 Morocco,Western_Sahara]))$ 3828 (%i6) draw(columns = 2, 3829 c1,c2,c3,c4)$ 3830 3831 Package 'worldmap' is also useful for plotting countries as 3832 polygons. In this case, graphic object 'geomap' is no longer 3833 necessary and the 'polygon' object is used instead. Since lists 3834 are now used and not arrays, maps rendering will be slower. See 3835 also 'make_poly_country' and 'make_poly_continent' to understand 3836 the following code. 3837 3838 (%i1) load(worldmap)$ 3839 (%i2) mymap: append( 3840 [color = white], /* borders are white */ 3841 [fill_color = red], make_poly_country(Bolivia), 3842 [fill_color = cyan], make_poly_country(Paraguay), 3843 [fill_color = green], make_poly_country(Colombia), 3844 [fill_color = blue], make_poly_country(Chile), 3845 [fill_color = "#23ab0f"], make_poly_country(Brazil), 3846 [fill_color = goldenrod], make_poly_country(Argentina), 3847 [fill_color = "midnight-blue"], make_poly_country(Uruguay))$ 3848 (%i3) apply(draw2d, mymap)$ 3849 3850 3D 3851 3852 'geomap(<numlist>)' projects map boundaries on the sphere of radius 3853 1 centered at (0,0,0). It is possible to change the sphere or the 3854 projection type by using 'geomap(<numlist>,<3Dprojection>)'. 3855 3856 Available 3D projections: 3857 3858 * '[spherical_projection,<x>, <y>, <z>, <r>]': projects map 3859 boundaries on the sphere of radius <r> centered at (<x>, <y>, 3860 <z>). 3861 3862 (%i1) load(worldmap)$ 3863 (%i2) draw3d(geomap(Australia), /* default projection */ 3864 geomap(Australia, 3865 [spherical_projection,2,2,2,3]))$ 3866 3867 * '[cylindrical_projection, <x>, <y>, <z>, <r>, <rc>]': 3868 re-projects spherical map boundaries on the cylinder of radius 3869 <rc> and axis passing through the poles of the globe of radius 3870 <r> centered at (<x>, <y>, <z>). 3871 3872 (%i1) load(worldmap)$ 3873 (%i2) draw3d(geomap([America_coastlines,Eurasia_coastlines], 3874 [cylindrical_projection,2,2,2,3,4]))$ 3875 3876 * '[conic_projection, <x>, <y>, <z>, <r>, <alpha>]': re-projects 3877 spherical map boundaries on the cones of angle <alpha>, with 3878 axis passing through the poles of the globe of radius <r> 3879 centered at (<x>, <y>, <z>). Both the northern and southern 3880 cones are tangent to sphere. 3881 3882 (%i1) load(worldmap)$ 3883 (%i2) draw3d(geomap(World_coastlines, 3884 [conic_projection,0,0,0,1,90]))$ 3885 3886 See also <http://riotorto.users.sf.net/gnuplot/geomap> for more 3887 elaborated examples. 3888 3889 3890File: maxima.info, Node: drawdf, Next: dynamics, Prev: draw, Up: Top 3891 389243 drawdf 3893********* 3894 3895* Menu: 3896 3897* Introduction to drawdf:: 3898* Functions and Variables for drawdf:: 3899 3900 3901File: maxima.info, Node: Introduction to drawdf, Next: Functions and Variables for drawdf, Prev: drawdf, Up: drawdf 3902 390343.1 Introduction to drawdf 3904=========================== 3905 3906The function 'drawdf' draws the direction field of a first-order 3907Ordinary Differential Equation (ODE) or a system of two autonomous 3908first-order ODE's. 3909 3910Since this is an additional package, in order to use it you must first 3911load it with 'load(drawdf)'. Drawdf is built upon the 'draw' package, 3912which requires Gnuplot 4.2. 3913 3914To plot the direction field of a single ODE, the ODE must be written in 3915the form: 3916 dy 3917 -- = F(x,y) 3918 dx 3919 3920and the function <F> should be given as the argument for 'drawdf'. If 3921the independent and dependent variables are not <x>, and <y>, as in the 3922equation above, then those two variables should be named explicitly in a 3923list given as an argument to the drawdf command (see the examples). 3924 3925To plot the direction field of a set of two autonomous ODE's, they must 3926be written in the form 3927 dx dy 3928 -- = G(x,y) -- = F(x,y) 3929 dt dt 3930 3931and the argument for 'drawdf' should be a list with the two functions 3932<G> and <F>, in that order; namely, the first expression in the list 3933will be taken to be the time derivative of the variable represented on 3934the horizontal axis, and the second expression will be the time 3935derivative of the variable represented on the vertical axis. Those two 3936variables do not have to be <x> and <y>, but if they are not, then the 3937second argument given to drawdf must be another list naming the two 3938variables, first the one on the horizontal axis and then the one on the 3939vertical axis. 3940 3941If only one ODE is given, 'drawdf' will implicitly admit 'x=t', and 3942'G(x,y)=1', transforming the non-autonomous equation into a system of 3943two autonomous equations. 3944 3945 3946File: maxima.info, Node: Functions and Variables for drawdf, Prev: Introduction to drawdf, Up: drawdf 3947 394843.2 Functions and Variables for drawdf 3949======================================= 3950 395143.2.1 Functions 3952---------------- 3953 3954 -- Function: drawdf (<dydx>, ...options and objects...) 3955 -- Function: drawdf (<dvdu>, '['<u>,<v>']', ...options and objects...) 3956 -- Function: drawdf (<dvdu>, '['<u>,<umin>,<umax>']', 3957 '['<v>,<vmin>,<vmax>']', ...options and objects...) 3958 -- Function: drawdf ('['<dxdt>,<dydt>']', ...options and objects...) 3959 -- Function: drawdf ('['<dudt>,<dvdt>']', '['<u>,<v>']', ...options and 3960 objects...) 3961 -- Function: drawdf ('['<dudt>,<dvdt>']', '['<u>,<umin>,<umax>']', 3962 '['<v>,<vmin>,<vmax>']', ...options and objects...) 3963 3964 Function 'drawdf' draws a 2D direction field with optional solution 3965 curves and other graphics using the 'draw' package. 3966 3967 The first argument specifies the derivative(s), and must be either 3968 an expression or a list of two expressions. <dydx>, <dxdt> and 3969 <dydt> are expressions that depend on <x> and <y>. <dvdu>, <dudt> 3970 and <dvdt> are expressions that depend on <u> and <v>. 3971 3972 If the independent and dependent variables are not <x> and <y>, 3973 then their names must be specified immediately following the 3974 derivative(s), either as a list of two names '['<u>,<v>']', or as 3975 two lists of the form '['<u>,<umin>,<umax>']' and 3976 '['<v>,<vmin>,<vmax>']'. 3977 3978 The remaining arguments are graphic options, graphic objects, or 3979 lists containing graphic options and objects, nested to arbitrary 3980 depth. The set of graphic options and objects supported by 3981 'drawdf' is a superset of those supported by 'draw2d' and 'gr2d' 3982 from the 'draw' package. 3983 3984 The arguments are interpreted sequentially: graphic options affect 3985 all following graphic objects. Furthermore, graphic objects are 3986 drawn on the canvas in order specified, and may obscure graphics 3987 drawn earlier. Some graphic options affect the global appearence 3988 of the scene. 3989 3990 The additional graphic objects supported by 'drawdf' include: 3991 'solns_at', 'points_at', 'saddles_at', 'soln_at', 'point_at', and 3992 'saddle_at'. 3993 3994 The additional graphic options supported by 'drawdf' include: 3995 'field_degree', 'soln_arrows', 'field_arrows', 'field_grid', 3996 'field_color', 'show_field', 'tstep', 'nsteps', 'duration', 3997 'direction', 'field_tstep', 'field_nsteps', and 'field_duration'. 3998 3999 Commonly used graphic objects inherited from the 'draw' package 4000 include: 'explicit', 'implicit', 'parametric', 'polygon', 'points', 4001 'vector', 'label', and all others supported by 'draw2d' and 'gr2d'. 4002 4003 Commonly used graphic options inherited from the 'draw' package 4004 include: 4005 'points_joined', 'color', 4006 'point_type', 'point_size', 'line_width', 4007 'line_type', 'key', 'title', 'xlabel', 4008 'ylabel', 'user_preamble', 'terminal', 4009 'dimensions', 'file_name', and all 4010 others supported by 'draw2d' and 'gr2d'. 4011 4012 See also 'draw2d'. 4013 4014 Users of wxMaxima or Imaxima may optionally use 'wxdrawdf', which 4015 is identical to 'drawdf' except that the graphics are drawn within 4016 the notebook using 'wxdraw'. 4017 4018 To make use of this function, write first 'load(drawdf)'. 4019 4020 Examples: 4021 4022 (%i1) load(drawdf)$ 4023 (%i2) drawdf(exp(-x)+y)$ /* default vars: x,y */ 4024 (%i3) drawdf(exp(-t)+y, [t,y])$ /* default range: [-10,10] */ 4025 (%i4) drawdf([y,-9*sin(x)-y/5], [x,1,5], [y,-2,2])$ 4026 4027 For backward compatibility, 'drawdf' accepts most of the parameters 4028 supported by plotdf. 4029 4030 (%i5) drawdf(2*cos(t)-1+y, [t,y], [t,-5,10], [y,-4,9], 4031 [trajectory_at,0,0])$ 4032 4033 'soln_at' and 'solns_at' draw solution curves passing through the 4034 specified points, using a slightly enhanced 4th-order Runge Kutta 4035 numerical integrator. 4036 4037 (%i6) drawdf(2*cos(t)-1+y, [t,-5,10], [y,-4,9], 4038 solns_at([0,0.1],[0,-0.1]), 4039 color=blue, soln_at(0,0))$ 4040 4041 'field_degree=2' causes the field to be composed of quadratic 4042 splines, based on the first and second derivatives at each grid 4043 point. 'field_grid=['<COLS>,<ROWS>']' specifies the number of 4044 columns and rows in the grid. 4045 4046 (%i7) drawdf(2*cos(t)-1+y, [t,-5,10], [y,-4,9], 4047 field_degree=2, field_grid=[20,15], 4048 solns_at([0,0.1],[0,-0.1]), 4049 color=blue, soln_at(0,0))$ 4050 4051 'soln_arrows=true' adds arrows to the solution curves, and (by 4052 default) removes them from the direction field. It also changes 4053 the default colors to emphasize the solution curves. 4054 4055 (%i8) drawdf(2*cos(t)-1+y, [t,-5,10], [y,-4,9], 4056 soln_arrows=true, 4057 solns_at([0,0.1],[0,-0.1],[0,0]))$ 4058 4059 'duration=40' specifies the time duration of numerical integration 4060 (default 10). Integration will also stop automatically if the 4061 solution moves too far away from the plotted region, or if the 4062 derivative becomes complex or infinite. Here we also specify 4063 'field_degree=2' to plot quadratic splines. The equations below 4064 model a predator-prey system. 4065 4066 (%i9) drawdf([x*(1-x-y), y*(3/4-y-x/2)], [x,0,1.1], [y,0,1], 4067 field_degree=2, duration=40, 4068 soln_arrows=true, point_at(1/2,1/2), 4069 solns_at([0.1,0.2], [0.2,0.1], [1,0.8], [0.8,1], 4070 [0.1,0.1], [0.6,0.05], [0.05,0.4], 4071 [1,0.01], [0.01,0.75]))$ 4072 4073 'field_degree='solns' causes the field to be composed of many small 4074 solution curves computed by 4th-order Runge Kutta, with better 4075 results in this case. 4076 4077 (%i10) drawdf([x*(1-x-y), y*(3/4-y-x/2)], [x,0,1.1], [y,0,1], 4078 field_degree='solns, duration=40, 4079 soln_arrows=true, point_at(1/2,1/2), 4080 solns_at([0.1,0.2], [0.2,0.1], [1,0.8], 4081 [0.8,1], [0.1,0.1], [0.6,0.05], 4082 [0.05,0.4], [1,0.01], [0.01,0.75]))$ 4083 4084 'saddles_at' attempts to automatically linearize the equation at 4085 each saddle, and to plot a numerical solution corresponding to each 4086 eigenvector, including the separatrices. 'tstep=0.05' specifies 4087 the maximum time step for the numerical integrator (the default is 4088 0.1). Note that smaller time steps will sometimes be used in order 4089 to keep the x and y steps small. The equations below model a 4090 damped pendulum. 4091 4092 (%i11) drawdf([y,-9*sin(x)-y/5], tstep=0.05, 4093 soln_arrows=true, point_size=0.5, 4094 points_at([0,0], [2*%pi,0], [-2*%pi,0]), 4095 field_degree='solns, 4096 saddles_at([%pi,0], [-%pi,0]))$ 4097 4098 'show_field=false' suppresses the field entirely. 4099 4100 (%i12) drawdf([y,-9*sin(x)-y/5], tstep=0.05, 4101 show_field=false, soln_arrows=true, 4102 point_size=0.5, 4103 points_at([0,0], [2*%pi,0], [-2*%pi,0]), 4104 saddles_at([3*%pi,0], [-3*%pi,0], 4105 [%pi,0], [-%pi,0]))$ 4106 4107 'drawdf' passes all unrecognized parameters to 'draw2d' or 'gr2d', 4108 allowing you to combine the full power of the 'draw' package with 4109 'drawdf'. 4110 4111 (%i13) drawdf(x^2+y^2, [x,-2,2], [y,-2,2], field_color=gray, 4112 key="soln 1", color=black, soln_at(0,0), 4113 key="soln 2", color=red, soln_at(0,1), 4114 key="isocline", color=green, line_width=2, 4115 nticks=100, parametric(cos(t),sin(t),t,0,2*%pi))$ 4116 4117 'drawdf' accepts nested lists of graphic options and objects, 4118 allowing convenient use of makelist and other function calls to 4119 generate graphics. 4120 4121 (%i14) colors : ['red,'blue,'purple,'orange,'green]$ 4122 (%i15) drawdf([x-x*y/2, (x*y - 3*y)/4], 4123 [x,2.5,3.5], [y,1.5,2.5], 4124 field_color = gray, 4125 makelist([ key = concat("soln",k), 4126 color = colors[k], 4127 soln_at(3, 2 + k/20) ], 4128 k,1,5))$ 4129 4130 4131File: maxima.info, Node: dynamics, Next: ezunits, Prev: drawdf, Up: Top 4132 413344 dynamics 4134*********** 4135 4136* Menu: 4137 4138* Introduction to dynamics:: 4139* Functions and Variables for dynamics:: 4140 4141 4142File: maxima.info, Node: Introduction to dynamics, Next: Functions and Variables for dynamics, Prev: dynamics, Up: dynamics 4143 414444.1 Introduction to dynamics 4145============================= 4146 4147The additional package 'dynamics' includes several functions to create 4148various graphical representations of discrete dynamical systems and 4149fractals, and an implementation of the Runge-Kutta 4th-order numerical 4150method for solving systems of differential equations. 4151 4152To use the functions in this package you must first load it with 4153'load("dynamics")'. 4154 4155Starting with Maxima 5.12, the dynamics package now uses the function 4156'plot2d' to do the graphs. The commands that produce graphics (with the 4157exception of 'julia' and 'mandelbrot') now accept any options of 4158'plot2d', including the option to change among the various graphical 4159interfaces, using different plot styles and colors, and representing one 4160or both axes in a logarithmic scale. The old options <domain>, 4161<pointsize>, <xcenter>, <xradius>, <ycenter>, <yradius>, <xaxislabel> 4162and <yaxislabel> are not accepted in this new version. 4163 4164All programs will now accept any variables names, and not just <x> and 4165<y> as in the older versions. Two required parameters have changes in 4166two of the programs: 'evolution2d' now requires a list naming 4167explicitely the two independent variables, and the horizontal range for 4168'orbits' no longer requires a step size; the range should only specify 4169the variable name, and the minimum and maximum values; the number of 4170steps can now be changed with the option <nticks>. 4171 4172 4173File: maxima.info, Node: Functions and Variables for dynamics, Prev: Introduction to dynamics, Up: dynamics 4174 417544.2 Functions and Variables for dynamics 4176========================================= 4177 4178 -- Function: chaosgame ('[['<x1>, <y1>']', ..., '['<xm>, <ym>']]', 4179 '['<x0>, <y0>']', <b>, <n>, ..., options, ...) 4180 4181 Implements the so-called chaos game: the initial point (<x0>, <y0>) 4182 is plotted and then one of the <m> points '['<x1>, <y1>']', ..., 4183 '['<xm>, <ym>']' will be selected at random. The next point 4184 plotted will be on the segment from the previous point plotted to 4185 the point chosen randomly, at a distance from the random point 4186 which will be <b> times that segment's length. The procedure is 4187 repeated <n> times. 4188 4189 -- Function: evolution (<F>, <y0>, <n>, ..., options, ...) 4190 4191 Draws <n+1> points in a two-dimensional graph, where the horizontal 4192 coordinates of the points are the integers 0, 1, 2, ..., <n>, and 4193 the vertical coordinates are the corresponding values <y(n)> of the 4194 sequence defined by the recurrence relation 4195 y(n+1) = F(y(n)) 4196 4197 With initial value <y(0)> equal to <y0>. <F> must be an expression 4198 that depends only on one variable (in the example, it depend on 4199 <y>, but any other variable can be used), <y0> must be a real 4200 number and <n> must be a positive integer. 4201 4202 -- Function: evolution2d ('['<F>, <G>']', '['<u>, <v>']', '['<u0>, 4203 <y0>']', <n>, ..., options, ...) 4204 4205 Shows, in a two-dimensional plot, the first <n+1> points in the 4206 sequence of points defined by the two-dimensional discrete 4207 dynamical system with recurrence relations 4208 u(n+1) = F(u(n), v(n)) v(n+1) = G(u(n), v(n)) 4209 4210 With initial values <u0> and <v0>. <F> and <G> must be two 4211 expressions that depend only on two variables, <u> and <v>, which 4212 must be named explicitely in a list. 4213 4214 -- Function: ifs ('['<r1>, ..., <rm>']', '['<A1>, ..., <Am>']', 4215 '[['<x1>, <y1>']', ..., '['<xm>, <ym>']]', '['<x0>, <y0>']', 4216 <n>, ..., options, ...) 4217 4218 Implements the Iterated Function System method. This method is 4219 similar to the method described in the function 'chaosgame', but 4220 instead of shrinking the segment from the current point to the 4221 randomly chosen point, the 2 components of that segment will be 4222 multiplied by the 2 by 2 matrix <Ai> that corresponds to the point 4223 chosen randomly. 4224 4225 The random choice of one of the <m> attractive points can be made 4226 with a non-uniform probability distribution defined by the weights 4227 <r1>, ..., <rm>. Those weights are given in cumulative form; for 4228 instance if there are 3 points with probabilities 0.2, 0.5 and 0.3, 4229 the weights <r1>, <r2> and <r3> could be 2, 7 and 10. 4230 4231 -- Function: orbits (<F>, <y0>, <n1>, <n2>, [<x>, <x0>, <xf>, <xstep>], 4232 ..., options, ...) 4233 4234 Draws the orbits diagram for a family of one-dimensional discrete 4235 dynamical systems, with one parameter <x>; that kind of diagram is 4236 used to study the bifurcations of a one-dimensional discrete 4237 system. 4238 4239 The function <F(y)> defines a sequence with a starting value of 4240 <y0>, as in the case of the function 'evolution', but in this case 4241 that function will also depend on a parameter <x> that will take 4242 values in the interval from <x0> to <xf> with increments of 4243 <xstep>. Each value used for the parameter <x> is shown on the 4244 horizontal axis. The vertical axis will show the <n2> values of 4245 the sequence <y(n1+1)>,..., <y(n1+n2+1)> obtained after letting the 4246 sequence evolve <n1> iterations. 4247 4248 -- Function: rk (<ODE>, <var>, <initial>, <domain>) 4249 -- Function: rk ([<ODE1>, ..., <ODEm>], [<v1>, ..., <vm>], [<init1>, 4250 ..., <initm>], <domain>) 4251 4252 The first form solves numerically one first-order ordinary 4253 differential equation, and the second form solves a system of m of 4254 those equations, using the 4th order Runge-Kutta method. <var> 4255 represents the dependent variable. <ODE> must be an expression 4256 that depends only on the independent and dependent variables and 4257 defines the derivative of the dependent variable with respect to 4258 the independent variable. 4259 4260 The independent variable is specified with 'domain', which must be 4261 a list of four elements as, for instance: 4262 [t, 0, 10, 0.1] 4263 the first element of the list identifies the independent variable, 4264 the second and third elements are the initial and final values for 4265 that variable, and the last element sets the increments that should 4266 be used within that interval. 4267 4268 If <m> equations are going to be solved, there should be <m> 4269 dependent variables <v1>, <v2>, ..., <vm>. The initial values for 4270 those variables will be <init1>, <init2>, ..., <initm>. There will 4271 still be just one independent variable defined by 'domain', as in 4272 the previous case. <ODE1>, ..., <ODEm> are the expressions that 4273 define the derivatives of each dependent variable in terms of the 4274 independent variable. The only variables that may appear in those 4275 expressions are the independent variable and any of the dependent 4276 variables. It is important to give the derivatives <ODE1>, ..., 4277 <ODEm> in the list in exactly the same order used for the dependent 4278 variables; for instance, the third element in the list will be 4279 interpreted as the derivative of the third dependent variable. 4280 4281 The program will try to integrate the equations from the initial 4282 value of the independent variable until its last value, using 4283 constant increments. If at some step one of the dependent 4284 variables takes an absolute value too large, the integration will 4285 be interrupted at that point. The result will be a list with as 4286 many elements as the number of iterations made. Each element in 4287 the results list is itself another list with <m>+1 elements: the 4288 value of the independent variable, followed by the values of the 4289 dependent variables corresponding to that point. 4290 4291 -- Function: staircase (<F>, <y0>, <n>, ..., options, ...) 4292 4293 Draws a staircase diagram for the sequence defined by the 4294 recurrence relation 4295 y(n+1) = F(y(n)) 4296 4297 The interpretation and allowed values of the input parameters is 4298 the same as for the function 'evolution'. A staircase diagram 4299 consists of a plot of the function <F(y)>, together with the line 4300 <G(y)> '=' <y>. A vertical segment is drawn from the point (<y0>, 4301 <y0>) on that line until the point where it intersects the function 4302 <F>. From that point a horizontal segment is drawn until it 4303 reaches the point (<y1>, <y1>) on the line, and the procedure is 4304 repeated <n> times until the point (<yn>, <yn>) is reached. 4305 4306Options 4307 4308Each option is a list of two or more items. The first item is the name 4309of the option, and the remainder comprises the arguments for the option. 4310 4311The options accepted by the functions 'evolution', 'evolution2d', 4312'staircase', 'orbits', 'ifs' and 'chaosgame' are the same as the options 4313for 'plot2d'. In addition to those options, 'orbits' accepts and extra 4314option <pixels> that sets up the maximum number of different points that 4315will be represented in the vertical direction. 4316 4317Examples 4318 4319Graphical representation and staircase diagram for the sequence: 2, 4320cos(2), cos(cos(2)),... 4321 4322 (%i1) load("dynamics")$ 4323 4324 (%i2) evolution(cos(y), 2, 11); 4325 4326 (%i3) staircase(cos(y), 1, 11, [y, 0, 1.2]); 4327 4328If your system is slow, you'll have to reduce the number of iterations 4329in the following examples. And if the dots appear too small in your 4330monitor, you might want to try a different style, such as 4331'['<style>,'['<points>,0.8']]'. 4332 4333Orbits diagram for the quadratic map, with a parameter <a>. 4334 x(n+1) = a + x(n)^2 4335 4336 (%i4) orbits(x^2+a, 0, 50, 200, [a, -2, 0.25], [style, dots]); 4337 4338To enlarge the region around the lower bifurcation near x '=' -1.25 use: 4339 (%i5) orbits(x^2+a, 0, 100, 400, [a,-1,-1.53], [x,-1.6,-0.8], 4340 [nticks, 400], [style,dots]); 4341 4342Evolution of a two-dimensional system that leads to a fractal: 4343 4344 (%i6) f: 0.6*x*(1+2*x)+0.8*y*(x-1)-y^2-0.9$ 4345 4346 (%i7) g: 0.1*x*(1-6*x+4*y)+0.1*y*(1+9*y)-0.4$ 4347 4348 (%i8) evolution2d([f,g], [x,y], [-0.5,0], 50000, [style,dots]); 4349 4350And an enlargement of a small region in that fractal: 4351 4352 (%i9) evolution2d([f,g], [x,y], [-0.5,0], 300000, [x,-0.8,-0.6], 4353 [y,-0.4,-0.2], [style, dots]); 4354 4355A plot of Sierpinsky's triangle, obtained with the chaos game: 4356 4357 (%i9) chaosgame([[0, 0], [1, 0], [0.5, sqrt(3)/2]], [0.1, 0.1], 1/2, 4358 30000, [style, dots]); 4359 4360Barnsley's fern, obtained with an Iterated Function System: 4361 4362 (%i10) a1: matrix([0.85,0.04],[-0.04,0.85])$ 4363 4364 (%i11) a2: matrix([0.2,-0.26],[0.23,0.22])$ 4365 4366 (%i12) a3: matrix([-0.15,0.28],[0.26,0.24])$ 4367 4368 (%i13) a4: matrix([0,0],[0,0.16])$ 4369 4370 (%i14) p1: [0,1.6]$ 4371 4372 (%i15) p2: [0,1.6]$ 4373 4374 (%i16) p3: [0,0.44]$ 4375 4376 (%i17) p4: [0,0]$ 4377 4378 (%i18) w: [85,92,99,100]$ 4379 4380 (%i19) ifs(w, [a1,a2,a3,a4], [p1,p2,p3,p4], [5,0], 50000, [style,dots]); 4381 4382To solve numerically the differential equation 4383 4384 dx/dt = t - x^2 4385 4386With initial value x(t=0) = 1, in the interval of t from 0 to 8 and with 4387increments of 0.1 for t, use: 4388 4389 (%i20) results: rk(t-x^2,x,1,[t,0,8,0.1])$ 4390 4391the results will be saved in the list 'results'. 4392 4393To solve numerically the system: 4394 4395 dx/dt = 4-x^2-4*y^2 dy/dt = y^2-x^2+1 4396 4397for t between 0 and 4, and with values of -1.25 and 0.75 for x and y at 4398t=0: 4399 4400 (%i21) sol: rk([4-x^2-4*y^2,y^2-x^2+1],[x,y],[-1.25,0.75],[t,0,4,0.02])$ 4401 4402 4403File: maxima.info, Node: ezunits, Next: f90, Prev: dynamics, Up: Top 4404 440545 ezunits 4406********** 4407 4408* Menu: 4409 4410* Introduction to ezunits:: 4411* Introduction to physical_constants:: 4412* Functions and Variables for ezunits:: 4413 4414 4415File: maxima.info, Node: Introduction to ezunits, Next: Introduction to physical_constants, Prev: ezunits, Up: ezunits 4416 441745.1 Introduction to ezunits 4418============================ 4419 4420'ezunits' is a package for working with dimensional quantities, 4421including some functions for dimensional analysis. 'ezunits' can carry 4422out arithmetic operations on dimensional quantities and unit 4423conversions. The built-in units include Systeme Internationale (SI) and 4424US customary units, and other units can be declared. See also 4425'physical_constants', a collection of physical constants. 4426 4427'load(ezunits)' loads this package. 'demo(ezunits)' displays several 4428examples. The convenience function 'known_units' returns a list of the 4429built-in and user-declared units, while 'display_known_unit_conversions' 4430displays the set of known conversions in an easy-to-read format. 4431 4432An expression a ` b represents a dimensional quantity, with 'a' 4433indicating a nondimensional quantity and 'b' indicating the dimensional 4434units. A symbol can be used as a unit without declaring it as such; 4435unit symbols need not have any special properties. The quantity and 4436unit of an expression a ` b can be extracted by the 'qty' and 'units' 4437functions, respectively. 4438 4439A symbol may be declared to be a dimensional quantity, with specified 4440quantity or specified units or both. 4441 4442An expression a ` b `` c converts from unit 'b' to unit 'c'. 'ezunits' 4443has built-in conversions for SI base units, SI derived units, and some 4444non-SI units. Unit conversions not already known to 'ezunits' can be 4445declared. The unit conversions known to 'ezunits' are specified by the 4446global variable 'known_unit_conversions', which comprises built-in and 4447user-defined conversions. Conversions for products, quotients, and 4448powers of units are derived from the set of known unit conversions. 4449 4450As Maxima generally prefers exact numbers (integers or rationals) to 4451inexact (float or bigfloat), so 'ezunits' preserves exact numbers when 4452they appear in dimensional quantities. All built-in unit conversions 4453are expressed in terms of exact numbers; inexact numbers in declared 4454conversions are coerced to exact. 4455 4456There is no preferred system for display of units; input units are not 4457converted to other units unless conversion is explicitly indicated. 4458'ezunits' recognizes the prefixes m-, k-, M, and G- (for milli-, kilo-, 4459mega-, and giga-) as applied to SI base units and SI derived units, but 4460such prefixes are applied only when indicated by an explicit conversion. 4461 4462Arithmetic operations on dimensional quantities are carried out by 4463conventional rules for such operations. 4464 4465 * (x ` a) * (y ` b) is equal to (x * y) ` (a * b). 4466 * (x ` a) + (y ` a) is equal to (x + y) ` a. 4467 * (x ` a)^y is equal to x^y ` a^y when 'y' is nondimensional. 4468 4469'ezunits' does not require that units in a sum have the same dimensions; 4470such terms are not added together, and no error is reported. 4471 4472'ezunits' includes functions for elementary dimensional analysis, namely 4473the fundamental dimensions and fundamental units of a dimensional 4474quantity, and computation of dimensionless quantities and natural units. 4475The functions for dimensional analysis were adapted from similar 4476functions in another package, written by Barton Willis. 4477 4478For the purpose of dimensional analysis, a list of fundamental 4479dimensions and an associated list of fundamental units are maintained; 4480by default the fundamental dimensions are length, mass, time, charge, 4481temperature, and quantity, and the fundamental units are the associated 4482SI units, but other fundamental dimensions and units can be declared. 4483 4484 4485File: maxima.info, Node: Introduction to physical_constants, Next: Functions and Variables for ezunits, Prev: Introduction to ezunits, Up: ezunits 4486 448745.2 Introduction to physical_constants 4488======================================= 4489 4490'physical_constants' is a collection of physical constants, copied from 4491CODATA 2006 recommended values. [1] 'load(physical_constants)' loads 4492this package, and loads 'ezunits' also, if it is not already loaded. 4493 4494A physical constant is represented as a symbol which has a property 4495which is the constant value. The constant value is a dimensional 4496quantity, as represented by 'ezunits'. The function 'constvalue' 4497fetches the constant value; the constant value is not the ordinary value 4498of the symbol, so symbols of physical constants persist in evaluated 4499expressions until their values are fetched by 'constvalue'. 4500 4501'physical_constants' includes some auxilliary information, namely, a 4502description string for each constant, an estimate of the error of its 4503numerical value, and a property for TeX display. To identify physical 4504constants, each symbol has the 'physical_constant' property; 4505'propvars(physical_constant)' therefore shows the list of all such 4506symbols. 4507 4508'physical_constants' comprises the following constants. 4509 4510'%c' 4511 speed of light in vacuum 4512'%mu_0' 4513 magnetic constant 4514'%e_0' 4515 electric constant 4516'%Z_0' 4517 characteristic impedance of vacuum 4518'%G' 4519 Newtonian constant of gravitation 4520'%h' 4521 Planck constant 4522'%h_bar' 4523 Planck constant 4524'%m_P' 4525 Planck mass 4526'%T_P' 4527 Planck temperature 4528'%l_P' 4529 Planck length 4530'%t_P' 4531 Planck time 4532'%%e' 4533 elementary charge 4534'%Phi_0' 4535 magnetic flux quantum 4536'%G_0' 4537 conductance quantum 4538'%K_J' 4539 Josephson constant 4540'%R_K' 4541 von Klitzing constant 4542'%mu_B' 4543 Bohr magneton 4544'%mu_N' 4545 nuclear magneton 4546'%alpha' 4547 fine-structure constant 4548'%R_inf' 4549 Rydberg constant 4550'%a_0' 4551 Bohr radius 4552'%E_h' 4553 Hartree energy 4554'%ratio_h_me' 4555 quantum of circulation 4556'%m_e' 4557 electron mass 4558'%N_A' 4559 Avogadro constant 4560'%m_u' 4561 atomic mass constant 4562'%F' 4563 Faraday constant 4564'%R' 4565 molar gas constant 4566'%%k' 4567 Boltzmann constant 4568'%V_m' 4569 molar volume of ideal gas 4570'%n_0' 4571 Loschmidt constant 4572'%ratio_S0_R' 4573 Sackur-Tetrode constant (absolute entropy constant) 4574'%sigma' 4575 Stefan-Boltzmann constant 4576'%c_1' 4577 first radiation constant 4578'%c_1L' 4579 first radiation constant for spectral radiance 4580'%c_2' 4581 second radiation constant 4582'%b' 4583 Wien displacement law constant 4584'%b_prime' 4585 Wien displacement law constant 4586 4587References: 4588 4589[1] <http://physics.nist.gov/constants> 4590 4591Examples: 4592 4593The list of all symbols which have the 'physical_constant' property. 4594 4595 (%i1) load (physical_constants)$ 4596 (%i2) propvars (physical_constant); 4597 (%o2) [%c, %mu_0, %e_0, %Z_0, %G, %h, %h_bar, %m_P, %T_P, %l_P, 4598 %t_P, %%e, %Phi_0, %G_0, %K_J, %R_K, %mu_B, %mu_N, %alpha, 4599 %R_inf, %a_0, %E_h, %ratio_h_me, %m_e, %N_A, %m_u, %F, %R, %%k, 4600 %V_m, %n_0, %ratio_S0_R, %sigma, %c_1, %c_1L, %c_2, %b, %b_prime] 4601 4602Properties of the physical constant '%c'. 4603 4604 (%i1) load (physical_constants)$ 4605 (%i2) constantp (%c); 4606 (%o2) true 4607 (%i3) get (%c, description); 4608 (%o3) speed of light in vacuum 4609 (%i4) constvalue (%c); 4610 m 4611 (%o4) 299792458 ` - 4612 s 4613 (%i5) get (%c, RSU); 4614 (%o5) 0 4615 (%i6) tex (%c); 4616 $$c$$ 4617 (%o6) false 4618 4619The energy equivalent of 1 pound-mass. The symbol '%c' persists until 4620its value is fetched by 'constvalue'. 4621 4622 (%i1) load (physical_constants)$ 4623 (%i2) m * %c^2; 4624 2 4625 (%o2) %c m 4626 (%i3) %, m = 1 ` lbm; 4627 2 4628 (%o3) %c ` lbm 4629 (%i4) constvalue (%); 4630 2 4631 lbm m 4632 (%o4) 89875517873681764 ` ------ 4633 2 4634 s 4635 (%i5) E : % `` J; 4636 Computing conversions to base units; may take a moment. 4637 366838848464007200 4638 (%o5) ------------------ ` J 4639 9 4640 (%i6) E `` GJ; 4641 458548560580009 4642 (%o6) --------------- ` GJ 4643 11250000 4644 (%i7) float (%); 4645 (%o7) 4.0759872051556356e+7 ` GJ 4646 4647 4648File: maxima.info, Node: Functions and Variables for ezunits, Prev: Introduction to physical_constants, Up: ezunits 4649 465045.3 Functions and Variables for ezunits 4651======================================== 4652 4653 -- Operator: ` 4654 4655 The dimensional quantity operator. An expression a ` b represents 4656 a dimensional quantity, with 'a' indicating a nondimensional 4657 quantity and 'b' indicating the dimensional units. A symbol can be 4658 used as a unit without declaring it as such; unit symbols need not 4659 have any special properties. The quantity and unit of an 4660 expression a ` b can be extracted by the 'qty' and 'units' 4661 functions, respectively. 4662 4663 Arithmetic operations on dimensional quantities are carried out by 4664 conventional rules for such operations. 4665 4666 * (x ` a) * (y ` b) is equal to (x * y) ` (a * b). 4667 * (x ` a) + (y ` a) is equal to (x + y) ` a. 4668 * (x ` a)^y is equal to x^y ` a^y when 'y' is nondimensional. 4669 4670 'ezunits' does not require that units in a sum have the same 4671 dimensions; such terms are not added together, and no error is 4672 reported. 4673 4674 'load(ezunits)' enables this operator. 4675 4676 Examples: 4677 4678 SI (Systeme Internationale) units. 4679 4680 (%i1) load (ezunits)$ 4681 (%i2) foo : 10 ` m; 4682 (%o2) 10 ` m 4683 (%i3) qty (foo); 4684 (%o3) 10 4685 (%i4) units (foo); 4686 (%o4) m 4687 (%i5) dimensions (foo); 4688 (%o5) length 4689 4690 "Customary" units. 4691 4692 (%i1) load (ezunits)$ 4693 (%i2) bar : x ` acre; 4694 (%o2) x ` acre 4695 (%i3) dimensions (bar); 4696 2 4697 (%o3) length 4698 (%i4) fundamental_units (bar); 4699 2 4700 (%o4) m 4701 4702 Units ad hoc. 4703 4704 (%i1) load (ezunits)$ 4705 (%i2) baz : 3 ` sheep + 8 ` goat + 1 ` horse; 4706 (%o2) 8 ` goat + 3 ` sheep + 1 ` horse 4707 (%i3) subst ([sheep = 3*goat, horse = 10*goat], baz); 4708 (%o3) 27 ` goat 4709 (%i4) baz2 : 1000`gallon/fortnight; 4710 gallon 4711 (%o4) 1000 ` --------- 4712 fortnight 4713 (%i5) subst (fortnight = 14*day, baz2); 4714 500 gallon 4715 (%o5) --- ` ------ 4716 7 day 4717 4718 Arithmetic operations on dimensional quantities. 4719 4720 (%i1) load (ezunits)$ 4721 (%i2) 100 ` kg + 200 ` kg; 4722 (%o2) 300 ` kg 4723 (%i3) 100 ` m^3 - 100 ` m^3; 4724 3 4725 (%o3) 0 ` m 4726 (%i4) (10 ` kg) * (17 ` m/s^2); 4727 kg m 4728 (%o4) 170 ` ---- 4729 2 4730 s 4731 (%i5) (x ` m) / (y ` s); 4732 x m 4733 (%o5) - ` - 4734 y s 4735 (%i6) (a ` m)^2; 4736 2 2 4737 (%o6) a ` m 4738 4739 -- Operator: `` 4740 4741 The unit conversion operator. An expression a ` b `` c converts 4742 from unit 'b' to unit 'c'. 'ezunits' has built-in conversions for 4743 SI base units, SI derived units, and some non-SI units. Unit 4744 conversions not already known to 'ezunits' can be declared. The 4745 unit conversions known to 'ezunits' are specified by the global 4746 variable 'known_unit_conversions', which comprises built-in and 4747 user-defined conversions. Conversions for products, quotients, and 4748 powers of units are derived from the set of known unit conversions. 4749 4750 There is no preferred system for display of units; input units are 4751 not converted to other units unless conversion is explicitly 4752 indicated. 'ezunits' does not attempt to simplify units by 4753 prefixes (milli-, centi-, deci-, etc) unless such conversion is 4754 explicitly indicated. 4755 4756 'load(ezunits)' enables this operator. 4757 4758 Examples: 4759 4760 The set of known unit conversions. 4761 4762 (%i1) load (ezunits)$ 4763 (%i2) display2d : false$ 4764 (%i3) known_unit_conversions; 4765 (%o3) {acre = 4840*yard^2,Btu = 1055*J,cfm = feet^3/minute, 4766 cm = m/100,day = 86400*s,feet = 381*m/1250,ft = feet, 4767 g = kg/1000,gallon = 757*l/200,GHz = 1000000000*Hz, 4768 GOhm = 1000000000*Ohm,GPa = 1000000000*Pa, 4769 GWb = 1000000000*Wb,Gg = 1000000*kg,Gm = 1000000000*m, 4770 Gmol = 1000000*mol,Gs = 1000000000*s,ha = hectare, 4771 hectare = 100*m^2,hour = 3600*s,Hz = 1/s,inch = feet/12, 4772 km = 1000*m,kmol = 1000*mol,ks = 1000*s,l = liter, 4773 lbf = pound_force,lbm = pound_mass,liter = m^3/1000, 4774 metric_ton = Mg,mg = kg/1000000,MHz = 1000000*Hz, 4775 microgram = kg/1000000000,micrometer = m/1000000, 4776 micron = micrometer,microsecond = s/1000000, 4777 mile = 5280*feet,minute = 60*s,mm = m/1000, 4778 mmol = mol/1000,month = 2629800*s,MOhm = 1000000*Ohm, 4779 MPa = 1000000*Pa,ms = s/1000,MWb = 1000000*Wb, 4780 Mg = 1000*kg,Mm = 1000000*m,Mmol = 1000000000*mol, 4781 Ms = 1000000*s,ns = s/1000000000,ounce = pound_mass/16, 4782 oz = ounce,Ohm = s*J/C^2, 4783 pound_force = 32*ft*pound_mass/s^2, 4784 pound_mass = 200*kg/441,psi = pound_force/inch^2, 4785 Pa = N/m^2,week = 604800*s,Wb = J/A,yard = 3*feet, 4786 year = 31557600*s,C = s*A,F = C^2/J,GA = 1000000000*A, 4787 GC = 1000000000*C,GF = 1000000000*F,GH = 1000000000*H, 4788 GJ = 1000000000*J,GK = 1000000000*K,GN = 1000000000*N, 4789 GS = 1000000000*S,GT = 1000000000*T,GV = 1000000000*V, 4790 GW = 1000000000*W,H = J/A^2,J = m*N,kA = 1000*A, 4791 kC = 1000*C,kF = 1000*F,kH = 1000*H,kHz = 1000*Hz, 4792 kJ = 1000*J,kK = 1000*K,kN = 1000*N,kOhm = 1000*Ohm, 4793 kPa = 1000*Pa,kS = 1000*S,kT = 1000*T,kV = 1000*V, 4794 kW = 1000*W,kWb = 1000*Wb,mA = A/1000,mC = C/1000, 4795 mF = F/1000,mH = H/1000,mHz = Hz/1000,mJ = J/1000, 4796 mK = K/1000,mN = N/1000,mOhm = Ohm/1000,mPa = Pa/1000, 4797 mS = S/1000,mT = T/1000,mV = V/1000,mW = W/1000, 4798 mWb = Wb/1000,MA = 1000000*A,MC = 1000000*C, 4799 MF = 1000000*F,MH = 1000000*H,MJ = 1000000*J, 4800 MK = 1000000*K,MN = 1000000*N,MS = 1000000*S, 4801 MT = 1000000*T,MV = 1000000*V,MW = 1000000*W, 4802 N = kg*m/s^2,R = 5*K/9,S = 1/Ohm,T = J/(m^2*A),V = J/C, 4803 W = J/s} 4804 4805 Elementary unit conversions. 4806 4807 (%i1) load (ezunits)$ 4808 (%i2) 1 ` ft `` m; 4809 Computing conversions to base units; may take a moment. 4810 381 4811 (%o2) ---- ` m 4812 1250 4813 (%i3) %, numer; 4814 (%o3) 0.3048 ` m 4815 (%i4) 1 ` kg `` lbm; 4816 441 4817 (%o4) --- ` lbm 4818 200 4819 (%i5) %, numer; 4820 (%o5) 2.205 ` lbm 4821 (%i6) 1 ` W `` Btu/hour; 4822 720 Btu 4823 (%o6) --- ` ---- 4824 211 hour 4825 (%i7) %, numer; 4826 Btu 4827 (%o7) 3.412322274881517 ` ---- 4828 hour 4829 (%i8) 100 ` degC `` degF; 4830 (%o8) 212 ` degF 4831 (%i9) -40 ` degF `` degC; 4832 (%o9) (- 40) ` degC 4833 (%i10) 1 ` acre*ft `` m^3; 4834 60228605349 3 4835 (%o10) ----------- ` m 4836 48828125 4837 (%i11) %, numer; 4838 3 4839 (%o11) 1233.48183754752 ` m 4840 4841 Coercing quantities in feet and meters to one or the other. 4842 4843 (%i1) load (ezunits)$ 4844 (%i2) 100 ` m + 100 ` ft; 4845 (%o2) 100 ` m + 100 ` ft 4846 (%i3) (100 ` m + 100 ` ft) `` ft; 4847 Computing conversions to base units; may take a moment. 4848 163100 4849 (%o3) ------ ` ft 4850 381 4851 (%i4) %, numer; 4852 (%o4) 428.0839895013123 ` ft 4853 (%i5) (100 ` m + 100 ` ft) `` m; 4854 3262 4855 (%o5) ---- ` m 4856 25 4857 (%i6) %, numer; 4858 (%o6) 130.48 ` m 4859 4860 Dimensional analysis to find fundamental dimensions and fundamental 4861 units. 4862 4863 (%i1) load (ezunits)$ 4864 (%i2) foo : 1 ` acre * ft; 4865 (%o2) 1 ` acre ft 4866 (%i3) dimensions (foo); 4867 3 4868 (%o3) length 4869 (%i4) fundamental_units (foo); 4870 3 4871 (%o4) m 4872 (%i5) foo `` m^3; 4873 Computing conversions to base units; may take a moment. 4874 60228605349 3 4875 (%o5) ----------- ` m 4876 48828125 4877 (%i6) %, numer; 4878 3 4879 (%o6) 1233.48183754752 ` m 4880 4881 Declared unit conversions. 4882 4883 (%i1) load (ezunits)$ 4884 (%i2) declare_unit_conversion (MMBtu = 10^6*Btu, kW = 1000*W); 4885 (%o2) done 4886 (%i3) declare_unit_conversion (kWh = kW*hour, 4887 MWh = 1000*kWh, bell = 1800*s); 4888 (%o3) done 4889 (%i4) 1 ` kW*s `` MWh; 4890 Computing conversions to base units; may take a moment. 4891 1 4892 (%o4) ------- ` MWh 4893 3600000 4894 (%i5) 1 ` kW/m^2 `` MMBtu/bell/ft^2; 4895 1306449 MMBtu 4896 (%o5) ---------- ` -------- 4897 8242187500 2 4898 bell ft 4899 4900 -- Function: constvalue (<x>) 4901 -- Function: declare_constvalue (<a>, <x>) 4902 4903 Returns the declared constant value of a symbol, or value of an 4904 expression with declared constant values substituted for symbols. 4905 4906 Constant values are declared by 'declare_constvalue'. Note that 4907 constant values as recognized by 'constvalue' are separate from 4908 values declared by 'numerval' and recognized by 'constantp'. 4909 4910 The 'physical_units' package declares constant values for a number 4911 of physical constants. 4912 4913 'load(ezunits)' loads these functions. 4914 4915 Examples: 4916 4917 Constant value of a physical constant. 4918 4919 (%i1) load (physical_constants)$ 4920 (%i2) constvalue (%G); 4921 3 4922 m 4923 (%o2) 6.67428 ` ----- 4924 2 4925 kg s 4926 (%i3) get ('%G, 'description); 4927 (%o3) Newtonian constant of gravitation 4928 4929 Declaring a new constant. 4930 4931 (%i1) load (ezunits)$ 4932 (%i2) declare_constvalue (FOO, 100 ` lbm / acre); 4933 lbm 4934 (%o2) 100 ` ---- 4935 acre 4936 (%i3) FOO * (50 ` acre); 4937 (%o3) 50 FOO ` acre 4938 (%i4) constvalue (%); 4939 (%o4) 5000 ` lbm 4940 4941 -- Function: units (<x>) 4942 -- Function: declare_units (<a>, <u>) 4943 4944 Returns the units of a dimensional quantity <x>, or returns 1 if 4945 <x> is nondimensional. 4946 4947 <x> may be a literal dimensional expression a ` b, a symbol with 4948 declared units via 'declare_units', or an expression containing 4949 either or both of those. 4950 4951 'declare_units' declares that 'units(<a>)' should return <u>, where 4952 <u> is an expression. 4953 4954 'load(ezunits)' loads these functions. 4955 4956 Examples: 4957 4958 'units' applied to literal dimensional expressions. 4959 4960 (%i1) load (ezunits)$ 4961 (%i2) foo : 100 ` kg; 4962 (%o2) 100 ` kg 4963 (%i3) bar : x ` m/s; 4964 m 4965 (%o3) x ` - 4966 s 4967 (%i4) units (foo); 4968 (%o4) kg 4969 (%i5) units (bar); 4970 m 4971 (%o5) - 4972 s 4973 (%i6) units (foo * bar); 4974 kg m 4975 (%o6) ---- 4976 s 4977 (%i7) units (foo / bar); 4978 kg s 4979 (%o7) ---- 4980 m 4981 (%i8) units (foo^2); 4982 2 4983 (%o8) kg 4984 4985 'units' applied to symbols with declared units. 4986 4987 (%i1) load (ezunits)$ 4988 (%i2) units (aa); 4989 (%o2) 1 4990 (%i3) declare_units (aa, J); 4991 (%o3) J 4992 (%i4) units (aa); 4993 (%o4) J 4994 (%i5) units (aa^2); 4995 2 4996 (%o5) J 4997 (%i6) foo : 100 ` kg; 4998 (%o6) 100 ` kg 4999 (%i7) units (aa * foo); 5000 (%o7) kg J 5001 5002 -- Function: qty (<x>) 5003 -- Function: declare_qty (<a>, <x>) 5004 5005 'qty' returns the nondimensional part of a dimensional quantity 5006 <x>, or returns <x> if <x> is nondimensional. <x> may be a literal 5007 dimensional expression a ` b, a symbol with declared quantity, or 5008 an expression containing either or both of those. 5009 5010 'declare_qty' declares that 'qty(<a>)' should return <x>, where <x> 5011 is a nondimensional quantity. 5012 5013 'load(ezunits)' loads these functions. 5014 5015 Examples: 5016 5017 'qty' applied to literal dimensional expressions. 5018 5019 (%i1) load (ezunits)$ 5020 (%i2) foo : 100 ` kg; 5021 (%o2) 100 ` kg 5022 (%i3) qty (foo); 5023 (%o3) 100 5024 (%i4) bar : v ` m/s; 5025 m 5026 (%o4) v ` - 5027 s 5028 (%i5) foo * bar; 5029 kg m 5030 (%o5) 100 v ` ---- 5031 s 5032 (%i6) qty (foo * bar); 5033 (%o6) 100 v 5034 5035 'qty' applied to symbols with declared quantity. 5036 5037 (%i1) load (ezunits)$ 5038 (%i2) declare_qty (aa, xx); 5039 (%o2) xx 5040 (%i3) qty (aa); 5041 (%o3) xx 5042 (%i4) qty (aa^2); 5043 2 5044 (%o4) xx 5045 (%i5) foo : 100 ` kg; 5046 (%o5) 100 ` kg 5047 (%i6) qty (aa * foo); 5048 (%o6) 100 xx 5049 5050 -- Function: unitp (<x>) 5051 5052 Returns 'true' if <x> is a literal dimensional expression, a symbol 5053 declared dimensional, or an expression in which the main operator 5054 is declared dimensional. 'unitp' returns 'false' otherwise. 5055 5056 'load(ezunits)' loads this function. 5057 5058 Examples: 5059 5060 'unitp' applied to a literal dimensional expression. 5061 5062 (%i1) load (ezunits)$ 5063 (%i2) unitp (100 ` kg); 5064 (%o2) true 5065 5066 'unitp' applied to a symbol declared dimensional. 5067 5068 (%i1) load (ezunits)$ 5069 (%i2) unitp (foo); 5070 (%o2) false 5071 (%i3) declare (foo, dimensional); 5072 (%o3) done 5073 (%i4) unitp (foo); 5074 (%o4) true 5075 5076 'unitp' applied to an expression in which the main operator is 5077 declared dimensional. 5078 5079 (%i1) load (ezunits)$ 5080 (%i2) unitp (bar (x, y, z)); 5081 (%o2) false 5082 (%i3) declare (bar, dimensional); 5083 (%o3) done 5084 (%i4) unitp (bar (x, y, z)); 5085 (%o4) true 5086 5087 -- Function: declare_unit_conversion (<u> = <v>, ...) 5088 5089 Appends equations <u> = <v>, ... to the list of unit conversions 5090 known to the unit conversion operator ``. <u> and <v> are both 5091 multiplicative terms, in which any variables are units, or both 5092 literal dimensional expressions. 5093 5094 At present, it is necessary to express conversions such that the 5095 left-hand side of each equation is a simple unit (not a 5096 multiplicative expression) or a literal dimensional expression with 5097 the quantity equal to 1 and the unit being a simple unit. This 5098 limitation might be relaxed in future versions. 5099 5100 'known_unit_conversions' is the list of known unit conversions. 5101 5102 'load(ezunits)' loads this function. 5103 5104 Examples: 5105 5106 Unit conversions expressed by equations of multiplicative terms. 5107 5108 (%i1) load (ezunits)$ 5109 (%i2) declare_unit_conversion (nautical_mile = 1852 * m, 5110 fortnight = 14 * day); 5111 (%o2) done 5112 (%i3) 100 ` nautical_mile / fortnight `` m/s; 5113 Computing conversions to base units; may take a moment. 5114 463 m 5115 (%o3) ---- ` - 5116 3024 s 5117 5118 Unit conversions expressed by equations of literal dimensional 5119 expressions. 5120 5121 (%i1) load (ezunits)$ 5122 (%i2) declare_unit_conversion (1 ` fluid_ounce = 2 ` tablespoon); 5123 (%o2) done 5124 (%i3) declare_unit_conversion (1 ` tablespoon = 3 ` teaspoon); 5125 (%o3) done 5126 (%i4) 15 ` fluid_ounce `` teaspoon; 5127 Computing conversions to base units; may take a moment. 5128 (%o4) 90 ` teaspoon 5129 5130 -- Function: declare_dimensions (<a_1>, <d_1>, ..., <a_n>, <d_n>) 5131 -- Function: remove_dimensions (<a_1>, ..., <a_n>) 5132 5133 'declare_dimensions' declares <a_1>, ..., <a_n> to have dimensions 5134 <d_1>, ..., <d_n>, respectively. 5135 5136 Each <a_k> is a symbol or a list of symbols. If it is a list, then 5137 every symbol in <a_k> is declared to have dimension <d_k>. 5138 5139 'remove_dimensions' reverts the effect of 'declare_dimensions'. 5140 5141 'load(ezunits)' loads these functions. 5142 5143 Examples: 5144 5145 (%i1) load (ezunits) $ 5146 (%i2) declare_dimensions ([x, y, z], length, [t, u], time); 5147 (%o2) done 5148 (%i3) dimensions (y^2/u); 5149 2 5150 length 5151 (%o3) ------- 5152 time 5153 (%i4) fundamental_units (y^2/u); 5154 0 errors, 0 warnings 5155 2 5156 m 5157 (%o4) -- 5158 s 5159 5160 -- Function: declare_fundamental_dimensions (<d_1>, <d_2>, <d_3>, ...) 5161 -- Function: remove_fundamental_dimensions (<d_1>, <d_2>, <d_3>, ...) 5162 -- Global variable: fundamental_dimensions 5163 5164 'declare_fundamental_dimensions' declares fundamental dimensions. 5165 Symbols <d_1>, <d_2>, <d_3>, ... are appended to the list of 5166 fundamental dimensions, if they are not already on the list. 5167 5168 'remove_fundamental_dimensions' reverts the effect of 5169 'declare_fundamental_dimensions'. 5170 5171 'fundamental_dimensions' is the list of fundamental dimensions. By 5172 default, the list comprises several physical dimensions. 5173 5174 'load(ezunits)' loads these functions. 5175 5176 Examples: 5177 5178 (%i1) load (ezunits) $ 5179 (%i2) fundamental_dimensions; 5180 (%o2) [length, mass, time, current, temperature, quantity] 5181 (%i3) declare_fundamental_dimensions (money, cattle, happiness); 5182 (%o3) done 5183 (%i4) fundamental_dimensions; 5184 (%o4) [length, mass, time, current, temperature, quantity, 5185 money, cattle, happiness] 5186 (%i5) remove_fundamental_dimensions (cattle, happiness); 5187 (%o5) done 5188 (%i6) fundamental_dimensions; 5189 (%o6) [length, mass, time, current, temperature, quantity, money] 5190 5191 -- Function: declare_fundamental_units (<u_1>, <d_1>, ..., <u_n>, 5192 <d_n>) 5193 -- Function: remove_fundamental_units (<u_1>, ..., <u_n>) 5194 5195 'declare_fundamental_units' declares <u_1>, ..., <u_n> to have 5196 dimensions <d_1>, ..., <d_n>, respectively. All arguments must be 5197 symbols. 5198 5199 After calling 'declare_fundamental_units', 'dimensions(<u_k>)' 5200 returns <d_k> for each argument <u_1>, ..., <u_n>, and 5201 'fundamental_units(<d_k>)' returns <u_k> for each argument <d_1>, 5202 ..., <d_n>. 5203 5204 'remove_fundamental_units' reverts the effect of 5205 'declare_fundamental_units'. 5206 5207 'load(ezunits)' loads these functions. 5208 5209 Examples: 5210 5211 (%i1) load (ezunits) $ 5212 (%i2) declare_fundamental_dimensions (money, cattle, happiness); 5213 (%o2) done 5214 (%i3) declare_fundamental_units (dollar, money, goat, 5215 cattle, smile, happiness); 5216 (%o3) [dollar, goat, smile] 5217 (%i4) dimensions (100 ` dollar/goat/km^2); 5218 money 5219 (%o4) -------------- 5220 2 5221 cattle length 5222 (%i5) dimensions (x ` smile/kg); 5223 happiness 5224 (%o5) --------- 5225 mass 5226 (%i6) fundamental_units (money*cattle/happiness); 5227 0 errors, 0 warnings 5228 dollar goat 5229 (%o6) ----------- 5230 smile 5231 5232 -- Function: dimensions (<x>) 5233 -- Function: dimensions_as_list (<x>) 5234 5235 'dimensions' returns the dimensions of the dimensional quantity <x> 5236 as an expression comprising products and powers of base dimensions. 5237 5238 'dimensions_as_list' returns the dimensions of the dimensional 5239 quantity <x> as a list, in which each element is an integer which 5240 indicates the power of the corresponding base dimension in the 5241 dimensions of <x>. 5242 5243 'load(ezunits)' loads these functions. 5244 5245 Examples: 5246 5247 (%i1) load (ezunits)$ 5248 (%i2) dimensions (1000 ` kg*m^2/s^3); 5249 2 5250 length mass 5251 (%o2) ------------ 5252 3 5253 time 5254 (%i3) declare_units (foo, acre*ft/hour); 5255 acre ft 5256 (%o3) ------- 5257 hour 5258 (%i4) dimensions (foo); 5259 3 5260 length 5261 (%o4) ------- 5262 time 5263 5264 (%i1) load (ezunits)$ 5265 (%i2) fundamental_dimensions; 5266 (%o2) [length, mass, time, charge, temperature, quantity] 5267 (%i3) dimensions_as_list (1000 ` kg*m^2/s^3); 5268 (%o3) [2, 1, - 3, 0, 0, 0] 5269 (%i4) declare_units (foo, acre*ft/hour); 5270 acre ft 5271 (%o4) ------- 5272 hour 5273 (%i5) dimensions_as_list (foo); 5274 (%o5) [3, 0, - 1, 0, 0, 0] 5275 5276 -- Function: fundamental_units (<x>) 5277 -- Function: fundamental_units () 5278 5279 'fundamental_units(<x>)' returns the units associated with the 5280 fundamental dimensions of <x>. as determined by 'dimensions(<x>)'. 5281 5282 <x> may be a literal dimensional expression a ` b, a symbol with 5283 declared units via 'declare_units', or an expression containing 5284 either or both of those. 5285 5286 'fundamental_units()' returns the list of all known fundamental 5287 units, as declared by 'declare_fundamental_units'. 5288 5289 'load(ezunits)' loads this function. 5290 5291 Examples: 5292 5293 (%i1) load (ezunits)$ 5294 (%i2) fundamental_units (); 5295 (%o2) [m, kg, s, A, K, mol] 5296 (%i3) fundamental_units (100 ` mile/hour); 5297 m 5298 (%o3) - 5299 s 5300 (%i4) declare_units (aa, g/foot^2); 5301 g 5302 (%o4) ----- 5303 2 5304 foot 5305 (%i5) fundamental_units (aa); 5306 kg 5307 (%o5) -- 5308 2 5309 m 5310 5311 -- Function: dimensionless (<L>) 5312 5313 Returns a basis for the dimensionless quantities which can be 5314 formed from a list <L> of dimensional quantities. 5315 5316 'load(ezunits)' loads this function. 5317 5318 Examples: 5319 5320 (%i1) load (ezunits) $ 5321 (%i2) dimensionless ([x ` m, y ` m/s, z ` s]); 5322 0 errors, 0 warnings 5323 0 errors, 0 warnings 5324 y z 5325 (%o2) [---] 5326 x 5327 5328 Dimensionless quantities derived from fundamental physical 5329 quantities. Note that the first element on the list is 5330 proportional to the fine-structure constant. 5331 5332 (%i1) load (ezunits) $ 5333 (%i2) load (physical_constants) $ 5334 (%i3) dimensionless([%h_bar, %m_e, %m_P, %%e, %c, %e_0]); 5335 0 errors, 0 warnings 5336 0 errors, 0 warnings 5337 2 5338 %%e %m_e 5339 (%o3) [--------------, ----] 5340 %c %e_0 %h_bar %m_P 5341 5342 -- Function: natural_unit (<expr>, [<v_1>, ..., <v_n>]) 5343 5344 Finds exponents <e_1>, ..., <e_n> such that 'dimension(<expr>) = 5345 dimension(<v_1>^<e_1> ... <v_n>^<e_n>)'. 5346 5347 'load(ezunits)' loads this function. 5348 5349 Examples: 5350 5351 5352 5353File: maxima.info, Node: f90, Next: finance, Prev: ezunits, Up: Top 5354 535546 f90 5356****** 5357 5358* Menu: 5359 5360* Functions and Variables for f90:: 5361 5362 5363File: maxima.info, Node: Functions and Variables for f90, Prev: f90, Up: f90 5364 536546.1 Functions and Variables for f90 5366==================================== 5367 5368 -- Function: f90 (<expr_1>, ..., <expr_n>) 5369 5370 Prints one or more expressions <expr_1>, ..., <expr_n> as a Fortran 5371 90 program. Output is printed to the standard output. 5372 5373 'f90' prints output in the so-called "free form" input format for 5374 Fortran 90: there is no special attention to column positions. 5375 Long lines are split at a fixed width with the ampersand '&' 5376 continuation character. 5377 5378 'load(f90)' loads this function. See also the function 'fortran'. 5379 5380 Examples: 5381 5382 (%i1) load (f90)$ 5383 (%i2) foo : expand ((xxx + yyy + 7)^4); 5384 4 3 3 2 2 2 5385 (%o2) yyy + 4 xxx yyy + 28 yyy + 6 xxx yyy + 84 xxx yyy 5386 2 3 2 5387 + 294 yyy + 4 xxx yyy + 84 xxx yyy + 588 xxx yyy + 1372 yyy 5388 4 3 2 5389 + xxx + 28 xxx + 294 xxx + 1372 xxx + 2401 5390 (%i3) f90 ('foo = foo); 5391 foo = yyy**4+4*xxx*yyy**3+28*yyy**3+6*xxx**2*yyy**2+84*xxx*yyy**2& 5392 +294*yyy**2+4*xxx**3*yyy+84*xxx**2*yyy+588*xxx*yyy+1372*yyy+xxx**& 5393 4+28*xxx**3+294*xxx**2+1372*xxx+2401 5394 (%o3) false 5395 5396 Multiple expressions. Capture standard output into a file via the 5397 'with_stdout' function. 5398 5399 (%i1) load (f90)$ 5400 (%i2) foo : sin (3*x + 1) - cos (7*x - 2); 5401 (%o2) sin(3 x + 1) - cos(7 x - 2) 5402 (%i3) with_stdout ("foo.f90", 5403 f90 (x=0.25, y=0.625, 'foo=foo, 'stop, 'end)); 5404 (%o3) false 5405 (%i4) printfile ("foo.f90"); 5406 x = 0.25 5407 y = 0.625 5408 foo = sin(3*x+1)-cos(7*x-2) 5409 stop 5410 end 5411 (%o4) foo.f90 5412 5413 5414File: maxima.info, Node: finance, Next: fractals, Prev: f90, Up: Top 5415 541647 finance 5417********** 5418 5419* Menu: 5420 5421* Introduction to finance:: 5422* Functions and Variables for finance:: 5423 5424 5425File: maxima.info, Node: Introduction to finance, Next: Functions and Variables for finance, Prev: finance, Up: finance 5426 542747.1 Introduction to finance 5428============================ 5429 5430This is the Finance Package (Ver 0.1). 5431 5432In all the functions, <rate> is the compound interest rate, <num> is the 5433number of periods and must be postivive and <flow> refers to cash flow 5434so if you have an Output the flow is negative and positive for Inputs. 5435 5436Note that before using the functions defined in this package, you have 5437to load it writing 'load(finance)$'. 5438 5439Author: Nicolas Guarin Zapata. 5440 5441 5442File: maxima.info, Node: Functions and Variables for finance, Prev: Introduction to finance, Up: finance 5443 544447.2 Functions and Variables for finance 5445======================================== 5446 5447 -- Function: days360 (<year1>, <month1>, <day1>, <year2>, <month2>, 5448 <day2>) 5449 5450 Calculates the distance between 2 dates, assuming 360 days years, 5451 30 days months. 5452 5453 Example: 5454 5455 (%i1) load(finance)$ 5456 (%i2) days360(2008,12,16,2007,3,25); 5457 (%o2) - 621 5458 5459 -- Function: fv (<rate>, <PV>, <num>) 5460 5461 We can calculate the future value of a Present one given a certain 5462 interest rate. <rate> is the interest rate, <PV> is the present 5463 value and <num> is the number of periods. 5464 5465 Example: 5466 5467 (%i1) load(finance)$ 5468 (%i2) fv(0.12,1000,3); 5469 (%o2) 1404.928 5470 5471 -- Function: pv (<rate>, <FV>, <num>) 5472 5473 We can calculate the present value of a Future one given a certain 5474 interest rate. <rate> is the interest rate, <FV> is the future 5475 value and <num> is the number of periods. 5476 5477 Example: 5478 5479 (%i1) load(finance)$ 5480 (%i2) pv(0.12,1000,3); 5481 (%o2) 711.7802478134108 5482 5483 -- Function: graph_flow (<val>) 5484 5485 Plots the money flow in a time line, the positive values are in 5486 blue and upside; the negative ones are in red and downside. The 5487 direction of the flow is given by the sign of the value. <val> is 5488 a list of flow values. 5489 5490 Example: 5491 5492 (%i1) load(finance)$ 5493 (%i2) graph_flow([-5000,-3000,800,1300,1500,2000])$ 5494 5495 -- Function: annuity_pv (<rate>, <PV>, <num>) 5496 5497 We can calculate the annuity knowing the present value (like an 5498 ammount), it is a constant and periodic payment. <rate> is the 5499 interest rate, <PV> is the present value and <num> is the number of 5500 periods. 5501 5502 Example: 5503 5504 (%i1) load(finance)$ 5505 (%i2) annuity_pv(0.12,5000,10); 5506 (%o2) 884.9208207992202 5507 5508 -- Function: annuity_fv (<rate>, <FV>, <num>) 5509 5510 We can calculate the annuity knowing the desired value (future 5511 value), it is a constant and periodic payment. <rate> is the 5512 interest rate, <FV> is the future value and <num> is the number of 5513 periods. 5514 5515 Example: 5516 5517 (%i1) load(finance)$ 5518 (%i2) annuity_fv(0.12,65000,10); 5519 (%o2) 3703.970670389863 5520 5521 -- Function: geo_annuity_pv (<rate>, <growing_rate>, <PV>, <num>) 5522 5523 We can calculate the annuity knowing the present value (like an 5524 ammount), in a growing periodic payment. <rate> is the interest 5525 rate, <growing_rate> is the growing rate, <PV> is the present value 5526 and <num> is the number of periods. 5527 5528 Example: 5529 5530 (%i1) load(finance)$ 5531 (%i2) geo_annuity_pv(0.14,0.05,5000,10); 5532 (%o2) 802.6888176505123 5533 5534 -- Function: geo_annuity_fv (<rate>, <growing_rate>, <FV>,<num>) 5535 5536 We can calculate the annuity knowing the desired value (future 5537 value), in a growing periodic payment. <rate> is the interest 5538 rate, <growing_rate> is the growing rate, <FV> is the future value 5539 and <num> is the number of periods. 5540 5541 Example: 5542 5543 (%i1) load(finance)$ 5544 (%i2) geo_annuity_fv(0.14,0.05,5000,10); 5545 (%o2) 216.5203395312695 5546 5547 -- Function: amortization (<rate>, <ammount>, <num>) 5548 5549 Amortization table determinated by a specific rate. <rate> is the 5550 interest rate, <ammount> is the ammount value, and <num> is the 5551 number of periods. 5552 5553 Example: 5554 5555 (%i1) load(finance)$ 5556 (%i2) amortization(0.05,56000,12)$ 5557 "n" "Balance" "Interest" "Amortization" "Payment" 5558 0.000 56000.000 0.000 0.000 0.000 5559 1.000 52481.777 2800.000 3518.223 6318.223 5560 2.000 48787.643 2624.089 3694.134 6318.223 5561 3.000 44908.802 2439.382 3878.841 6318.223 5562 4.000 40836.019 2245.440 4072.783 6318.223 5563 5.000 36559.597 2041.801 4276.422 6318.223 5564 6.000 32069.354 1827.980 4490.243 6318.223 5565 7.000 27354.599 1603.468 4714.755 6318.223 5566 8.000 22404.106 1367.730 4950.493 6318.223 5567 9.000 17206.088 1120.205 5198.018 6318.223 5568 10.000 11748.170 860.304 5457.919 6318.223 5569 11.000 6017.355 587.408 5730.814 6318.223 5570 12.000 0.000 300.868 6017.355 6318.223 5571 5572 -- Function: arit_amortization (<rate>, <increment>, <ammount>, <num>) 5573 5574 The amortization table determinated by a specific rate and with 5575 growing payment can be claculated by 'arit_amortization'. Notice 5576 that the payment is not constant, it presents an arithmetic 5577 growing, increment is then the difference between two consecutive 5578 rows in the "Payment" column. <rate> is the interest rate, 5579 <increment> is the increment, <ammount> is the ammount value, and 5580 <num> is the number of periods. 5581 5582 Example: 5583 5584 (%i1) load(finance)$ 5585 (%i2) arit_amortization(0.05,1000,56000,12)$ 5586 "n" "Balance" "Interest" "Amortization" "Payment" 5587 0.000 56000.000 0.000 0.000 0.000 5588 1.000 57403.679 2800.000 -1403.679 1396.321 5589 2.000 57877.541 2870.184 -473.863 2396.321 5590 3.000 57375.097 2893.877 502.444 3396.321 5591 4.000 55847.530 2868.755 1527.567 4396.321 5592 5.000 53243.586 2792.377 2603.945 5396.321 5593 6.000 49509.443 2662.179 3734.142 6396.321 5594 7.000 44588.594 2475.472 4920.849 7396.321 5595 8.000 38421.703 2229.430 6166.892 8396.321 5596 9.000 30946.466 1921.085 7475.236 9396.321 5597 10.000 22097.468 1547.323 8848.998 10396.321 5598 11.000 11806.020 1104.873 10291.448 11396.321 5599 12.000 -0.000 590.301 11806.020 12396.321 5600 5601 -- Function: geo_amortization (<rate>, <growing_rate>, <ammount>, 5602 <num>) 5603 5604 The amortization table determinated by rate, ammount, and number of 5605 periods can be found by 'geo_amortization'. Notice that the 5606 payment is not constant, it presents a geometric growing, 5607 <growing_rate> is then the quotient between two consecutive rows in 5608 the "Payment" column. <rate> is the interest rate, <ammount> is 5609 the ammount value, and <num> is the number of periods. 5610 5611 Example: 5612 5613 (%i1) load(finance)$ 5614 (%i2) geo_amortization(0.05,0.03,56000,12)$ 5615 "n" "Balance" "Interest" "Amortization" "Payment" 5616 0.000 56000.000 0.000 0.000 0.000 5617 1.000 53365.296 2800.000 2634.704 5434.704 5618 2.000 50435.816 2668.265 2929.480 5597.745 5619 3.000 47191.930 2521.791 3243.886 5765.677 5620 4.000 43612.879 2359.596 3579.051 5938.648 5621 5.000 39676.716 2180.644 3936.163 6116.807 5622 6.000 35360.240 1983.836 4316.475 6300.311 5623 7.000 30638.932 1768.012 4721.309 6489.321 5624 8.000 25486.878 1531.947 5152.054 6684.000 5625 9.000 19876.702 1274.344 5610.176 6884.520 5626 10.000 13779.481 993.835 6097.221 7091.056 5627 11.000 7164.668 688.974 6614.813 7303.787 5628 12.000 0.000 358.233 7164.668 7522.901 5629 5630 -- Function: saving (<rate>, <ammount>, <num>) 5631 5632 The table that represents the values in a constant and periodic 5633 saving can be found by 'saving'. <ammount> represents the desired 5634 quantity and num the number of periods to save. 5635 5636 Example: 5637 5638 (%i1) load(finance)$ 5639 (%i2) saving(0.15,12000,15)$ 5640 "n" "Balance" "Interest" "Payment" 5641 0.000 0.000 0.000 0.000 5642 1.000 252.205 0.000 252.205 5643 2.000 542.240 37.831 252.205 5644 3.000 875.781 81.336 252.205 5645 4.000 1259.352 131.367 252.205 5646 5.000 1700.460 188.903 252.205 5647 6.000 2207.733 255.069 252.205 5648 7.000 2791.098 331.160 252.205 5649 8.000 3461.967 418.665 252.205 5650 9.000 4233.467 519.295 252.205 5651 10.000 5120.692 635.020 252.205 5652 11.000 6141.000 768.104 252.205 5653 12.000 7314.355 921.150 252.205 5654 13.000 8663.713 1097.153 252.205 5655 14.000 10215.474 1299.557 252.205 5656 15.000 12000.000 1532.321 252.205 5657 5658 -- Function: npv (<rate>, <val>) 5659 5660 Calculates de present value of a value series to evaluate the 5661 viability in a project. <flowValues> es una lista con los valores 5662 para cada periodo. 5663 5664 Example: 5665 5666 (%i1) load(finance)$ 5667 (%i2) npv(0.25,[100,500,323,124,300]); 5668 (%o2) 714.4703999999999 5669 5670 -- Function: irr (<val>, <IO>) 5671 5672 IRR (Internal Rate of Return) is the value of rate which makes Net 5673 Present Value zero. <flowValues> los valores para cada periodo 5674 (para periodos mayores a 0) y <I0> el valor para el periodo cero. 5675 5676 Example: 5677 5678 (%i1) load(finance)$ 5679 (%i2) res:irr([-5000,0,800,1300,1500,2000],0)$ 5680 (%i3) rhs(res[1][1]); 5681 (%o3) .03009250374237132 5682 5683 -- Function: benefit_cost (<rate>, <input>, <output>) 5684 5685 Calculates the ratio Benefit/Cost. Benefit is the Net Present 5686 Value (NPV) of the inputs, and Cost is the Net Present Value (NPV) 5687 of the outputs. Notice that if there is not an input or output 5688 value in a specific period, the input/output would be a zero for 5689 that period. <rate> is the interest rate, <input> is a list of 5690 input values, and <output> is a list of output values. 5691 5692 Example: 5693 5694 (%i1) load(finance)$ 5695 (%i2) benefit_cost(0.24,[0,300,500,150],[100,320,0,180]); 5696 (%o2) 1.427249324905784 5697 5698 5699File: maxima.info, Node: fractals, Next: ggf, Prev: finance, Up: Top 5700 570148 fractals 5702*********** 5703 5704* Menu: 5705 5706* Introduction to fractals:: 5707* Definitions for IFS fractals:: 5708* Definitions for complex fractals:: 5709* Definitions for Koch snowflakes:: 5710* Definitions for Peano maps:: 5711 5712 5713File: maxima.info, Node: Introduction to fractals, Next: Definitions for IFS fractals, Prev: fractals, Up: fractals 5714 571548.1 Introduction to fractals 5716============================= 5717 5718This package defines some well known fractals: 5719 5720 * with random IFS (Iterated Function System): the Sierpinsky 5721 triangle, a Tree and a Fern 5722 * Complex Fractals: the Mandelbrot and Julia Sets 5723 * the Koch snowflake sets 5724 * Peano maps: the Sierpinski and Hilbert maps 5725 5726Author: José Ramírez Labrador. 5727 5728For questions, suggestions and bugs, please feel free to contact me at 5729pepe DOT ramirez AAATTT uca DOT es 5730 5731 5732File: maxima.info, Node: Definitions for IFS fractals, Next: Definitions for complex fractals, Prev: Introduction to fractals, Up: fractals 5733 573448.2 Definitions for IFS fractals 5735================================= 5736 5737Some fractals can be generated by iterative applications of contractive 5738affine transformations in a random way; see Hoggar S. G., "Mathematics 5739for computer graphics", Cambridge University Press 1994. 5740 5741We define a list with several contractive affine transformations, and we 5742randomly select the transformation in a recursive way. The probability 5743of the choice of a transformation must be related with the contraction 5744ratio. 5745 5746You can change the transformations and find another fractal 5747 5748 -- Function: sierpinskiale (<n>) 5749 5750 Sierpinski Triangle: 3 contractive maps; .5 contraction constant 5751 and translations; all maps have the same contraction ratio. 5752 Argument <n> must be great enougth, 10000 or greater. 5753 5754 Example: 5755 5756 (%i1) load(fractals)$ 5757 (%i2) n: 10000$ 5758 (%i3) plot2d([discrete,sierpinskiale(n)], [style,dots])$ 5759 5760 -- Function: treefale (<n>) 5761 5762 3 contractive maps all with the same contraction ratio. Argument 5763 <n> must be great enougth, 10000 or greater. 5764 5765 Example: 5766 5767 (%i1) load(fractals)$ 5768 (%i2) n: 10000$ 5769 (%i3) plot2d([discrete,treefale(n)], [style,dots])$ 5770 5771 -- Function: fernfale (<n>) 5772 5773 4 contractive maps, the probability to choice a transformation must 5774 be related with the contraction ratio. Argument <n> must be great 5775 enougth, 10000 or greater. 5776 5777 Example: 5778 5779 (%i1) load(fractals)$ 5780 (%i2) n: 10000$ 5781 (%i3) plot2d([discrete,fernfale(n)], [style,dots])$ 5782 5783 5784File: maxima.info, Node: Definitions for complex fractals, Next: Definitions for Koch snowflakes, Prev: Definitions for IFS fractals, Up: Top 5785 578648.3 Definitions for complex fractals 5787===================================== 5788 5789 -- Function: mandelbrot_set (<x>, <y>) 5790 5791 Mandelbrot set. 5792 5793 Example: 5794 5795 This program is time consuming because it must make a lot of 5796 operations; the computing time is also related with the number of 5797 grid points. 5798 5799 (%i1) load(fractals)$ 5800 (%i2) plot3d (mandelbrot_set, [x, -2.5, 1], [y, -1.5, 1.5], 5801 [gnuplot_preamble, "set view map"], 5802 [gnuplot_pm3d, true], 5803 [grid, 150, 150])$ 5804 5805 -- Function: julia_set (<x>, <y>) 5806 5807 Julia sets. 5808 5809 This program is time consuming because it must make a lot of 5810 operations; the computing time is also related with the number of 5811 grid points. 5812 5813 Example: 5814 5815 (%i1) load(fractals)$ 5816 (%i2) plot3d (julia_set, [x, -2, 1], [y, -1.5, 1.5], 5817 [gnuplot_preamble, "set view map"], 5818 [gnuplot_pm3d, true], 5819 [grid, 150, 150])$ 5820 5821 See also 'julia_parameter'. 5822 5823 -- Option variable: julia_parameter 5824 Default value: '%i' 5825 5826 Complex parameter for Julia fractals. Its default value is '%i'; 5827 we suggest the values '-.745+%i*.113002', '-.39054-%i*.58679', 5828 '-.15652+%i*1.03225', '-.194+%i*.6557' and '.011031-%i*.67037'. 5829 5830 -- Function: julia_sin (<x>, <y>) 5831 5832 While function 'julia_set' implements the transformation 5833 'julia_parameter+z^2', function 'julia_sin' implements 5834 'julia_parameter*sin(z)'. See source code for more details. 5835 5836 This program runs slowly because it calculates a lot of sines. 5837 5838 Example: 5839 5840 This program is time consuming because it must make a lot of 5841 operations; the computing time is also related with the number of 5842 grid points. 5843 5844 (%i1) load(fractals)$ 5845 (%i2) julia_parameter:1+.1*%i$ 5846 (%i3) plot3d (julia_sin, [x, -2, 2], [y, -3, 3], 5847 [gnuplot_preamble, "set view map"], 5848 [gnuplot_pm3d, true], 5849 [grid, 150, 150])$ 5850 5851 See also 'julia_parameter'. 5852 5853 5854File: maxima.info, Node: Definitions for Koch snowflakes, Next: Definitions for Peano maps, Prev: Definitions for complex fractals, Up: Top 5855 585648.4 Definitions for Koch snowflakes 5857==================================== 5858 5859 -- Function: snowmap (<ent>, <nn>) 5860 5861 Koch snowflake sets. Function 'snowmap' plots the snow Koch map 5862 over the vertex of an initial closed polygonal, in the complex 5863 plane. Here the orientation of the polygon is important. Argument 5864 <nn> is the number of recursive applications of Koch 5865 transformation; <nn> must be small (5 or 6). 5866 5867 Examples: 5868 5869 (%i1) load(fractals)$ 5870 (%i2) plot2d([discrete, 5871 snowmap([1,exp(%i*%pi*2/3),exp(-%i*%pi*2/3),1],4)])$ 5872 (%i3) plot2d([discrete, 5873 snowmap([1,exp(-%i*%pi*2/3),exp(%i*%pi*2/3),1],4)])$ 5874 (%i4) plot2d([discrete, snowmap([0,1,1+%i,%i,0],4)])$ 5875 (%i5) plot2d([discrete, snowmap([0,%i,1+%i,1,0],4)])$ 5876 5877 5878File: maxima.info, Node: Definitions for Peano maps, Prev: Definitions for Koch snowflakes, Up: fractals 5879 588048.5 Definitions for Peano maps 5881=============================== 5882 5883Continuous curves that cover an area. Warning: the number of points 5884exponentially grows with <n>. 5885 5886 -- Function: hilbertmap (<nn>) 5887 5888 Hilbert map. 5889 5890 Argument <nn> must be small (5, for example). Maxima can crash if 5891 <nn> is 7 or greater. 5892 5893 Example: 5894 5895 (%i1) load(fractals)$ 5896 (%i2) plot2d([discrete,hilbertmap(6)])$ 5897 5898 -- Function: sierpinskimap (<nn>) 5899 5900 Sierpinski map. 5901 5902 Argument <nn> must be small (5, for example). Maxima can crash if 5903 <nn> is 7 or greater. 5904 5905 Example: 5906 5907 (%i1) load(fractals)$ 5908 (%i2) plot2d([discrete,sierpinskimap(6)])$ 5909 5910 5911File: maxima.info, Node: ggf, Next: graphs, Prev: fractals, Up: Top 5912 591349 ggf 5914****** 5915 5916* Menu: 5917 5918* Functions and Variables for ggf:: 5919 5920 5921File: maxima.info, Node: Functions and Variables for ggf, Prev: ggf, Up: ggf 5922 592349.1 Functions and Variables for ggf 5924==================================== 5925 5926 -- Option variable: GGFINFINITY 5927 Default value: 3 5928 5929 This is an option variable for function 'ggf'. 5930 5931 When computing the continued fraction of the generating function, a 5932 partial quotient having a degree (strictly) greater than 5933 <GGFINFINITY> will be discarded and the current convergent will be 5934 considered as the exact value of the generating function; most 5935 often the degree of all partial quotients will be 0 or 1; if you 5936 use a greater value, then you should give enough terms in order to 5937 make the computation accurate enough. 5938 5939 See also 'ggf'. 5940 5941 -- Option variable: GGFCFMAX 5942 Default value: 3 5943 5944 This is an option variable for function 'ggf'. 5945 5946 When computing the continued fraction of the generating function, 5947 if no good result has been found (see the <GGFINFINITY> flag) after 5948 having computed <GGFCFMAX> partial quotients, the generating 5949 function will be considered as not being a fraction of two 5950 polynomials and the function will exit. Put freely a greater value 5951 for more complicated generating functions. 5952 5953 See also 'ggf'. 5954 5955 -- Function: ggf (<l>) 5956 5957 Compute the generating function (if it is a fraction of two 5958 polynomials) of a sequence, its first terms being given. <l> is a 5959 list of numbers. 5960 5961 The solution is returned as a fraction of two polynomials. If no 5962 solution has been found, it returns with 'done'. 5963 5964 This function is controlled by global variables <GGFINFINITY> and 5965 <GGFCFMAX>. See also <GGFINFINITY> and <GGFCFMAX>. 5966 5967 To use this function write first 'load("ggf")'. 5968 5969 5970File: maxima.info, Node: graphs, Next: grobner, Prev: ggf, Up: Top 5971 597250 graphs 5973********* 5974 5975* Menu: 5976 5977* Introduction to graphs:: 5978* Functions and Variables for graphs:: 5979 5980 5981File: maxima.info, Node: Introduction to graphs, Next: Functions and Variables for graphs, Prev: graphs, Up: graphs 5982 598350.1 Introduction to graphs 5984=========================== 5985 5986The 'graphs' package provides graph and digraph data structure for 5987Maxima. Graphs and digraphs are simple (have no multiple edges nor 5988loops), although digraphs can have a directed edge from <u> to <v> and a 5989directed edge from <v> to <u>. 5990 5991Internally graphs are represented by adjacency lists and implemented as 5992a lisp structures. Vertices are identified by their ids (an id is an 5993integer). Edges/arcs are represented by lists of length 2. Labels can 5994be assigned to vertices of graphs/digraphs and weights can be assigned 5995to edges/arcs of graphs/digraphs. 5996 5997There is a 'draw_graph' function for drawing graphs. Graphs are drawn 5998using a force based vertex positioning algorithm. 'draw_graph' can also 5999use graphviz programs available from <http://www.graphviz.org>. 6000'draw_graph' is based on the maxima 'draw' package. 6001 6002To use the 'graphs' package, first load it with 'load(graphs)'. 6003 6004 6005File: maxima.info, Node: Functions and Variables for graphs, Prev: Introduction to graphs, Up: graphs 6006 600750.2 Functions and Variables for graphs 6008======================================= 6009 601050.2.1 Building graphs 6011---------------------- 6012 6013 -- Function: create_graph (<v_list>, <e_list>) 6014 -- Function: create_graph (<n>, <e_list>) 6015 -- Function: create_graph (<v_list>, <e_list>, <directed>) 6016 Creates a new graph on the set of vertices <v_list> and with edges 6017 <e_list>. 6018 6019 <v_list> is a list of vertices ('[v1, v2,..., vn]') or a list of 6020 vertices together with vertex labels ('[[v1,l1], [v2,l2],..., 6021 [vn,ln]]'). 6022 6023 <n> is the number of vertices. Vertices will be identified by 6024 integers from 0 to n-1. 6025 6026 <e_list> is a list of edges ('[e1, e2,..., em]') or a list of edges 6027 together with edge-weights ('[[e1, w1], ..., [em, wm]]'). 6028 6029 If <directed> is not 'false', a directed graph will be returned. 6030 6031 Example 1: create a cycle on 3 vertices: 6032 (%i1) load (graphs)$ 6033 (%i2) g : create_graph([1,2,3], [[1,2], [2,3], [1,3]])$ 6034 (%i3) print_graph(g)$ 6035 Graph on 3 vertices with 3 edges. 6036 Adjacencies: 6037 3 : 1 2 6038 2 : 3 1 6039 1 : 3 2 6040 6041 Example 2: create a cycle on 3 vertices with edge weights: 6042 (%i1) load (graphs)$ 6043 (%i2) g : create_graph([1,2,3], [[[1,2], 1.0], [[2,3], 2.0], 6044 [[1,3], 3.0]])$ 6045 (%i3) print_graph(g)$ 6046 Graph on 3 vertices with 3 edges. 6047 Adjacencies: 6048 3 : 1 2 6049 2 : 3 1 6050 1 : 3 2 6051 6052 Example 3: create a directed graph: 6053 (%i1) load (graphs)$ 6054 (%i2) d : create_graph( 6055 [1,2,3,4], 6056 [ 6057 [1,3], [1,4], 6058 [2,3], [2,4] 6059 ], 6060 'directed = true)$ 6061 (%i3) print_graph(d)$ 6062 Digraph on 4 vertices with 4 arcs. 6063 Adjacencies: 6064 4 : 6065 3 : 6066 2 : 4 3 6067 1 : 4 3 6068 6069 -- Function: copy_graph (<g>) 6070 Returns a copy of the graph <g>. 6071 6072 -- Function: circulant_graph (<n>, <d>) 6073 Returns the circulant graph with parameters <n> and <d>. 6074 6075 Example: 6076 (%i1) load (graphs)$ 6077 (%i2) g : circulant_graph(10, [1,3])$ 6078 (%i3) print_graph(g)$ 6079 Graph on 10 vertices with 20 edges. 6080 Adjacencies: 6081 9 : 2 6 0 8 6082 8 : 1 5 9 7 6083 7 : 0 4 8 6 6084 6 : 9 3 7 5 6085 5 : 8 2 6 4 6086 4 : 7 1 5 3 6087 3 : 6 0 4 2 6088 2 : 9 5 3 1 6089 1 : 8 4 2 0 6090 0 : 7 3 9 1 6091 6092 -- Function: clebsch_graph () 6093 Returns the Clebsch graph. 6094 6095 -- Function: complement_graph (<g>) 6096 Returns the complement of the graph <g>. 6097 6098 -- Function: complete_bipartite_graph (<n>, <m>) 6099 Returns the complete bipartite graph on <n+m> vertices. 6100 6101 -- Function: complete_graph (<n>) 6102 Returns the complete graph on <n> vertices. 6103 6104 -- Function: cycle_digraph (<n>) 6105 Returns the directed cycle on <n> vertices. 6106 6107 -- Function: cycle_graph (<n>) 6108 Returns the cycle on <n> vertices. 6109 6110 -- Function: cuboctahedron_graph (<n>) 6111 Returns the cuboctahedron graph. 6112 6113 -- Function: cube_graph (<n>) 6114 Returns the <n>-dimensional cube. 6115 6116 -- Function: dodecahedron_graph () 6117 Returns the dodecahedron graph. 6118 6119 -- Function: empty_graph (<n>) 6120 Returns the empty graph on <n> vertices. 6121 6122 -- Function: flower_snark (<n>) 6123 Returns the flower graph on <4n> vertices. 6124 6125 Example: 6126 (%i1) load (graphs)$ 6127 (%i2) f5 : flower_snark(5)$ 6128 (%i3) chromatic_index(f5); 6129 (%o3) 4 6130 6131 -- Function: from_adjacency_matrix (<A>) 6132 Returns the graph represented by its adjacency matrix <A>. 6133 6134 -- Function: frucht_graph () 6135 Returns the Frucht graph. 6136 6137 -- Function: graph_product (<g1>, <g1>) 6138 Returns the direct product of graphs <g1> and <g2>. 6139 6140 Example: 6141 (%i1) load (graphs)$ 6142 (%i2) grid : graph_product(path_graph(3), path_graph(4))$ 6143 (%i3) draw_graph(grid)$ 6144 6145 -- Function: graph_union (<g1>, <g1>) 6146 Returns the union (sum) of graphs <g1> and <g2>. 6147 6148 -- Function: grid_graph (<n>, <m>) 6149 Returns the <n x m> grid. 6150 6151 -- Function: great_rhombicosidodecahedron_graph () 6152 Returns the great rhombicosidodecahedron graph. 6153 6154 -- Function: great_rhombicuboctahedron_graph () 6155 Returns the great rhombicuboctahedron graph. 6156 6157 -- Function: grotzch_graph () 6158 Returns the Grotzch graph. 6159 6160 -- Function: heawood_graph () 6161 Returns the Heawood graph. 6162 6163 -- Function: icosahedron_graph () 6164 Returns the icosahedron graph. 6165 6166 -- Function: icosidodecahedron_graph () 6167 Returns the icosidodecahedron graph. 6168 6169 -- Function: induced_subgraph (<V>, <g>) 6170 Returns the graph induced on the subset <V> of vertices of the 6171 graph <g>. 6172 6173 Example: 6174 (%i1) load (graphs)$ 6175 (%i2) p : petersen_graph()$ 6176 (%i3) V : [0,1,2,3,4]$ 6177 (%i4) g : induced_subgraph(V, p)$ 6178 (%i5) print_graph(g)$ 6179 Graph on 5 vertices with 5 edges. 6180 Adjacencies: 6181 4 : 3 0 6182 3 : 2 4 6183 2 : 1 3 6184 1 : 0 2 6185 0 : 1 4 6186 6187 -- Function: line_graph (<g>) 6188 Returns the line graph of the graph <g>. 6189 6190 -- Function: make_graph (<vrt>, <f>) 6191 -- Function: make_graph (<vrt>, <f>, <oriented>) 6192 Creates a graph using a predicate function <f>. 6193 6194 <vrt> is a list/set of vertices or an integer. If <vrt> is an 6195 integer, then vertices of the graph will be integers from 1 to 6196 <vrt>. 6197 6198 <f> is a predicate function. Two vertices <a> and <b> will be 6199 connected if 'f(a,b)=true'. 6200 6201 If <directed> is not <false>, then the graph will be directed. 6202 6203 Example 1: 6204 (%i1) load(graphs)$ 6205 (%i2) g : make_graph(powerset({1,2,3,4,5}, 2), disjointp)$ 6206 (%i3) is_isomorphic(g, petersen_graph()); 6207 (%o3) true 6208 (%i4) get_vertex_label(1, g); 6209 (%o4) {1, 2} 6210 6211 Example 2: 6212 (%i1) load(graphs)$ 6213 (%i2) f(i, j) := is (mod(j, i)=0)$ 6214 (%i3) g : make_graph(20, f, directed=true)$ 6215 (%i4) out_neighbors(4, g); 6216 (%o4) [8, 12, 16, 20] 6217 (%i5) in_neighbors(18, g); 6218 (%o5) [1, 2, 3, 6, 9] 6219 6220 -- Function: mycielski_graph (<g>) 6221 Returns the mycielskian graph of the graph <g>. 6222 6223 -- Function: new_graph () 6224 Returns the graph with no vertices and no edges. 6225 6226 -- Function: path_digraph (<n>) 6227 Returns the directed path on <n> vertices. 6228 6229 -- Function: path_graph (<n>) 6230 Returns the path on <n> vertices. 6231 6232 -- Function: petersen_graph () 6233 -- Function: petersen_graph (<n>, <d>) 6234 Returns the petersen graph <P_{n,d}>. The default values for <n> 6235 and <d> are 'n=5' and 'd=2'. 6236 6237 -- Function: random_bipartite_graph (<a>, <b>, <p>) 6238 Returns a random bipartite graph on 'a+b' vertices. Each edge is 6239 present with probability <p>. 6240 6241 -- Function: random_digraph (<n>, <p>) 6242 Returns a random directed graph on <n> vertices. Each arc is 6243 present with probability <p>. 6244 6245 -- Function: random_regular_graph (<n>) 6246 -- Function: random_regular_graph (<n>, <d>) 6247 Returns a random <d>-regular graph on <n> vertices. The default 6248 value for <d> is 'd=3'. 6249 6250 -- Function: random_graph (<n>, <p>) 6251 Returns a random graph on <n> vertices. Each edge is present with 6252 probability <p>. 6253 6254 -- Function: random_graph1 (<n>, <m>) 6255 Returns a random graph on <n> vertices and random <m> edges. 6256 6257 -- Function: random_network (<n>, <p>, <w>) 6258 Returns a random network on <n> vertices. Each arc is present with 6259 probability <p> and has a weight in the range '[0,w]'. The 6260 function returns a list '[network, source, sink]'. 6261 6262 Example: 6263 (%i1) load (graphs)$ 6264 (%i2) [net, s, t] : random_network(50, 0.2, 10.0); 6265 (%o2) [DIGRAPH, 50, 51] 6266 (%i3) max_flow(net, s, t)$ 6267 (%i4) first(%); 6268 (%o4) 27.65981397932507 6269 6270 -- Function: random_tournament (<n>) 6271 Returns a random tournament on <n> vertices. 6272 6273 -- Function: random_tree (<n>) 6274 Returns a random tree on <n> vertices. 6275 6276 -- Function: small_rhombicosidodecahedron_graph () 6277 Returns the small rhombicosidodecahedron graph. 6278 6279 -- Function: small_rhombicuboctahedron_graph () 6280 Returns the small rhombicuboctahedron graph. 6281 6282 -- Function: snub_cube_graph () 6283 Returns the snub cube graph. 6284 6285 -- Function: snub_dodecahedron_graph () 6286 Returns the snub dodecahedron graph. 6287 6288 -- Function: truncated_cube_graph () 6289 Returns the truncated cube graph. 6290 6291 -- Function: truncated_dodecahedron_graph () 6292 Returns the truncated dodecahedron graph. 6293 6294 -- Function: truncated_icosahedron_graph () 6295 Returns the truncated icosahedron graph. 6296 6297 -- Function: truncated_tetrahedron_graph () 6298 Returns the truncated tetrahedron graph. 6299 6300 -- Function: tutte_graph () 6301 Returns the Tutte graph. 6302 6303 -- Function: underlying_graph (<g>) 6304 Returns the underlying graph of the directed graph <g>. 6305 6306 -- Function: wheel_graph (<n>) 6307 Returns the wheel graph on <n+1> vertices. 6308 630950.2.2 Graph properties 6310----------------------- 6311 6312 -- Function: adjacency_matrix (<gr>) 6313 Returns the adjacency matrix of the graph <gr>. 6314 6315 Example: 6316 (%i1) load (graphs)$ 6317 (%i2) c5 : cycle_graph(4)$ 6318 (%i3) adjacency_matrix(c5); 6319 [ 0 1 0 1 ] 6320 [ ] 6321 [ 1 0 1 0 ] 6322 (%o3) [ ] 6323 [ 0 1 0 1 ] 6324 [ ] 6325 [ 1 0 1 0 ] 6326 6327 -- Function: average_degree (<gr>) 6328 Returns the average degree of vertices in the graph <gr>. 6329 6330 Example: 6331 (%i1) load (graphs)$ 6332 (%i2) average_degree(grotzch_graph()); 6333 40 6334 (%o2) -- 6335 11 6336 6337 -- Function: biconected_components (<gr>) 6338 Returns the (vertex sets of) 2-connected components of the graph 6339 <gr>. 6340 6341 Example: 6342 (%i1) load (graphs)$ 6343 (%i2) g : create_graph( 6344 [1,2,3,4,5,6,7], 6345 [ 6346 [1,2],[2,3],[2,4],[3,4], 6347 [4,5],[5,6],[4,6],[6,7] 6348 ])$ 6349 (%i3) biconnected_components(g); 6350 (%o3) [[6, 7], [4, 5, 6], [1, 2], [2, 3, 4]] 6351 6352 -- Function: bipartition (<gr>) 6353 Returns a bipartition of the vertices of the graph <gr> or an empty 6354 list if <gr> is not bipartite. 6355 6356 Example: 6357 6358 (%i1) load (graphs)$ 6359 (%i2) h : heawood_graph()$ 6360 (%i3) [A,B]:bipartition(h); 6361 (%o3) [[8, 12, 6, 10, 0, 2, 4], [13, 5, 11, 7, 9, 1, 3]] 6362 (%i4) draw_graph(h, show_vertices=A, program=circular)$ 6363 6364 -- Function: chromatic_index (<gr>) 6365 Returns the chromatic index of the graph <gr>. 6366 6367 Example: 6368 (%i1) load (graphs)$ 6369 (%i2) p : petersen_graph()$ 6370 (%i3) chromatic_index(p); 6371 (%o3) 4 6372 6373 -- Function: chromatic_number (<gr>) 6374 Returns the chromatic number of the graph <gr>. 6375 6376 Example: 6377 (%i1) load (graphs)$ 6378 (%i2) chromatic_number(cycle_graph(5)); 6379 (%o2) 3 6380 (%i3) chromatic_number(cycle_graph(6)); 6381 (%o3) 2 6382 6383 -- Function: clear_edge_weight (<e>, <gr>) 6384 Removes the weight of the edge <e> in the graph <gr>. 6385 6386 Example: 6387 6388 (%i1) load (graphs)$ 6389 (%i2) g : create_graph(3, [[[0,1], 1.5], [[1,2], 1.3]])$ 6390 (%i3) get_edge_weight([0,1], g); 6391 (%o3) 1.5 6392 (%i4) clear_edge_weight([0,1], g)$ 6393 (%i5) get_edge_weight([0,1], g); 6394 (%o5) 1 6395 6396 -- Function: clear_vertex_label (<v>, <gr>) 6397 Removes the label of the vertex <v> in the graph <gr>. 6398 6399 Example: 6400 (%i1) load (graphs)$ 6401 (%i2) g : create_graph([[0,"Zero"], [1, "One"]], [[0,1]])$ 6402 (%i3) get_vertex_label(0, g); 6403 (%o3) Zero 6404 (%i4) clear_vertex_label(0, g); 6405 (%o4) done 6406 (%i5) get_vertex_label(0, g); 6407 (%o5) false 6408 6409 -- Function: connected_components (<gr>) 6410 Returns the (vertex sets of) connected components of the graph 6411 <gr>. 6412 6413 Example: 6414 (%i1) load (graphs)$ 6415 (%i2) g: graph_union(cycle_graph(5), path_graph(4))$ 6416 (%i3) connected_components(g); 6417 (%o3) [[1, 2, 3, 4, 0], [8, 7, 6, 5]] 6418 6419 -- Function: diameter (<gr>) 6420 Returns the diameter of the graph <gr>. 6421 6422 Example: 6423 (%i1) load (graphs)$ 6424 (%i2) diameter(dodecahedron_graph()); 6425 (%o2) 5 6426 6427 -- Function: edge_coloring (<gr>) 6428 Returns an optimal coloring of the edges of the graph <gr>. 6429 6430 The function returns the chromatic index and a list representing 6431 the coloring of the edges of <gr>. 6432 6433 Example: 6434 (%i1) load (graphs)$ 6435 (%i2) p : petersen_graph()$ 6436 (%i3) [ch_index, col] : edge_coloring(p); 6437 (%o3) [4, [[[0, 5], 3], [[5, 7], 1], [[0, 1], 1], [[1, 6], 2], 6438 [[6, 8], 1], [[1, 2], 3], [[2, 7], 4], [[7, 9], 2], [[2, 3], 2], 6439 [[3, 8], 3], [[5, 8], 2], [[3, 4], 1], [[4, 9], 4], [[6, 9], 3], 6440 [[0, 4], 2]]] 6441 (%i4) assoc([0,1], col); 6442 (%o4) 1 6443 (%i5) assoc([0,5], col); 6444 (%o5) 3 6445 6446 -- Function: degree_sequence (<gr>) 6447 Returns the list of vertex degrees of the graph <gr>. 6448 6449 Example: 6450 (%i1) load (graphs)$ 6451 (%i2) degree_sequence(random_graph(10, 0.4)); 6452 (%o2) [2, 2, 2, 2, 2, 2, 3, 3, 3, 3] 6453 6454 -- Function: edge_connectivity (<gr>) 6455 Returns the edge-connectivity of the graph <gr>. 6456 6457 See also 'min_edge_cut'. 6458 6459 -- Function: edges (<gr>) 6460 Returns the list of edges (arcs) in a (directed) graph <gr>. 6461 6462 Example: 6463 (%i1) load (graphs)$ 6464 (%i2) edges(complete_graph(4)); 6465 (%o2) [[2, 3], [1, 3], [1, 2], [0, 3], [0, 2], [0, 1]] 6466 6467 -- Function: get_edge_weight (<e>, <gr>) 6468 -- Function: get_edge_weight (<e>, <gr>, <ifnot>) 6469 Returns the weight of the edge <e> in the graph <gr>. 6470 6471 If there is no weight assigned to the edge, the function returns 1. 6472 If the edge is not present in the graph, the function signals an 6473 error or returns the optional argument <ifnot>. 6474 6475 Example: 6476 (%i1) load (graphs)$ 6477 (%i2) c5 : cycle_graph(5)$ 6478 (%i3) get_edge_weight([1,2], c5); 6479 (%o3) 1 6480 (%i4) set_edge_weight([1,2], 2.0, c5); 6481 (%o4) done 6482 (%i5) get_edge_weight([1,2], c5); 6483 (%o5) 2.0 6484 6485 -- Function: get_vertex_label (<v>, <gr>) 6486 Returns the label of the vertex <v> in the graph <gr>. 6487 6488 Example: 6489 (%i1) load (graphs)$ 6490 (%i2) g : create_graph([[0,"Zero"], [1, "One"]], [[0,1]])$ 6491 (%i3) get_vertex_label(0, g); 6492 (%o3) Zero 6493 6494 -- Function: graph_charpoly (<gr>, <x>) 6495 Returns the characteristic polynomial (in variable <x>) of the 6496 graph <gr>. 6497 6498 Example: 6499 (%i1) load (graphs)$ 6500 (%i2) p : petersen_graph()$ 6501 (%i3) graph_charpoly(p, x), factor; 6502 5 4 6503 (%o3) (x - 3) (x - 1) (x + 2) 6504 6505 -- Function: graph_center (<gr>) 6506 Returns the center of the graph <gr>. 6507 6508 Example: 6509 (%i1) load (graphs)$ 6510 (%i2) g : grid_graph(5,5)$ 6511 (%i3) graph_center(g); 6512 (%o3) [12] 6513 6514 -- Function: graph_eigenvalues (<gr>) 6515 Returns the eigenvalues of the graph <gr>. The function returns 6516 eigenvalues in the same format as maxima 'eigenvalue' function. 6517 6518 Example: 6519 (%i1) load (graphs)$ 6520 (%i2) p : petersen_graph()$ 6521 (%i3) graph_eigenvalues(p); 6522 (%o3) [[3, - 2, 1], [1, 4, 5]] 6523 6524 -- Function: graph_periphery (<gr>) 6525 Returns the periphery of the graph <gr>. 6526 6527 Example: 6528 (%i1) load (graphs)$ 6529 (%i2) g : grid_graph(5,5)$ 6530 (%i3) graph_periphery(g); 6531 (%o3) [24, 20, 4, 0] 6532 6533 -- Function: graph_size (<gr>) 6534 Returns the number of edges in the graph <gr>. 6535 6536 Example: 6537 (%i1) load (graphs)$ 6538 (%i2) p : petersen_graph()$ 6539 (%i3) graph_size(p); 6540 (%o3) 15 6541 6542 -- Function: graph_order (<gr>) 6543 Returns the number of vertices in the graph <gr>. 6544 6545 Example: 6546 (%i1) load (graphs)$ 6547 (%i2) p : petersen_graph()$ 6548 (%i3) graph_order(p); 6549 (%o3) 10 6550 6551 -- Function: girth (<gr>) 6552 Returns the length of the shortest cycle in <gr>. 6553 6554 Example: 6555 (%i1) load (graphs)$ 6556 (%i2) g : heawood_graph()$ 6557 (%i3) girth(g); 6558 (%o3) 6 6559 6560 -- Function: hamilton_cycle (<gr>) 6561 Returns the Hamilton cycle of the graph <gr> or an empty list if 6562 <gr> is not hamiltonian. 6563 6564 Example: 6565 (%i1) load (graphs)$ 6566 (%i2) c : cube_graph(3)$ 6567 (%i3) hc : hamilton_cycle(c); 6568 (%o3) [7, 3, 2, 6, 4, 0, 1, 5, 7] 6569 (%i4) draw_graph(c, show_edges=vertices_to_cycle(hc))$ 6570 6571 -- Function: hamilton_path (<gr>) 6572 Returns the Hamilton path of the graph <gr> or an empty list if 6573 <gr> does not have a Hamilton path. 6574 6575 Example: 6576 (%i1) load (graphs)$ 6577 (%i2) p : petersen_graph()$ 6578 (%i3) hp : hamilton_path(p); 6579 (%o3) [0, 5, 7, 2, 1, 6, 8, 3, 4, 9] 6580 (%i4) draw_graph(p, show_edges=vertices_to_path(hp))$ 6581 6582 -- Function: isomorphism (<gr1>, <gr2>) 6583 6584 Returns a an isomorphism between graphs/digraphs <gr1> and <gr2>. 6585 If <gr1> and <gr2> are not isomorphic, it returns an empty list. 6586 6587 Example: 6588 (%i1) load (graphs)$ 6589 (%i2) clk5:complement_graph(line_graph(complete_graph(5)))$ 6590 (%i3) isomorphism(clk5, petersen_graph()); 6591 (%o3) [9 -> 0, 2 -> 1, 6 -> 2, 5 -> 3, 0 -> 4, 1 -> 5, 3 -> 6, 6592 4 -> 7, 7 -> 8, 8 -> 9] 6593 6594 -- Function: in_neighbors (<v>, <gr>) 6595 Returns the list of in-neighbors of the vertex <v> in the directed 6596 graph <gr>. 6597 6598 Example: 6599 (%i1) load (graphs)$ 6600 (%i2) p : path_digraph(3)$ 6601 (%i3) in_neighbors(2, p); 6602 (%o3) [1] 6603 (%i4) out_neighbors(2, p); 6604 (%o4) [] 6605 6606 -- Function: is_biconnected (<gr>) 6607 Returns 'true' if <gr> is 2-connected and 'false' otherwise. 6608 6609 Example: 6610 (%i1) load (graphs)$ 6611 (%i2) is_biconnected(cycle_graph(5)); 6612 (%o2) true 6613 (%i3) is_biconnected(path_graph(5)); 6614 (%o3) false 6615 6616 -- Function: is_bipartite (<gr>) 6617 Returns 'true' if <gr> is bipartite (2-colorable) and 'false' 6618 otherwise. 6619 6620 Example: 6621 (%i1) load (graphs)$ 6622 (%i2) is_bipartite(petersen_graph()); 6623 (%o2) false 6624 (%i3) is_bipartite(heawood_graph()); 6625 (%o3) true 6626 6627 -- Function: is_connected (<gr>) 6628 Returns 'true' if the graph <gr> is connected and 'false' 6629 otherwise. 6630 6631 Example: 6632 (%i1) load (graphs)$ 6633 (%i2) is_connected(graph_union(cycle_graph(4), path_graph(3))); 6634 (%o2) false 6635 6636 -- Function: is_digraph (<gr>) 6637 Returns 'true' if <gr> is a directed graph and 'false' otherwise. 6638 6639 Example: 6640 (%i1) load (graphs)$ 6641 (%i2) is_digraph(path_graph(5)); 6642 (%o2) false 6643 (%i3) is_digraph(path_digraph(5)); 6644 (%o3) true 6645 6646 -- Function: is_edge_in_graph (<e>, <gr>) 6647 Returns 'true' if <e> is an edge (arc) in the (directed) graph <g> 6648 and 'false' otherwise. 6649 6650 Example: 6651 (%i1) load (graphs)$ 6652 (%i2) c4 : cycle_graph(4)$ 6653 (%i3) is_edge_in_graph([2,3], c4); 6654 (%o3) true 6655 (%i4) is_edge_in_graph([3,2], c4); 6656 (%o4) true 6657 (%i5) is_edge_in_graph([2,4], c4); 6658 (%o5) false 6659 (%i6) is_edge_in_graph([3,2], cycle_digraph(4)); 6660 (%o6) false 6661 6662 -- Function: is_graph (<gr>) 6663 Returns 'true' if <gr> is a graph and 'false' otherwise. 6664 6665 Example: 6666 (%i1) load (graphs)$ 6667 (%i2) is_graph(path_graph(5)); 6668 (%o2) true 6669 (%i3) is_graph(path_digraph(5)); 6670 (%o3) false 6671 6672 -- Function: is_graph_or_digraph (<gr>) 6673 Returns 'true' if <gr> is a graph or a directed graph and 'false' 6674 otherwise. 6675 6676 Example: 6677 (%i1) load (graphs)$ 6678 (%i2) is_graph_or_digraph(path_graph(5)); 6679 (%o2) true 6680 (%i3) is_graph_or_digraph(path_digraph(5)); 6681 (%o3) true 6682 6683 -- Function: is_isomorphic (<gr1>, <gr2>) 6684 6685 Returns 'true' if graphs/digraphs <gr1> and <gr2> are isomorphic 6686 and 'false' otherwise. 6687 6688 See also 'isomorphism'. 6689 6690 Example: 6691 (%i1) load (graphs)$ 6692 (%i2) clk5:complement_graph(line_graph(complete_graph(5)))$ 6693 (%i3) is_isomorphic(clk5, petersen_graph()); 6694 (%o3) true 6695 6696 -- Function: is_planar (<gr>) 6697 6698 Returns 'true' if <gr> is a planar graph and 'false' otherwise. 6699 6700 The algorithm used is the Demoucron's algorithm, which is a 6701 quadratic time algorithm. 6702 6703 Example: 6704 (%i1) load (graphs)$ 6705 (%i2) is_planar(dodecahedron_graph()); 6706 (%o2) true 6707 (%i3) is_planar(petersen_graph()); 6708 (%o3) false 6709 (%i4) is_planar(petersen_graph(10,2)); 6710 (%o4) true 6711 6712 -- Function: is_sconnected (<gr>) 6713 Returns 'true' if the directed graph <gr> is strongly connected and 6714 'false' otherwise. 6715 6716 Example: 6717 (%i1) load (graphs)$ 6718 (%i2) is_sconnected(cycle_digraph(5)); 6719 (%o2) true 6720 (%i3) is_sconnected(path_digraph(5)); 6721 (%o3) false 6722 6723 -- Function: is_vertex_in_graph (<v>, <gr>) 6724 Returns 'true' if <v> is a vertex in the graph <g> and 'false' 6725 otherwise. 6726 6727 Example: 6728 (%i1) load (graphs)$ 6729 (%i2) c4 : cycle_graph(4)$ 6730 (%i3) is_vertex_in_graph(0, c4); 6731 (%o3) true 6732 (%i4) is_vertex_in_graph(6, c4); 6733 (%o4) false 6734 6735 -- Function: is_tree (<gr>) 6736 Returns 'true' if <gr> is a tree and 'false' otherwise. 6737 6738 Example: 6739 (%i1) load (graphs)$ 6740 (%i2) is_tree(random_tree(4)); 6741 (%o2) true 6742 (%i3) is_tree(graph_union(random_tree(4), random_tree(5))); 6743 (%o3) false 6744 6745 -- Function: laplacian_matrix (<gr>) 6746 Returns the laplacian matrix of the graph <gr>. 6747 6748 Example: 6749 (%i1) load (graphs)$ 6750 (%i2) laplacian_matrix(cycle_graph(5)); 6751 [ 2 - 1 0 0 - 1 ] 6752 [ ] 6753 [ - 1 2 - 1 0 0 ] 6754 [ ] 6755 (%o2) [ 0 - 1 2 - 1 0 ] 6756 [ ] 6757 [ 0 0 - 1 2 - 1 ] 6758 [ ] 6759 [ - 1 0 0 - 1 2 ] 6760 6761 -- Function: max_clique (<gr>) 6762 Returns a maximum clique of the graph <gr>. 6763 6764 Example: 6765 (%i1) load (graphs)$ 6766 (%i2) g : random_graph(100, 0.5)$ 6767 (%i3) max_clique(g); 6768 (%o3) [6, 12, 31, 36, 52, 59, 62, 63, 80] 6769 6770 -- Function: max_degree (<gr>) 6771 Returns the maximal degree of vertices of the graph <gr> and a 6772 vertex of maximal degree. 6773 6774 Example: 6775 (%i1) load (graphs)$ 6776 (%i2) g : random_graph(100, 0.02)$ 6777 (%i3) max_degree(g); 6778 (%o3) [6, 79] 6779 (%i4) vertex_degree(95, g); 6780 (%o4) 2 6781 6782 -- Function: max_flow (<net>, <s>, <t>) 6783 Returns a maximum flow through the network <net> with the source 6784 <s> and the sink <t>. 6785 6786 The function returns the value of the maximal flow and a list 6787 representing the weights of the arcs in the optimal flow. 6788 6789 Example: 6790 (%i1) load (graphs)$ 6791 (%i2) net : create_graph( 6792 [1,2,3,4,5,6], 6793 [[[1,2], 1.0], 6794 [[1,3], 0.3], 6795 [[2,4], 0.2], 6796 [[2,5], 0.3], 6797 [[3,4], 0.1], 6798 [[3,5], 0.1], 6799 [[4,6], 1.0], 6800 [[5,6], 1.0]], 6801 directed=true)$ 6802 (%i3) [flow_value, flow] : max_flow(net, 1, 6); 6803 (%o3) [0.7, [[[1, 2], 0.5], [[1, 3], 0.2], [[2, 4], 0.2], 6804 [[2, 5], 0.3], [[3, 4], 0.1], [[3, 5], 0.1], [[4, 6], 0.3], 6805 [[5, 6], 0.4]]] 6806 (%i4) fl : 0$ 6807 (%i5) for u in out_neighbors(1, net) 6808 do fl : fl + assoc([1, u], flow)$ 6809 (%i6) fl; 6810 (%o6) 0.7 6811 6812 -- Function: max_independent_set (<gr>) 6813 Returns a maximum independent set of the graph <gr>. 6814 6815 Example: 6816 (%i1) load (graphs)$ 6817 (%i2) d : dodecahedron_graph()$ 6818 (%i3) mi : max_independent_set(d); 6819 (%o3) [0, 3, 5, 9, 10, 11, 18, 19] 6820 (%i4) draw_graph(d, show_vertices=mi)$ 6821 6822 -- Function: max_matching (<gr>) 6823 Returns a maximum matching of the graph <gr>. 6824 6825 Example: 6826 (%i1) load (graphs)$ 6827 (%i2) d : dodecahedron_graph()$ 6828 (%i3) m : max_matching(d); 6829 (%o3) [[5, 7], [8, 9], [6, 10], [14, 19], [13, 18], [12, 17], 6830 [11, 16], [0, 15], [3, 4], [1, 2]] 6831 (%i4) draw_graph(d, show_edges=m)$ 6832 6833 -- Function: min_degree (<gr>) 6834 Returns the minimum degree of vertices of the graph <gr> and a 6835 vertex of minimum degree. 6836 6837 Example: 6838 (%i1) load (graphs)$ 6839 (%i2) g : random_graph(100, 0.1)$ 6840 (%i3) min_degree(g); 6841 (%o3) [3, 49] 6842 (%i4) vertex_degree(21, g); 6843 (%o4) 9 6844 6845 -- Function: min_edge_cut (<gr>) 6846 Returns the minimum edge cut in the graph <gr>. 6847 6848 See also 'edge_connectivity'. 6849 6850 -- Function: min_vertex_cover (<gr>) 6851 Returns the minimum vertex cover of the graph <gr>. 6852 6853 -- Function: min_vertex_cut (<gr>) 6854 Returns the minimum vertex cut in the graph <gr>. 6855 6856 See also 'vertex_connectivity'. 6857 6858 -- Function: minimum_spanning_tree (<gr>) 6859 Returns the minimum spanning tree of the graph <gr>. 6860 6861 Example: 6862 (%i1) load (graphs)$ 6863 (%i2) g : graph_product(path_graph(10), path_graph(10))$ 6864 (%i3) t : minimum_spanning_tree(g)$ 6865 (%i4) draw_graph(g, show_edges=edges(t))$ 6866 6867 -- Function: neighbors (<v>, <gr>) 6868 Returns the list of neighbors of the vertex <v> in the graph <gr>. 6869 6870 Example: 6871 (%i1) load (graphs)$ 6872 (%i2) p : petersen_graph()$ 6873 (%i3) neighbors(3, p); 6874 (%o3) [4, 8, 2] 6875 6876 -- Function: odd_girth (<gr>) 6877 Returns the length of the shortest odd cycle in the graph <gr>. 6878 6879 Example: 6880 (%i1) load (graphs)$ 6881 (%i2) g : graph_product(cycle_graph(4), cycle_graph(7))$ 6882 (%i3) girth(g); 6883 (%o3) 4 6884 (%i4) odd_girth(g); 6885 (%o4) 7 6886 6887 -- Function: out_neighbors (<v>, <gr>) 6888 Returns the list of out-neighbors of the vertex <v> in the directed 6889 graph <gr>. 6890 6891 Example: 6892 (%i1) load (graphs)$ 6893 (%i2) p : path_digraph(3)$ 6894 (%i3) in_neighbors(2, p); 6895 (%o3) [1] 6896 (%i4) out_neighbors(2, p); 6897 (%o4) [] 6898 6899 -- Function: planar_embedding (<gr>) 6900 6901 Returns the list of facial walks in a planar embedding of <gr> and 6902 'false' if <gr> is not a planar graph. 6903 6904 The graph <gr> must be biconnected. 6905 6906 The algorithm used is the Demoucron's algorithm, which is a 6907 quadratic time algorithm. 6908 6909 Example: 6910 (%i1) load (graphs)$ 6911 (%i2) planar_embedding(grid_graph(3,3)); 6912 (%o2) [[3, 6, 7, 8, 5, 2, 1, 0], [4, 3, 0, 1], [3, 4, 7, 6], 6913 [8, 7, 4, 5], [1, 2, 5, 4]] 6914 6915 -- Function: print_graph (<gr>) 6916 Prints some information about the graph <gr>. 6917 6918 Example: 6919 (%i1) load (graphs)$ 6920 (%i2) c5 : cycle_graph(5)$ 6921 (%i3) print_graph(c5)$ 6922 Graph on 5 vertices with 5 edges. 6923 Adjacencies: 6924 4 : 0 3 6925 3 : 4 2 6926 2 : 3 1 6927 1 : 2 0 6928 0 : 4 1 6929 (%i4) dc5 : cycle_digraph(5)$ 6930 (%i5) print_graph(dc5)$ 6931 Digraph on 5 vertices with 5 arcs. 6932 Adjacencies: 6933 4 : 0 6934 3 : 4 6935 2 : 3 6936 1 : 2 6937 0 : 1 6938 (%i6) out_neighbors(0, dc5); 6939 (%o6) [1] 6940 6941 -- Function: radius (<gr>) 6942 Returns the radius of the graph <gr>. 6943 6944 Example: 6945 (%i1) load (graphs)$ 6946 (%i2) radius(dodecahedron_graph()); 6947 (%o2) 5 6948 6949 -- Function: set_edge_weight (<e>, <w>, <gr>) 6950 Assigns the weight <w> to the edge <e> in the graph <gr>. 6951 6952 Example: 6953 (%i1) load (graphs)$ 6954 (%i2) g : create_graph([1, 2], [[[1,2], 1.2]])$ 6955 (%i3) get_edge_weight([1,2], g); 6956 (%o3) 1.2 6957 (%i4) set_edge_weight([1,2], 2.1, g); 6958 (%o4) done 6959 (%i5) get_edge_weight([1,2], g); 6960 (%o5) 2.1 6961 6962 -- Function: set_vertex_label (<v>, <l>, <gr>) 6963 Assigns the label <l> to the vertex <v> in the graph <gr>. 6964 6965 Example: 6966 (%i1) load (graphs)$ 6967 (%i2) g : create_graph([[1, "One"], [2, "Two"]], [[1,2]])$ 6968 (%i3) get_vertex_label(1, g); 6969 (%o3) One 6970 (%i4) set_vertex_label(1, "oNE", g); 6971 (%o4) done 6972 (%i5) get_vertex_label(1, g); 6973 (%o5) oNE 6974 6975 -- Function: shortest_path (<u>, <v>, <gr>) 6976 Returns the shortest path from <u> to <v> in the graph <gr>. 6977 6978 Example: 6979 (%i1) load (graphs)$ 6980 (%i2) d : dodecahedron_graph()$ 6981 (%i3) path : shortest_path(0, 7, d); 6982 (%o3) [0, 1, 19, 13, 7] 6983 (%i4) draw_graph(d, show_edges=vertices_to_path(path))$ 6984 6985 -- Function: shortest_weighted_path (<u>, <v>, <gr>) 6986 Returns the length of the shortest weighted path and the shortest 6987 weighted path from <u> to <v> in the graph <gr>. 6988 6989 The length of a weighted path is the sum of edge weights of edges 6990 in the path. If an edge has no weight, then it has a default 6991 weight 1. 6992 6993 Example: 6994 6995 (%i1) load (graphs)$ 6996 (%i2) g: petersen_graph(20, 2)$ 6997 (%i3) for e in edges(g) do set_edge_weight(e, random(1.0), g)$ 6998 (%i4) shortest_weighted_path(0, 10, g); 6999 (%o4) [2.575143920268482, [0, 20, 38, 36, 34, 32, 30, 10]] 7000 7001 -- Function: strong_components (<gr>) 7002 Returns the strong components of a directed graph <gr>. 7003 7004 Example: 7005 (%i1) load (graphs)$ 7006 (%i2) t : random_tournament(4)$ 7007 (%i3) strong_components(t); 7008 (%o3) [[1], [0], [2], [3]] 7009 (%i4) vertex_out_degree(3, t); 7010 (%o4) 3 7011 7012 -- Function: topological_sort (<dag>) 7013 7014 Returns a topological sorting of the vertices of a directed graph 7015 <dag> or an empty list if <dag> is not a directed acyclic graph. 7016 7017 Example: 7018 (%i1) load (graphs)$ 7019 (%i2) g:create_graph( 7020 [1,2,3,4,5], 7021 [ 7022 [1,2], [2,5], [5,3], 7023 [5,4], [3,4], [1,3] 7024 ], 7025 directed=true)$ 7026 (%i3) topological_sort(g); 7027 (%o3) [1, 2, 5, 3, 4] 7028 7029 -- Function: vertex_connectivity (<g>) 7030 Returns the vertex connectivity of the graph <g>. 7031 7032 See also 'min_vertex_cut'. 7033 7034 -- Function: vertex_degree (<v>, <gr>) 7035 Returns the degree of the vertex <v> in the graph <gr>. 7036 7037 -- Function: vertex_distance (<u>, <v>, <gr>) 7038 Returns the length of the shortest path between <u> and <v> in the 7039 (directed) graph <gr>. 7040 7041 Example: 7042 (%i1) load (graphs)$ 7043 (%i2) d : dodecahedron_graph()$ 7044 (%i3) vertex_distance(0, 7, d); 7045 (%o3) 4 7046 (%i4) shortest_path(0, 7, d); 7047 (%o4) [0, 1, 19, 13, 7] 7048 7049 -- Function: vertex_eccentricity (<v>, <gr>) 7050 7051 Returns the eccentricity of the vertex <v> in the graph <gr>. 7052 7053 Example: 7054 (%i1) load (graphs)$ 7055 (%i2) g:cycle_graph(7)$ 7056 (%i3) vertex_eccentricity(0, g); 7057 (%o3) 3 7058 7059 -- Function: vertex_in_degree (<v>, <gr>) 7060 Returns the in-degree of the vertex <v> in the directed graph <gr>. 7061 7062 Example: 7063 (%i1) load (graphs)$ 7064 (%i2) p5 : path_digraph(5)$ 7065 (%i3) print_graph(p5)$ 7066 Digraph on 5 vertices with 4 arcs. 7067 Adjacencies: 7068 4 : 7069 3 : 4 7070 2 : 3 7071 1 : 2 7072 0 : 1 7073 (%i4) vertex_in_degree(4, p5); 7074 (%o4) 1 7075 (%i5) in_neighbors(4, p5); 7076 (%o5) [3] 7077 7078 -- Function: vertex_out_degree (<v>, <gr>) 7079 Returns the out-degree of the vertex <v> in the directed graph 7080 <gr>. 7081 7082 Example: 7083 (%i1) load (graphs)$ 7084 (%i2) t : random_tournament(10)$ 7085 (%i3) vertex_out_degree(0, t); 7086 (%o3) 2 7087 (%i4) out_neighbors(0, t); 7088 (%o4) [7, 1] 7089 7090 -- Function: vertices (<gr>) 7091 Returns the list of vertices in the graph <gr>. 7092 7093 Example: 7094 (%i1) load (graphs)$ 7095 (%i2) vertices(complete_graph(4)); 7096 (%o2) [3, 2, 1, 0] 7097 7098 -- Function: vertex_coloring (<gr>) 7099 Returns an optimal coloring of the vertices of the graph <gr>. 7100 7101 The function returns the chromatic number and a list representing 7102 the coloring of the vertices of <gr>. 7103 7104 Example: 7105 (%i1) load (graphs)$ 7106 (%i2) p:petersen_graph()$ 7107 (%i3) vertex_coloring(p); 7108 (%o3) [3, [[0, 2], [1, 3], [2, 2], [3, 3], [4, 1], [5, 3], 7109 [6, 1], [7, 1], [8, 2], [9, 2]]] 7110 7111 -- Function: wiener_index (<gr>) 7112 Returns the Wiener index of the graph <gr>. 7113 7114 Example: 7115 (%i2) wiener_index(dodecahedron_graph()); 7116 (%o2) 500 7117 711850.2.3 Modifying graphs 7119----------------------- 7120 7121 -- Function: add_edge (<e>, <gr>) 7122 Adds the edge <e> to the graph <gr>. 7123 7124 Example: 7125 (%i1) load (graphs)$ 7126 (%i2) p : path_graph(4)$ 7127 (%i3) neighbors(0, p); 7128 (%o3) [1] 7129 (%i4) add_edge([0,3], p); 7130 (%o4) done 7131 (%i5) neighbors(0, p); 7132 (%o5) [3, 1] 7133 7134 -- Function: add_edges (<e_list>, <gr>) 7135 Adds all edges in the list <e_list> to the graph <gr>. 7136 7137 Example: 7138 (%i1) load (graphs)$ 7139 (%i2) g : empty_graph(3)$ 7140 (%i3) add_edges([[0,1],[1,2]], g)$ 7141 (%i4) print_graph(g)$ 7142 Graph on 3 vertices with 2 edges. 7143 Adjacencies: 7144 2 : 1 7145 1 : 2 0 7146 0 : 1 7147 7148 -- Function: add_vertex (<v>, <gr>) 7149 Adds the vertex <v> to the graph <gr>. 7150 7151 Example: 7152 (%i1) load (graphs)$ 7153 (%i2) g : path_graph(2)$ 7154 (%i3) add_vertex(2, g)$ 7155 (%i4) print_graph(g)$ 7156 Graph on 3 vertices with 1 edges. 7157 Adjacencies: 7158 2 : 7159 1 : 0 7160 0 : 1 7161 7162 -- Function: add_vertices (<v_list>, <gr>) 7163 Adds all vertices in the list <v_list> to the graph <gr>. 7164 7165 -- Function: connect_vertices (<v_list>, <u_list>, <gr>) 7166 Connects all vertices from the list <v_list> with the vertices in 7167 the list <u_list> in the graph <gr>. 7168 7169 <v_list> and <u_list> can be single vertices or lists of vertices. 7170 7171 Example: 7172 (%i1) load (graphs)$ 7173 (%i2) g : empty_graph(4)$ 7174 (%i3) connect_vertices(0, [1,2,3], g)$ 7175 (%i4) print_graph(g)$ 7176 Graph on 4 vertices with 3 edges. 7177 Adjacencies: 7178 3 : 0 7179 2 : 0 7180 1 : 0 7181 0 : 3 2 1 7182 7183 -- Function: contract_edge (<e>, <gr>) 7184 Contracts the edge <e> in the graph <gr>. 7185 7186 Example: 7187 (%i1) load (graphs)$ 7188 (%i2) g: create_graph( 7189 8, [[0,3],[1,3],[2,3],[3,4],[4,5],[4,6],[4,7]])$ 7190 (%i3) print_graph(g)$ 7191 Graph on 8 vertices with 7 edges. 7192 Adjacencies: 7193 7 : 4 7194 6 : 4 7195 5 : 4 7196 4 : 7 6 5 3 7197 3 : 4 2 1 0 7198 2 : 3 7199 1 : 3 7200 0 : 3 7201 (%i4) contract_edge([3,4], g)$ 7202 (%i5) print_graph(g)$ 7203 Graph on 7 vertices with 6 edges. 7204 Adjacencies: 7205 7 : 3 7206 6 : 3 7207 5 : 3 7208 3 : 5 6 7 2 1 0 7209 2 : 3 7210 1 : 3 7211 0 : 3 7212 7213 -- Function: remove_edge (<e>, <gr>) 7214 Removes the edge <e> from the graph <gr>. 7215 7216 Example: 7217 (%i1) load (graphs)$ 7218 (%i2) c3 : cycle_graph(3)$ 7219 (%i3) remove_edge([0,1], c3)$ 7220 (%i4) print_graph(c3)$ 7221 Graph on 3 vertices with 2 edges. 7222 Adjacencies: 7223 2 : 0 1 7224 1 : 2 7225 0 : 2 7226 7227 -- Function: remove_vertex (<v>, <gr>) 7228 Removes the vertex <v> from the graph <gr>. 7229 723050.2.4 Reading and writing to files 7231----------------------------------- 7232 7233 -- Function: dimacs_export (<gr>, <fl>) 7234 -- Function: dimacs_export (<gr>, <fl>, <comment1>, ..., <commentn>) 7235 7236 Exports the graph into the file <fl> in the DIMACS format. 7237 Optional comments will be added to the top of the file. 7238 7239 -- Function: dimacs_import (<fl>) 7240 7241 Returns the graph from file <fl> in the DIMACS format. 7242 7243 -- Function: graph6_decode (<str>) 7244 7245 Returns the graph encoded in the graph6 format in the string <str>. 7246 7247 -- Function: graph6_encode (<gr>) 7248 7249 Returns a string which encodes the graph <gr> in the graph6 format. 7250 7251 -- Function: graph6_export (<gr_list>, <fl>) 7252 7253 Exports graphs in the list <gr_list> to the file <fl> in the graph6 7254 format. 7255 7256 -- Function: graph6_import (<fl>) 7257 7258 Returns a list of graphs from the file <fl> in the graph6 format. 7259 7260 -- Function: sparse6_decode (<str>) 7261 7262 Returns the graph encoded in the sparse6 format in the string 7263 <str>. 7264 7265 -- Function: sparse6_encode (<gr>) 7266 7267 Returns a string which encodes the graph <gr> in the sparse6 7268 format. 7269 7270 -- Function: sparse6_export (<gr_list>, <fl>) 7271 7272 Exports graphs in the list <gr_list> to the file <fl> in the 7273 sparse6 format. 7274 7275 -- Function: sparse6_import (<fl>) 7276 7277 Returns a list of graphs from the file <fl> in the sparse6 format. 7278 727950.2.5 Visualization 7280-------------------- 7281 7282 -- Function: draw_graph (<graph>) 7283 -- Function: draw_graph (<graph>, <option1>, ..., <optionk>) 7284 7285 Draws the graph using the 'draw' package. 7286 7287 The algorithm used to position vertices is specified by the 7288 optional argument <program>. The default value is 7289 'program=spring_embedding'. <draw_graph> can also use the graphviz 7290 programs for positioning vertices, but graphviz must be installed 7291 separately. 7292 7293 Example 1: 7294 7295 (%i1) load (graphs)$ 7296 (%i2) g:grid_graph(10,10)$ 7297 (%i3) m:max_matching(g)$ 7298 (%i4) draw_graph(g, 7299 spring_embedding_depth=100, 7300 show_edges=m, edge_type=dots, 7301 vertex_size=0)$ 7302 7303 Example 2: 7304 7305 (%i1) load (graphs)$ 7306 (%i2) g:create_graph(16, 7307 [ 7308 [0,1],[1,3],[2,3],[0,2],[3,4],[2,4], 7309 [5,6],[6,4],[4,7],[6,7],[7,8],[7,10],[7,11], 7310 [8,10],[11,10],[8,9],[11,12],[9,15],[12,13], 7311 [10,14],[15,14],[13,14] 7312 ])$ 7313 (%i3) t:minimum_spanning_tree(g)$ 7314 (%i4) draw_graph( 7315 g, 7316 show_edges=edges(t), 7317 show_edge_width=4, 7318 show_edge_color=green, 7319 vertex_type=filled_square, 7320 vertex_size=2 7321 )$ 7322 7323 Example 3: 7324 7325 (%i1) load (graphs)$ 7326 (%i2) g:create_graph(16, 7327 [ 7328 [0,1],[1,3],[2,3],[0,2],[3,4],[2,4], 7329 [5,6],[6,4],[4,7],[6,7],[7,8],[7,10],[7,11], 7330 [8,10],[11,10],[8,9],[11,12],[9,15],[12,13], 7331 [10,14],[15,14],[13,14] 7332 ])$ 7333 (%i3) mi : max_independent_set(g)$ 7334 (%i4) draw_graph( 7335 g, 7336 show_vertices=mi, 7337 show_vertex_type=filled_up_triangle, 7338 show_vertex_size=2, 7339 edge_color=cyan, 7340 edge_width=3, 7341 show_id=true, 7342 text_color=brown 7343 )$ 7344 7345 Example 4: 7346 7347 (%i1) load (graphs)$ 7348 (%i2) net : create_graph( 7349 [0,1,2,3,4,5], 7350 [ 7351 [[0,1], 3], [[0,2], 2], 7352 [[1,3], 1], [[1,4], 3], 7353 [[2,3], 2], [[2,4], 2], 7354 [[4,5], 2], [[3,5], 2] 7355 ], 7356 directed=true 7357 )$ 7358 (%i3) draw_graph( 7359 net, 7360 show_weight=true, 7361 vertex_size=0, 7362 show_vertices=[0,5], 7363 show_vertex_type=filled_square, 7364 head_length=0.2, 7365 head_angle=10, 7366 edge_color="dark-green", 7367 text_color=blue 7368 )$ 7369 7370 Example 5: 7371 7372 (%i1) load(graphs)$ 7373 (%i2) g: petersen_graph(20, 2); 7374 (%o2) GRAPH 7375 (%i3) draw_graph(g, redraw=true, program=planar_embedding); 7376 (%o3) done 7377 7378 Example 6: 7379 7380 (%i1) load(graphs)$ 7381 (%i2) t: tutte_graph(); 7382 (%o2) GRAPH 7383 (%i3) draw_graph(t, redraw=true, 7384 fixed_vertices=[1,2,3,4,5,6,7,8,9]); 7385 (%o3) done 7386 7387 -- Option variable: draw_graph_program 7388 Default value: <spring_embedding> 7389 7390 The default value for the program used to position vertices in 7391 'draw_graph' program. 7392 7393 -- draw_graph option: show_id 7394 Default value: <false> 7395 7396 If <true> then ids of the vertices are displayed. 7397 7398 -- draw_graph option: show_label 7399 Default value: <false> 7400 7401 If <true> then labels of the vertices are displayed. 7402 7403 -- draw_graph option: label_alignment 7404 Default value: <center> 7405 7406 Determines how to align the labels/ids of the vertices. Can be 7407 'left', 'center' or 'right'. 7408 7409 -- draw_graph option: show_weight 7410 Default value: <false> 7411 7412 If <true> then weights of the edges are displayed. 7413 7414 -- draw_graph option: vertex_type 7415 Default value: <circle> 7416 7417 Defines how vertices are displayed. See the <point_type> option 7418 for the 'draw' package for possible values. 7419 7420 -- draw_graph option: vertex_size 7421 The size of vertices. 7422 7423 -- draw_graph option: vertex_color 7424 The color used for displaying vertices. 7425 7426 -- draw_graph option: show_vertices 7427 Default value: [] 7428 7429 Display selected vertices in the using a different color. 7430 7431 -- draw_graph option: show_vertex_type 7432 Defines how vertices specified in <show_vertices> are displayed. 7433 See the <point_type> option for the 'draw' package for possible 7434 values. 7435 7436 -- draw_graph option: show_vertex_size 7437 The size of vertices in <show_vertices>. 7438 7439 -- draw_graph option: show_vertex_color 7440 The color used for displaying vertices in the <show_vertices> list. 7441 7442 -- draw_graph option: vertex_partition 7443 Default value: [] 7444 7445 A partition '[[v1,v2,...],...,[vk,...,vn]]' of the vertices of the 7446 graph. The vertices of each list in the partition will be drawn in 7447 a different color. 7448 7449 -- draw_graph option: vertex_coloring 7450 Specifies coloring of the vertices. The coloring <col> must be 7451 specified in the format as returned by <vertex_coloring>. 7452 7453 -- draw_graph option: edge_color 7454 The color used for displaying edges. 7455 7456 -- draw_graph option: edge_width 7457 The width of edges. 7458 7459 -- draw_graph option: edge_type 7460 Defines how edges are displayed. See the <line_type> option for 7461 the 'draw' package. 7462 7463 -- draw_graph option: show_edges 7464 Display edges specified in the list <e_list> using a different 7465 color. 7466 7467 -- draw_graph option: show_edge_color 7468 The color used for displaying edges in the <show_edges> list. 7469 7470 -- draw_graph option: show_edge_width 7471 The width of edges in <show_edges>. 7472 7473 -- draw_graph option: show_edge_type 7474 Defines how edges in <show_edges> are displayed. See the 7475 <line_type> option for the 'draw' package. 7476 7477 -- draw_graph option: edge_partition 7478 A partition '[[e1,e2,...],...,[ek,...,em]]' of edges of the graph. 7479 The edges of each list in the partition will be drawn using a 7480 different color. 7481 7482 -- draw_graph option: edge_coloring 7483 The coloring of edges. The coloring must be specified in the 7484 format as returned by the function <edge_coloring>. 7485 7486 -- draw_graph option: redraw 7487 Default value: <false> 7488 7489 If 'true', vertex positions are recomputed even if the positions 7490 have been saved from a previous drawing of the graph. 7491 7492 -- draw_graph option: head_angle 7493 Default value: 15 7494 7495 The angle for the arrows displayed on arcs (in directed graphs). 7496 7497 -- draw_graph option: head_length 7498 Default value: 0.1 7499 7500 The length for the arrows displayed on arcs (in directed graphs). 7501 7502 -- draw_graph option: spring_embedding_depth 7503 Default value: 50 7504 7505 The number of iterations in the spring embedding graph drawing 7506 algorithm. 7507 7508 -- draw_graph option: terminal 7509 The terminal used for drawing (see the <terminal> option in the 7510 'draw' package). 7511 7512 -- draw_graph option: file_name 7513 The filename of the drawing if terminal is not screen. 7514 7515 -- draw_graph option: program 7516 Defines the program used for positioning vertices of the graph. 7517 Can be one of the graphviz programs (dot, neato, twopi, circ, fdp), 7518 <circular>, <spring_embedding> or <planar_embedding>. 7519 <planar_embedding> is only available for 2-connected planar graphs. 7520 When 'program=spring_embedding', a set of vertices with fixed 7521 position can be specified with the <fixed_vertices> option. 7522 7523 -- draw_graph option: fixed_vertices 7524 Specifies a list of vertices which will have positions fixed along 7525 a regular polygon. Can be used when 'program=spring_embedding'. 7526 7527 -- Function: vertices_to_path (<v_list>) 7528 Converts a list <v_list> of vertices to a list of edges of the path 7529 defined by <v_list>. 7530 7531 -- Function: vertices_to_cycle (<v_list>) 7532 Converts a list <v_list> of vertices to a list of edges of the 7533 cycle defined by <v_list>. 7534 7535 7536File: maxima.info, Node: grobner, Next: groups, Prev: graphs, Up: Top 7537 753851 grobner 7539********** 7540 7541* Menu: 7542 7543* Introduction to grobner :: 7544* Functions and Variables for grobner :: 7545 7546 7547File: maxima.info, Node: Introduction to grobner, Next: Functions and Variables for grobner, Prev: Top, Up: Top 7548 754951.1 Introduction to grobner 7550============================ 7551 7552'grobner' is a package for working with Groebner bases in Maxima. 7553 7554A tutorial on _Groebner Bases_ can be found at 7555<http://www.geocities.com/CapeCanaveral/Hall/3131/> 7556 7557To use the following functions you must load the 'grobner.lisp' package. 7558 7559 load(grobner); 7560 7561A demo can be started by 7562 demo("grobner.demo"); 7563 7564or 7565 batch("grobner.demo") 7566 7567Some of the calculation in the demo will take a lot of time therefore 7568the output 'grobner-demo.output' of the demo can be found in the same 7569directory as the demo file. 7570 757151.1.1 Notes on the grobner package 7572----------------------------------- 7573 7574The package was written by Marek Rychlik 7575<http://alamos.math.arizona.edu> and is released 2002-05-24 under the 7576terms of the General Public License(GPL) (see file 'grobner.lisp'. This 7577documentation was extracted from the files 7578'README', 'grobner.lisp', 'grobner.demo', 'grobner-demo.output' 7579by Günter Nowak. Suggestions for improvement of the documentation can 7580be discussed at the _maxima_-mailing-list <maxima@math.utexas.edu>. The 7581code is a little bit out of date now. Modern implementation use the 7582fast _F4_ algorithm described in "A new efficient algorithm for 7583computing Gröbner bases (F4)", Jean-Charles Faugère, LIP6/CNRS 7584Université Paris VI, January 20, 1999. 7585 758651.1.2 Implementations of admissible monomial orders in grobner 7587--------------------------------------------------------------- 7588 7589 * 'lex' pure lexicographic, default order for monomial comparisons 7590 7591 * 'grlex' total degree order, ties broken by lexicographic 7592 7593 * 'grevlex' total degree, ties broken by reverse lexicographic 7594 7595 * 'invlex' inverse lexicographic order 7596 7597 7598File: maxima.info, Node: Functions and Variables for grobner, Prev: Introduction to grobner, Up: Top 7599 760051.2 Functions and Variables for grobner 7601======================================== 7602 760351.2.1 Global switches for grobner 7604---------------------------------- 7605 7606 -- Option variable: poly_monomial_order 7607 Default value: 'lex' 7608 7609 This global switch controls which monomial order is used in 7610 polynomial and Groebner Bases calculations. If not set, 'lex' will 7611 be used. 7612 7613 -- Option variable: poly_coefficient_ring 7614 Default value: 'expression_ring' 7615 7616 This switch indicates the coefficient ring of the polynomials that 7617 will be used in grobner calculations. If not set, _maxima's_ 7618 general expression ring will be used. This variable may be set to 7619 'ring_of_integers' if desired. 7620 7621 -- Option variable: poly_primary_elimination_order 7622 Default value: 'false' 7623 7624 Name of the default order for eliminated variables in 7625 elimination-based functions. If not set, 'lex' will be used. 7626 7627 -- Option variable: poly_secondary_elimination_order 7628 Default value: 'false' 7629 7630 Name of the default order for kept variables in elimination-based 7631 functions. If not set, 'lex' will be used. 7632 7633 -- Option variable: poly_elimination_order 7634 Default value: 'false' 7635 7636 Name of the default elimination order used in elimination 7637 calculations. If set, it overrides the settings in variables 7638 'poly_primary_elimination_order' and 7639 'poly_secondary_elimination_order'. The user must ensure that this 7640 is a true elimination order valid for the number of eliminated 7641 variables. 7642 7643 -- Option variable: poly_return_term_list 7644 Default value: 'false' 7645 7646 If set to 'true', all functions in this package will return each 7647 polynomial as a list of terms in the current monomial order rather 7648 than a _maxima_ general expression. 7649 7650 -- Option variable: poly_grobner_debug 7651 Default value: 'false' 7652 7653 If set to 'true', produce debugging and tracing output. 7654 7655 -- Option variable: poly_grobner_algorithm 7656 Default value: 'buchberger' 7657 7658 Possible values: 7659 * 'buchberger' 7660 * 'parallel_buchberger' 7661 * 'gebauer_moeller' 7662 7663 The name of the algorithm used to find the Groebner Bases. 7664 7665 -- Option variable: poly_top_reduction_only 7666 Default value: 'false' 7667 7668 If not 'false', use top reduction only whenever possible. Top 7669 reduction means that division algorithm stops after the first 7670 reduction. 7671 767251.2.2 Simple operators in grobner 7673---------------------------------- 7674 7675'poly_add', 'poly_subtract', 'poly_multiply' and 'poly_expt' are the 7676arithmetical operations on polynomials. These are performed using the 7677internal representation, but the results are converted back to the 7678_maxima_ general form. 7679 7680 -- Function: poly_add (<poly1>, <poly2>, <varlist>) 7681 7682 Adds two polynomials <poly1> and <poly2>. 7683 7684 (%i1) poly_add(z+x^2*y,x-z,[x,y,z]); 7685 2 7686 (%o1) x y + x 7687 7688 -- Function: poly_subtract (<poly1>, <poly2>, <varlist>) 7689 7690 Subtracts a polynomial <poly2> from <poly1>. 7691 7692 (%i1) poly_subtract(z+x^2*y,x-z,[x,y,z]); 7693 2 7694 (%o1) 2 z + x y - x 7695 7696 -- Function: poly_multiply (<poly1>, <poly2>, <varlist>) 7697 7698 Returns the product of polynomials <poly1> and <poly2>. 7699 7700 (%i1) poly_multiply(z+x^2*y,x-z,[x,y,z])-(z+x^2*y)*(x-z),expand; 7701 (%o1) 0 7702 7703 -- Function: poly_s_polynomial (<poly1>, <poly2>, <varlist>) 7704 7705 Returns the _syzygy polynomial_ (_S-polynomial_) of two polynomials 7706 <poly1> and <poly2>. 7707 7708 -- Function: poly_primitive_part (<poly1>, <varlist>) 7709 7710 Returns the polynomial <poly> divided by the GCD of its 7711 coefficients. 7712 7713 (%i1) poly_primitive_part(35*y+21*x,[x,y]); 7714 (%o1) 5 y + 3 x 7715 7716 -- Function: poly_normalize (<poly>, <varlist>) 7717 7718 Returns the polynomial <poly> divided by the leading coefficient. 7719 It assumes that the division is possible, which may not always be 7720 the case in rings which are not fields. 7721 772251.2.3 Other functions in grobner 7723--------------------------------- 7724 7725 -- Function: poly_expand (<poly>, <varlist>) 7726 7727 This function parses polynomials to internal form and back. It is 7728 equivalent to 'expand(<poly>)' if <poly> parses correctly to a 7729 polynomial. If the representation is not compatible with a 7730 polynomial in variables <varlist>, the result is an error. It can 7731 be used to test whether an expression correctly parses to the 7732 internal representation. The following examples illustrate that 7733 indexed and transcendental function variables are allowed. 7734 7735 (%i1) poly_expand((x-y)*(y+x),[x,y]); 7736 2 2 7737 (%o1) x - y 7738 (%i2) poly_expand((y+x)^2,[x,y]); 7739 2 2 7740 (%o2) y + 2 x y + x 7741 (%i3) poly_expand((y+x)^5,[x,y]); 7742 5 4 2 3 3 2 4 5 7743 (%o3) y + 5 x y + 10 x y + 10 x y + 5 x y + x 7744 (%i4) poly_expand(-1-x*exp(y)+x^2/sqrt(y),[x]); 7745 2 7746 y x 7747 (%o4) - x %e + ------- - 1 7748 sqrt(y) 7749 7750 (%i5) poly_expand(-1-sin(x)^2+sin(x),[sin(x)]); 7751 2 7752 (%o5) - sin (x) + sin(x) - 1 7753 7754 -- Function: poly_expt (<poly>, <number>, <varlist>) 7755 7756 exponentitates <poly> by a positive integer <number>. If <number> 7757 is not a positive integer number an error will be raised. 7758 7759 (%i1) poly_expt(x-y,3,[x,y])-(x-y)^3,expand; 7760 (%o1) 0 7761 7762 -- Function: poly_content (<poly>, <varlist>) 7763 7764 'poly_content' extracts the GCD of its coefficients 7765 7766 (%i1) poly_content(35*y+21*x,[x,y]); 7767 (%o1) 7 7768 7769 -- Function: poly_pseudo_divide (<poly>, <polylist>, <varlist>) 7770 7771 Pseudo-divide a polynomial <poly> by the list of n polynomials 7772 <polylist>. Return multiple values. The first value is a list of 7773 quotients a. The second value is the remainder r. The third 7774 argument is a scalar coefficient c, such that c*poly can be divided 7775 by <polylist> within the ring of coefficients, which is not 7776 necessarily a field. Finally, the fourth value is an integer count 7777 of the number of reductions performed. The resulting objects 7778 satisfy the equation: 7779 7780 c*poly=sum(a[i]*polylist[i],i=1...n)+r. 7781 7782 -- Function: poly_exact_divide (<poly1>, <poly2>, <varlist>) 7783 7784 Divide a polynomial <poly1> by another polynomial <poly2>. Assumes 7785 that exact division with no remainder is possible. Returns the 7786 quotient. 7787 7788 -- Function: poly_normal_form (<poly>, <polylist>, <varlist>) 7789 7790 'poly_normal_form' finds the normal form of a polynomial <poly> 7791 with respect to a set of polynomials <polylist>. 7792 7793 -- Function: poly_buchberger_criterion (<polylist>, <varlist>) 7794 7795 Returns 'true' if <polylist> is a Groebner basis with respect to 7796 the current term order, by using the Buchberger criterion: for 7797 every two polynomials h1 and h2 in <polylist> the S-polynomial 7798 S(h1,h2) reduces to 0 modulo <polylist>. 7799 7800 -- Function: poly_buchberger (<polylist_fl> <varlist>) 7801 7802 'poly_buchberger' performs the Buchberger algorithm on a list of 7803 polynomials and returns the resulting Groebner basis. 7804 780551.2.4 Standard postprocessing of Groebner Bases 7806------------------------------------------------ 7807 7808The _k-th elimination Ideal_ I_k of an Ideal I over K[ x[1],...,x[n] ] 7809is the ideal intersect(I, K[ x[k+1],...,x[n] ]). 7810The _colon ideal_ I:J is the ideal {h|for all w in J: w*h in I}. 7811The ideal I:p^inf is the ideal {h| there is a n in N: p^n*h in I}. 7812The ideal I:J^inf is the ideal {h| there is a n in N and a p in J: p^n*h 7813in I}. 7814The _radical ideal_ sqrt(I) is the ideal {h| there is a n in N : h^n in 7815I }. 7816 7817 -- Function: poly_reduction (<polylist>, <varlist>) 7818 7819 'poly_reduction' reduces a list of polynomials <polylist>, so that 7820 each polynomial is fully reduced with respect to the other 7821 polynomials. 7822 7823 -- Function: poly_minimization (<polylist>, <varlist>) 7824 7825 Returns a sublist of the polynomial list <polylist> spanning the 7826 same monomial ideal as <polylist> but minimal, i.e. no leading 7827 monomial of a polynomial in the sublist divides the leading 7828 monomial of another polynomial. 7829 7830 -- Function: poly_normalize_list (<polylist>, <varlist>) 7831 7832 'poly_normalize_list' applies 'poly_normalize' to each polynomial 7833 in the list. That means it divides every polynomial in a list 7834 <polylist> by its leading coefficient. 7835 7836 -- Function: poly_grobner (<polylist>, <varlist>) 7837 7838 Returns a Groebner basis of the ideal span by the polynomials 7839 <polylist>. Affected by the global flags. 7840 7841 -- Function: poly_reduced_grobner (<polylist>, <varlist>) 7842 7843 Returns a reduced Groebner basis of the ideal span by the 7844 polynomials <polylist>. Affected by the global flags. 7845 7846 -- Function: poly_depends_p (<poly>, <var>, <varlist>) 7847 7848 'poly_depends' tests whether a polynomial depends on a variable 7849 <var>. 7850 7851 -- Function: poly_elimination_ideal (<polylist>, <number>, <varlist>) 7852 7853 'poly_elimination_ideal' returns the grobner basis of the number-th 7854 elimination ideal of an ideal specified as a list of generating 7855 polynomials (not necessarily Groebner basis). 7856 7857 -- Function: poly_colon_ideal (<polylist1>, <polylist2>, <varlist>) 7858 7859 Returns the reduced Groebner basis of the colon ideal 7860 7861 I(polylist1):I(polylist2) 7862 7863 where polylist1 and polylist2 are two lists of polynomials. 7864 7865 -- Function: poly_ideal_intersection (<polylist1>, <polylist2>, 7866 <varlist>) 7867 7868 'poly_ideal_intersection' returns the intersection of two ideals. 7869 7870 -- Function: poly_lcm (<poly1>, <poly2>, <varlist>) 7871 7872 Returns the lowest common multiple of <poly1> and <poly2>. 7873 7874 -- Function: poly_gcd (<poly1>, <poly2>, <varlist>) 7875 7876 Returns the greatest common divisor of <poly1> and <poly2>. 7877 7878 See also 'ezgcd', 'gcd', 'gcdex', and 'gcdivide'. 7879 7880 Example: 7881 7882 (%i1) p1:6*x^3+19*x^2+19*x+6; 7883 3 2 7884 (%o1) 6 x + 19 x + 19 x + 6 7885 (%i2) p2:6*x^5+13*x^4+12*x^3+13*x^2+6*x; 7886 5 4 3 2 7887 (%o2) 6 x + 13 x + 12 x + 13 x + 6 x 7888 (%i3) poly_gcd(p1, p2, [x]); 7889 2 7890 (%o3) 6 x + 13 x + 6 7891 7892 -- Function: poly_grobner_equal (<polylist1>, <polylist2>, <varlist>) 7893 7894 'poly_grobner_equal' tests whether two Groebner Bases generate the 7895 same ideal. Returns 'true' if two lists of polynomials <polylist1> 7896 and <polylist2>, assumed to be Groebner Bases, generate the same 7897 ideal, and 'false' otherwise. This is equivalent to checking that 7898 every polynomial of the first basis reduces to 0 modulo the second 7899 basis and vice versa. Note that in the example below the first 7900 list is not a Groebner basis, and thus the result is 'false'. 7901 7902 (%i1) poly_grobner_equal([y+x,x-y],[x,y],[x,y]); 7903 (%o1) false 7904 7905 -- Function: poly_grobner_subsetp (<polylist1>, <polylist2>, <varlist>) 7906 7907 'poly_grobner_subsetp' tests whether an ideal generated by 7908 <polylist1> is contained in the ideal generated by <polylist2>. 7909 For this test to always succeed, <polylist2> must be a Groebner 7910 basis. 7911 7912 -- Function: poly_grobner_member (<poly>, <polylist>, <varlist>) 7913 7914 Returns 'true' if a polynomial <poly> belongs to the ideal 7915 generated by the polynomial list <polylist>, which is assumed to be 7916 a Groebner basis. Returns 'false' otherwise. 7917 7918 'poly_grobner_member' tests whether a polynomial belongs to an 7919 ideal generated by a list of polynomials, which is assumed to be a 7920 Groebner basis. Equivalent to 'normal_form' being 0. 7921 7922 -- Function: poly_ideal_saturation1 (<polylist>, <poly>, <varlist>) 7923 7924 Returns the reduced Groebner basis of the saturation of the ideal 7925 7926 I(polylist):poly^inf 7927 7928 Geometrically, over an algebraically closed field, this is the set 7929 of polynomials in the ideal generated by <polylist> which do not 7930 identically vanish on the variety of <poly>. 7931 7932 -- Function: poly_ideal_saturation (<polylist1>, <polylist2>, 7933 <varlist>) 7934 7935 Returns the reduced Groebner basis of the saturation of the ideal 7936 7937 I(polylist1):I(polylist2)^inf 7938 7939 Geometrically, over an algebraically closed field, this is the set 7940 of polynomials in the ideal generated by <polylist1> which do not 7941 identically vanish on the variety of <polylist2>. 7942 7943 -- Function: poly_ideal_polysaturation1 (<polylist1>, <polylist2>, 7944 <varlist>) 7945 7946 <polylist2> ist a list of n polynomials '[poly1,...,polyn]'. 7947 Returns the reduced Groebner basis of the ideal 7948 7949 I(polylist):poly1^inf:...:polyn^inf 7950 7951 obtained by a sequence of successive saturations in the polynomials 7952 of the polynomial list <polylist2> of the ideal generated by the 7953 polynomial list <polylist1>. 7954 7955 -- Function: poly_ideal_polysaturation (<polylist>, <polylistlist>, 7956 <varlist>) 7957 7958 <polylistlist> is a list of n list of polynomials 7959 '[polylist1,...,polylistn]'. Returns the reduced Groebner basis of 7960 the saturation of the ideal 7961 7962 I(polylist):I(polylist_1)^inf:...:I(polylist_n)^inf 7963 7964 -- Function: poly_saturation_extension (<poly>, <polylist>, <varlist1>, 7965 <varlist2>) 7966 7967 'poly_saturation_extension' implements the famous Rabinowitz trick. 7968 7969 -- Function: poly_polysaturation_extension (<poly>, <polylist>, 7970 <varlist1>, <varlist2>) 7971 7972 7973File: maxima.info, Node: groups, Next: impdiff, Prev: grobner, Up: Top 7974 797552 groups 7976********* 7977 7978* Menu: 7979 7980* Functions and Variables for Groups:: 7981 7982 7983File: maxima.info, Node: Functions and Variables for Groups, Prev: groups, Up: groups 7984 798552.1 Functions and Variables for Groups 7986======================================= 7987 7988 -- Function: todd_coxeter (<relations>, <subgroup>) 7989 -- Function: todd_coxeter (<relations>) 7990 7991 Find the order of G/H where G is the Free Group modulo <relations>, 7992 and H is the subgroup of G generated by <subgroup>. <subgroup> is 7993 an optional argument, defaulting to []. In doing this it produces 7994 a multiplication table for the right action of G on G/H, where the 7995 cosets are enumerated [H,Hg2,Hg3,...]. This can be seen internally 7996 in the variable 'todd_coxeter_state'. 7997 7998 Example: 7999 8000 (%i1) symet(n):=create_list( 8001 if (j - i) = 1 then (p(i,j))^^3 else 8002 if (not i = j) then (p(i,j))^^2 else 8003 p(i,i) , j, 1, n-1, i, 1, j); 8004 <3> 8005 (%o1) symet(n) := create_list(if j - i = 1 then p(i, j) 8006 8007 <2> 8008 else (if not i = j then p(i, j) else p(i, i)), j, 1, n - 1, 8009 8010 i, 1, j) 8011 (%i2) p(i,j) := concat(x,i).concat(x,j); 8012 (%o2) p(i, j) := concat(x, i) . concat(x, j) 8013 (%i3) symet(5); 8014 <2> <3> <2> <2> <3> 8015 (%o3) [x1 , (x1 . x2) , x2 , (x1 . x3) , (x2 . x3) , 8016 8017 <2> <2> <2> <3> <2> 8018 x3 , (x1 . x4) , (x2 . x4) , (x3 . x4) , x4 ] 8019 (%i4) todd_coxeter(%o3); 8020 8021 Rows tried 426 8022 (%o4) 120 8023 (%i5) todd_coxeter(%o3,[x1]); 8024 8025 Rows tried 213 8026 (%o5) 60 8027 (%i6) todd_coxeter(%o3,[x1,x2]); 8028 8029 Rows tried 71 8030 (%o6) 20 8031 8032 8033File: maxima.info, Node: impdiff, Next: interpol, Prev: groups, Up: Top 8034 803553 impdiff 8036********** 8037 8038* Menu: 8039 8040* Functions and Variables for impdiff:: 8041 8042 8043File: maxima.info, Node: Functions and Variables for impdiff, Prev: impdiff, Up: impdiff 8044 804553.1 Functions and Variables for impdiff 8046======================================== 8047 8048 -- Function: implicit_derivative (<f>, <indvarlist>, <orderlist>, 8049 <depvar>) 8050 8051 This subroutine computes implicit derivatives of multivariable 8052 functions. <f> is an array function, the indexes are the 8053 derivative degree in the <indvarlist> order; <indvarlist> is the 8054 independent variable list; <orderlist> is the order desired; and 8055 <depvar> is the dependent variable. 8056 8057 To use this function write first 'load("impdiff")'. 8058 8059 8060File: maxima.info, Node: interpol, Next: lapack, Prev: impdiff, Up: Top 8061 806254 interpol 8063*********** 8064 8065* Menu: 8066 8067* Introduction to interpol:: 8068* Functions and Variables for interpol:: 8069 8070 8071File: maxima.info, Node: Introduction to interpol, Next: Functions and Variables for interpol, Prev: interpol, Up: interpol 8072 807354.1 Introduction to interpol 8074============================= 8075 8076Package 'interpol' defines the Lagrangian, the linear and the cubic 8077splines methods for polynomial interpolation. 8078 8079For comments, bugs or suggestions, please contact me at <'mario AT edu 8080DOT xunta DOT es'>. 8081 8082 8083File: maxima.info, Node: Functions and Variables for interpol, Prev: Introduction to interpol, Up: interpol 8084 808554.2 Functions and Variables for interpol 8086========================================= 8087 8088 -- Function: lagrange (<points>) 8089 -- Function: lagrange (<points>, <option>) 8090 8091 Computes the polynomial interpolation by the Lagrangian method. 8092 Argument <points> must be either: 8093 8094 * a two column matrix, 'p:matrix([2,4],[5,6],[9,3])', 8095 * a list of pairs, 'p: [[2,4],[5,6],[9,3]]', 8096 * a list of numbers, 'p: [4,6,3]', in which case the abscissas 8097 will be assigned automatically to 1, 2, 3, etc. 8098 8099 In the first two cases the pairs are ordered with respect to the 8100 first coordinate before making computations. 8101 8102 With the <option> argument it is possible to select the name for 8103 the independent variable, which is ''x' by default; to define 8104 another one, write something like 'varname='z'. 8105 8106 Note that when working with high degree polynomials, floating point 8107 evaluations are unstable. 8108 8109 Examples: 8110 8111 (%i1) load(interpol)$ 8112 (%i2) p:[[7,2],[8,2],[1,5],[3,2],[6,7]]$ 8113 (%i3) lagrange(p); 8114 (x - 7) (x - 6) (x - 3) (x - 1) 8115 (%o3) ------------------------------- 8116 35 8117 (x - 8) (x - 6) (x - 3) (x - 1) 8118 - ------------------------------- 8119 12 8120 7 (x - 8) (x - 7) (x - 3) (x - 1) 8121 + --------------------------------- 8122 30 8123 (x - 8) (x - 7) (x - 6) (x - 1) 8124 - ------------------------------- 8125 60 8126 (x - 8) (x - 7) (x - 6) (x - 3) 8127 + ------------------------------- 8128 84 8129 (%i4) f(x):=''%; 8130 (x - 7) (x - 6) (x - 3) (x - 1) 8131 (%o4) f(x) := ------------------------------- 8132 35 8133 (x - 8) (x - 6) (x - 3) (x - 1) 8134 - ------------------------------- 8135 12 8136 7 (x - 8) (x - 7) (x - 3) (x - 1) 8137 + --------------------------------- 8138 30 8139 (x - 8) (x - 7) (x - 6) (x - 1) 8140 - ------------------------------- 8141 60 8142 (x - 8) (x - 7) (x - 6) (x - 3) 8143 + ------------------------------- 8144 84 8145 (%i5) /* Evaluate the polynomial at some points */ 8146 expand(map(f,[2.3,5/7,%pi])); 8147 4 3 2 8148 919062 73 %pi 701 %pi 8957 %pi 8149 (%o5) [- 1.567535, ------, ------- - -------- + --------- 8150 84035 420 210 420 8151 5288 %pi 186 8152 - -------- + ---] 8153 105 5 8154 (%i6) %,numer; 8155 (%o6) [- 1.567535, 10.9366573451538, 2.89319655125692] 8156 (%i7) load(draw)$ /* load draw package */ 8157 (%i8) /* Plot the polynomial together with points */ 8158 draw2d( 8159 color = red, 8160 key = "Lagrange polynomial", 8161 explicit(f(x),x,0,10), 8162 point_size = 3, 8163 color = blue, 8164 key = "Sample points", 8165 points(p))$ 8166 (%i9) /* Change variable name */ 8167 lagrange(p, varname=w); 8168 (w - 7) (w - 6) (w - 3) (w - 1) 8169 (%o9) ------------------------------- 8170 35 8171 (w - 8) (w - 6) (w - 3) (w - 1) 8172 - ------------------------------- 8173 12 8174 7 (w - 8) (w - 7) (w - 3) (w - 1) 8175 + --------------------------------- 8176 30 8177 (w - 8) (w - 7) (w - 6) (w - 1) 8178 - ------------------------------- 8179 60 8180 (w - 8) (w - 7) (w - 6) (w - 3) 8181 + ------------------------------- 8182 84 8183 8184 -- Function: charfun2 (<x>, <a>, <b>) 8185 8186 Returns 'true' if number <x> belongs to the interval [a, b), and 8187 'false' otherwise. 8188 8189 -- Function: linearinterpol (<points>) 8190 -- Function: linearinterpol (<points>, <option>) 8191 8192 Computes the polynomial interpolation by the linear method. 8193 Argument <points> must be either: 8194 8195 * a two column matrix, 'p:matrix([2,4],[5,6],[9,3])', 8196 * a list of pairs, 'p: [[2,4],[5,6],[9,3]]', 8197 * a list of numbers, 'p: [4,6,3]', in which case the abscissas 8198 will be assigned automatically to 1, 2, 3, etc. 8199 8200 In the first two cases the pairs are ordered with respect to the 8201 first coordinate before making computations. 8202 8203 With the <option> argument it is possible to select the name for 8204 the independent variable, which is ''x' by default; to define 8205 another one, write something like 'varname='z'. 8206 8207 Examples: 8208 (%i1) load(interpol)$ 8209 (%i2) p: matrix([7,2],[8,3],[1,5],[3,2],[6,7])$ 8210 (%i3) linearinterpol(p); 8211 13 3 x 8212 (%o3) (-- - ---) charfun2(x, minf, 3) 8213 2 2 8214 + (x - 5) charfun2(x, 7, inf) + (37 - 5 x) charfun2(x, 6, 7) 8215 5 x 8216 + (--- - 3) charfun2(x, 3, 6) 8217 3 8218 8219 (%i4) f(x):=''%; 8220 13 3 x 8221 (%o4) f(x) := (-- - ---) charfun2(x, minf, 3) 8222 2 2 8223 + (x - 5) charfun2(x, 7, inf) + (37 - 5 x) charfun2(x, 6, 7) 8224 5 x 8225 + (--- - 3) charfun2(x, 3, 6) 8226 3 8227 (%i5) /* Evaluate the polynomial at some points */ 8228 map(f,[7.3,25/7,%pi]); 8229 62 5 %pi 8230 (%o5) [2.3, --, ----- - 3] 8231 21 3 8232 (%i6) %,numer; 8233 (%o6) [2.3, 2.952380952380953, 2.235987755982989] 8234 (%i7) load(draw)$ /* load draw package */ 8235 (%i8) /* Plot the polynomial together with points */ 8236 draw2d( 8237 color = red, 8238 key = "Linear interpolator", 8239 explicit(f(x),x,-5,20), 8240 point_size = 3, 8241 color = blue, 8242 key = "Sample points", 8243 points(args(p)))$ 8244 (%i9) /* Change variable name */ 8245 linearinterpol(p, varname='s); 8246 13 3 s 8247 (%o9) (-- - ---) charfun2(s, minf, 3) 8248 2 2 8249 + (s - 5) charfun2(s, 7, inf) + (37 - 5 s) charfun2(s, 6, 7) 8250 5 s 8251 + (--- - 3) charfun2(s, 3, 6) 8252 3 8253 8254 -- Function: cspline (<points>) 8255 -- Function: cspline (<points>, <option1>, <option2>, ...) 8256 8257 Computes the polynomial interpolation by the cubic splines method. 8258 Argument <points> must be either: 8259 8260 * a two column matrix, 'p:matrix([2,4],[5,6],[9,3])', 8261 * a list of pairs, 'p: [[2,4],[5,6],[9,3]]', 8262 * a list of numbers, 'p: [4,6,3]', in which case the abscissas 8263 will be assigned automatically to 1, 2, 3, etc. 8264 8265 In the first two cases the pairs are ordered with respect to the 8266 first coordinate before making computations. 8267 8268 There are three options to fit specific needs: 8269 * ''d1', default ''unknown', is the first derivative at x_1; if 8270 it is ''unknown', the second derivative at x_1 is made equal 8271 to 0 (natural cubic spline); if it is equal to a number, the 8272 second derivative is calculated based on this number. 8273 8274 * ''dn', default ''unknown', is the first derivative at x_n; if 8275 it is ''unknown', the second derivative at x_n is made equal 8276 to 0 (natural cubic spline); if it is equal to a number, the 8277 second derivative is calculated based on this number. 8278 8279 * ''varname', default ''x', is the name of the independent 8280 variable. 8281 8282 Examples: 8283 (%i1) load(interpol)$ 8284 (%i2) p:[[7,2],[8,2],[1,5],[3,2],[6,7]]$ 8285 (%i3) /* Unknown first derivatives at the extremes 8286 is equivalent to natural cubic splines */ 8287 cspline(p); 8288 3 2 8289 1159 x 1159 x 6091 x 8283 8290 (%o3) (------- - ------- - ------ + ----) charfun2(x, minf, 3) 8291 3288 1096 3288 1096 8292 3 2 8293 2587 x 5174 x 494117 x 108928 8294 + (- ------- + ------- - -------- + ------) charfun2(x, 7, inf) 8295 1644 137 1644 137 8296 3 2 8297 4715 x 15209 x 579277 x 199575 8298 + (------- - -------- + -------- - ------) charfun2(x, 6, 7) 8299 1644 274 1644 274 8300 3 2 8301 3287 x 2223 x 48275 x 9609 8302 + (- ------- + ------- - ------- + ----) charfun2(x, 3, 6) 8303 4932 274 1644 274 8304 8305 (%i4) f(x):=''%$ 8306 (%i5) /* Some evaluations */ 8307 map(f,[2.3,5/7,%pi]), numer; 8308 (%o5) [1.991460766423356, 5.823200187269903, 2.227405312429507] 8309 (%i6) load(draw)$ /* load draw package */ 8310 (%i7) /* Plotting interpolating function */ 8311 draw2d( 8312 color = red, 8313 key = "Cubic splines", 8314 explicit(f(x),x,0,10), 8315 point_size = 3, 8316 color = blue, 8317 key = "Sample points", 8318 points(p))$ 8319 (%i8) /* New call, but giving values at the derivatives */ 8320 cspline(p,d1=0,dn=0); 8321 3 2 8322 1949 x 11437 x 17027 x 1247 8323 (%o8) (------- - -------- + ------- + ----) charfun2(x, minf, 3) 8324 2256 2256 2256 752 8325 3 2 8326 1547 x 35581 x 68068 x 173546 8327 + (- ------- + -------- - ------- + ------) charfun2(x, 7, inf) 8328 564 564 141 141 8329 3 2 8330 607 x 35147 x 55706 x 38420 8331 + (------ - -------- + ------- - -----) charfun2(x, 6, 7) 8332 188 564 141 47 8333 3 2 8334 3895 x 1807 x 5146 x 2148 8335 + (- ------- + ------- - ------ + ----) charfun2(x, 3, 6) 8336 5076 188 141 47 8337 (%i8) /* Defining new interpolating function */ 8338 g(x):=''%$ 8339 (%i9) /* Plotting both functions together */ 8340 draw2d( 8341 color = black, 8342 key = "Cubic splines (default)", 8343 explicit(f(x),x,0,10), 8344 color = red, 8345 key = "Cubic splines (d1=0,dn=0)", 8346 explicit(g(x),x,0,10), 8347 point_size = 3, 8348 color = blue, 8349 key = "Sample points", 8350 points(p))$ 8351 8352 -- Function: ratinterpol (<points>, <numdeg>) 8353 -- Function: ratinterpol (<points>, <numdeg>, <option1>) 8354 8355 Generates a rational interpolator for data given by <points> and 8356 the degree of the numerator being equal to <numdeg>; the degree of 8357 the denominator is calculated automatically. Argument <points> 8358 must be either: 8359 8360 * a two column matrix, 'p:matrix([2,4],[5,6],[9,3])', 8361 * a list of pairs, 'p: [[2,4],[5,6],[9,3]]', 8362 * a list of numbers, 'p: [4,6,3]', in which case the abscissas 8363 will be assigned automatically to 1, 2, 3, etc. 8364 8365 In the first two cases the pairs are ordered with respect to the 8366 first coordinate before making computations. 8367 8368 There is one option to fit specific needs: 8369 * ''varname', default ''x', is the name of the independent 8370 variable. 8371 8372 Examples: 8373 8374 (%i1) load(interpol)$ 8375 (%i2) load(draw)$ 8376 (%i3) p:[[7.2,2.5],[8.5,2.1],[1.6,5.1],[3.4,2.4],[6.7,7.9]]$ 8377 (%i4) for k:0 thru length(p)-1 do 8378 draw2d( 8379 explicit(ratinterpol(p,k),x,0,9), 8380 point_size = 3, 8381 points(p), 8382 title = concat("Degree of numerator = ",k), 8383 yrange=[0,10])$ 8384 8385 8386File: maxima.info, Node: lapack, Next: lbfgs, Prev: interpol, Up: Top 8387 838855 lapack 8389********* 8390 8391* Menu: 8392 8393* Introduction to lapack:: 8394* Functions and Variables for lapack:: 8395 8396 8397File: maxima.info, Node: Introduction to lapack, Next: Functions and Variables for lapack, Prev: lapack, Up: lapack 8398 839955.1 Introduction to lapack 8400=========================== 8401 8402'lapack' is a Common Lisp translation (via the program 'f2c') of the 8403Fortran library LAPACK, as obtained from the SLATEC project. 8404 8405 8406File: maxima.info, Node: Functions and Variables for lapack, Prev: Introduction to lapack, Up: lapack 8407 840855.2 Functions and Variables for lapack 8409======================================= 8410 8411 -- Function: dgeev (<A>) 8412 -- Function: dgeev (<A>, <right_p>, <left_p>) 8413 8414 Computes the eigenvalues and, optionally, the eigenvectors of a 8415 matrix <A>. All elements of <A> must be integer or floating point 8416 numbers. <A> must be square (same number of rows and columns). 8417 <A> might or might not be symmetric. 8418 8419 'dgeev(<A>)' computes only the eigenvalues of <A>. 'dgeev(<A>, 8420 <right_p>, <left_p>)' computes the eigenvalues of <A> and the right 8421 eigenvectors when <right_p> = 'true' and the left eigenvectors when 8422 <left_p> = 'true'. 8423 8424 A list of three items is returned. The first item is a list of the 8425 eigenvalues. The second item is 'false' or the matrix of right 8426 eigenvectors. The third item is 'false' or the matrix of left 8427 eigenvectors. 8428 8429 The right eigenvector v(j) (the j-th column of the right 8430 eigenvector matrix) satisfies 8431 8432 A . v(j) = lambda(j) . v(j) 8433 8434 where lambda(j) is the corresponding eigenvalue. The left 8435 eigenvector u(j) (the j-th column of the left eigenvector matrix) 8436 satisfies 8437 8438 u(j)**H . A = lambda(j) . u(j)**H 8439 8440 where u(j)**H denotes the conjugate transpose of u(j). The Maxima 8441 function 'ctranspose' computes the conjugate transpose. 8442 8443 The computed eigenvectors are normalized to have Euclidean norm 8444 equal to 1, and largest component has imaginary part equal to zero. 8445 8446 Example: 8447 8448 (%i1) load (lapack)$ 8449 (%i2) fpprintprec : 6; 8450 (%o2) 6 8451 (%i3) M : matrix ([9.5, 1.75], [3.25, 10.45]); 8452 [ 9.5 1.75 ] 8453 (%o3) [ ] 8454 [ 3.25 10.45 ] 8455 (%i4) dgeev (M); 8456 (%o4) [[7.54331, 12.4067], false, false] 8457 (%i5) [L, v, u] : dgeev (M, true, true); 8458 [ - .666642 - .515792 ] 8459 (%o5) [[7.54331, 12.4067], [ ], 8460 [ .745378 - .856714 ] 8461 [ - .856714 - .745378 ] 8462 [ ]] 8463 [ .515792 - .666642 ] 8464 (%i6) D : apply (diag_matrix, L); 8465 [ 7.54331 0 ] 8466 (%o6) [ ] 8467 [ 0 12.4067 ] 8468 (%i7) M . v - v . D; 8469 [ 0.0 - 8.88178E-16 ] 8470 (%o7) [ ] 8471 [ - 8.88178E-16 0.0 ] 8472 (%i8) transpose (u) . M - D . transpose (u); 8473 [ 0.0 - 4.44089E-16 ] 8474 (%o8) [ ] 8475 [ 0.0 0.0 ] 8476 8477 -- Function: dgeqrf (<A>) 8478 8479 Computes the QR decomposition of the matrix <A>. All elements of 8480 <A> must be integer or floating point numbers. <A> may or may not 8481 have the same number of rows and columns. 8482 8483 A list of two items is returned. The first item is the matrix <Q>, 8484 which is a square, orthonormal matrix which has the same number of 8485 rows as <A>. The second item is the matrix <R>, which is the same 8486 size as <A>, and which has all elements equal to zero below the 8487 diagonal. The product '<Q> . <R>', where "." is the 8488 noncommutative multiplication operator, is equal to <A> (ignoring 8489 floating point round-off errors). 8490 8491 Examples: 8492 8493 (%i1) load (lapack) $ 8494 (%i2) fpprintprec : 6 $ 8495 (%i3) M : matrix ([1, -3.2, 8], [-11, 2.7, 5.9]) $ 8496 (%i4) [q, r] : dgeqrf (M); 8497 [ - .0905357 .995893 ] 8498 (%o4) [[ ], 8499 [ .995893 .0905357 ] 8500 [ - 11.0454 2.97863 5.15148 ] 8501 [ ]] 8502 [ 0 - 2.94241 8.50131 ] 8503 (%i5) q . r - M; 8504 [ - 7.77156E-16 1.77636E-15 - 8.88178E-16 ] 8505 (%o5) [ ] 8506 [ 0.0 - 1.33227E-15 8.88178E-16 ] 8507 (%i6) mat_norm (%, 1); 8508 (%o6) 3.10862E-15 8509 8510 -- Function: dgesv (<A>, <b>) 8511 8512 Computes the solution <x> of the linear equation <A> <x> = <b>, 8513 where <A> is a square matrix, and <b> is a matrix of the same 8514 number of rows as <A> and any number of columns. The return value 8515 <x> is the same size as <b>. 8516 8517 The elements of <A> and <b> must evaluate to real floating point 8518 numbers via 'float'; thus elements may be any numeric type, 8519 symbolic numerical constants, or expressions which evaluate to 8520 floats. The elements of <x> are always floating point numbers. 8521 All arithmetic is carried out as floating point operations. 8522 8523 'dgesv' computes the solution via the LU decomposition of <A>. 8524 8525 Examples: 8526 8527 'dgesv' computes the solution of the linear equation <A> <x> = <b>. 8528 8529 (%i1) A : matrix ([1, -2.5], [0.375, 5]); 8530 [ 1 - 2.5 ] 8531 (%o1) [ ] 8532 [ 0.375 5 ] 8533 (%i2) b : matrix ([1.75], [-0.625]); 8534 [ 1.75 ] 8535 (%o2) [ ] 8536 [ - 0.625 ] 8537 (%i3) x : dgesv (A, b); 8538 [ 1.210526315789474 ] 8539 (%o3) [ ] 8540 [ - 0.215789473684211 ] 8541 (%i4) dlange (inf_norm, b - A.x); 8542 (%o4) 0.0 8543 8544 <b> is a matrix with the same number of rows as <A> and any number 8545 of columns. <x> is the same size as <b>. 8546 8547 (%i1) A : matrix ([1, -0.15], [1.82, 2]); 8548 [ 1 - 0.15 ] 8549 (%o1) [ ] 8550 [ 1.82 2 ] 8551 (%i2) b : matrix ([3.7, 1, 8], [-2.3, 5, -3.9]); 8552 [ 3.7 1 8 ] 8553 (%o2) [ ] 8554 [ - 2.3 5 - 3.9 ] 8555 (%i3) x : dgesv (A, b); 8556 [ 3.103827540695117 1.20985481742191 6.781786185657722 ] 8557 (%o3) [ ] 8558 [ -3.974483062032557 1.399032116146062 -8.121425428948527 ] 8559 (%i4) dlange (inf_norm, b - A . x); 8560 (%o4) 1.1102230246251565E-15 8561 8562 The elements of <A> and <b> must evaluate to real floating point 8563 numbers. 8564 8565 (%i1) A : matrix ([5, -%pi], [1b0, 11/17]); 8566 [ 5 - %pi ] 8567 [ ] 8568 (%o1) [ 11 ] 8569 [ 1.0b0 -- ] 8570 [ 17 ] 8571 (%i2) b : matrix ([%e], [sin(1)]); 8572 [ %e ] 8573 (%o2) [ ] 8574 [ sin(1) ] 8575 (%i3) x : dgesv (A, b); 8576 [ 0.690375643155986 ] 8577 (%o3) [ ] 8578 [ 0.233510982552952 ] 8579 (%i4) dlange (inf_norm, b - A . x); 8580 (%o4) 2.220446049250313E-16 8581 8582 -- Function: dgesvd (<A>) 8583 -- Function: dgesvd (<A>, <left_p>, <right_p>) 8584 8585 Computes the singular value decomposition (SVD) of a matrix <A>, 8586 comprising the singular values and, optionally, the left and right 8587 singular vectors. All elements of <A> must be integer or floating 8588 point numbers. <A> might or might not be square (same number of 8589 rows and columns). 8590 8591 Let m be the number of rows, and n the number of columns of <A>. 8592 The singular value decomposition of <A> comprises three matrices, 8593 <U>, <Sigma>, and <V^T>, such that 8594 8595 <A> = <U> . <Sigma> . <V>^T 8596 8597 where <U> is an m-by-m unitary matrix, <Sigma> is an m-by-n 8598 diagonal matrix, and <V^T> is an n-by-n unitary matrix. 8599 8600 Let sigma[i] be a diagonal element of Sigma, that is, <Sigma>[i, i] 8601 = <sigma>[i]. The elements sigma[i] are the so-called singular 8602 values of <A>; these are real and nonnegative, and returned in 8603 descending order. The first min(m, n) columns of <U> and <V> are 8604 the left and right singular vectors of <A>. Note that 'dgesvd' 8605 returns the transpose of <V>, not <V> itself. 8606 8607 'dgesvd(<A>)' computes only the singular values of <A>. 8608 'dgesvd(<A>, <left_p>, <right_p>)' computes the singular values of 8609 <A> and the left singular vectors when <left_p> = 'true' and the 8610 right singular vectors when <right_p> = 'true'. 8611 8612 A list of three items is returned. The first item is a list of the 8613 singular values. The second item is 'false' or the matrix of left 8614 singular vectors. The third item is 'false' or the matrix of right 8615 singular vectors. 8616 8617 Example: 8618 8619 (%i1) load (lapack)$ 8620 (%i2) fpprintprec : 6; 8621 (%o2) 6 8622 (%i3) M: matrix([1, 2, 3], [3.5, 0.5, 8], [-1, 2, -3], [4, 9, 7]); 8623 [ 1 2 3 ] 8624 [ ] 8625 [ 3.5 0.5 8 ] 8626 (%o3) [ ] 8627 [ - 1 2 - 3 ] 8628 [ ] 8629 [ 4 9 7 ] 8630 (%i4) dgesvd (M); 8631 (%o4) [[14.4744, 6.38637, .452547], false, false] 8632 (%i5) [sigma, U, VT] : dgesvd (M, true, true); 8633 (%o5) [[14.4744, 6.38637, .452547], 8634 [ - .256731 .00816168 .959029 - .119523 ] 8635 [ ] 8636 [ - .526456 .672116 - .206236 - .478091 ] 8637 [ ], 8638 [ .107997 - .532278 - .0708315 - 0.83666 ] 8639 [ ] 8640 [ - .803287 - .514659 - .180867 .239046 ] 8641 [ - .374486 - .538209 - .755044 ] 8642 [ ] 8643 [ .130623 - .836799 0.5317 ]] 8644 [ ] 8645 [ - .917986 .100488 .383672 ] 8646 (%i6) m : length (U); 8647 (%o6) 4 8648 (%i7) n : length (VT); 8649 (%o7) 3 8650 (%i8) Sigma: 8651 genmatrix(lambda ([i, j], if i=j then sigma[i] else 0), 8652 m, n); 8653 [ 14.4744 0 0 ] 8654 [ ] 8655 [ 0 6.38637 0 ] 8656 (%o8) [ ] 8657 [ 0 0 .452547 ] 8658 [ ] 8659 [ 0 0 0 ] 8660 (%i9) U . Sigma . VT - M; 8661 [ 1.11022E-15 0.0 1.77636E-15 ] 8662 [ ] 8663 [ 1.33227E-15 1.66533E-15 0.0 ] 8664 (%o9) [ ] 8665 [ - 4.44089E-16 - 8.88178E-16 4.44089E-16 ] 8666 [ ] 8667 [ 8.88178E-16 1.77636E-15 8.88178E-16 ] 8668 (%i10) transpose (U) . U; 8669 [ 1.0 5.55112E-17 2.498E-16 2.77556E-17 ] 8670 [ ] 8671 [ 5.55112E-17 1.0 5.55112E-17 4.16334E-17 ] 8672 (%o10) [ ] 8673 [ 2.498E-16 5.55112E-17 1.0 - 2.08167E-16 ] 8674 [ ] 8675 [ 2.77556E-17 4.16334E-17 - 2.08167E-16 1.0 ] 8676 (%i11) VT . transpose (VT); 8677 [ 1.0 0.0 - 5.55112E-17 ] 8678 [ ] 8679 (%o11) [ 0.0 1.0 5.55112E-17 ] 8680 [ ] 8681 [ - 5.55112E-17 5.55112E-17 1.0 ] 8682 8683 -- Function: dlange (<norm>, <A>) 8684 -- Function: zlange (<norm>, <A>) 8685 8686 Computes a norm or norm-like function of the matrix <A>. 8687 8688 'max' 8689 Compute max(abs(A(i, j))) where i and j range over the rows 8690 and columns, respectively, of <A>. Note that this function is 8691 not a proper matrix norm. 8692 'one_norm' 8693 Compute the L[1] norm of <A>,that is, the maximum of the sum 8694 of the absolute value of elements in each column. 8695 'inf_norm' 8696 Compute the L[inf] norm of <A>, that is, the maximum of the 8697 sum of the absolute value of elements in each row. 8698 'frobenius' 8699 Compute the Frobenius norm of <A>, that is, the square root of 8700 the sum of squares of the matrix elements. 8701 8702 -- Function: dgemm (<A>, <B>) 8703 -- Function: dgemm (<A>, <B>, <options>) 8704 8705 Compute the product of two matrices and optionally add the product 8706 to a third matrix. 8707 8708 In the simplest form, 'dgemm(<A>, <B>)' computes the product of the 8709 two real matrices, <A> and <B>. 8710 8711 In the second form, 'dgemm' computes the <alpha> * <A> * <B> + 8712 <beta> * <C> where <A>, <B>, <C> are real matrices of the 8713 appropriate sizes and <alpha> and <beta> are real numbers. 8714 Optionally, <A> and/or <B> can be transposed before computing the 8715 product. The extra parameters are specifed by optional keyword 8716 arguments: The keyword arguments are optional and may be specified 8717 in any order. They all take the form 'key=val'. The keyword 8718 arguments are: 8719 8720 'C' 8721 The matrix <C> that should be added. The default is 'false', 8722 which means no matrix is added. 8723 'alpha' 8724 The product of <A> and <B> is multiplied by this value. The 8725 default is 1. 8726 'beta' 8727 If a matrix <C> is given, this value multiplies <C> before it 8728 is added. The default value is 0, which implies that <C> is 8729 not added, even if <C> is given. Hence, be sure to specify a 8730 non-zero value for <beta>. 8731 'transpose_a' 8732 If 'true', the transpose of <A> is used instead of <A> for the 8733 product. The default is 'false'. 8734 'transpose_b' 8735 If 'true', the transpose of <B> is used instead of <B> for the 8736 product. The default is 'false'. 8737 8738 Examples: 8739 8740 (%i1) load (lapack)$ 8741 (%i2) A : matrix([1,2,3],[4,5,6],[7,8,9]); 8742 [ 1 2 3 ] 8743 [ ] 8744 (%o2) [ 4 5 6 ] 8745 [ ] 8746 [ 7 8 9 ] 8747 (%i3) B : matrix([-1,-2,-3],[-4,-5,-6],[-7,-8,-9]); 8748 [ - 1 - 2 - 3 ] 8749 [ ] 8750 (%o3) [ - 4 - 5 - 6 ] 8751 [ ] 8752 [ - 7 - 8 - 9 ] 8753 (%i4) C : matrix([3,2,1],[6,5,4],[9,8,7]); 8754 [ 3 2 1 ] 8755 [ ] 8756 (%o4) [ 6 5 4 ] 8757 [ ] 8758 [ 9 8 7 ] 8759 (%i5) dgemm(A,B); 8760 [ - 30.0 - 36.0 - 42.0 ] 8761 [ ] 8762 (%o5) [ - 66.0 - 81.0 - 96.0 ] 8763 [ ] 8764 [ - 102.0 - 126.0 - 150.0 ] 8765 (%i6) A . B; 8766 [ - 30 - 36 - 42 ] 8767 [ ] 8768 (%o6) [ - 66 - 81 - 96 ] 8769 [ ] 8770 [ - 102 - 126 - 150 ] 8771 (%i7) dgemm(A,B,transpose_a=true); 8772 [ - 66.0 - 78.0 - 90.0 ] 8773 [ ] 8774 (%o7) [ - 78.0 - 93.0 - 108.0 ] 8775 [ ] 8776 [ - 90.0 - 108.0 - 126.0 ] 8777 (%i8) transpose(A) . B; 8778 [ - 66 - 78 - 90 ] 8779 [ ] 8780 (%o8) [ - 78 - 93 - 108 ] 8781 [ ] 8782 [ - 90 - 108 - 126 ] 8783 (%i9) dgemm(A,B,c=C,beta=1); 8784 [ - 27.0 - 34.0 - 41.0 ] 8785 [ ] 8786 (%o9) [ - 60.0 - 76.0 - 92.0 ] 8787 [ ] 8788 [ - 93.0 - 118.0 - 143.0 ] 8789 (%i10) A . B + C; 8790 [ - 27 - 34 - 41 ] 8791 [ ] 8792 (%o10) [ - 60 - 76 - 92 ] 8793 [ ] 8794 [ - 93 - 118 - 143 ] 8795 (%i11) dgemm(A,B,c=C,beta=1, alpha=-1); 8796 [ 33.0 38.0 43.0 ] 8797 [ ] 8798 (%o11) [ 72.0 86.0 100.0 ] 8799 [ ] 8800 [ 111.0 134.0 157.0 ] 8801 (%i12) -A . B + C; 8802 [ 33 38 43 ] 8803 [ ] 8804 (%o12) [ 72 86 100 ] 8805 [ ] 8806 [ 111 134 157 ] 8807 8808 8809