Docsity
Docsity

Prepare-se para as provas
Prepare-se para as provas

Estude fácil! Tem muito documento disponível na Docsity


Ganhe pontos para baixar
Ganhe pontos para baixar

Ganhe pontos ajudando outros esrudantes ou compre um plano Premium


Guias e Dicas
Guias e Dicas

Maxima Book Chapter1, Manuais, Projetos, Pesquisas de Física

chapter 1 book Maxima

Tipologia: Manuais, Projetos, Pesquisas

2013

Compartilhado em 21/04/2013

edney-granhen-8
edney-granhen-8 🇧🇷

4.8

(4)

18 documentos

Pré-visualização parcial do texto

Baixe Maxima Book Chapter1 e outras Manuais, Projetos, Pesquisas em PDF para Física, somente na Docsity! Introduction to Maxima Maxima is a symbolic-based mathematical software providing a number of functions for algebraic manipulation, calculus operations, matrix and linear algebra, and other mathematical calculations. Maxima web page The Maxima web page is located at: http://maxima.sourceforge.net/ Read the description of Maxima shown in this page. The page also includes a number of links including a Download link. Download and install Maxima in your computer as indicated in the download page. The Maxima web page also includes a Documentation link with a number of tutorials on the use of Maxima. xMaxima and wxMaxima The figure below shows the listing of programs and documents available for Maxima 5.14.0 in a Windows Vista installation. You will notice that there are two possible instances of Maxima called XMaxima and wxMaxima. While both allow the user access to the Maxima commands, the difference is in the graphic user interface (GUI) used to communicate with Maxima. XMaxima An example of the XMaxima interface is shown in Figure 1.1. The top of the GUI is the input window for Maxima commands. The lower part is a display of a Maxima Primer document providing the user with some information about getting started with Maxima. In between the top and lower part of the display you will find buttons labeled File, Back, 1-1 © Gilberto E. Urroz, 2008 Forward, Edit, Options, and Url: The last button refers to the file specification shown in the field immediately to its right. In this case, the file specification reads: file:/C:/PROGRA~/MAXIMA~1.0/share/maxima/514~1.0/xmaxima/INTRO~1.HTM The full reference to this file should be: file:/C:/Program Files/Maxima-5.14.0/share/maxima/5.14.0/xmaxima/intro.html The XMaxima GUI abbreviates some of the sub-folders in the first file specification producing the reference shown above, which could be a bit confusing. The full file specification shows the location of the file being shown in the bottom window of the XMaxima GUI. This html file is located in the Maxima installation as indicated above. Figure 1.1. XMaxima starting GUI 1-2 © Gilberto E. Urroz, 2008 Click-off the graphical windows before continuing with the other commands in the Maxima Primer. wxMaxima wxMaxima uses an interface as shown in Figure 1.2, below. Figure 1.2. The wxMaxima GUI. This interface is more sophisticated than that of XMaxima for the following reasons: ● wxMaxima produces true two-dimensional mathematical output ● wxMaxima provides most Maxima commands in menus (e.g., Equations, Algebra, etc.) ● Some commands can be activated by using the buttons shown at the bottom of the interface, e.g., Simplify, Factor, etc. ● wxMaxima provides dialogues to enter parameters of selected commands. ● wxMaxima maintains a command line history buffer where previously used commands can be accessed, repeated, or edited. ● wxMaxima allows mixing text with mathematical expressions to produce printable documents. ● The current version of wxMaxima supports simple animations (to see the current version use the menu item Help > About). 1-5 © Gilberto E. Urroz, 2008 A web page for wxMaxima is available here: http://wxmaxima.sourceforge.net/wiki/index.php/Main_Page For hints on the efficient use of wxMaxima visit: http://wxmaxima.sourceforge.net/wiki/index.php/Howto NOTE: Because of the additional features available in wxMaxima, we will use this GUI exclusively to present the examples contained in this and subsequent chapters. We will not be using XMaxima anymore in this or subsequent chapters. wxMaxima menus Take some time to explore the different menus in the wxMaxima GUI: ● The File menu contains items typically found in windows-based applications such as Open, Read file, Save, Save As..., Export to HTML, Select File, Print, and Exit. Some items in the File menu, such as Load package, Batch file, and Monitor File, are proper of wxMaxima. ● The Edit menu contains typical commands such as Copy, Cut, and Paste, as well as others that are proper for wxMaxima. ● The Maxima menu contains items that allow the user to control the operation of Maxima. ● The Equations, Algebra, Calculus, Simplify, Plotting, and Numeric menus provide mathematical functions that are entered using dialogues. ● The Help menu contains several items of interest such as: ○ Maxima help: opens the Maxima Manual window with description and examples of Maxima commands. ○ Describe: produces a dialogue where the user can enter the name of a specific command. Try, for example, plot3d, and press OK. The dialogue will access the section of the Maxima Manual corresponding to the requested command. ○ Example: enters a series of examples of applications of the requested command into the wxMaxima interface. Try, for example, integrate, and press OK. ○ Apropos: use this dialogue to enter a keyword to search for a command that is similar to the keyword. For example, if you were seeking information on integration, you could enter the word integra, to get a listing of commands that may be related to integra. Then, you can use Describe or Example with one of the commands listed. ○ Show tip: shows tips on the use of Maxima. ○ Build info: provides information on the current version of Maxima. ○ Bug report: provides a web site where users can report errors in the operation of Maxima, or unexpected results of some operations. These “bugs” are reported to the programming team and solutions to them (if available) get incorporated in the new versions of the software. ○ About: provides the current version of wxMaxima. Notice that the versions of Maxima and vxMaxima are not necessarily the same. My installation, at the 1-6 © Gilberto E. Urroz, 2008 moment of typing this book, showed Maxima version 5.14.0 and wxMaxima version 0.7.4. Remember that Maxima is the computer program that performs the mathematical calculations, while wxMaxima is the graphics user interface (GUI). wxMaxima tool bar The wxMaxima GUI provides a tool bar with the following buttons: (1) Open session (2) Save session (3) Print document (4) Configure wxMaxima (5) Copy selection (6) Delete selection (7) Insert text (8) Insert input group (9) Interrupt current computation (10) Show Maxima help (same as menu item Help > Maxima help) Using the INPUT line The INPUT line in the wxMaxima interface can be used for a variety of purposes such as: ● To perform a calculation, e.g., sqrt(1+3.5^2)/sin(%pi/6); ● To define one or more variables, e.g., a:2; b:2; ● To define a function, e.g., f(x):=sqrt(1+x^2); ● To evaluate a function, e.g., f(2/3); ● To produce a plot, e.g., plot2d(f(x),[x,-2,2]); ● To enter other type of operations, e.g., a derivative: diff(t^2*sin(t), t); Here are some observations from the examples shown above: ● To enter the value of a variable use a colon (:) ● To define a function use a colon followed by the equal sign (:=) ● Maxima expressions end with a semi-colon. If you forget to enter the semi-colon in the INPUT line, wxMaxima will enter it for you. This is additional information useful when entering expressions: ● Variable or function names must start with a letter, and may include letters, numbers, and undersign, e.g., vx:2; x2:3; y_2:5; Initial_Velocity:-2.5; 1-7 © Gilberto E. Urroz, 2008 Using the button panel The bottom of the xwMaxima GUI contains 12 buttons that can be used for common operations. The collection of buttons is shown in the figure below, with the Maxima commands associated with them. Buttons (1) through (4), and (7) through (10) operate on an expression typed in the INPUT line before pressing the corresponding button. Buttons (5), (6), (11), and (12) trigger dialogues to performed the associated operations. The operation of the buttons, with appropriate examples, is shown next. (1) Simplify: simplifies algebraic operations, e.g., (x+2)*(x-2); [Simplify] (2) Simplify(r): simplifies expressions containing logs, exponentials, and radicals, e.g., (%e^x-1)/(%e^(x/2)+1); [Simplify(r)] (3) Factor: factors an algebraic expression, e.g., x^2+y^2-2*x*y; [simplify(r)] (4) Expand: expands an algebraic expression, e.g., (x+1)*(x-1)*(x^2+1); [Expand] (5) Solve...: solves an equation, e.g., (6) Plot 2D...: produces an x-y (two dimensional) plot, e.g., 1-10 © Gilberto E. Urroz, 2008 (7) Simplify(tr): trigonometric simplification in terms of sin and cos,e.g., tan(x) [Simplify (tr)] (8) Expand(tr): expands a trigonometric expression, e.g., sin(x+y) [Expand(tr)] (9) Reduce(tr): convert powers of trigonometric functions to those of multiples of the angle, e.g., x+3*cos(x)^2-sin(x)^2; [Reduce(tr)] (10)Rectform: produces the rectangular form of a complex number, e.g., 1/(2+3*%i); [Rectform] (11)Solve ODE...: solves a 1st order or 2nd order ordinary differential equation, e.g., Note: Derivatives are written using 'diff(y,x,n) to represent d n y dxn . 1-11 © Gilberto E. Urroz, 2008 (12) Plot3D: produces a three-dimensional plot, e.g., Using the full button panel The button panel described above is referred to as the Basic button panel. It is possible to activate a Full button panel by using the menu option Edit > Configure. This activates a wxMaxima configuration window as shown next: 1-12 © Gilberto E. Urroz, 2008 (16) integrate: calculates an integral (17) limit: calculates a limit 1-15 © Gilberto E. Urroz, 2008 (18) taylor: calculates a Taylor series for an expression: (19) subst: substitute an expression into a variable name (20) map: maps a function to a list 1-16 © Gilberto E. Urroz, 2008 Using Greek letters In order to write Greek letters in Maxima you need to have the font SPIonic installed in your computer. You can download this font from: http://www.drshirley.org/fonts/SPIonic.ttf After installing the font in your computer, you need to select it to show Greek characters in your wxMaxima interface. Proceed as follows: ● Select the menu option Edit>Configure ● Click on the Style tab ● Check-off the Use greek font entry, and select SPIonic ● Press OK To enter Greek letters type the English name of the letter in an expression, or precede the name with the percentage symbol (%), e.g., factor(beta^2-1); rectform(1/(%alpha+%beta*%i); expand((alpa-1)*(beta+gamma)); expand((%alpha-1)*(%beta+%gamma)); Notice the difference between typing gamma and %gamma in the last two examples. Typing gamma (without %) produces the upper-case Greek letter Γ which represents the Gamma function from mathematics, whereas, %gamma produces Euler constant γ, defined, as the limit as n , of the quantity ∑ k=1 n 1 k −ln n  . To illustrate the use of the Gamma function try the following exercises in wxMaxima: gamma(2.5); plot2d(gamma(x),[x,0.5,3.0]); Examples from the Equations menu In this section we present some examples of applications from the Equations menu. We use it to illustrate the use of menus such as Equations, Algebra, Calculus, etc. A listing of the available applications in the Equations menu is shown below: Try the following examples by selecting entries from this menu: ● Solve ... same as: solve([x^2+32*x-160=0], [x]); 1-17 © Gilberto E. Urroz, 2008 ● Initial value problem (2) ... Initial value problem for second-order ODE. Uses two steps: first Solve ODE ..., then Initial value problem (2). Equivalent to: ode2('diff(y,x)+y=x,y,x); ic1(%,x=0,y=1); ● Boundary value problem ... Boundary value problem for second-order ODE. Uses two steps: first Solve ODE ..., then Boundary value problem. Equivalent to: ode2('diff(x,t,2)+x=sin(t),x,t); ic2(%,t=0,x=1,'diff(x,t)=-1); 1-20 © Gilberto E. Urroz, 2008 ● Solve ODE with Laplace – Solve an ordinary differential equation using Laplace transforms. Equivalent to desolve('diff(x(t),t,2)+x(t) = sin(t),x(t)); ● At value ... - Replace a variable in an expression. In this example the replacement takes place in the solution to an ODE. Managing a wxMaxima session In this section we illustrate the use of inputs and outputs and of the command history to perform operations on algebraic expressions. Inputs and outputs If you have been trying the examples shown above, your wxMaxima interface would show a number of inputs and outputs. Inputs are shown by the prompt (%i...) with an associated number, e.g., Outputs are shown by the prompt (%o...) with an associated number, e.g., 1-21 © Gilberto E. Urroz, 2008 Restarting Maxima Since the inputs and outputs in your wxMaxima interface will be different than this example, let's restart Maxima by using the menu option Edit > Restart Maxima, and press [OK] at the prompt. This action will clear Maxima's memory and reset the interface to that shown in Figure 1.2 (see above). At this point, only input (%1) will be available. Let's try the following session. Type the commands as shown next: Operations on input and output references Now, we are going to use the input and output references to perform operations. Try the following commands: Thus, references such as %i1, %o1, etc., act like variable names that can be operated upon as any other variable. An alternative would be to actually assign variable names to the expressions entered. To try this approach we will also illustrate the use of the command history for performing operations. 1-22 © Gilberto E. Urroz, 2008 Reloading your session Restart Maxima (Edit > Restart Maxima) and use the menu item File > Open to browse your computer file system. For example, in a Windows Vista environment, I located the file I want to load in the following dialog form: In this case, Maxima opens the file and executes every command, stopping at input (%i15) where it asks again about the value of coefficient w in variable myODE1. Repeating the response nonzero allows Maxima to continue evaluating the file to recover the entire session saved. Printing your session To produce a hard-copy of your session use the menu item File > Print. Loading a session without executing it An alternative way to load a saved session is by using the menu item File > Read File. Using this option will list all the commands in the session without executing it. The commands will be available in the command history, and could be reactivated by using the up- and down-arrow keys, and pressing [ENTER] when the proper command is in the INPUT line. Interrupting a calculation If, for some reason, wxMaxima seems to be hung up in a calculation, you can interrupt the processing by using the menu item Maxima > Interrupt, or type Cntl-G. Alternatively, use the interrupt button in the menu bar: 1-25 © Gilberto E. Urroz, 2008 Ending your session To end your session use the menu item File > Exit, or click the [x] in the upper right corner of the wxMaxima window. This action produces the dialog form shown below. Select [OK] if you don't want to save your current session. Otherwise, press [Cancel], save your session as indicated above, and exit wxMaxima once more. Formatting your session This section includes some examples of the use of text for commenting your session, as well as inserting sections and titles in your session. Inserting text (comments) in wxMaxima To enter text in wxMaxima use the menu item Edit > Insert > Text. The characters /* will be shown above the next input reference. Type one or more lines of text at the current cursor location. This line (or lines) of text can be used to comment your session. An example is shown next: Text lines contained in saved session files get loaded with the rest of the commands when using File > Open or File > Read file. Inserting a title or a section in wxMaxima To insert a title use the menu item Edit > Insert > Title. This operation is similar to inserting text, except that the text is provided in a larger font. To insert a section use the menu item Edit > Insert > Section. This operation is also similar to inserting text, except that the text is provided in a larger font and with an underline. The following example shows a title and a section insertion in a wxMaxima session. 1-26 © Gilberto E. Urroz, 2008 Inserting input The menu item Edit > Insert > Input produces a prompt input as illustrated in the following example: If you enter a new command in the INPUT line, then the statement in front of the input prompt remains unevaluated. However, if you click on the input prompt statement, thus selecting it, and do a right-click, you can evaluate the command by selecting the option Re-evaluate input. In this case, the input gets evaluated as follows: Clearing the screen The option Edit > Clear screen clears the current wxMaxima screen, showing at the top of the screen the current input reference, e.g., 1-27 © Gilberto E. Urroz, 2008 Creating a batch file In an earlier exercise we saved a file called myFirstMaximaSession.wxm. In this section we will show you how to create a Maxima batch file out of your saved session. In order to create a batch file we need to edit the session file using a text editor. In this example I will use the Notepad++ text editor to open the session file. Notepad++ is available at http://notepad-plus.sourceforge.net/uk/site.htm . When opened with Notepad ++, the file myFirstMaximaSession.wxm looks as follows: Notice that you are warned in the very first line of the file to not edit the file by hand. This is for the wmx file. If you change anything in the file it may not be readable by wxMaxima again. The way to proceed is to save the file as a batch file, with the .mac suffix. Save it, for example, as myFirstMaximaBatchFile.mac, and edit it to look as shown below. This is the batch file that includes a number of comment lines (text between /* and */), and Maxima commands. 1-30 © Gilberto E. Urroz, 2008 To load a batch file use the menu item File > Batch file, and select the proper file to load. The result of the batch file operation will be shown in your wxMaxima window. Notice, however, that the comment lines are not shown in the wxMaxima window. If you want to show explanatory text from your batch file, you may want to replace the comments by a string, making sure that the string ends in a dollar sign ($) rather than in a semi-colon (;). 1-31 © Gilberto E. Urroz, 2008 With theses changes, the output in the wxMaxima is now well documented, although the comment strings are now part of the input (with no output), rather than inserted text. Part of the output from the batch file is shown below: A batch file can also be created from scratch. Simply type the Maxima commands in a text file and save it with the suffix .mac. Here is an example of a batch file created from scratch: 1-32 © Gilberto E. Urroz, 2008 Nouns and verbs To understand the use of the argument nouns in the examples above, please open the Maxima Manual, available through the menu item Help > Maxima help, and find section 6.3 Nouns and verbs in the Contents tab, as shown in the figure below. Read this section in the Manual to understand the idea of verbs and nouns, as well how to convert form one to the other. Online help In an earlier section we presented the different options available in the Help menu. A quick way to obtain help is by using the ?? operator. For example, if you are interested in finding information about the function eval, use: Maxima reply by listing a number of entries that include the particle eval, and requesting additional input from the user. At this point, the user can enter a particular number referring to the 7 options listed, or enter the particles all or none. Enter none to stop the online help process. 1-35 © Gilberto E. Urroz, 2008 The following is another example related to the function integrate. 1-36 © Gilberto E. Urroz, 2008
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved