Chapter Contents Previous Next
 The NLIN Procedure

## Automatic Derivatives

Depending on the optimization method you select, analytical first- and second-order derivatives are computed automatically. Derivatives can still be supplied using the DER.parm syntax. These DER.parm derivatives are not verified by the differentiator. If any needed derivatives are not supplied, they are computed and added to the program statements. To view the computed derivatives, use the LISTDER or LIST option.

The following model is solved using Newton's method. Analytical first- and second-order derivatives are automatically computed.

```   proc nlin data=Enzyme method=newton list;
parms x1=4 x2=2 ;
model Velocity = x1 * exp (x2 * Concentration);
run;
```

 The NLIN Procedure

 Listing of Compiled Program Code Stmt Line:Col Statement as Parsed 1 471:74 MODEL.Velocity = x1 * EXP(x2 * Concentration); 1 471:74 @MODEL.Velocity/@x1 = EXP(x2 * Concentration); 1 471:74 @MODEL.Velocity/@x2 = x1 * Concentration * EXP(x2 * Concentration); 1 471:74 @@MODEL.Velocity/@x1/@x2 = Concentration * EXP(x2 * Concentration); 1 471:74 @@MODEL.Velocity/@x2/@x1 = Concentration * EXP(x2 * Concentration); 1 471:74 @@MODEL.Velocity/@x2/@x2 = x1 * Concentration * Concentration * EXP(x2 * Concentration);

Figure 45.5: Model and Derivative Code Output

Note that all the derivatives require the evaluation of EXP(X2 * Concentration). If you specify the LISTCODE option in the PROC NLIN statement, the actual machine level code produced is as follows.

 The NLIN Procedure

 Code Listing 1 Stmt MODEL line 328 column 78. (1) arg=MODEL.Velocity argsave=MODEL.Velocity Source Text: model Velocity = x1 * exp (x2 * Concentration); Oper * at 328:108 (30,0,2). * : #temp1 <- x2 Concentration Oper EXP at 328:104 (103,0,1). EXP : #temp2 <- #temp1 Oper * at 328:98 (30,0,2). * : MODEL.Velocity <- x1 #temp2 Oper eeocf at 328:104 (18,0,1). eeocf : _DER_ <- _DER_ Oper * at 328:104 (30,0,2). * : @1dt1_1 <- Concentration #temp2 Oper = at 328:98 (1,0,1). = : @MODEL.Velocity/@x1 <- #temp2 Oper * at 328:98 (30,0,2). * : @MODEL.Velocity/@x2 <- x1 @1dt1_1 Oper * at 328:104 (30,0,2). * : @2dt1_1 <- Concentration @1dt1_1 Oper = at 328:98 (1,0,1). = : @@MODEL.Velocity/@x1/@x2 <- @1dt1_1 Oper = at 328:98 (1,0,1). = : @@MODEL.Velocity/@x2/@x1 <- @1dt1_1 Oper * at 328:98 (30,0,2). * : @@MODEL.Velocity/@x2/@x2 <- x1 @2dt1_1

Figure 45.6: LISTCODE Output

Note that, in the generated code, only one exponentiation is performed. The generated code reuses previous operations to be more efficient.

 Chapter Contents Previous Next Top