19 views

Uploaded by luciange

maxima examples

- Fundamentals of Math
- AlgebraicReasoningLessons.ppt1
- bhumd-hgiow.pdf
- 1.3 Order of Operations
- Ramanujan's series for π a survey.pdf
- GNU Units Manual
- product of powers
- Homework Sol
- Untitled
- Introduction to Finite Element Methods (2001)(en)(489s)
- CHSEM2
- study notes 1
- Other School 2 EM P1
- multiplication lesson plan
- 35507446 Rancangan Pengajaran Tahunan Matematik
- Discoverer Calculated Functions - How to Guide
- sympy-0.7.2
- HidalgoHausmann_PNAS_2009_PaperAndSM
- Operator Precedence in Java
- cipher quick math game 5

You are on page 1of 4

**First Examples Share This Page
**

First Examples

— P. Lutus — Message Page —

Copyright © 2007, P. Lutus

Preliminaries | More Substance | Moving On

(double-click any word to see its deﬁnition)

Preliminaries

Here are some useful hints for using wxMaxima and Maxima.

To get help with a name used by Maxima, just type "? name":

? integrate

(wxMaxima launches a Maxima help dialog focused on the term "integrate")

? =

(sometimes the help finder doesn't match your entry exactly, but there will be a list of

matches at the left to choose from)

Maxima uses some nonintuitive syntax for assigning a value to a label. Here are the rules:

Use ":" to assign a value to a variable: a : 3;, a : b; etc.

Use "=" to compare values for equality: a = 3;,a = b; etc., also "<" (less than),">" (greater than) and "#" (unequal)

Use ":=" to deﬁne a function: f(x) := x^2;

Use "kill(name);" to erase a previous assignment of a variable or function: kill(a);, kill(f);

Use "kill(all);" to erase all assignments.

Experiment with these assignment and comparison operators until you understand how they work:

a : 3; (spaces are optional, could be a:3;)

3

a

3

a + 3;

6

a * a;

9

f(x) := x^2;

f(x):=x

2

f(x);

x

2

f(9);

81

b : 4;

4

a - b;

-1

is(a = b); (think: "is a equal to b?")

false

is(a < b); (think: "is a less than b?")

true

