/usr/share/euler/progs/fmin.en is in euler 1.61.0-10.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | % We demonstrate minimization of a function in two variables.
%
% First we define a rather complicate function.
>A=[1,2;3.1];
>function f(x)
$global A;
$return sin(x).A.(x-1)'
$endfunction
% Let us try a minimization.
>mi=neldermin("f",[1,2])
-5.48095 1.49917
% Since the function is not a function of two variables, we must
% define an intermediate function to plot.
>function g(x,y)
$return f([x,y])
$endfunction
>color(1);fcd(''map("g",x,y)'',50,-10,10,-10,10); xplot(); wait(20);
% We mark the found minimum and another local minimum around -5,-5.
>markerstyle("x");hold; color(0); mark(mi[1],mi[2]); hold; wait(20);
>mi=nelder("f",[-5,-5],1,epsilon)
-4.94517 -4.81818
>hold; mark(mi[1],mi[2]); hold; wait(20);
>mi=nelder("f",[8,-8],1,epsilon)
8.04959 -7.94387
>hold; mark(mi[1],mi[2]); hold; wait(20);
>
|