ebook img

Hands-On Start to Wolfram Mathematica: And Programming with the Wolfram Language PDF

488 Pages·2016·19.237 MB·
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Hands-On Start to Wolfram Mathematica: And Programming with the Wolfram Language

HANDS-ON START TO WOLFRAM MATHEMATICA® and Programming with the Wolfram Language™ SECOND EDITION Cliff Hastings Kelvin Mischo Michael Morrison Champaign ����� �� �������� Introduction vii ���� � THECOMPLETEOVERVIEW1 Chapter1 TheVeryBasics 3 Chapter2 ASampleProjectinMathematica 11 Chapter3 InputandOutput 21 Chapter4 WordProcessingandTypesetting 43 Chapter5 PresentingwithSlideShows 59 Chapter6 FundamentalsoftheWolframLanguage 73 Chapter7 CreatingInteractiveModelswithaSingleCommand 93 Chapter8 SharingMathematicaNotebooks 115 Chapter9 FindingHelp 125 ���� �� EXTENDINGKNOWLEDGE 133 Chapter10 2Dand3DGraphics 135 Chapter11 VisualizingData 157 Chapter12 StylingandCustomizingGraphics179 Chapter13 CreatingFiguresandDiagramswithGraphicsPrimitives 213 Chapter14 AlgebraicManipulationandEquationSolving 233 Chapter15 Calculus 245 Chapter16 DifferentialEquations 261 Chapter17 LinearAlgebra 271 Chapter18 ProbabilityandStatistics 289 Chapter19 ImportingandExportingData 305 Chapter20 DataFilteringandManipulation 327 Chapter21 WorkingwithCuratedData 359 Chapter22 UsingWolfram|AlphaDatainMathematica 393 Chapter23 StatisticalFunctionalityforDataAnalysis 419 Chapter24 CreatingPrograms 437 Chapter25 CreatingParallelandGPUPrograms 459 Index 477 INTRODUCTION How to Use This Book Create Examples while Reading Thisbookismeanttobeanactivecompanionduringtheprocessoflearninghowtouse Mathematica®.Themainbodyofthetextwillcertainlyprovideinsightsintohow Mathematicaworks,buttheexamplesshouldberetypedasastartingpointforindividual exploration.Eachchaptercontainsdiscussion,tipsandadescriptionofMathematica functionality,alongwithactualexamplesthatserveasstartingpoints.Eachchapterends withadditionalexercisestoemphasizecomprehension,whichcanbeusedasanassign- menttostudentsorsimplytoworkthroughonyourown. Nomatterwhatformatthisbookisviewedin,itisrecommendedthatreadershave MathematicaonthedesktoporMathematicaOnline™ immediatelyaccessibletotype theexamplesandworkthroughtheexercises.Itisrecommendedthatasreaderswork throughthebook,theysaveanewfileforeachchapterinWolframNotebook™ format (.nb),eitherlocallyorintheWolframCloud™,forfuturereference. (cid:1) Anytextinthistypeofstyledboxismeanttobeatipbytheauthors.Theadviceis meanttopassalongexperiencegainedfromteachingthousandsofpeoplehowto useMathematica. Part I: The Complete Overview Is Required Reading AllnewMathematicausersshouldworkthroughchaptersonethroughninefirsttoobtain thenecessarybasisofknowledgefortherestofthebook.Thesechapterswillbeofvalueto intermediateMathematicausersbyfillingingapsinknowledgethatcanresultfromusing Mathematicaonlyforanarrowlydefinedsetoftasks,orbybroadeningthehorizonsof userswhomayhavelearnedMathematicafromanolderversion. ��� ������������ Part II: Extending Knowledge Is Suggested Reading OncePartI:TheCompleteOverviewisfinished,therestofthechapterscanbereadin orderasacompletebookorcanbereadintheorderthatmostappealstothereader. Chapter1:TheVeryBasicsisdesignedtogiveyouexperiencewithtypingcommandsin Mathematica.Knowingwhatcommandstouseandwhentousethosecommandswillbe discussedinsubsequentchapters;thepurposeofthefirstchapterissimplytoprovide initialpracticeandimmersioninusingMathematica. Chapter2:ASampleProjectinMathematicaismeanttoshowthescopeofMathematica andhowitcanbeappliedtoquicklyexploreareal-worldproblem.Thegoalofthechapter isnottounderstandthedetailsofthecommandsbutratherthethoughtprocessfor buildinguponeachstep,andtheprocessofworkingtowardaninterestingfinalresult. Subsequentchapterswillexplaintheindividualcommandsinmuchmoredetail.Theywill providethenecessarybuildingblocksofknowledgetocreatesimilaranalyseswhileusing Mathematicafluidlyandfluently. Mathematica on the Desktop and Mathematica Online ThisbookisaboutMathematicaandisprimarilywrittenfromtheperspectiveofusing Mathematicaonadesktopcomputer.Adifferentproduct,MathematicaOnline,providesa waytouseMathematicaviaawebbrowser,anditcanalsobeusedtofollowalongwiththe book'sexamples.ThisbookiswrittenfromtheperspectiveofusingMathematicaonthe desktop,sotheremaybetimeswhentheprocessfordoingsomething,likenavigatingamenu, maynotbeexactlythesameastheprocessinMathematicaOnline.Forcaseswherethereare dramaticdifferencesbetweenthedesktopversionofMathematicaandMathematica Online—suchasworkingwithslideshows,stylesheets,palettesandparallelcomputing—the textcontainsnotestomakethereaderawareofthesedifferences.Forthevastmajorityof examples,however,therewillbenodifferenceinenteringthecommandsinMathematicaon thedesktoporMathematicaOnline. Getting Access to Mathematica IfyoudonotcurrentlyhaveaccesstoMathematica,youcanrequestatriallicensefrom theWolframwebsiteatwww.wolfram.com/mathematica/trialandusethattowork alongwiththebook. ���� Part I The Complete Overview CHAPTER 1 The Very Basics First Interactions with Mathematica AlthoughMathematicahasfunctionalitythatspansmanyspecializedareas,knowledgeof theentiresoftwarepackageisnotrequiredtogetstarted.Oftenitisthesimplethingsin Mathematicathatarethemostimpressive,especiallywhenusersarestartingout. SubsequentchaptersinthisbookwillexplainwhycommandsinMathematicaproduce certainoutputandwillalsoexplainthescopeofthesystem.Thischapterisdesignedtobe usedaspractice,sincebytypingcommandsintoMathematica,onecanbecomeacquainted withtheworkflow.Manypeoplelearnbydoing,andthisistheprecisespiritofthischapter, whichwillprovidesomerepetitiontomaketheotherchaptersinthebookmoremeaningful. AcommonthemeinthisbookisthatMathematicausestheWolframLanguage,and WolframLanguagecommandsallfollowthesamerules.Acertainintuitiondevelopsforthese rules,makingiteasytoapplycommandstonewsituations.Thischapterwillhelpexplain somecommandsandgivesomebriefgeneraldescriptionstoaidindevelopingthisintuition. LaunchMathematicaandcreateanewnotebookbyclickingtheFilemenu,choosingNew andthenselectingNotebook.Ablankdocumentwithahorizontalcursorwillappear. Thisiscalledanotebook.ThehorizontalcursormeansthatMathematicaisreadytobe givenacommand.Type10!toenteracalculation.Whenfinished,evaluatethecommand bypressingShift+Enter.Alternatively,inputscanbeevaluatedbypressingtheEnterkeyon thenumerickeypadifthekeyboardbeingusedhassuchakeypad.Mathematicawilltake theinput,performthedesignatedoperationandreturntheresultof3628800.Oncea commandhasfinished,themouseorarrowkeyscanbeusedtoplacethecursorbelowthe result,atwhichtimeMathematicaisreadytoreceiveanewcommand.Withthesebrief instructions,recreatethefollowingexamples. (cid:1) Ifyougetstuckduringthissection,itmightbeeasiertowatchavideoofsomeone elsetypingcommandsintoMathematicaandtomirrorthoseactions.Youcanvisit theWolframwebsite(wolfr.am/hostm)towatchtheHands-onStarttoMathematica videoseries,whichisasubsetofthecontentofthisbook.Infact,thisbookwas writteninresponsetorequestsfrompeoplewhowatchedthevideosandwanteda morethoroughintroduction. � �������� Typethefollowingcommandtodivide717by3. 717/3 239 Findtheexactanswerto718dividedby3. 718/3 718 3 Findtheapproximateanswerto718dividedby3. N[718/3] 239.333 Findtheapproximateanswerto718dividedby3roundedto5digits. N[718/3,5] 239.33 Usefree-forminputtocalculate718dividedby3.Free-forminputisinvokedbypressing the=key,andthentherestofthecommandcanbetypedandevaluated.Seerelatedcalcula- tionsbyclickingtheplusiconafterevaluating. � ������������� Assignthevalue5toavariablenameda. a=5 5 Calculate3a+1,whereaisalreadydefinedas5. 3a+1 16 Clearthevariabledefinitionofa,whichwillmakeaundefined. Clear[a] Expandthealgebraicexpression(a+5)(a+9). Expand[(a+5)(a+9)] 45+14a+a2 Solvetheequation2x-7 = 0forx. Solve[2x-7⩵0,x] 7 (cid:1)(cid:1)x→ (cid:3)(cid:3) 2 (cid:1) Noticethattwoequalsigns(==)wereusedinthiscommand.Thereasonforthat willbediscussedinChapter6:FundamentalsoftheWolframLanguage. Solvetheequation2x-7 = 0forxandfindanumericapproximationoftheresult. NSolve[2x-7⩵0,x] {{x→3.5}} � �������� Usefree-forminputtosolvetheequation2x-7 = 0forx. (cid:1) ����� ��-�=� ������ Reduce[-7 + 2*x == 0, x] 7 x⩵ 2 Solvethetwoequationswithtwounknowns,2x- y = 0and3x-2 y = 0, forbothxand y. Solve[{2x-7⩵0, 3x-2y⩵0}, {x,y}] 7 21 (cid:1)(cid:1)x→ ,y→ (cid:3)(cid:3) 2 4 Solvetheequationax2+bx+c = 0forx. Solve[a*x^2+b*x+c⩵0,x] -b- b2-4ac -b+ b2-4ac (cid:1)(cid:1)x→ (cid:3),(cid:1)x→ (cid:3)(cid:3) 2a 2a Plottheequation y = 2x-7,wherexgoesfrom-10to10. Plot[2x-7, {x, -10, 10}] �� -�� -� � �� -�� -�� �

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.