is(a # b); (think: "is a not equal to b?")

true

kill(all); (this erases all our assignments)

done

is(a < b);

unknown

Hey! That was an intelligent answer! We erased all the assignments, so variables a and b are now undeﬁned, so whether a < b (whether

a is less than b) is ... well ... unknown. And the program knew it, and said so!

More Substance

02. First Examples http://arachnoid.com/maxima/ﬁrst_examples.html

1 din 4 02.11.2014 23:19

Here is some simple arithmetic and algebra entered at the keyboard:

2^32

4294967296

111111111^2 (that's a row of nine 1s)

12345678987654321 (who would have guessed?)

sales_tax : 0.085 (that's 8.5%)

0.085

cost : 40 (the before-tax price of something)

40

cost * sales_tax (compute the tax on the cost)

3.4

cost * 1 + sales_tax (does this give the total amount?)

40.085 (apparently not)

cost * (1 + sales_tax) (does this give the total amount?)

43.4 (yes)

Notice about this example that the result depends on something called the "order of operations". In a mathematical expression without

parentheses, there is an established order of operations:

Powers and roots. 1.

Multiplication and division. 2.

Addition and subtraction. 3.

In that order.

To force a particular sequence of operations that diﬀers from the natural order, use parentheses to group the desired operations together in

your expressions. Operations inside parentheses are performed ﬁrst, followed by operations outside parentheses. And there can be more than

one layer of parentheses.

In this example:

((a+b)*(c+d))^n

First a is added to b, and c added to d. Then those two subgroups are multplied together. Then the result is raised to the power n. This example

forces an opposite of the normal order of precedence on its terms. Remember when in doubt about how your expressions will be evaluated,

group terms using parentheses to clarify your intentions.

Some more algebra examples:

%pi; (this is how we identify π to Maxima)

π (this will appear as a Greek letter only if a Greek font has been installed, see

"Installation")

ﬂoat(%pi); (meaning "give me the numerical value")

3.141592653589793

fpprec:1000; (increase the "floating point precision" or "fpprec")

1000

ﬂoat(%pi); (again, "give me the numerical value")

3.141592653589793 (no change in the number of displayed places. Why?)

bﬂoat(%pi); ("bfloat" means "big float")

3.1415926535897932384626433832[943 digits]3001927876611195909216420196b0 (better, but not what I

was hoping for)

set_display(ascii); (this is a special wxMaxima setting that forces all the digits to be printed out)

set_display(ascii);

bﬂoat(%pi); (try again)

(a list of 1000 digits of π)

set_display(xml); (return to the default way of displaying things)

set_display(xml);

The "fpprec" and "set_display(ascii)" settings only aﬀect ﬂoating-point numbers, integers are always printed out fully:

50!;

30414093201713378043612608166064768844377641568960512000000000000

500!;

(a huge list of digits)

Here's an example that uses a Maxima function, plus one we deﬁne as well:

apply("+",[1,2,3,4,5]);

15

This gives me an idea.

average(a) := apply("+",a)/length(a);

02. First Examples http://arachnoid.com/maxima/ﬁrst_examples.html

2 din 4 02.11.2014 23:19

There is another way to write this function:

average(a) := sum(a[i],i,1,length(a))/length(a)

average([1,2,3,4,5,6,7,8,9,10]);

ﬂoat(%);

5.5

Hold on. What does "%" mean? Well, it refers to the prior result. If you are creating intermediate results and want to refer to the immediate prior

result, use "%". There are variations on this operator that can be used to get any arbitrary prior result — examine the help entry for "%".

Here's something we need to watch out for:

set_display(ascii);

radians(x) := x * %pi / 180;

x %pi

radians(x) := -----

180

Hold on again. Why did the display revert to a more primitive state (not drawing equations nicely or rendering Greek letters)? It's because we

forgot to return to "set_display(xml)", so let's ﬁx that:

set_display(xml);

set_display(xml);

radians(x) := x * %pi / 180;

Okay, new rule: if you want to list all the digits of a ﬂoating-point value, use "set_display(ascii);". If you want wxMaxima to render equations and

functions in a pretty way, use "set_display(xml);". It seems you can't have both at the same time.

? diﬀ

(description of "diff" and related functions from the Maxima help file)

f(x) := x^3

f(x):=x

3

According to my Calculus textbook, the ﬁrst derivative of x

3

should be 3 x

2

. Let's see.

diﬀ(f(x),x)

3 x

2

diﬀ(f(x),x,2)

6 x

diﬀ(f(x),x,3)

6

diﬀ(f(x),x,4)

0

All correct. When using the "diﬀ()" function, remember we can tell it which derivative to acquire by adding an optional third argument — 2 for

second derivative, 3 for third derivative, etc.. Now let's try the function that does the opposite of derivation.

integrate(f(x),x);

integrate(integrate(f(x),x),x);

integrate(integrate(integrate(f(x),x),x),x);

Okay, those are the right results, but it seems we can't simply specify which integral to obtain as we can with taking derivatives, instead we must

nest our calls to "integrate". One could write a recursion function to do this to any arbitrary depth, but that's an advanced topic — later for that.

02. First Examples http://arachnoid.com/maxima/ﬁrst_examples.html

3 din 4 02.11.2014 23:19

sum(n,n,1,9);

45

sum(n^2,n,1,9);

285

The function "sum()" adds together the results of an expression or function, according to the provided index values.

product(n,n,1,9);

362880

product(n^2,n,1,9);

131681894400

"product()" is somewhat like "sum()", but it multiplies the results together instead of adding them. Given how multiplication works, the above

example might as well be:

product(n,n,2,9);

362880

product(n^2,n,2,9);

131681894400

Do you see why? It's because the original form multiplied the result by 1, a rather pointless operation.

Moving On

I ask that my readers feel free to explore what this program oﬀers. Type in equations that you are curious about, create functions to encapsulate

things you have discovered. Explore.

In the next section, I will show how to load and save your work, and how to put the solution to one problem in a wrapper that makes it available to

solve others.

Home | Mathematics | * Maxima | 02. First Examples Share This Page

02. First Examples http://arachnoid.com/maxima/ﬁrst_examples.html

4 din 4 02.11.2014 23:19

- Fundamentals of MathUploaded byNorman Serna
- AlgebraicReasoningLessons.ppt1Uploaded byBill Laulo
- bhumd-hgiow.pdfUploaded bysaleh
- 1.3 Order of OperationsUploaded byChris Goldie Lorezo
- Ramanujan's series for π a survey.pdfUploaded byx
- GNU Units ManualUploaded bybariumbitmap
- product of powersUploaded byapi-261958886
- Homework SolUploaded byAbdurraouf Aghila
- UntitledUploaded byapi-150536296
- Introduction to Finite Element Methods (2001)(en)(489s)Uploaded bygreen77park
- CHSEM2Uploaded byJASON_INGHAM
- study notes 1Uploaded byapi-270402873
- Other School 2 EM P1Uploaded byNicholas Teh
- multiplication lesson planUploaded byapi-248716727
- 35507446 Rancangan Pengajaran Tahunan MatematikUploaded byskynet_up901997
- Discoverer Calculated Functions - How to GuideUploaded bynthack
- sympy-0.7.2Uploaded byLuis Oliveira Silva
- HidalgoHausmann_PNAS_2009_PaperAndSMUploaded byAlejandro Vega
- Operator Precedence in JavaUploaded byGabriela Pech
- cipher quick math game 5Uploaded byapi-110273599
- Excel 2010session IIIAUploaded byPrajumnaAdokshaja
- CAT de Quant Test 45Uploaded bycomplore
- Lecture Notes Ch7 StudentsUploaded byMahmoud Elgebaly
- English for mathUploaded byRita Fajriati
- Lab Ex 3Uploaded byNgô Như Tuyến
- 10_Factorization Using Cross MultiplicationUploaded byMaverick Lam
- pa03kc_lesson10Uploaded byAnniaRV
- problem3.5.3Uploaded bytariqraza
- Brazil 2Uploaded byPi
- Data AnalysisUploaded byMona Farag

- Caiet Dna Fleancu-probleme MateUploaded byluciange
- Cantarile Sfintei Liturghii (Notatie Lineara Si Psaltica)Uploaded byugubro
- Measuring TimeUploaded byluciange
- Raport de Activitate Al Comisiei Metodice a Profesorilor de Matematică Și Informatică Din Școala GimnazialăUploaded byluciange
- Shell TimerUploaded byluciange
- VectoriUploaded byluciange
- Strong PasswordUploaded byluciange
- TruflaWords-FontCharMap.pdfUploaded byluciange
- despre Soft educationalUploaded byluciange
- TruflaWords-FontCharMapUploaded byluciange
- Shell Edit ScriptUploaded byluciange
- Ion Vulcanescu - Curs Yoga (1973)Uploaded bymatanga
- Shell First ScriptUploaded byluciange
- Shell HTML ScriptUploaded byluciange
- Shell Script TimingUploaded byluciange
- inegalitatiUploaded byluciange
- AlgebraUploaded byluciange
- Securitate 1Uploaded byluciange
- Securitate 2Uploaded byluciange
- MaximaUploaded byluciange
- Metodologie definitivat 2015Uploaded byiIoana4n
- analiza-rUploaded byluciange
- Securitate DataUploaded byluciange
- Maxima Problem SolvingUploaded byluciange
- GeometrieUploaded byluciange
- probabilitatiUploaded byluciange
- Securitate EncrUploaded byluciange
- SecuritateUploaded byluciange
- Maxima PlotUploaded byluciange

- Sharc Instruction SetUploaded byRavi Babu Ayyalwar
- Chapter_5 Descriptions of Function InstructionsUploaded byCarlos_Duque1958
- unit V 2 mark.docUploaded byAnonymous G5c7SYAnzy
- Manual TD 200Uploaded byEduardo_77
- Learning the Java LanguageUploaded byNaveen Kumar
- DB2BP Physical Design OLTP 0412Uploaded bylivbest
- Programming Computer Notes for 10th classUploaded byAbdul Hadi
- float.pdfUploaded bySrinivas Cheruku
- 1cppUploaded byAbid Nazir
- Bit Twiddling HacksUploaded byRitu Garg
- Java ProgrammingUploaded byManas Ku Sahoo
- ArmUploaded bycameraman01
- CS 31 Intro to Programming UCLA C++Uploaded byManuel Sosaeta
- Design of High Speed Ieee-754 Single-Precision Floating Point MultiplierUploaded byIJAETMAS
- spdatawpUploaded byDebanjan Manna
- chapter_1Uploaded byJammalamadugu Ravindranadh
- 6Uploaded byPaul Gutiérrez
- OMUj0_ComputerProgramming.pdfUploaded bygpdharan
- Hw3_solutions.pdfUploaded byKiran Adhikari
- Floating Point NumbersUploaded byDramane Bonkoungou
- p233-loitschUploaded byAnonymous xZkpgi
- COA-QBUploaded bySANDJITH
- COMMODORE 64 PROGRAMMER'S REFERENCE GUIDEUploaded bymjmt
- 25. ISC Computer Science -2015Uploaded byBimal Roy Mehta
- 008PHP_ Integers - ManualUploaded byDenuya Ersa
- 01 Manual C++Uploaded byNooraFukuzawa Nor Fauziah
- Python_Cheat-Sheet.pdfUploaded byAnonymous 8KGdHjjqN
- Analysis of Parallel SpeedupsUploaded byWenqi Wu
- Ece126 Slide NotesUploaded byAmin Tumin
- Numerical Computation Guide and What every scientist should know about floating point arithmetic.pdfUploaded bywbdsdvyo