• Aucun résultat trouvé

Getting Help

Dans le document Second Edition (Page 28-35)

⎥⎥

⎥⎥

⎥⎥

]

6 x + 7 y + 10 z

⎥⎥⎥

⎥⎥

⎥⎥

1.7 Getting Help

There are many sources of help in Mathematica. First and foremost is the Documentation Center (as shown in the following figure) available from the Help menu. There you will find all available commands grouped by topic, or you can search for the help you need by typing in a few keywords. The Function Navigator contains a listing of all the functions available in Mathematica arranged by topic, and the entire Mathematica manual may be accessed by going to the Virtual Book.

The help files contain numerous examples that you may want to explore. Feel free to make any changes in the help files without fear of modifying their content. These files are protected and your changes will not be permanent.

If you know the name of the command you want, you can use a question mark, ?, followed by the name of the command to determine its syntax. More extensive information about the command, including attributes and options, can be obtained using ??. Or you can type the name of the command, place the cursor within its name, and then press F1. You will be taken to a page with a complete description and illustrative examples.

Occasionally, when you make an error, Mathematica will beep or the cell will change color. If you are not sure what you did to cause this, you can get a clue by going to Help⇒Why The Beep? orHelp⇒ Why The Coloring?

EXAMPLE 20 Suppose you know that the command Plot graphs a function, but you cannot remember its syntax.

?Plot

Plot[ f, {x, xmin, xmax}] generates a plot of f as a function of x from xmin to xmax. Plot[{f1, f2,...}, {x, xmin, xmax}] plots several functions fi. 

If information is needed about attributes or optional settings (and their defaults), ?? can be used.

??Plot

Plot[ f, {x, xmin, xmax}] generates a plot of f as a function of x from xmin to xmax. Plot[{ f1, f2,...}, {x, xmin, xmax}] plots several functions fi. 

Attributes[Plot]={HoldAll,Protected}

1 Options[Plot]={AlignmentPoint → Center, AspectRatio

GoldenRatio , Axes → True, AxesLabel → None,AxesOrigin → Automatic,AxesStyle → {},

Background → None,BaselinePosition → Automatic, BaseStyle → {},

ClippingStyle → None, ColorFunction → Automatic, ColorFunctionScaling → True, ColorOutput → Automatic, ContentSelectable → Automatic,

DisplayFunction $DisplayFunction, Epilog → {},

Evaluated → System`Private`$Evaluated, EvaluationMonitor → None, Exclusions → Automatic, ExclusionsStyle → None, Filling → None,

FillingStyle → Automatic, FormatTypeTraditionalForm, Frame → False, FrameLabel → None,FrameStyle → {},FrameTicks → Automatic,

FrameTicksStyle → {}, GridLines → None, GridLinesStyle → {}, Imagemargins → 0.,ImagePadding → All, ImageSize → Automatic, LabelStyle → {},MaxRecursion → Automatic, Mesh → None,

MeshFunctions → {#1 &}, MeshShading → None, MeshStyle → Automatic, Method → Automatic,PerformanceGoal$PerformanceGoal,

PlotLabel → None, PlotPoints → Automatic,PlotRange → {Full, Automatic}, PlotRangeClipping → True, PlotRangePadding → Automatic,

PlotRegion → Automatic, PlotStyle → Automatic,

PreserveImageOptions → Automatic, Prolog → {}, RegionFunction → (True &), RotateLabel → True, Ticks → Automatic, TicksStyle → {},

WorkingPrecision → MachinePrecision}

Options can also be obtained using the Options command. This is useful if you want to specify an option but cannot remember its name.

EXAMPLE 21

Options[Solve]

{InverseFunctions→Automatic,MakeRules→False,Method→3,Mode→Generic,

Sort→True,VerifySolutions→Automatic,WorkingPrecision→∞}

Very often you may remember part of a symbol name, but not the whole name. If you know the beginning is “Arc,” for example, type in the part you know and then press [CTRL] + [K]. This will generate a menu of all commands and functions beginning with Arc. Then click on the one you want.

If you are using a Macintosh computer, use [COMMAND] + [K]. (The [COMMAND] key is the key with the apple on it.)

EXAMPLE 22 Type Arc and then press [CTRL] +[K] or [COMMAND] +[K] .

Another way of determining symbol names is to use ? together with wildcards. The character “ * ” acts as a “wildcard” and takes the place of any sequence of characters. Wildcards can be used anywhere, at the beginning, middle, or end of a symbol.

EXAMPLE 23 Output may vary depending upon your version of Mathematica (a) Find all commands beginning with “Inv.”

?Inv*

(b) Find all commands ending with “in.”

? *in

(c) Find all commands with “our” in the middle.

? *our*

Wildcards can also be used to determine which symbols have been used thus far by the kernel. Typing ?` * returns a list of all symbols that have been defined during your Mathematica session. The character ` (backquote) stands for global—you want a list of all global symbols. (See the appendix for a discussion of global symbols.)

EXAMPLE 24 Note: The results of this example may be slightly different on your computer, depending upon the symbols you have defined.

a = 3;

b2xy = 4;

xyz7 = 5;

?` * Global`

a b2xy xyz7

Clear["` * "] will clear all global symbols. Remove["`*"] will remove all global symbols.

EXAMPLE 25 Remove["`*"]

?` * Check to see if any symbols remain.

Remove õ rmnsm : There are no symbols matching "`*".

SOLVED PROBLEMS

1.28 Obtain basic information about the Mathematica command Simplify.

SOLUTION

? Simplify

Simplify[expr] performs a sequence of algebraic and other transformations on expr, and returns the simplest form it finds.

Simplify[expr, assum] does simplification using assumptions. 

1.29 Obtain extended information about the Mathematica command Simplify including default settings for options.

SOLUTION

?? Simplify

Simplify[expr] performs a sequence of algebraic and other transformations on expr, and returns the simplest form it finds.

Simplify[expr, assum] does simplification using assumptions.  Attributes[Simplify]={Protected}

Options[Simplify]={Assumptions  $Assumptions,

ComplexityFunction → Automatic,ExcludedForms {},TimeConstraint 300, TransformationFunctions → Automatic,Trig True}

1.30 Obtain help on the Mathematica command Factor and then factor x3 – 6x2+ 11x – 6.

SOLUTION

?Factor

Factor[ poly] factors a polynomial over the integers.

Factor[ poly, Modulus → p] factors a polynomial modulo a prime p.

Factor[ poly, Extension {a1, a2,...}] factors a polynomial allowing coefficients that are rational combinations of the algebraic numbers ai. 

Factor[x3 – 6 x2 + 11 x – 6]

( –3 + x)( –2 + x)( –1 + x)

1.31 Find all Mathematica commands beginning with “Abs.”

SOLUTION

?Abs*

1.32 Find all Mathematica commands beginning with “Si” and ending with “al.”

SOLUTION

?Si*al

1.33 Find all Mathematica commands beginning with “Fi.”

SOLUTION

?Fi*

1.34 Find all Mathematica commands beginning with “Fi” and ending with “t.”

SOLUTION

?Fi*t

Once a package is loaded you can get a list of the functions it contains by using the Names command.

1.8 Packages

There are many specialized functions and procedures that are not loaded when Mathematica is initially invoked. Rather, they must be loaded separately from files in the Mathematica directory on the hard drive.

These files are of the form filename.m.

EXAMPLE 26 A map of the world can be obtained from the command WorldPlot which is located in the package WorldPlot`. To load this command, simply type (note the ` at the end)

