Maxima by Example, Ch. 2, Plots, Files, Read, Write, and Fit

Ted Woollett



Chapter 2 has been revised to include a large section on working with files from within Maxima. The new software file mfiles.mac includes many useful file manipulation functions. The small file mfiles1.lisp is loaded in by mfiles.mac.

Since Jan. 19, 2012, all updates reflect the necessity of using the complete file path (in ver. 5.26.0 thru 5.31) for all of the "file name slots" in the file manipulation functions defined in mfiles.mac. To save typing, one can define (in your maxima-init.mac file) a function mkp (make path) which makes use of a global parameter bpath which is a string which provides the base of the path to your work folder. One can then use mkp("myfile1.txt") instead of "c:/work2/myfile1.txt" as an argument to a file name slot. This is discussed at length in the introduction to the File section of chapter two.

This chapter has many examples of the use of plot2d. Before you read and try out the examples, run the appropriate plot2dtest file available above the Ch. 1 section. You may need to use one of the draw2d substitutes, depending on the version of Maxima you are using.

  1. --mbe2plotfit.pdf : Jan. 6, 2014, Maxima 5.31.2, 40 pages
  2. --mbe2plotfit.tex : Jan. 6, 2014, Latex code file
  3. --mbe2toc.txt : Detailed table of contents, Jan. 6, 2014
  4. --mbe2code.txt : Code file: Jan. 6, 2014, Maxima 5.31.2
  5. --qplot.mac : Maxima code for quick plots, Oct. 3, 2011, Maxima 5.25.1
  6. --mfiles.mac : Maxima code for file work, Jan. 19, 2012, Maxima 5.28.0
  7. --mfiles1.lisp : Lisp code loaded by mfiles.mac, Oct. 3, 2011, Maxima 5.25.1
  8. --coffee.dat : Coffee cooling tab separated data file: July, 13, 2009

Chapter 2 Topics

Introduction to plot2d

  1. First Steps with plot2d
  2. Parametric Plots
  3. Line Width and Color Controls
  4. Discrete Data Plots: Point Size, Color, and Type Control
  5. Plot of a Discontinuous Function
  6. Using qplot for Quick Plots of One or More Functions
  7. Multiple Plots Using the Embedded Option

Working with Files Using the Package mfiles.mac

  1. file_search, probe_file, ls, and dir
  2. ftype, file_length, file_info
  3. print_file, print_lines
  4. rename_file, delete_file, copy_file, file_convert, ftext_replace
  5. Break file lines with pbreak(), email reply with reply_to
  6. Search File with search_file
  7. Search Multiple files with search_mfiles
  8. read_data, read_text, write_data, with_stdout

Least Squares Fit to Experimental Data

  1. Syntax of lsquares_estimates
  2. Coffee Cooling Model
  3. Experiment Data for Coffee Cooling
  4. Least Squares Fit of Coffee Cooling Data

The new function read_data is designed to work correctly with unix, mac, and windows type text files. read_data uses the new function read_line which is a replacement for the current Maxima function readline.

The new function print_file correctly reads unix, mac, and windows files and is a replacement for the current Maxima function printfile.