# Question:How use NPLSolve

## Question:How use NPLSolve

Maple

Dear Experts,

I want to solve 2 workssheets with NPL Solve with Maple 12.

But how is it done? In worksheet 1 I always get this error. Unless I have solved this worksheet one err I can not continue wrking on worksheet two.

Thnaks for help

Walter

> with(Optimization); datax := [10, 15, 20, 25, 30, 45, 60, 90, 120, 150, 180]; datay := [428, 334.1, 280.7, 262.7, 242.4, 212.9, 182.2, 151, 130.5, 116.9, 109.5]; tau := 1;
[ImportMPS, Interactive, LPSolve, LSSolve, Maximize, Minimize, NLPSolve,

QPSolve]
> model := N1*exp(lambda1*(t-tau))+N2*exp(lambda2*(t-tau));
N1 exp(lambda1 (t - 1)) + N2 exp(lambda2 (t - 1))

> residuals(N1,N2,lambda1,lambda2) := [sum( (datay[i]-eval(model,t=datax[i]))^(2), i=1..nops(datax))];
[
[
[
[
(N1, N2, lambda1, lambda2) -> [
[
[

nops(datax)                                         ]
-----                                             ]
\                                                ]
)                                              2]
/       (datay[i] - (eval(model, t = datax[i]))) ]
-----                                             ]
i = 1                                            ]

> NLPSolve((428-N1*exp(9*lambda1)-N2*exp(9*lambda2))^2+(334.1-N1*exp(14*lambda1)-N2*exp(14*lambda2))^2+(280.7-N1*exp(19*lambda1)-N2*exp(19*lambda2))^2+(262.7-N1*exp(24*lambda1)-N2*exp(24*lambda2))^2+(242.4-N1*exp(29*lambda1)-N2*exp(29*lambda2))^2+(212.9-N1*exp(44*lambda1)-N2*exp(44*lambda2))^2+(182.2-N1*exp(59*lambda1)-N2*exp(59*lambda2))^2+(151-N1*exp(89*lambda1)-N2*exp(89*lambda2))^2+(130.5-N1*exp(119*lambda1)-N2*exp(119*lambda2))^2+(116.9-N1*exp(149*lambda1)-N2*exp(149*lambda2))^2+(109.5-N1*exp(179*lambda1)-N2*exp(179*lambda2))^2, initialpoint = {N1 = 1.122*10^3, N2 = 1.2830*10^3, lambda1 = -0.39e-1, lambda2 = -.326}, method = sqp);
[439.485735349367132, [N1 = 257.198668654980508, N2 = 531.115292604514707,

lambda1 = -0.00532918849969983132, lambda2 = -0.119870376119667720]]
> NLPSolve(residuals(N1, N2, lambda1, lambda2), initialpoint = {N1 = 1.122*10^3, N2 = 1.2830*10^3, lambda1 = -0.39e-1, lambda2 = -.326}, method = sqp);
Error, (in Optimization:-NLPSolve) objective function must be specified as a procedure or algebraic expression

> residuals(N1, N2, lambda1, lambda2);
[                                             2
[(428 - N1 exp(9 lambda1) - N2 exp(9 lambda2))

2
+ (334.1 - N1 exp(14 lambda1) - N2 exp(14 lambda2))

2
+ (280.7 - N1 exp(19 lambda1) - N2 exp(19 lambda2))

2
+ (262.7 - N1 exp(24 lambda1) - N2 exp(24 lambda2))

2
+ (242.4 - N1 exp(29 lambda1) - N2 exp(29 lambda2))

2
+ (212.9 - N1 exp(44 lambda1) - N2 exp(44 lambda2))

2
+ (182.2 - N1 exp(59 lambda1) - N2 exp(59 lambda2))

2
+ (151 - N1 exp(89 lambda1) - N2 exp(89 lambda2))

2
+ (130.5 - N1 exp(119 lambda1) - N2 exp(119 lambda2))

2
+ (116.9 - N1 exp(149 lambda1) - N2 exp(149 lambda2))

2]
+ (109.5 - N1 exp(179 lambda1) - N2 exp(179 lambda2)) ]

﻿