Sei sulla pagina 1di 6

3

Chapter 5: Basic Calculus


Derivatives Derivatives can be evaluated in Mathematica using many different commands. The D command requires three arguments inside the square brackets: the function, the variable and the number of derivatives. The last two arguments must be in a list.

Clear f f = Sin x ; firstDer = D f, x, 1 ; Print "1st derivative of f = ", firstDer


1st derivative of f = Cos x

secDer = D f, x, 2 ; Print "2nd derivative of f = ", secDer


2nd derivative of f = - Sin x

@ D @ D @ 8 < D @ @ D D @ 8 < D @ @ D D

Partial Derivatives Another way of evaluating derivatives is to use the palettes. The symbol x f will evaluate the partial derivative of the function f with respect to the variable x: x f
Cos x

Try this command on a function containing two variables, x and y:

g = Sin x - Cos y ; x g; Print "The partial derivative of g with respect to x = ", %


The partial y g; derivative of g with respect to x = Cos x

Print "The partial derivative of g with respect to y = ", %


The partial derivative of g with respect to y = Sin y

@ D @ D @ D @ D @ D

@ D @ D

3&

!ou can also evaluate the derivative of a function with respect to several variables using the palettes. The e"pression x y h will allow you to evaluate the partial derivative of h with respect to y and the partial derivative of the result with respect to x.

h = x2 y4 ; x y h
8 x y3

The e"pression above can also be written as y,x h where the list of variables after the symbol gives the order of differentiation: y,x h
8 x y3

From Physical Chemistry A Molecular Approach, by Donald McQuarrie and John D !imon: "#ample $%& "valuate the t'o (irst partial derivatives o( the molar pressure P (or the van der )aals e*uation: RT % a P+ V - b V# P depends on T and V so P $ P (T, V). Define an equation for P:

%sing D, take the partial derivative of P with respect to T at constant V:

%sing V P , take the partial derivative of P with respect to V at constant T:

,n(inite !eries

H L @ 8 < D A H L E H L A H L E H L HL
P= *T
a RT + 2 V - b +V

! - " - a !2

der1 = D P, T, 1 ; P Print " ! = ", der1 T


P T
V =

R - b +V

der2 = ! P; P Print " !


P V
T =

= ", der2
RT - b +V 2

2a V3

33

The Taylor series of the function f at xo $ c can be e"pressed as:


f c x - c n $ f (c) ) +! x ) f '"( $ n! ,f c $ -, we have the .aclauren series: n f* c f ** c #!

f '"( $

The command /eries will e"ecute a Taylor series for any function. The command requires four arguments: the function, the variable, the initial value of the variable and the order of the e"pansion. The last three arguments must be in a list. 0or e"ample, e"ecute the Taylor series for c $ + to the th order for the function: f (x) = ln x

f* 0 f ** 0 f n 0 x n $ f (0) ) +! x ) #! x# ) n!

H L LH L H L H L H H L LH L H L H
x, 1, $
1 2 1 x- 1 2+ 3 1 x- 1 3-

x# )

1ow e"ecute the .aclauren series for c $ - to the 2th order for the function: g(x) = + + +x #

@ @ D 8< D H LH LH LH LH L@ D H L @ H L 8@ < D D
Series #og x ,
x- 1 x- 1 + 1 ! x - 1 ! +" x - 1 #

Series 1

1 +x

, x, %, 4

1 - 2 x + 3 x2 -

x3 + ! x +" x !

34

IM IM IM
U V T

From Physical Chemistry A Molecular Approach, by Donald McQuarrie and John D !imon: Problem $%U "valuate V T (or an ideal .as and (or a van der )aals .as + T
P T V

%P

,deal .as: P +

RT V

van der )aals .as: P +

RT % a V - b V#

39

Ans'ers: Problem $%0or an ideal gas:

Define an equation for the molar pressure P of an ideal gas:

Clear , T, !, P Pideal = * T !
RT V

@ D
P 6 P to get T V

%sing T Pideal , take the partial derivative of Pideal with respect to T at constant V:

der&deal = T Pideal

5valuate T

7ecall that the molar pressure P was defined as Pideal. %se the substitution command 8. and print out the actual answer:

JNJN A H L E H L A H L H L
R V

U and print out the answer: V T

ans1 = T * der&deal - P; ' Print " T = ", ans1 !


$ V
T = - P+

RT V

ans2 = ans1 ' Print " !


$ V

P ( Pideal;

= ", ans2, " for an ideal gas"


gas

T = % for an ideal

The internal energy U of an ideal gas is independent of V at constant T.

2-

0or a van der :aals gas:

Define an equation for the molar pressure P of a van der :aals gas:

Clear , T, !, P, a, " Pvdw = * T ! - " - a !2


a RT + 2 V - b +V

@ D H L
P 6 P to get T V

%sing T Pvdw , take the partial derivative of Pvdw with respect to T at constant V:

dervdw = T Pvdw

5valuate T

7ecall that the molar pressure P was defined as Pvdw. %se the substitution command 8. and print out the actual answer:

JNJN A H L E H L A H L H L
R - b +V

U and print out the answer: V T

ans) = T * dervdw - P; ' Print " T = ", ans) !


$ V
T = - P+

RT - b +V

ans4 = ans) ' Print " !


$ V
T =

P ( Pvdw;

= ", ans4, " for a van der *aals gas"


gas

a V2

for a van der &aals

The internal energy U of a van der :aals gas is dependent on V at constant T.

Potrebbero piacerti anche