1 / 40

Plotting in Maxima

Plotting in Maxima. There are two packages currently used for plotting in Maxima. gnuplot xMaxima There may be some problems plotting if Maxima is not completely and correctly installed. We will use gnuplot most of the time. There are many ways to plot in Maxima.

maxwellb
Download Presentation

Plotting in Maxima

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Plotting in Maxima

  2. There are two packages currently used for plotting in Maxima • gnuplot • xMaxima • There may be some problems plotting if Maxima is not completely and correctly installed. • We will use gnuplot most of the time.

  3. There are many ways to plot in Maxima • Recall the function f(x) defined as SIN(x) * SQRT(1 + X^3) that we used in our spreadsheet example using Excel. We can plot this in Maxima, also.

  4. One way to plot in Maxima: • Example: plot2d(sin(x)*sqrt(1 + x^3), [x, 1, 20]);

  5. The Maxima system has an interface to the external gnuplot plotting software. • What’s gnu? • An effort of the free software foundation • The creator of the GNU General Public License

  6. The GPL • The GNU Public license says, basically • You can use the software • You can copy it • You can bundle it commercially • You can sell it • You can sell services (installation, maintenance, etc.) • You can modify it, but …

  7. The GPL • The GNU Public license says, basically • You can use the software • You can copy it • You can bundle it commercially • You can sell it • You can sell services (installation, maintenance, etc.) • You can modify it, but • You have to make the code available to anyone

  8. We will use the GNU plotting routines almost exclusively • The next example, do the plot, but save it to a file. • What type of file? • jpg

  9. We did plot2d(sin(x)*sqrt(1 + x^3), [x, 1, 20]; before – now save graph to a file. load(draw); plot2d(sin(x)*sqrt(1 + x^3), [x, 1, 20], [gnuplot_term, png], [gnuplot_out_file, "F:\sin-sqrt-graph.jpg"]);

  10. Something is created

  11. How can we open it? • This can now be shared with any other application that can read jpg files. • A standard for scientific description of data.

  12. How can we open it? A browser

  13. Other applications can open file

  14. Lets’ go over the syntax plot2d(sin(x)*sqrt(1 + x^3), [x, 1, 20], [gnuplot_term, png], [gnuplot_out_file, "F:\sin-sqrt-graph.jpg"]); • Code to print to a file is in teal color • Notice that everything inside the closing right parenthesis is delimited by square brackets [ and ]

  15. What is delimited by [ and ] ? • Lists • Arrays • The Maxima evaluation software uses lists to indicate optional arguments

  16. [gnuplot_term, png], [gnuplot_out_file, "F:\sin-sqrt-graph.jpg"]); • First term of the list is in red • It sets the value of the optional argument of gnuplot_term to png, for sending data

  17. [gnuplot_term, png], [gnuplot_out_file, "F:\sin-sqrt-graph.jpg"]); • First term of the list is in red • It sets the value of the optional argument of gnuplot_term to png, for sending data • Second term of the list is in teal color • It sets the optional argument – the name of the output file, gnuplot_out_file, to"F:\sin-sqrt-graph.jpg"

  18. gnuplot • Extremely powerful • Many options, probably too many to master completely • Use the examples here as a prototype for your work

  19. Plotting discrete points in Maxima

  20. Another graphing example • Plotting a discrete set of points

  21. In Maxima: A : array(flonum, 20, 2); for i: 0 step 1 thru 19 do A[i,0]: i; for i : 0 step 1 thru 19 do A[i,1] :sin(i)* sqrt(1 + i ^3); We need flonum to provide floating point numbers to the graphics routine

  22. Can do the two loops together as for i: 0 step 1 thru 19 do { A[i,0]: i , A[i,1] :sin(i)* sqrt(1 + i ^3) };

  23. Now draw the points load(draw); C:/PROGRA~1/MAXIMA~1.1/share/maxima/5.18.1/share/draw/draw.lisp draw2d(points(A));

  24. Note the cursor position in bottom left

  25. Note the cursor position in bottom left

  26. Maxima does calculus

  27. Let’s try some calculus f(x):= sin(x)*sqrt(1 +x^3)$ Now differentiate with respect to x g(x):=diff(f(x),x)$ Plot them both plot2d([f(x),g(x)] , [x,1,20]); Note the use of a list for f(x), g(x)

  28. Where are the maxima and minima? • We can use Maxima to find the maxima (and minima) • Find the critical points – where the derivative is 0 • Remember – gnuplot tracks cursor position • Move the cursor to where the derivative appears to be 0 – these are the critical points (approximately)

  29. Let’s solve g(x) = 0

  30. Maxima can’t “solve” g(x) = 0 for x

  31. Maxima can’t do everything • It can’t solve such general equations • Equation solving usually requires equations with algebraic functions only.

More Related