Вы находитесь на странице: 1из 1

INTRODUCTION TO MATHCAD

Mathcad is a "numerical scratchpad" which allows you to solve comple systems o! e"uations# !ind
roots o! polynomials and plot results$ It can evaluate inte%rals and derivatives# &oth numerically
and sym&olically$ Units are easily incorporated# and numerical answers cannot &e !ound i! the units
are inconsistent$ Mathcad is a power!ul tool# &ut easy to use$ These notes are a &rie! introduction$
They are meant to &e used while wor'in% in Mathcad$
I! you enter Mathcad# you will notice there are several menus that appear on the top line ()ile# *dit#
Tet# etc$+$ There is a drop,down "Math" palette containin% icons !or calculator# %raphs# matrices#
etc$ I! you move the cursor to an icon# there is a &rie! messa%e eplainin% it$ I! you clic' on an
icon# a palette with various operations appears$ Clic' on the calculator palette and select the
sym&ol$ Type - and you %et
3.142
.ome sym&ols# such as # % (acceleration o! %ravity+ and R (de%rees Ran'ine+# have a speci!ic meanin%
unless you rede!ine them$
Now# choose the nth root sym&ol and put in some num&ers# such as/
6
458247 8.78
To enter a num&er# 0ust clic' on the appropriate placeholder (the &lac' &o+$
These eamples show how to use the "-" si%n# which means evaluate or calculate$ Mathcad
can &e used as a calculator in this way# althou%h it is a &it epensive and not particularly
porta&le (unless you have a lap top+$ I! you choose the *valuation and 1oolean icon# you will
see there are several 'inds o! e"uals# in addition to ine"ualities$ The "/-" si%n means "is
de!ined &y$" Type !ollowed &y this si%n# and assi%n a num&er such as/
x 4.75 :
In addition to usin% the *valuation palette# this "/-" si%n can &e inserted simply &y typin% a colon (/+$
Once is de!ined# we could then use it in an epression such as/
ln x ( ) x
2
+
To %et the natural lo%# simply type "ln"$ There are a num&er o! &uilt in !unctions availa&le as
you can see &y clic'in% o! the "!(+" icon and scrollin% throu%h the list$ It includes error
!unctions and 1essel !unctions# in addition to the more mundane ones$ *ach comes with a
&rie! eplanation$ There are also !unctions !or numerical inte%ration usin% the Run%e,2utta
method$ 3e will use the simple ones here$
Return to the present pro&lem$ I! you now type a re%ular e"uals si%n# !rom the palette or the
'ey&oard# you %et/
ln x ( ) x
2
+ 24.121
4ou could also de!ine a dependent varia&le# !# as this !unction o! # !or use in later calculations/
f ln x ( ) x
2
+ :
I! you want the numerical value o! !# simply type
f 24.121
This type o! !unction may &e called eplicit/ you can write ! e"uals some epression which contains
only the independent varia&le# $ .uppose# however# we turned the e"uation around and wanted to
!ind the !or which/
24.121 ln x ( ) x
2
+
This is an eample o! an implicit e"uation$ 4ou cannot rearran%e this to %et it into the !orm -
(somethin% containin% no +$ 4ou can# however# solve this e"uation in Mathcad$ This is
accomplished
in a "%iven , !ind" &loc'$ Mathcad does this numerically and needs initial %uesses !or the
un'nowns# in this case $ *nter a %uess/
x 1 :
Then type "%iven" with or without a capital 5$ (In most cases# Mathcad is not case sensitive$+
Given
Net# enter the e"uation$ In these &loc's you must use a third type o! "e"uals" which
means "is constrained &y" and is used in these "%iven,!ind" &loc's$ (In the *valuation
palette# this is called a "1oolean e"uals$"+ This is the &old !aced "-" !rom the evaluation
palette (or CTR6 - !rom the 'ey&oard+$
24.121 ln x ( ) x
2
+
To %et an answer# type "!ind(+" !ollowed &y an -
Find x ( ) 4.75
I! you net type -# you will not see the solution (7$89+# &ut the initial %uess$ This is &ecause you
have not rede!ined the value o! $ I! you want the value o! to &e the solution# you can proceed
as !ollows/
x 1 :
(Initial %uess+
Given
24.121 ln x ( ) x
2
+
x Find x ( ) :
Now has &een replaced &y the solution o! the e"uation$ To see the value# 0ust type/
x 4.75
The ma0or restriction on the %iven,!ind statements is that you cannot use %eneral su&scripted
varia&les (i$e$# i or 0+ in them$ 4ou can# however# solve some interestin% pro&lems$ In the analysis
o! !low o! a power law !luid in an annulus# you need to !ind the value o! in the !ollowin% e"uation/

,
1
n

(
(
(
(
(

1


2

,
1
n

(
(
(
(
(

d
where is the ratio o! the inner to the outer radius# n is the power law inde and is the radial
coordinate$ In order to %et the inte%ral si%n# %o to the calculus palette and choose the de!inite
inte%ral$ 3e can solve this e"uation usin% "%iven , !ind" as a&ove$ )irst de!ine the and n and
%uess a value !or /
0.4 : n 0.3 : 1 :
Given

,
1
n

(
(
(
(
(

1


2

,
1
n

(
(
(
(
(

d
Find ( ) 0.657
3e can also include units in Mathcad calculations$ Many units are already de!ined in Mathcad:
others can &e assi%ned$ I! you clic' on the measurin% cup# you can see a list o! the units
availa&le$ 4ou can chan%e the de!ault system o! units &y choosin% Math then Units then Chan%e
.ystem o! Units$ However# whatever system o! units you are in# you can also always %o !rom one
to another$ )or eample# ta'e the acceleration o! %ravity# %$ Type %- to see its value in .I
(presumin% the de!ault system is set on M2.+/
g 9.807m s
2

4ou notice a "placeholder" or a &lac' s"uare a!ter the units$ Clic' on this value and insert another
set o! units/
g 5.004 10
9
in hr
2

As an eample o! a pro&lem with units# suppose we want investi%ate the ;,<,T &ehavior o!
methane usin% the Redlich,2won% e"uation o! state$ )irst# we enter the critical values !or
methane/
Tc 190.6 K : c 45.99 !"r :
3hen you do this# the pressure units# &ar# are hi%hli%hted$ Mathcad doesn=t reco%ni>e that unit$ 3e
can de!ine this as a new unit usin% the third type o! e"ual si%n/
!"r 10
5
"
Here is yet another type o! e"uals$ 4ou can %et this sym&ol !rom the *valuation ;alette# or
&y typin% a tilde (?+$ Once you de!ine the units &ar in this !ashion# the hi%hli%ht disappears$
Notice# however# what happens i! you use the "/-" to de!ine the &ar unit$ In this case# the &ar
in the ;c e"uation still remains hi%hli%hted$ This "triple e"uals" is a "%lo&al assi%nment:" it=s
%ood throu%hout the Mathcad document$ The other e"uals (/-+ means the de!inition is %ood
!rom this point on# and can &e re,de!ined$
Now# introduce the %as constant and the two constants associated with the Redlich,2won%
e"uation/
# 1.987
c"l
m$le K
:
! 0.08664 #
Tc
c
:
" 0.42748 #
2

Tc
5
2
c
:
3e can de!ine the moles in terms o! %rams !or methane/
(.ee what happens later i! you do not use this %lo&al
assi%nment$+
m$le 16 gm
.uppose we were %iven a volume and a temperature and wanted to !ind the pressure$ The
speci!ied temperature and volume are/
T 165 K : v 53.29
cm
3
m$le
:
Accordin% to the Redlich , 2won% e"uation# pressure is %iven &y the epression/

# T
v !
"
v v ! + ( ) T
1
2

:
There!ore/
19.12 "%m
To !ind the volume at @A92 and @B$CB &ar# we have to solve an implicit e"uation usin% 5iven , )ind/
19.39 !"r : v 1.0
m
3
m$le
: (Initial %uess+
Given

# T
v !
"
v v ! + ( ) T
1
2

Find v ( ) 0.032
m
3
&g

The de!ault units o! '% and m can &e chan%ed to moles and cm# or anythin% else you desire$
In this pro&lem# as in many others# the solution is sensitive to the initial %uess$ Try usin% a
di!!erent value !or the %uess$ .ometimes# the numerical procedure will not conver%e# or will
conver%e on a di!!erent root$
One o! the other Mathcad !eatures is root !indin%$ 5iven a polynomial# we can !ind all the
roots# real and ima%inary# usin% the "polyroots" !unction$ To use this !eature in this pro&lem#
!irst# write the e"uation in polynomial !orm$ The Redlich , 2won% e"uation is cu&ic in the
volume (it is an eample o! a "cu&ic e"uation o! state"+/
'
3 # T

'
2
!
2 ! # T

+
"
T
0.5

,
'
" !
T
0.5

0
Net# !orm a vector# call it <# o! the coe!!icients in this e"uation$ The !irst element is the
coe!!icient o! <
0
# the net# <
@
# etc/
Notice that the elements o! this vector# as with
any vector# must have the same units$ To use
the root !indin% !unction# however# the elements
must all &e dimensionless$ The three roots are
then !ound simply &y usin% the "polyroots"
!unction/
'
"
!
T
.5

&g
3
m
9

!
2
! #
T

,
"
T
.5

1
1
]

&g
2
m
6

#
T

&g
m
3

1
1
1
1
1
1
1
1
1
1
1
]
:
($l)r$$%s ' ( )
3.33 10
3

8.845 10
3

0.032

To decide on which root means what# we have to 'now a little a&out the physics o! the situation$
The vapor volume is the maimum value# so de!ine/
'g m"x ($l)r$$%s ' ( ) ( )
m
3
&g
:
.ince we too' out the units in the vector <# we have
to add them &ac' a%ain$ 3e also have to put &ac'
the same ones we too' out# that is# i! we multiplied the
elements o! < &y '%Dm
C
# we must use m
C
D'%a s the units !or <$
'g 0.032m
3
&g
1

The li"uid volume is the minimum/
'f min ($l)r$$%s ' ( ) ( )
m
3
&g
:
'f 3.33 10
3
m
3
&g
1

The middle value has no physical si%ni!icance$ (It mi%ht &e interestin% to some# at least# to note
that the actual vapor volume o! methane at these conditions is E$ECF# as calculated$ The li"uid
volume is C$EB9 @E
,C
$+
Try usin% a di!!erent T and ;# say CEE2 and @ atm# and see what the roots are$
Now# let=s plot the compressi&ility !actor !or methane as a !unction o! pressure !or a temperature o! CEE2$
3e need to !ind v !or a num&er o! values o! ;$ However# only one %iven,!ind statement is needed$ 3e can
proceed as &e!ore/
T 300 K :
(3e already have an initial %uess !or v a&ove$+ *" 10
6
"
Given

# T
v !
"
v v ! + ( ) T
1
2

v ( ) Find v ( ) :
The v(;+ means that v is a !unction o! ;: !or each value o! ;# a di!!erent v is !ound$ I! we speci!y
a particular value o! ; we %et a numerical answer/
v 4 *" ( ) 0.036m
3
&g
1

Now# introduce a ran%e o! pressures$ This could have &een done &e!ore the %iven , !ind statement i!
desired/
0.1 *" 0.2 *" , 10 *" .. :
This means ; ta'es on the values E$@# E$F# E$C# $$$ all the way to @E M;a$ The two dots appear
when you type a semicolon (:+$ Note that units must &e included$
De!ine the compressi&ility !actor/
+ ( )
v ( )
# T
:
Notice that > is also a !unction o! ;$ Now create an ,y plot usin% the 5raphics menu# the
5raphin% palette# or simply .H)T G$ ;ut the cursor on the placeholders !or the and y aes
and put in ; and >(;+# respectively/
0 2 10
6
4 10
6
6 10
6
8 10
6
1 10
7

0.85
0.9
0.95
1
+ ( )

Notice the values o! ; are much lar%er than you de!ined$ That=s &ecause this ; is in ;a (the
de!ault units !or pressure+# not M;a$ To chan%e the scale# you can plot ;DM;a rather than ;
(or ;Datm# ;Dpsi# or anythin% you want+$ I! you dou&le clic' on the %raph# or i! you choose
")ormat" with the ri%ht mouse &uton# you can customi>e your %raphs$ 1y clic'in% the mouse
in the re%ion near the %raph (or anythin% else+# you can %et a line enclosin% it$ 4ou can move
the %raph# tet or e"uation anywhere on the pa%e usin% the cursor$ 3hen the cursor is at the
&oundary o! the line# an arrow appears$ This can &e used to re,si>e the %raph$
As an eample o! a somewhat more complicated pro&lem# consider the velocity o! a !reely !allin% drop o! water
in air$
The diameter o! the drop is/
, 1.0 mm :
Density o! the water/ s 62.4
l!
f%
3
:
Density and 'inematic viscosity o! air/ 0.0735
l!
f%
3
:
0.169 10
3

f%
2
sec
:
The drop velocity v depends on the !riction !actor !# which also depends on the Reynolds
num&er# NRe# vDD$ 3e can write this as F e"uations with F un'nowns# v and !$ In addition# i!
we are a&ove the creepin% !low re%ime# ! is %iven &y one o! two epressions# dependin% on the
value o! the Reynolds num&er$ I! NRe is %reater than 9EE# ! is E$77$ I! NRe is less than 9EE# !
depends on NRe$ The "i!" statement in Mathcad provides an easy way to handle this$ The
synta o! this statement is/ i! (condition# true# !alse+$ In this eample# ! e"uals E$77 i! vDD is
%reater than 9EE$
Initial %uesses/
v 1
f%
sec
: f 0.44 :
Given
Momentum &alance/ f
4
3
g
,
v
2

f if
v ,

500 <
18.5
v ,

,
3
5
, 0.44 ,

1
1
1
1
1
]
)riction !actor/
The solution to this %iven , !ind statement will &e a two component vector# v and !$ To !orm this
vector# %o to the <ectors and Matrices ;alette# choose the sym&ol !or a matri# enter the num&er o!
rows and columns (F and @ in this case+# and hit "Create"$ 4ou will then see a %eneral F component
vector$ De!ine the elements as the un'nowns and de!ine this vector as the "!ind"/
v
f

,
Find v f , ( ) : v 13.501
f%
sec

f 0.655
The value o! the Reynolds num&er is/ -#e
v ,

: -#e 262.094
There is o!ten an easier way to set a pro&lem up# and so ma'e the solution easier$ <ery o!ten# with
multiple un'nowns in a %iven , solve &loc'# the solution is very sensitive to the initial %uesses$
There!ore# it is always easier to have only one un'nown$ In the present pro&lem# we are interested
in the velocity# and not really the Reynolds num&er and !riction !actor$ 3e could# there!ore# de!ine
these two !unctions outside o! the %iven , !ind statement$
-#e vel ( ) vel
,

: f vel ( ) if -#e vel ( ) 500 <


18.5
-#e vel ( ) ( )
3
5
, 0.44 ,

1
1
1
1
]
:
To avoid any possi&le con!usion &etween these F eamples# we=ll use a di!!erent sym&ol !or velocity$
Initial %uess !or vel/ vel 1
f%
sec
:
Given
f vel ( )
4
3
g
,
vel
2

vel Find vel ( ) : vel 13.501


f%
sec

I! we wanted the Reynolds num&er and the !riction !actor# then we
could evaluate them/
-#e vel ( ) 262.094
f vel ( ) 0.655
3hile it is convenient to have only one un'nown in a %iven , !ind &loc'# it is not always possi&le to do
so$ However# the !ewer the un'nowns# the easier it is to !ind a solution$ The num&er can usually &e
reduced to a num&er smaller than you mi%ht thin'$ It 0ust re"uires a little "up,!ront" thou%ht a&out the
nature o! the pro&lem and what are the 'nowns$ Consider this comple vapor , li"uid e"uili&rium
pro&lem$ A solution o! F,propanol and water is at a pressure o! @E@$CC &ar and the mole !raction o!
propanol in the vapor phase is E$7$ 3e want to !ind the temperature and the mole !raction o! propanol
in the li"uid$ The li"uid phase is non,ideal# and we have to use activity coe!!icients !or the li"uid$
These depend on temperature and li"uid composition$ 3e=ll assume the 3ilson model can &e
employed$
)irst# introduce some constants !or this system o! components/
"
12
437.98
c"l
m$le K
: "
21
1238
c"l
m$le K
: '
1
76.92 : '
2
18.07 :
Two temperature,dependent !unctions which appear in the activity coe!!icient model are/
12 T ( )
'
2
'
1
ex(
"
12
# T

,
: 21 T ( )
'
1
'
2
ex(
"
21
# T

,
:
3e also have the Antoine e"uations !or the vapor pressures/
1s"% T ( ) ex( 16.678
3640.2
T 53.54

,
: 2s"% T ( ) ex( 16.2887
3816.44
T 46.13

,
:
The mole !raction o! component F is/
x2 x1 ( ) 1 x1 :
The activity coe!!icients are/
1 T x1 , ( ) ex( ln x1 x2 x1 ( ) 12 T ( ) + ( ) x2 x1 ( )
12 T ( )
x1 x2 x1 ( ) 12 T ( ) +
21 T ( )
x2 x1 ( ) x1 21 T ( ) +

,
+

1
1
]
:
2 T x1 , ( ) ex( ln x2 x1 ( ) x1 21 T ( ) + ( ) x1
12 T ( )
x1 x2 x1 ( ) 12 T ( ) +
21 T ( )
x2 x1 ( ) x1 21 T ( ) +

1
1
]
:
The total pressure is/
T x1 , ( ) x1 1 T x1 , ( ) 1s"% T ( ) x2 x1 ( ) 2 T x1 , ( ) 2s"% T ( ) + :
Notice that this di!!ers !rom the case o! Raoult=s law &ecuase o! the presence o! the activity
coe!!icients# @ and
The vapor phase composition is %iven &y/
)1 T x1 , ( )
x1 1 T x1 , ( ) 1s"% T ( )
T x1 , ( )
:
There are a lar%e num&er o! un'nowns in this pro&lem/ the vapor pressures# the activity coe!!icients#
the li"uid phase compositions# the temperature$ However# there are only two independent varia&les#
@ and T$ Once these are 'nown# all the others can &e !ound$ The %iven , !ind statement is 0ust/
Initial %uess/
T 200 : x1 0.5 :
Given
T x1 , ( ) 101.33
)1 T x1 , ( ) 0.4
T
x1

,
Find T x1 , ( ) :
T 360.617 x1 0.064
I! desired# we could !ind all the other dependent varia&les/
1s"% T ( ) 124.417 2s"% T ( ) 63.641 1 T x1 , ( ) 5.099 2 T x1 , ( ) 1.021
Mathcad cannot# apparently# handle !unctions which have %eneral su&scripts$ I!# !or eample# you
want to evaluate the vapor pressure o! a set o! components as a !unction o! temperature (as in the
previous pro&lem+# you mi%ht !irst introduce the Antoine constants$ To place a su&script on a
varia&le# use the le!t &rac'et H $ A!ter you enter the !irst num&er# type a comma$ Mathcad will then
start to !orm a vector$
i 1 2 .. : &" 10
3
"
.
i
13.8594
14.0045
: /1
i
2773.78
3279.47
: 01
i
220.07
213.2
:
4ou can either enter the constants
times 2# or rede!ine the values as
done here$
/ /1 K :
0 01 K :
4ou would li'e to de!ine the vapor pressure with an e"uation li'e/

s"%
T ( )
i
ex( .
i
/
i
T 0
i
+

,
&"
4ou can de!ine varia&les with su&scripts as we did here &y typin% ";$" (; with a period+$ This is
sometimes convenient$ There is a !undamental di!!erence &etween the su&script !ormed in this way
and that !ormed with the le!t &rac'et$ The !ormer ("sat" a&ove+ is simply part o! the name o! a
varia&le$ The latter ("i"+ ma'es the varia&le a vector with components i$ In addition# the varia&le i
must &e de!ined separately$
Returnin% to the pro&lem at hand# note that i! you de!ine the vapor pressure in this way (usin%
the /- si%n to de!ine the !unction+ Mathcad tells you this is not a proper name$ One way around
this di!!iculty is to employ the "vectori>e" option/ treat ;
sat
as a vector ma'e the ri%ht side o! the
e"uation a vector$ Notice that we did this sort o! thin% a&ove when we said C/-C@I2$ Instead o!
rede!inin% each o! the components o! C# we rede!ined the whole vector$
3rite the Antoine e"uation without su&scripts# &ut place an over&ar (!rom the <ectors and
Matrices ;alette+ over the entire ri%ht side/

s"%
T ( ) ex( .
/
0 T +

,
&"

:
3ithout the vectori>e operation# Mathcad will want to divide one vector &y another/ an ille%al array
operation$
There is one pro&lem with this approach$ Choose a temperature and evaluate the vapor pressures
(in this e"uation# temperature must &e in Celsius# &ut Mathcad# un!ortunately# cannot %o !rom C to
2$ I! you want to employ Celsius de%rees# you must also use the sym&ol 2 and &e care!ul+/

s"%
90 K ( )
1
136.148
24.247

,
&"
How did we wind up with C pressures when we only de!ined F componentsJ Mathcad always
assumes that the !irst element o! a vector is num&ered E# the net @# and so !orth$ .ince we did not
de!ine the constants A
0
# etc$# Mathcad too' them to &e >ero$ Hence the !irst vapor pressure is
ep(E+ or @$ 3e can %et around this pro&lem &y rede!inin% the !irst element usin% the ORI5IN
command$ (Case is important here$+
1#2G2- 1
Now calculate the pressures/

s"%
90 K ( )
136.148
24.247

,
&"
The !irst element o! the vector is now num&ered @# and we have only F components$
1* CAR*)U6 3H*N 4OU U.* THI. "ORI5IN" .TAT*M*NTK
As a !inal class o! eamples# consider curve !ittin%$ The !irst eample is strai%ht!orward$ The
!ollowin% set o! data %ives dimensionless temperature as a !unction o! dimensionless distance in a
!i&er spinnin% eperiment$ *ach set !orms a vector$ One way to represent the vector is to use
su&scripts to denote each element o! its elements$ .ince# &y de!ault# the num&erin% o! elements in a
Mathcad vector &e%ins with E# we will return to that de!ault settin%/
Here we used the re%ular de!inition /-# rather than the %lo&al# so that this
num&erin% system ta'es e!!ect !rom here on$
1#2G2- 0 :
i 0 8 .. :
Mathcad assumes the increment is one unless you tell it otherwise$
Net# type in the data/

i
1
0.91
0.78
0.72
0.7
0.65
0.5
0.31
0.2
:
i
0
0.9
1.2
1.8
2.3
2.7
5.5
11
15.3
:
3e epect the temperature to !ollow the e"uation/
ex( 0.1625 -3 ( )
where Nu is the Nusselt num&er# which we must !ind$ The
constant# E$@AF9# comes a&out !rom the way and Nu are
de!ined$
3e can ta'e the natural lo% o! this e"uation to put it in linear
!orm/
ln ( )
where is the slope (,E$@AF9 Nu+$ )indin% the slope o! a strai%ht line is easy in Mathcad$
)irst# we need to de!ine a new dependent varia&le as the lo% o! /
4
i
ln
i
( )
:
The slope o! a strai%ht line throu%h these points is !ound &y usin% the
"slope(#y+" !unction# where is the vector o! independent varia&les /
sl$(e 4 , ( ) : 0.1
There!ore# the Nu is/ -3

0.1625
: -3 0.616
To veri!y# we can plot the data (# + and the prediction# p/
(
i
ex( 0.1625 -3
i

( )
:
A!ter you create the ,y plot# you can customi>e it to display the eperimental data as points#
rather than a line$ Dou&le clic' on the %raph# %o to )ormat and Traces$ )or the !irst trace (in
this case the measured temperatures+ choose a sym&ol# and "points" !or Type$ To plot F
varia&les on the same ais# put a &o around the !irst one# here
i
# then type a comma$ A new
place holder will appear on the ais$ Unless you tell it otherwise# Mathcad will plot each o! the
dependent varia&les a%ainst the same independent varia&le$
In this case# the !it is not all that %ood# perhaps &ecause the strai%ht line !it does not have an
intercept o! >ero$ 3e can chec' that with the "intercept" !unction/
in%erce(% 4 , ( ) 0.095 ex( in%erce(% 4 , ( ) ( ) 0.909
Mathcad FEEE contains a series o! curve !ittin% routines which can &e !ound with the !unction 'ey$ One is
simply "line$" I! we employ the line !unction here we %et/
line 4 , ( )
0.095
0.1

,
The intercept and the slope are %iven directly$
The predicted &est !it usin% a strai%ht line model with non,unity intercept is/
(2
i
ex( in%erce(% 4 , ( ) ( ) ex( 0.1625 -3
i

( )
:
0 5 10 15 20
0
0.2
0.4
0.6
0.8
1

i
(
i
(2
i

i
The !it is improved with
(2
i
# &ut now the
initial temperature is not @$ 4ou mi%ht also
try chan%in% the y,ais to a lo% scale usin%
L,4 ;lot# )ormat# L,4 Aes$
There is one more !it we can try# this time
!orcin% the intercept to &e unity$
De!ine a new !unction# ..*(Nu+# as the sum o! the s"uare error &etween the measured and predicted
temperature/
556 -3 ( )
i

i
ex( 0.1625 -3
i

( )

( )
2

:
3e want to !ind the value o! Nu which ma'es this !unction a minimum$ Notice it will not &e >ero
unless the !it were eact$ To !ind this minimum# we can use a procedure related to the 5iven , )ind
method/
Given
Notice we already have a %uess !or Nu de!ined a&ove$
Instead o! ")ind#" we use "Minerr"$ The value o! Nu which
%ives the minimum error in the e"uation is/
556 -3 ( ) 0
-33 *inerr -3 ( ) :
-33 0.797
This is "uite di!!erent !rom the previous value$ 3e can de!ine another predicted
temperature/
3(
i
ex( 0.1625 -33
i

( )
:
And plot this !unction to compare with the data and the other two predictions/
0 5 10 15 20
0.1
1

i
(
i
(2
i
3(
i

i
Mathcad FEEE also provides an eponential !it !unction$ The !orm is aI(eM&I+Nc$ There are a
!ew pro&lems with this# not the least o! which is that we do not want a !it o! this !orm$ (It has the
etra constant# c$ There does not appear to &e any way to use this !unction without the constant$
Also# the results seem very sensitive to the initial %uesses$ 3e will not pursue this method$
)or those who pre!er a more ri%orous way o! !indin% the &est value o! Nu# we can !ind the value which
!orces the derivative o! the ..* e"uation with respect to the Nusselt num&er to &e to >ero/
Given
i
-3

i
ex( 0.1625 -3
i

( )

( )
2

1
]
d
d

0
-34 Find -3 ( ) : -34 0.797
This is "uite close to what we 0ust !ound usin% Minerr$ In %eneral# the procedure usin%
the derivative seems to %ive &etter results (in the sense o! a smaller value o! the sum o!
the s"uare errors+ than Minerr procedure$ However# the derivative method is more
sensitive to the initial %uess$
There are two aditional Mathcad !unctions which can &e used !or data !ittin%# lin!it and %en!it$
.uppose we have the !ollowin% set o! ,y data$ 3e want to !it these data to an e"uation o! the
!orm/
) " ! x + c x
2
+
3e could use either o! the methods discussed a&ove$ In addition# we could use the lin!it
!unction$ This is use!ul whenever we can write the dependent varia&le as series o! any
!unctions# not 0ust powers as in this eample$
)irst# de!ine the varia&les/
i 0 11 .. :
x
i
0.045
0.094
0.183
0.291
0.398
0.507
0.546
0.595
0.721
0.814
0.897
0.957
:
)
i
1.121
1.107
1.048
1.021
1.01
1.012
1.014
1.018
1.04
1.064
1.103
1.148
:
Then de!ine a vector# called ) here# which %ives the various
!unctions which appear in the epression !or the
dependentvaria&le$ In the present case/
F x ( )
1
x
x
2

,
:
The lin!it !unction returns a vector# called . here# which
contains the coe!!icients used to create a linear com&ination
o! the !unctions in ) which %ive the &est !it to the data in and
y/
5 linfi% x ) , F , ( ) :
5
1.146
0.579
0.6

The &est !it to the data is then easily written in matri notation/
)
!es%
x ( ) F x ( ) 5 :
Another way o! representin% this series is/
F2 x ( )
x
1 x
x 1 x ( )

1
1
1
]
:
52 linfi% x ) , F2 , ( ) : 52
1.167
1.146
0.6

4ou can easily veri!y the two results are the same$
<ery o!ten# we cannot write the dependent varia&le as a linear com&ination o! !unctions$
.uppose we wanted to !it the a&ove y values to an e"uation o! the !orm/
) x ( )
ln x 1 x ( ) 3
0
+

1
]

1 x
ln 1 x x 3
1
+
( )
x

and want to !ind the &est values o! u


0
and u
@
$ In this case# we can use the %en!it !unction$ 3e !irst
de!ine a vector 5(#u+$ The !irst element is the desired !unction: the second# the derivative o! the
!unction with respect to the !irst constant: and the third# the derivative with respect to the second/
Then we %ive a vector o! %uesses !or the
constants/
G x 3 , ( )
ln x 1 x ( ) 3
0
+

1
]

1 x
ln 1 x x 3
1
+
( )
x

1
x 1 x ( ) 3
0
+

1
]
1
1 x x 3
1
+
( )

1
1
1
1
1
1
1
1
]
:
g
1
1

,
:
The %en!it !unction returns the &est values o! the constants/
3 genfi% x ) , g , G , ( ) :
3
0.55
0.527

The &est !it is then/


)
!es%2
x ( )
ln x 1 x ( ) 3
0
+

1
]

1 x
ln 1 x x 3
1
+
( )
x
:
+ 0 0.05 , 1 .. :
0 0.2 0.4 0.6 0.8 1
0.4
0.6
0.8
1
1.2
)
i
)
!es%
+ ( )
)
!es%2
+ ( )
x
i
+ , + ,
Clearly# the second !unction does not
%ive a very %ood !it in this case$ The
polynomial is clearly superior$

Вам также может понравиться