WorldPlot` or Needs["WorldPlot`"]

The appropriate command can then be accessed.

WorldPlot[World]

EXAMPLE 27 (Continuation of Example 26) Names["WorldPlot`*"]

{Africa, Albers, Asia, ContiguousUSStates, Equirectangular, Europe, LambertAzimuthal, LambertCylindrical, Mercator, MiddleEast, Mollweide,

NorthAmerica, Oceania, Orthographic, RandomColors, RandomGrays, ShowTooltips, Simple, Sinusoidal, SouthAmerica, ToMinutes, USData, USStates, World,

WorldBackground, WorldBorders, WorldClipping, WorldCountries, WorldData, WorldDatabase, WorldFrame, WorldFrameParts, WorldGraphics, WorldGrid, WorldGridBehind, WorldGridStyle, WorldPlot, WorldPoints, WorldProjection, WorldRange, WorldRotatedRange, WorldRotation, WorldToGraphics}

EXAMPLE 28 The package Calendar` includes some interesting calendar functions.

Calendar`

Names["Calendar`*"]

{Calendar, CalendarChange, DateQ, DayOfWeek, DaysBetween, DaysPlus,

EasterSunday, EasterSundayGreekOrthodox, Friday, Gregorian, Islamic, Jewish, JewishNewYear, Julian, Monday, Saturday, Sunday, Thursday, Tuesday, Wednesday}

?DaysBetween

DaysBetween[{year1, month1, day1}, {year2, month2, day2}] gives the number of days between the dates {year1, month1, day1} and {year2, month2, day2}.

DaysBetween[{year1, month1, day1, hour1, minute1, second1}, {year2, month2, day2, hour2, minute2, second2}]

gives the number of days between the given dates.  DaysBetween[{2007,8,3},{2008,12,5}] 490

SOLVED PROBLEMS

1.35 The function DayOfWeek appears in the package Calendar` and gives the day of the week of any date in the calendar. Load the package, obtain help to determine its syntax, and then determine which day of the week January 1, 2000, was.

SOLUTION

Calendar`

? DayOfWeek

DayOfWeek[{year, month, day}] gives the day of the week on which the given date {year, month, day}

occurred.

DayOfWeek[{year, month, day, hour, minute, second}] gives the day of theweek for the given date.  DayOfWeek[{2000, 1, 1}]

Saturday

1.36 The package Combinatorica` contains functions in combinatorics and graph theory. One of these is KSubsets, which lists all subsets of size k of a given set. Load the package and execute Ksubsets[{1,2,3,4,5},3].

SOLUTION

Combinatorica`

KSubsets[{1, 2, 3, 4, 5}, 3]

{{1, 2, 3}, {1, 2, 4}, {1, 2, 5}, {1, 3, 4}, {1, 3, 5}, {1, 4, 5}, {2, 3, 4}, {2, 3, 5}, {2, 4, 5}, {3, 4, 5}}

Dans le document Second Edition (Page 28-35)