From b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b Mon Sep 17 00:00:00 2001 From: priyanka Date: Wed, 24 Jun 2015 15:03:17 +0530 Subject: initial commit / add all books --- 1202/CH19/EX19.2/19_2.sce | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 1202/CH19/EX19.2/19_2.sce (limited to '1202/CH19/EX19.2') diff --git a/1202/CH19/EX19.2/19_2.sce b/1202/CH19/EX19.2/19_2.sce new file mode 100755 index 000000000..41d38d659 --- /dev/null +++ b/1202/CH19/EX19.2/19_2.sce @@ -0,0 +1,28 @@ +clear +clc + +//Example 19.2 +disp('Example 19.2') + +function y=f_DNO3(r1) + D1=0.5;D2=0.5; + r2=0.4-0.5*r1; + y=r1*D1/(1+r1)^2/(1+r2)+r2*D2/(1+r1)/(1+r2)^2 +endfunction + +function [f, g, ind] = costf(x, ind) + f=-f_DNO3(x);//cost is negative of function to be maximised + g=-derivative(f_DNO3,x);//derivative of the cost function +endfunction + +[fopt, xopt] = optim(costf,0.5); + +disp(xopt,"Optimum value of r1=") +disp(-fopt,"Max value of DNO3=") + +mprintf('Note that the answer in book is not as accurate as the one\n... +calculated from scilab') + + + + -- cgit