Manual Mercury

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 23

Escuela Militar de Ingeniera

Mariscal Antonio Jos de Sucre


Materia
Optimizacin
Mercury 2!"
#ocente
$uri %amorano &raun
2!!'
Mercury 2.00 manual
===================
(C) Copyright 1990 Roger Schlafly.
All Rights Resere!.
"ortions of the soft#are (C) Copyright 19$%&$$ 'orlan! (nternational.
All Rights Resere!.
Author)s *ote+ ,his is a !raft of the Mercury 2.00 manual- an! #as the
latest ascii ersion. .nce ( typeset it- it no longer /ecame practical
to up!ate this ersion. Registere! copies of Mercury come #ith a 90
page typeset manual #hich is more complete an! has fe#er errors.
Contents
&&&&&&&&
1. (ntro!uction
0eatures
1istory
Share#are policy
2isclaimer
0iles
1ar!#are Re3uirements
(nstallation
2. "ro/lems
4!iting
*um/ers
.perators
Constants
5. Soling
Solutions
6raphs
Reports
7. 0eature Reference
0unctions
Statements
Comman!s
1. (ntro!uction
(ntro!uction
&&&&&&&&&&&&
Mercury is a program for soling e3uations on the ('M "C. (t is
easy to use- interactie- an! po#erful. 8ith it- you can
9 ealuate mathematical e:pressions.
9 sole for the roots of an e3uation.
9 sole a system of e3uations.
9 ma:imi;e or minimi;e a function- #ith or #ithout constraints.
9 ealuate !eriaties an! !efinite integrals.
9 plot one or more functions.
9 print a report or a graph.
Mercury has a /uilt&in e!itor- pull&!o#n menus- online help-
an! all the coneniences necessary to ma<e it accessi/le to
computer noices.
0or a 3uic< !emonstration of Mercury)s capa/ilities- run M4RC=R>
an! then loa! an! sole some of the sample pro/lems (9.4?A). (f
you get stuc<- @ust press the 01 <ey for help.
Mercury is an outgro#th of 4ure<a- a pro!uct of 'orlan!
(nternational of Scotts Aalley- California. 8hen
'orlan! !eci!e! to concentrate on sprea!sheet an! !ata/ase
pro!ucts- 4ure<a #as spun off. Mercury #as
!eelope! from that co!e /ase- an! is /eing release! in this
form to satisfy customer re3uests for ne# ersions of 4ure<a. (t
is la/elle! ersion 2.0 /ecause it is similar to #hat ersion 2.0 of
4ure<a #oul! hae /een.
4ure<a #as also aaila/le on the Apple Macintosh. *o ersion
of Mercury for the Macintosh is planne! at this time.
Mercury is aaila/le as Share#are. Share#are is a name for
programs #hich are !istri/ute! freely or at nominal charge- /ut
#hich are copyrighte! an! hae restrictions on their usage.
Mercury may /e copie! freely for e:amination purposes. 2istri/utors
may charge a nominal fee- proi!e! that they a!here to the con!itions in
A4*2.R.2.C. Commercial an! institutional use is prohi/ite!
#ithout a registere! license. Such a license may /e o/taine! /y
sen!ing B79 to
Real Soft#are
". 'o: 1C$0
So3uel- CA 9D0%5
=SA
phone or fa:+ 70$&7%C&5DD0
CompuSere+ %CC7C-525
6enie+ R.Schlafly
''S+ 70$&7%C&10DD
"ayment may /e /y chec<- MasterCar!- or Aisa. See R46(S,4R.2.C
for an or!er form. 0oreign or!ers shoul! inclu!e BD for shipping.
,hose #ho register a license #ill get the latest ersion of the
soft#are- an installation program- an! a printe! manual. ,hey #ill
/e eligi/le for technical support- an! #ill /e on the mailing list
for future information an! up!ates.
Site licenses an! other special arrangements are aaila/le.
Comments- /ug reports- an! suggestions are especially #elcome.
2isclaimer
&&&&&&&&&&
,he author has ma!e his /est effort in pro!ucing this soft#are- /ut
here/y !isclaims all #arranties. 1e #ill not /e lia/le for any !amages
e:cee!ing the price pai! for the license to use the soft#are. ,he
person using the soft#are /ears all ris< as to the 3uality an!
performance of the soft#are.
Mercury is not a 'orlan! pro!uct. 'orlan! #ill not proi!e any
technical support. 4ure<a is a registere! tra!emar< of 'orlan!
(nternational. 'orlan! copyrights an! tra!emar<s are use! #ith
permission. Mercury is a tra!emar< of the author.
0iles
&&&&&
Mercury consists of these files.
M4RC=R>.4E4 main program
M4RC=R>.1F" help file
9.'6( graphics !riers
9.C1R fonts
9.4?A sample pro/lems
MA*=AF user manual (this file)
R4A2M4 3uic< instructions
R46(S,4R.2.C registration form
A4*2.R.2.C en!or information
Au:illiary files+
9.4?A more sample pro/lems
9.'6( more graphics !riers
9.'(* e:ternal functions
9.C source to e:ternal functions
MA,1F.1 tools for ma<ing e:ternal functions
9..'G tools for ma<ing e:ternal functions
9.F(' tools for ma<ing e:ternal functions
(f you !o#nloa!e! Mercury from an online serice- you may fin! the
au:illiary files archie! separately. ,he e:tra files are not nee!e!
/y most people- an! are store! separately to sae on connect time.
,he e:tra !riers are for uncommon har!#are only- an! the tools for
ma<ing e:ternal functions re3uire 'orlan!)s ,ur/o CHH.
Registere! customers also get (*S,.C.M- an installation program
for configura/le options.
1ar!#are Re3uirements
&&&&&&&&&&&&&&&&&&&&&
Mercury re3uires an ('M "C or clone #ith at least C70?
of RAM. A/out D00? of free RAM is nee!e!. (n a!!ition-
e:ten!e! memory (4MS memory) is use! if present. (f a
math coprocessor is aaila/le- it #ill /e use!. A math
coprocessor is recommen!e! for serious num/er crunchers.
"lots re3uire a graphics monitor an! a C6A- 46A- A6A- or
1ercules car!.
>ou can print reports an! graphs on any of the popular
printers. Select "rinter an! Mo!el from the .ptions menu
for the list of supporte! printers.
(nstallation
&&&&&&&&&&&&
,here are no special installation re3uirements. ,he simplest
proce!ure is to ma<e a ne# !irectory on your har! !is<- an! to
copy all of the files there. >ou may #ish to put the Mercury
!irectory on your path- or to copy some of the files to your
RAM !is<.
,he program (*S, may /e use! to change the e!it <ey /in!ings-
an! to ma<e a fe# other installation choices. Aarious other
configuration options are aaila/le from #ithin Mercury- an!
these may /e sae! to !is<. See .ptions- /elo#.
Mercury tries to !etect automatically #hat har!#are is present-
/ut there some situations #here you may #ant to oerri!e the
!etection logic.
(f you hae a C6A monitor- it may or may not hae the Isno#I
pro/lem. (f so- you may notice ran!om sno# on the screen as
characters are #ritten there. (f so- you can eliminate it /y
typing
set C6AS*.8C1?=>
at the 2.S prompt /efore loa!ing Mercury. ,here must not /e any spaces
surroun!ing the e3uals sign.
Mercury automatically !etects the math coprocessor- /ut
occasionally Mercury fails /ecause the chip is !efectie. (t can
/e turne! off #ith
set $%=*
at the 2.S prompt.
Mercury also !etects arious graphics car!s- /ut some cannot /e
!etecte!. See the SCR44* statement in Chapter 7.
(f you hae a graphics printer- you #ill #ant to select it at the
"rinter menu. ,he graphics car! an! printer selection can /e
sae! to the M4RC=R>.C06 file- an! then it #ill /e automatic each
time Mercury is loa!e!.
4rrors
&&&&&&
4rror messages are pretty much self&e:planatory. (f an error is
!etecte! #hile parsing the pro/lem file- Mercury puts you in the
4!it #in!o# #ith the cursor at the point of the error. ,he error
message at the top of the #in!o#- an! !isappears as soon as you
start e!iting. .ther errors are !isplaye! in a special /o: #hich
is place! on the screen. After you ac<no#le!ge the error /y
pressing the 4scape <ey- you are put /ac< in the menu system.
2. "ro/lems
A pro/lem is entere! into Mercury /y either loa!ing an e:isting
one from the !is<- or /y creating a ne# one in the 4!it #in!o#. ,his
chapter e:plains ho# to use the e!itor- an! ho# to create a pro/lem
for soling.
4!iting
&&&&&&&
Mercury inclu!es a complete te:t e!itor for creating an!
mo!ifying pro/lem files. =sage of the e!itor is similar
to 8or!Star in non!ocument mo!e- or to
'orlan!)s Si!e?ic<. ,he pro/lem files are
or!inary ascii files- an! can /e e!ite! #ith any other
te:t e!itor.
>ou can moe the cursor aroun! in the e!itor #ith the arro#
<eys- "age =p- "age 2o#n- an! some other <eys liste! /elo#. ,he
e!itor has t#o typing mo!es- (nsert an! .er#rite. (n (nsert
mo!e- anything you type is inserte! at the cursor position. (n
.er#rite mo!e- pressing a <ey replaces the current character
at the cursor position #ith the ne# type! character. (nitially-
the e!itor operates in (nsert mo!e- a !efault you
can change #ith the (*S, program. ,o s#itch mo!es- press the
(nsert <ey or Ctrl&A. (Ctrl&A means to hol! !o#n the Ctrl <ey
on your <ey/oar! #hile you press A. ,he A nee! not /e in upper
case.)
*o 8or!&8rap
=nli<e a more stan!ar! #or! processing program- the e!itor !oes
not hae #or!&#rap. >ou must press 4nter at the en! of each line.
Auto(n!ent
,he e!itor has an autoin!ent feature that allo#s su/se3uent lines
to automatically in!ent. (f you leae seeral spaces at the
start of a line- use Ctrl&.( to in!ent su/se3uent lines the same
amount. ,he comman! se3uence is a toggle- so you nee! only
press Ctrl&.( again to stop in!enting.
Joom
Sometimes you may #ant to see more than the area coere! /y the
current #in!o#. >ou can I;oomI the #in!o#- e:pan!ing it to the
si;e of the entire screen- /y pressing 0D. ,o return the #in!o#
to its usual si;e- press 0D again. 0or other #in!o# comman!s-
such as moing an! resi;ing a #in!o#- see the 8in!o# menu- /elo#.
1ere is a summary of the e!iting comman!s. Many of these
comman!s can /e change! #ith the (*S, installation program.
Cursor Moement Comman!s+
Character left Ctrl&S or Feft arro#
Character right Ctrl&2 or Right arro#
8or! left Ctrl&A
8or! right Ctrl&0
Fine up Ctrl&4 or =p arro#
Fine !o#n Ctrl&E or 2o#n arro#
Scroll up Ctrl&8
Scroll !o#n Ctrl&J
"age up Ctrl&R
"age !o#n Ctrl&C
Feft of line Ctrl&KS or 1ome
Right of line Ctrl&K2 or 4n!
,op of screen Ctrl&K4 or Ctrl&1ome
'ottom of screen Ctrl&KE or Ctrl&4n!
,op of file Ctrl&KR or Ctrl&"g=p
'ottom of file Ctrl&KC or Ctrl&"g2n
Moe to /loc< /egin Ctrl&K'
Moe to /loc< en! Ctrl&K?
Moe to preious point Ctrl&K"
Moe to mar<er 0 Ctrl&K0
Moe to mar<er 1 Ctrl&K1
Moe to mar<er 2 Ctrl&K2
Moe to mar<er 5 Ctrl&K5
Set mar<er 0 Ctrl&?0
Set mar<er 1 Ctrl&?1
Set mar<er 2 Ctrl&?2
Set mar<er 5 Ctrl&?5
(nsert L 2elete Comman!s+
(nsert mo!e onMoff Ctrl&A or (ns
(nsert line Ctrl&*
2elete line Ctrl&>
2elete to en! of line Ctrl&K>
2elete character left Ctrl&1 or 'ac<space
2elete character Ctrl&6 or 2el
2elete #or! right Ctrl&,
'loc< comman!s+
Set /loc< /egin Ctrl&?' or 0%
Set /loc< en! Ctrl&?? or 0$
Mar< #or! Ctrl&?,
1i!e /loc< Ctrl&?1
Copy /loc< Ctrl&?C
Moe /loc< Ctrl&?A
2elete /loc< Ctrl&?>
Rea! /loc< Ctrl&?R
8rite /loc< Ctrl&?8
"rint /loc< Ctrl&?"
Miscellaneous Comman!s+
Kuit e!it- no sae Ctrl&?2- Ctrl&?K- or 4sc
Sae an! e!it Ctrl&?S or 02
*e# file 05
,a/ Ctrl&( or ,a/
,a/ mo!e toggle Ctrl&.,
Auto in!ent onMoff Ctrl&.(
Restore line Ctrl&KF
0in! Ctrl&K0
0in! L replace Ctrl&KA
Repeat last fin! Ctrl&F
Control <ey prefi: Ctrl&"
A/ort operation Ctrl&=
Restore error message Ctrl&K8
Search .ptions+
' 'ac<#ar!s search
6 6lo/al search
n n = any num/er. Search n times
* Replace #ithout as<ing
= (gnore upperMlo#er case
8 Search for #hole #or!s only
S Soun!e:
"ro/lems
&&&&&&&&
A pro/lem is a te:t (ascii) file consisting of comments-
!efinitions- e3uations- an! statements. See the sample
files for e:amples of pro/lems.
Comments are not rea! /y the Mercury soler- an! sere
merely for clarity or !ocumentation. A comment starts
#ith a semicolon (N) an! runs until the en! of the line.
Alternatiely- comments can /e enclose! in curly /races (OP)
an! may occupy seeral lines.
2efinitions may /e either aria/le initiali;ations or function
!efinitions an! are characteri;e! /y the += assignment
operator. (f the left&han!&si!e is a name- it is ta<en to
/e a aria/le an! the right&han!&si!e is an e:pression #hich
ealuates to the initial alue for that aria/le. Such initial
alues can /e critical to the iteratie soler. (f the
left&han!&si!e is a function- as in S3uare(:) += :Q2- then the
right&han!&si!e seres as the !efinition for that function. (n
this case- S3uare is then a function of one argument- an!
S3uare(D) = 2D.
43uations hae a mathematical e:pression on each si!e of
an e3uals sign (=). An e3uation may also /e an ine3uality
constraint- in #hich case the e3uals sign is replace! /y
R- R=- S- or S=.
Statements are special !irecties to Mercury. ,hey are
instructions either to !o something other than sole the e3uations-
or to control the solution process. ,he allo#e! statements
are liste! /elo#- an! e:amples are in the pro/lem files.
*um/ers
&&&&&&&
,he range of num/ers is plus or minus 1e&50% to 1eH50%.
8hen using the e:act soler- a 3uestion mar< in!icates that the
ne:t !igit is uncertain. 0or e:ample- 1.25T in!icates a num/er
that might /e anything /et#een 1.22D an! 1.25D- as these are the
num/ers #hich roun! to 1.25.
(maginary num/ers are in!icate! #ith the suffi: i. 0or e:ample-
: = 2 H 5i is the comple: num/er #ith real part 2 an! imaginary
part 5.
"ercentages may /e e:presse! #ith the suffi: U. 0or e:ample- D.1U
is the same as .0D1.
4:amples
&&&&&&&&
A num/er of e:ample pro/lem files (9.4?A) are on the program
!is<. 4:amination of these is strongly recommen!e!- as these
!emonstrate most of Mercury)s features. See Chapter D.
5. Soling
Soling
&&&&&&&
Mercury features three soler technologies.
1. 2irect soler. ,his metho! consists of applying the rules of
high school alge/ra to manipulate the e3uations until solutions are
o/taine! for all the aria/les. 0or e:ample-
2 : H 5 y = $
7 : H D y = 17
can /e sole! !irectly /y rearranging the first e3uation to
y = ($ & 2 :)M5 an! su/stituting for y in the secon! e3uation.
See the F4A4F statement for user control oer #hat manipulations
are allo#e!.
2. (teratie soler. ,he most !ifficult systems of e3uations cannot
/e sole! analytically. ,he /est #e can !o is fin! some appro:imate
solution an! then apply some iteratie proce!ure to improe the
accuracy. (n such case it is a!isa/le to proi!e starting alues
for the aria/les.
5. 4:act soler. Mercury)s most innoatie feature is its a/ility
to use e:act metho!s in many cases.
Solution 8in!o#
&&&&&&&&&&&&&&&
8hen you apply Sole to a pro/lem file- the result is in the
Solution 8in!o#. ,he #in!o# is e!ita/le li<e the 4!it #in!o#-
an! can /e scrolle! an! ;oome! for easy ie#e!. ,he contents
can /e sae! in a report- if that is !esire!.
,he solution lists all of the aria/les- #ith their final
alues. =sually- the alue is @ust a num/er- !isplaye! to
ho#eer many !igits is specifie! in the 2(6(,S statements or
menu options.
(n some cases- a aria/le #as sole! !irectly an! sym/olically
in terms of other aria/les. (f such an e:pression #as use!
to calculate the alue- then the e:pression is sho#n.
(f no alue #as eer assigne! to the aria/le- then its alue
is gien as I=*240(*42I or I*. S.F=,(.*I. ,his occurs if the aria/le is
use! only as a !ummy aria/le- such as in a function !efinition
or as a aria/le of integration.
.ccasionally- a aria/le alue #ill /e gien as *A*- #hich
means *ot&A&*um/er. ,his means the aria/le coul! not /e compute!
accurately- an! only cru!e /oun!s #ere o/taine!. 0or e:ample-
a result I: = *A*(2.1-%.D)I in!icates that : may /e anything
/et#een 2.1 an! %.D. Sometimes such imprecise results represent
the /est that can /e sai! a/out an ill&pose! pro/lem- /ut sometimes
it represents a failure on the part of Mercury. Such results
shoul! /e use! #ith caution.
8hen a aria/le appears to hae the alue of a simple fraction-
it is note! in the solution. 0or e:ample- soling 5 : = 1 gies
: = 0.555555555555555 O 1 M 5 P. ,he fraction is re!uce!- meaning
that the numerator an! !enominator hae no nontriial factors. ,he
logic #hich recogni;es these fractions is particularly effectie
#ith the 4:act soler.
(n some cases- multiple roots for some aria/le are foun!. ,hese
are liste! after the list of aria/le alues.
(f the pro/lem file has a F(S, statement- then the list of the
a/scissae an! or!inate appear in the solution #in!o#.
,he solution al#ays has a list of resi!uals. ,hese are e:tremely
important for assessing the ali!ity an! accuracy of a solution.
A resi!ual is a 3uantity that shoul! /e ;ero if the e3uation #ere
sole! perfectly. (t is the a/solute alue of the !ifference
/et#een the left an! right han! si!es of the e3uation. 0or
e:ample- soling S(*(:) = .D might gie as a resi!ual
O 14&1C P S(*(:)&.D=0
,he num/er in /races- 14&1C- is the resi!ual. (t is the a/solute
alue of S(*(:)&.D using the sole! alue of :. Resi!uals of this
si;e are 3uite common- as internally Mercury calculates to 1C&!igit
precision- an! there is no machine representa/le : for #hich S(*(:)
is e:actly 0.D.
,he e3uation to the right of the /races is often the same as one of
the input e3uations- /ut sometimes Mercury rearranges some terms.
(t might /e a simple rearrangement as a/oe- /ut it may also the
result of sym/olically soling for one of aria/les an! su/stituting
it into other e3uations. (n any case- the e3uations sho#n #ith the
resi!uals are the actual e3uations use! /y the soler. Some control
of the sym/olic su/stitutions is allo#e! /y the F4A4F statement or
the Feel option un!er the Soler menu.
.ccasionally- you may see aria/les name ,1- ,2- ... ,hese are temporary
aria/les intro!uce! /y Mercury in the course of soling. Most
commonly- they are use! to enforce ine3uality constraints.
,he constraint
4E"(: H y) H y 9 ; R= 10
may /e replace! #ith
4E"(: H y) H y 9 ; H ,1 = 10
,1 S= 0
,he latter has some technical a!antages- een though there is an
e:tra e3uation an! an e:tra aria/le. Aalues for the e:tra aria/le
are not sho#n.
0inally- the solution en!s #ith the largest resi!ual- the metho!- an!
the processor. ,he largest resi!ual is simply the ma:imum of the
preious resi!uals. Assuming your pro/lem is not scale! too /a!ly-
then anything less than a/out 14&10 shoul! /e consi!ere! a success.
,he metho! is 4:act- 2irect- or (teratie. ,he e:act an! !irect
solers are more relia/le- an! Mercury tries them first. ,his logic
can /e altere! #ith the M4,1.2 statement. ,he processor is a $0$%-
$02$%- $05$%- or emulator.
Reports
&&&&&&&
A report is an unformatte! ascii file hol!ing the pro/lem an! the
solution. (t can /e sae! to !is< or printe! to <eep a recor! of
the solution. ,o sae to !is<- press 6o in the Report menu. (,his
menu item !oesn)t /ecome actie until you hae sole! a pro/lem.)
*ormally- the report has the same name as the pro/lem /ut #ith the
.4?A suffi: replace! #ith .R",. >ou can use other file names if you
please.
Another #ay to <eep a recor! of pro/lems an! solutions is to hae
a Fog file. Gust turn Capture .n in the Report menu. ,hen all
pro/lems an! solutions #ill /e appen!e! to a log file.
,he reports an! logs are or!inary ascii files- an! can /e printe!.
(f you hae a "ostscript printer- you #ill hae to select a mo!e
in #hich it #ill accept an ascii file- or loa! a utility for
printing ascii files. (*o such utility is proi!e! #ith Mercury.)
6raphics
&&&&&&&&
Mercury may /e use! to generate graphs. ,hese isually sho#
the /ehaior of functions. A graphics monitor is re3uire!.
,o get a graph- you must first !efine a function of one aria/le
in your pro/lem file. An e:ample from the file '=M">.4?A is
/umpy(:) += :Q2 S(*(:)
#hich !efines a function calle! I/umpyI. ,he I:I is a !ummy aria/le.
,he has alues func(0) = 0Q2 S(*(0)- func(1) = 1Q2 S(*(1)- etc. ,o
graph the function from &1D to H1D- use the statements+
"F., /umpy
6'.=*2S &1D- H1D
,o assimilate this information into the Mercury soler- you must !o
a Sole- een though you are not really soling for anything in this
case. .nce the pro/lem has /een sole!- the Aie#- "rint- an! 8rite
comman!s /ecome aaila/le un!er the 6raph menu. Select Aie# to see
the graph on the screen.
(f the graph loo<s a little ragge!- perhaps not enough points #ere
use! to plot it. ,he !efault is 50. (ncreasing it to 100 #ill gie
a much smoother graph. ,his can /e !one /y either a!!ing the
6".(*,S 100 statement to the pro/lem file an! soling it again- or
/y selecting 6"oints from the 6raph menu.
(t is also possi/le to hae IparametricI plots- #here /oth E an!
> are functions of some other in!epen!ent aria/le. Merely use
the EAE(S statement to specify the E function. ,he 6'.=*2S statement
then refers to the in!epen!ent aria/le.
,hese graphs can /e printe! on graphics printers. ,his inclu!es
most printers- e:cept for !aisy&#heel printers. Selecting "rint
#ill print the graph to #hateer printer has /een selecte! un!er
the .ptionsM"rinter menu.
>ou can also select 8rite- #hich prints the graph to a file. Such
a file can /e sent to a printer at a later time. ,he primary
usefulness of this feature is to e:port the graph in Fotus or
"ostscript format- #here it can /e importe! /y another program.
,he arious options in the 6raph menu are really the !efaults- an!
are oerri!!en /y the correspon!ing statements in the pro/lem file.
(f there are statements in the pro/lem file setting graph options-
then the menu may not accurately reflect the options use! to !ra#
the graph. *eertheless- once a graph has /een create!- these
options can /e mo!ifie! from the graph menu- an! then Aie# #ill
sho# the reise! graph.
7. 0eature Reference
,his chapter gies an alpha/etical loo<up for the Mercury /uilt&in
functions an! statements.
.perators
&&&&&&&&&
H a!!.
& su/tract.
9 multiply. a space may also /e use!.
M !ii!e.
Q po#er. 4g- 2Q5 = $.
V comple: con@ugate.
R less than.
R= less than.
S greater than.
S= greater than.
= e3uals.
+= aria/le initiali;ation or function !efinition.
+ e3uation separator.
U percent- eg- 1%U = .1%.
,hese hae the usual mathematical prece!ence rules- #ith Q haing
higher prece!ence than 9 an! M- #hich in turn are higher than H an! &.
Constants
&&&&&&&&&
,hese t#o constants are /uilt&in.
(*0 plus infinity
"( 5.171D92CD5D... >ou can also use the gree< letter /y typing Alt&".
0unctions
&&&&&&&&&
0unctions ta<e one or more arguments. ,he arguments are separate!
/y commas an! enclose! in parentheses. 1ere is a list of the
/uilt&in functions. A!!itional functions can /e !efine! #ithin
a pro/lem file.
A'S(:)
,he a/solute alue of :. >ou can also use W:W.
AC.S(:)
,he arc cosine of :- inerse to C.S(:).
,he result is in ra!ians.
AS(*(:)
,he arc sine of :- inerse to S(*(:).
,he result is in ra!ians.
A,A*(:)
,he arc tangent of :- inerse to ,A*(:).
,he result is in ra!ians.
'4SSG(n-:)
,he 'essel function of the first <in!.
,he first argument must /e an integer.
'4SS>(n-:)
,he 'essel function of the secon! <in!- sometimes
also calle! the 8e/er function.
,he first argument must /e an integer.
0or each n- it is a solution to 'essel)s
!ifferential e3uation #ith a singularity at ;ero.
'(*.M(n-<)
,he num/er of com/inations- choosing < of n items.
6ien /y nX M (<X (n&<)X).
C4(F(:)
,he smallest integer greater than or e3ual to :.
4g- C4(F(7.%) = D.
C.S(:)
,he cosine of :. ,he angle : is measure! in ra!ians.
C.S1(:)
,he hyper/olic cosine of :- (4E"(:) H 4E"(&:))M2.
C,4RM(rate-f-p)
,he num/er of perio!s re3uire! for a gien present
alue (p) to increase to a gien future alue (f)
if it gro#s at the gien interest rate. ,he function
is compati/le #ith KuattroMFotus.
24R(A(f(:)-:)
,he !eriatie of the function f(:) #ith respect to :.
(n most cases- the !eriatie is compute! sym/olically.
2F6AMMA(n-:)
,he n&th !eriatie of F.66AMMA- n = 0-1-2-...
4R0(:)
,he error function of :. (t is relate! to *C=M(:).
4R0(:) = 2 *C=M(: SKR,(2)) & 1
4g- 4R0(&(*0) = &1- 4R0(0) = 0- 4R0(H(*0) = H1.
4R0C(:)
,he complementary error function of :. See 4R0 an! *C=M.
4R0C(:) = 1 & 4R0(:)
4g- 4R0C(&(*0) = H1- 4R0C(0) = 0- 4R0C(H(*0) = &1.
4E"(:)
,he e:ponential function of :- eQ:- e = 2.%1$2$...
(t is the inerse to F*(:).
0AC,(:)
: factorial- sometimes #ritten :X.
4g- 0AC,(D) = D97959291 = 120.
0F..R(:)
,he largest integer less than or e3ual to :.
4g- 0F..R(7.%) = 7.
0RAC(:)
,he fractional part of :- : & 0F..R(:).
4g- 0RAC(7.%) = 0.%.
0A(pmt-rate-nper)
,he future alue of payments (pmt) at the en! of nper
perio!s- assuming the gien interest rate.
,he function is compati/le #ith KuattroMFotus.
0AAF(rate-nper-pmt-p)
6ies the future alue of a financial #ith a payment
pmt in each of nper perio!s- #ith the gien present
alue p- an! the gien interest rate.
,he function is compati/le #ith Kuattro "ro.
(t uses the financial mo!e specifie! /y the 0(*A*C4
statement to !etermine #hether the payments are at the
en! of the perio! (the !efault) or the /eginning.
1>".,(:-y)
,he polar coor!inate ra!ius correspon!ing to cartesian
coor!inates (:-y). 4g- 1>".,(5-7) = D.
(0".S(:-y-;)
6ies y if : S= 0- else it gies ;. 4g- (0".S(&5-C-%) = %.
(M(:)
,he imaginary part of :. ,he C.M"F4E option must /e in use.
(*,46(f(:)-:-a-/)
(*,46(f(:)-:-a-/) gies the numerical integral of f(:) #ith
respect to : from a to /. (mproper integrals are allo#e!- so a
can /e &(*0- / can /e H(*0- an! f can /e singular at a or /. ,he
appro:imation metho! is a!aptie an! nonlinear- an! often is
accurate to 1D !igits.
(*,461(f(:)-:-a-/)
(*,461 is similar to (*,46- /ut uses a simpler
strategy. (t is nona!aptie an! linear- an! may /e preferre! in
situations #here the result is suppose! to /e a smooth function
of a an! /. (*,461 is not nearly as accurate as (*,46 on
singular functions.
F(M(,(f(:)-:-a-(*0)
4stimates the limit of f(:)- as : goes from a to infinity.
(t uses a numerical metho! to compute the limit
of f(:)- as : goes from a to infinity. (t is an nonlinear
e:trapolation /ase! on a fairly small num/er of terms. ,he
limit is only relia/le if the function is #ell&/ehae!- an!
this feature shoul! /e use! #ith caution.
F*(:)
,he natural logarithm (/ase e) of :.
(t is the inerse to 4E"(:).
F.610(:)
,he logarithm of : to the /ase 10. ,he inerse is 10Q:.
F.66AMMA(:)
,he logarithm of the gamma function of :.
MAE(:-...)
,he ma:imum alue of the arguments.
4g- MAE(&10-D-%) = %.
M(*(:-...)
,he minimum alue of the arguments.
4g- M(*(&10-D-%) = &10.
*C=M(:)
,he normal cumulatie pro/a/ility function. *C=M(E) is the
pro/a/ility that a normal ran!om aria/le is /elo# its mean-
plus E stan!ar! !eiations.
4g- *C=M(&(*0) = 0- *C=M(0) = .D- *C=M(H(*0) = 1.
"A>M,(rate-nper-p-f)
6ies the present alue of a financial #ith a payment
pmt in each of nper perio!s- #ith the gien future
alue f- an! the gien interest rate.
,he function is compati/le #ith Kuattro "ro.
(t uses the financial mo!e specifie! /y the 0(*A*C4
statement to !etermine #hether the payments are at the
en! of the perio! (the !efault) or the /eginning.
"M,(p-rate-nper)
6ies the amount of the payments re3uire! in each of nper
perio!s to /alance the gien present alue p an! interest rate.
,he function is compati/le #ith KuattroMFotus.
".FAR(:-y)
,he polar coor!inate angle correspon!ing to cartesian (:-y).
Same as the KuattroMFotus YA,A*2(:-y) or the 0ortranMC atan2(y-:).
".F>(:-a0-a1-...-an)
,he polynomial a0 :Qn H ... H an.
4g- the polynomial 2 :Q5 & 5 : H % can also /e #ritten
".F>(:-2-0-&5-%). ,he chief a!antage of the latter is
notational conenience- an! so it can /e recogni;e! /y the
special polynomial soler.
".S(:)
,he positie part of :- ie- : if positie an! 0 if negatie.
"A(pmt-rate-nper)
6ies the present alue of nper payments of amount pmt-
using the gien interest rate.
,he function is compati/le #ith KuattroMFotus.
"AAF(rate-nper-pmt-f)
6ies the present alue of a financial #ith a payment
pmt in each of nper perio!s- #ith the gien future
alue f- an! the gien interest rate.
,he function is compati/le #ith Kuattro "ro.
(t uses the financial mo!e specifie! /y the 0(*A*C4
statement to !etermine #hether the payments are at the
en! of the perio! (the !efault) or the /eginning.
RA,4(f-p-nper)
6ies the interest rate re3uire! for the present
alue (p) to increase to the future alue (f) in
nper perio!s. ,he function is compati/le #ith KuattroMFotus.
R4(:)
,he real part of :. ,he C.M"F4E option must /e in use.
R4M(:-y)
,he remain!er of : !ii!e! /y y. 4g- R4M(20-5) = 2.
S6*(:)
6ies H1 if : S 0- &1 if : R 0.
S(*(:)
,he sine of :. ,he angle : is measure! in ra!ians.
S(*1(:)
,he hyper/olic sine of :- (4E"(:) & 4E"(&:))M2.
SKR,(:)
,he s3uare root of :.
S=M(f(:)-:-a-/)
,he sum of f from a to /-
f(a) H f(a H 1) H ... H f(/)
(f / = H(*0- the limit is estimate! as #ith the F(M(, function.
,A*(:)
,he tangent of :- S(*(:)MC.S(:).
,he angle : is measure! in ra!ians.
,A*1(:)
,he hyper/olic tangent of :- S(*1(:)MC.S1(:).
,4RM(pmt-rate-f)
,he num/er of perio!s re3uire! for a gien payment
stream (pmt) to increase to a gien future alue (f)
if it gro#s at the gien interest rate.
,he function is compati/le #ith KuattroMFotus.
Statements
&&&&&&&&&&
'.=*2S lo#er-upper
Specify /oun!s for the !omains of the aria/les. ,he !efault is
'.=*2S &(*0-(*0. Some soling time can /e sae! #ith the
statement '.=*2S &1eC-1eC if you are sure that all the releant
alues of your aria/les are less than a million.
CAS40.F2
(gnore case in names. .ther#ise- the aria/le : is !ifferent from E.
CAS4S,R(C,
=sing CAS4S,R(C,- #ith no args- causes /uilt&in functions-
constants- an! statements to /e upper case only. *ormally such
pre!efine! names are not case sensitie- so S(*(:) is the same as
sin(:). =sing this option re!uces the chance of a name conflict.
C.M"F4E
2eclares that all the aria/les are to /e consi!ere! comple:
aria/les. ,heir solutions hae a real an! imaginary part.
,hese /uilt&in functions may /e use! in a comple: pro/lem+
A'S- C.S- C.S1- 4E"- (M- F*- R4- S(*- S(*1- SKR,-
S=M- ,A*- ,A*1.
2(6(,S n
2isplay real num/ers to n !igits of precision. ,he !efault is 1$.
4"S(F.* :
0orces num/ers ery close to ;ero to /e !isplaye! as ;ero. =seful
for sho#ing comple: num/ers #hich are actually real. 2efault is 4"S(F.* 0.
4E,4R*AF function
2eclares the name to /e an e:ternally !efine! function- to /e
foun! on the !is< in the pro/lem !irectory #ith the file name
function.'(*. ,hese functions are #ritten in ,ur/o CHH or ,ASM-
an! compile! into .'(* files. See the samples.
0(*A*C4 type
6ies the type parameter to the Kuattro compati/le financial
functions- "AAF- "A>M,- an! 0AAF. ,he !efault is
type = 0- meaning that the payments are at the en! of the
perio!. =se type = 1 if the payments are at the /eginning.
6'.=*2S :left- :right
,he lo#er (:left) an! upper (:right) /oun!s for the E&a:is in a graph.
6".(*,S n
,he num/er of points (function alues) use! to !ra# a graph. ,he
!efault is 50. (f your graph is too ragge!- try increasing the
num/er of points.
6S,>F4 n
Allo#s graph cures to /e thic< (6S,>F4 0) or thin (6S,>F4 1).
(*CF=24 filename
,he file #ith the gien name is inserte! in the pro/lem at
that point. ,he filename must /e in 3uotes- as in (*CF=24 IC.*S,.(*CI. ,he
!efault file name e:tension is .(*C. (nclu!e files cannot /e neste!.
(,4RA,(.*S n
,he ma:imum num/er of iterations use! /y the iteratie soler. ,he
!efault is 100.
F464*2
"uts a legen! on the graph #hich i!entifies the function or functions.
Recommen!e! #hen plotting more than one function.
F4A4F n
Allo#s user control oer #hat sym/olic su/stitutions are ma!e.
0. no sym/olic soling
1. sole E = constant
2. sole E = constant e:pression
5. sole only #hen E occurs once- no other aria/les
7. sole only #hen E occurs once- other aria/les possi/le
D. sole linear e3uations
C. sole s3uares- using s3uare roots
%. sole 3ua!ratic e3uations
$. sole po#ers
,he !efault is F4A4F D- soling linear e3uations /ut not using
s3uare roots. Strictly spea<ing- the su/stitutions inoling
roots are not mathematically e3uialent- as the su/stitution must
ar/itrarily choose the positie or negatie s3uare root.
(t is sometimes prefera/le to use F4A4F 0 to turn off all the
sym/olic manipulations. ,hen Mercury effectiely #eights all
e3uations e3ually- an! the solution can /e consi!ere! the solution
to a least s3uares pro/lem.
F(S, function
Fist one or more functions in the solution #in!o#. Synta: is the
same as for "F.,.
MAE(M(J4 :
,he aria/le : is ma:imi;e!.
M4,1.2 n
Specify the soler metho!- #here n = 1- 2- or 5.
1. 4:act
2. 2irect
5. (teratie
,he !efault is M4,1.2 1- the e:act soler. (f it fails- the !irect
soler is trie!- an! it that also fails- the iteratie soler is
trie!.
M(*(M(J4 :
,he aria/le : is minimi;e!.
"4*AF,> n
,he alue of the penalty constant- an ar/itrary constant use!
to enforce constraints #hen the iteratie soler is use! to
ma:imi;e or minimi;e a aria/le. ,he !efault is 50. (ncreasing
it forces the appro:imate solutions closer to the constraint
manifol! at the cost of ma<ing the e:tremum har!er to fin!. Rea!ers
of ,he 1itchhi<er)s 6ui!e to the 6ala:y suggest using the alue 72.
"F., function
Creates a plot of the name! function. ,o ie# the graph- select
6raph from the main menu. ,o plot seeral functions on the same
graph- list the names separate! /y commas. ,he functions must /e
!efine! in the pro/lem file- an! /e functions of one aria/le. 0or
e:ample- to plot S(*(:) an! :Q5&: from &D to HD- use
f(:) += S(*(:)
g(:) += :Q5 & :
6'.=*2S &D- HD
"F., f- g
"R(*,
Same as "R(*,0(F4 IF",1I. (t prints the graph to the 2.S !eice F",1-
#hich is usually a printer on parallel port 1. ,he printing can /e
configure! to use another port from the .ptions menu- an! the result
sae! to a setup file.
"R(*,0(F4 filename
"rint the graph to the gien file- #hose name is in 3uotes.
,hese names hae special meaning.
I"AR1I parallel port 1
IS4R1I serial port 1
I"AR2I parallel port 2
IS4R2I serial port 2
IF",1I 2.S lpt1
IF",2I 2.S lpt2
IF",5I 2.S lpt5
IF",7I 2.S lpt7
I4",I ('M postscript port
"R.6R4SS :
Sho# the alue of the aria/le : in the "rogress /o:. Mercury
!oes not sole for all aria/les at once- so sometimes there
might /e no alue for the aria/le until the en! of the solution
process. (n such cases- the "rogress #in!o# sho#s I: = *A*I-
meaning I: is not a num/erI.
(f no "R.6R4SS statement is gien- the "rogress #in!o# sho#s the
alue of the IResi!ualI. ,his is the sum of s3uares of 3uantities
#hich shoul! /e ;ero- an! #hich Mercury is trying to minimi;e. ,he
smaller the alue- the more li<ely that Mercury is getting close to
the solution.
R4".R, filename
Allo#s naming a report file from #ithin a pro/lem.
R..,S(6* n
8hen soling an e3uation li<e :Q2 = a- Mercury may ta<e the s3uare
root of /oth si!es. ,his intro!uces t#o roots- HSKR,(a) an!
&SKR,(a)- an! Mercury !oes not <no# #hich to ta<e. >ou can specify
that you al#ays #ant the positie root #ith R..,S(6* H1- or
al#ays the negatie root #ith R..,S(6* &1. ,he !efault is
R..,S(6* 0- #hich leaes Mercury una/le to ealuate the s3uare
root.
SCR44* n
Choose a graphics screen. ,he !efault is SCR44* 0- #hich means
Mercury automatically tries to !etect your graphics har!#are.
Some graphics car!s an! mo!es cannot /e !etecte!- an! must /e
selecte! #ith a SCR44* statement.
0. Auto2etect
1. C6A
2. MC6A
5. 46A C7<
7. 46A 2DC<
D. 46A Mono
C. ('M $D17
%. 1ercules
$. A,, 700 line
9. A6A
10. 52%0 "C
11. ,an!y 1000
12. A,( Super A6A
15. .rchi! Super A6A
17. "ara!ise Super A6A
1D. Aega Super A6A
1C. Compro A'F4 (( Super A6A
1%. S.,A Super A6A
0rom the main menu- the graphics screen can /e selecte! #ith
6raphMMo!e. Such a selection is ineffectie after the first
graph is !ra#n- as the graphics has /een initiali;e! at that
point. 8e recommen! saing the !esire! graphics mo!e to the
M4RC=R>.C06 configuration file.
(*ote+ ,he !riers for some of these graphics mo!es is not
inclu!e! #ith some ersions of Mercury. Registere! customers
receie the full set of !riers.)
S1.8 :
Sho# specifie! aria/les in the specifie! or!er. .ther aria/les
are not !isplaye! in the solution #in!o#.
S.FA4 :
(nstructs Mercury to sole only for the aria/le :. 'y !efault- it
soles for all aria/les name! in the pro/lem.
(f S.FA4 is gien #ith a polynomial function name- as in
S.FA4 f
f(:) += ".F>(:-1-0-0-1)
then Mercury #ill apply a special polynomial root fin!er to get all
real an! comple: roots.
S,AR, :
,he starting alue for uninitiali;e! aria/les #hile using the
iteratie soler. ,he !efault is 1.00.
,4RMS n
,he most num/er of terms use! /y the (*,46 an! F(M(, functions. ,he
!efault is D0.
,(M4 n
,he ma:imum time allo#e! for solution. ,he !efault is 200 secon!s.
Same as MAE,(M4 in 4ure<a 1.0.
,(,F4 la/el
Argument is a 3uote! string- to /e use! as a graph title.
2efault is no title.
S=',(,F4 la/el
Argument is a 3uote! string- to /e use! as a graph su/title.
2efault is no title.
EFA'4F la/el
A la/el for the E&a:is of a graph. ,he la/el must /e in 3uotes.
>FA'4F la/el
A la/el for the >&a:is of a graph. ,he la/el must /e in 3uotes.
EAE(S function
Specifies that the E&a:is /e a function instea! of an in!epen!ent
aria/le. ,he function must /e !efine! else#here as a function
of one aria/le.
,he E a:is of the graph is a function #ith the gien name. =seful
for parametric plots. 4g- to graph (:-y) = (cos(t)-sin(t)) as
t goes from 0 to 29"(- use
:(t) += cos(t)
y(t) += sin(t)
6'.=*2S 0- 2 "(
EAE(S :
"F., y

You might also like