A 10 Minute Tutorial For Solving Math Problems With Maxima
A 10 Minute Tutorial For Solving Math Problems With Maxima
withMaxima
PostedbyAntonioCangianoinEssentialMath,SoftwareonJune4th,2007|138responses
About50,000peoplereadmyarticle3awesomefreeMathprograms.Chancesarethatatleastsomeof
themdownloadedandinstalledMaxima.IfyouareoneofthembutarenotacquaintedwithCAS
(ComputerAlgebraSystem)software,Maximamayappearverycomplicatedanddifficulttouse,even
fortheresolutionofsimplehighschoolorcalculusproblems.Thisdoesnthavetobethecasethough,
whetheryouarelookingformoremathresourcestouseinyourcareerorastudentinanonline
bachelorsdegreeinmathlookingforhomeworkhelp,Maximaisveryfriendlyandthis10minute
tutorialwillgetyoustartedrightaway.Onceyouvegotthefirststepsdown,youcanalwayslookupthe
specificfunctionthatyouneed,orlearnmorefromMaximasofficialmanual.Alternatively,youcanuse
thequestionmarkfollowedbyastringtoobtaininlinedocumentation(e.g.?integrate).Thistutorial
takesapracticalapproach,wheresimpleexamplesaregiventoshowyouhowtocomputecommontasks.
Ofcoursethisisjustthetipoftheiceberg.Maximaissomuchmorethanthis,butscratchingevenjust
thesurfaceshouldbeenoughtogetyougoing.Intheendyouareonlyinvesting10minutes.
Maximaasacalculator
YoucanuseMaximaasafastandreliablecalculatorwhoseprecisionisarbitrarywithinthelimitsof
yourPCshardware.Maximaexpectsyoutoenteroneormorecommandsandexpressionsseparatedbya
semicoloncharacter(),justlikeyouwoulddoinmanyprogramminglanguages.
(%i1) 9+7;
(%o1)
(%i2) -17*19;
(%o2)
(%i3) 10/2;
(%o3)
Maximaallowsyoutorefertothelatestresultthroughthe%character,andtoanypreviousinputor
outputbyitsrespectiveprompted%i(input)or%o(output).Forexample:
(%i4) % - 10;
(%o4)
(%i5) %o1 * 3;
(%o5)
Forthesakeofsimplicity,fromnowonwewillomitthenumberedinputandoutputpromptsproduced
byMaximasconsole,andindicatetheoutputwitha=>sign.Whenthenumeratoranddenominatorare
bothintegers,areducedfractionoranintegervalueisreturned.Thesecanbeevaluatedinfloatingpoint
byusingthefloatfunction(orbfloatforbigfloatingpointnumbers):
8/2;
=>
8/2.0;
=>
2/6;
=>
float(1/3);
=>
1/3.0;
=>
26/4;
=>
float(26/4);
=>
Asmentionedabove,bignumbersarenotanissue:
13^26;
=>
13.0^26
=>
30!;
=>
float((7/3)^35);
=>
Constantsandcommonfunctions
HereisalistofcommonconstantsinMaxima,whichyoushouldbeawareof:
%eEulersNumber
%pi
%phithegoldenmean(
%itheimaginaryunit(
)
infrealpositiveinfinity( )
minfrealminusinfinity(
)
infinitycomplexinfinity
Wecanusesomeofthesealongwithcommonfunctions:
sin(%pi/2) + cos(%pi/3);
=>
tan(%pi/3) * cot(%pi/3);
=>
float(sec(%pi/3) + csc(%pi/3));
=>
sqrt(81);
=>
log(%e);
=>
Definingfunctionsandvariables
Variablescanbeassignedthroughacolon:andfunctionsthrough:=.Thefollowingcodeshowshow
tousethem:
a:7; b:8;
=>
=>
sqrt(a^2+b^2);
=>
f(x):= x^2 -x + 1;
=>
f(3);
=>
f(a);
=>
f(b);
=>
PleasenotethatMaximaonlyoffersthenaturallogarithmfunctionlog.log10isnotavailablebydefault
butyoucandefineityourselfasshownbelow:
log10(x):= log(x)/log(10);
=>
log10(10)
=>
SymbolicCalculations
factorenablesustofindtheprimefactorizationofanumber:
factor(30!);
=>
Wecanalsofactorpolynomials:
factor(x^2 + x -6);
=>
Andexpandthem:
expand((x+3)^4);
=>
Simplifyrationalexpressions:
ratsimp((x^2-1)/(x+1));
=>
Andsimplifytrigonometricexpressions:
trigsimp(2*cos(x)^2 + sin(x)^2);
=>
Similarly,wecanexpandtrigonometricexpressions:
trigexpand(sin(2*x)+cos(2*x));
=>
PleasenotethatMaximawontaccept2xasaproduct,itrequiresyoutoexplicitlyspecify2*x.Ifyou
wishtoobtaintheTeXrepresentationofagivenexpression,youcanusethetexfunction:
tex(%);
=> $$-\sin ^2x+2\,\cos x\,\sin x+\cos ^2x$$
SolvingEquationsandSystems
Wecaneasilysolveequationsandsystemsofequationsthroughthefunctionsolve:
solve(x^2-4,x);
=>
%[2]
=>
solve(x^3=1,x);
=>
trigsimp(solve([cos(x)^2-x=2-sin(x)^2], [x]));
=>
solve([x - 2*y = 14, x + 3*y = 9],[x,y]);
=>
2Dand3DPlotting
Maximaenablesustoplot2Dand3Dgraphics,andevenmultiplefunctionsinthesamechart.The
functionsplot2dandplot3darequitestraightforwardasyoucanseebelow.Thesecond(andinthecase
ofplot3d,thethird)parameter,isjusttherangeofvaluesforx(andy)thatdefinewhatportionofthe
chartgetsplotted.
plot2d(x^2-x+3,[x,-10,10]);
Limits
limit((1+1/x)^x,x,inf);
=> %
limit(sin(x)/x,x,0);
=>
limit(2*(x^2-4)/(x-2),x,2);
=>
limit(log(x),x,0,plus);
=>
limit(sqrt(-x)/x,x,0,minus);
=>
Differentiation
diff(sin(x), x);
=>
diff(x^x, x);
=>
Wecancalculatehigherorderderivativesbypassingtheorderasanoptionalnumbertothedifffunction:
diff(tan(x), x, 4);
=>
Integration
Maximaoffersseveraltypesofintegration.Tosymbolicallysolveindefiniteintegralsuseintegrate:
integrate(1/x, x);
=>
Fordefiniteintegration,justspecifythelimitsofintegrationsasthetwolastparameters:
integrate(x+2/(x -3), x, 0,1);
=>
integrate(%e^(-x^2),x,minf,inf);
=>
Ifthefunctionintegrateisunabletocalculateanintegral,youcandoanumericalapproximationthrough
oneofthemethodsavailable(e.g.romberg):
romberg(cos(sin(x+1)), x, 0, 1);
=> 0.57591750059682
SumsandProducts
sumandproductaretwofunctionsforsummationandproductcalculation.Thesimpsumoption
simplifiesthesumwheneverpossible.Noticehowtheproductcanbeusetodefineyourownversionof
thefactorialfunctionaswell.
sum(k, k, 1, n);
=>
sum(k, k, 1, n), simpsum;
=>
sum(1/k^4, k, 1, inf), simpsum;
=>
fact(n):=product(k, k, 1, n);
=>
fact(10);
=>
SeriesExpansions
Seriesexpansionscanbecalculatedthroughthetaylormethod(thelastparameterspecifiesthedepth),or
throughthemethodpowerseries:
niceindices(powerseries(%e^x, x, 0));
=>
taylor(%e^x, x, 0, 5);
=>
Thetruncmethodalongwithplot2disusedwhentaylorsoutputneedstobeplotted(todealwiththe
intaylorsoutput):
plot2d([trunc(%), %e^x], [x,-5,5]);
IhopeyoullfindthisusefulandthatitwillhelpyougetstartedwithMaxima.CAScanbepowerful
toolsandifyouarewillingtolearnhowtousethemproperly,youwillsoondiscoverthatitwastime
wellinvested.