4 (load("lbfgs"), float_approx_equal_tolerance : 1e-12, 'done);
7 block([n, FOM], local(t1, t2),
9 t2[j] := 10*(u[j + 1] - u[j]^2),
11 FOM : sum (t1[2*j - 1]^2 + t2[2*j - 1]^2, j, 1, n/2),
12 lbfgs (FOM, '[u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8]],
13 [-1.2, 1, -1.2, 1, -1.2, 1, -1.2, 1], 1e-3, [1, 0]));
14 [u[1] = 1.000005339816132,u[2] = 1.000009942840108,u[3] = 1.000005339816132,
15 u[4] = 1.000009942840108,u[5] = 1.000005339816132,u[6] = 1.000009942840108,
16 u[7] = 1.000005339816132,u[8] = 1.000009942840108]$
18 block([FOM, X, Y], local(F),
19 FOM : '((1/length(X))*sum((F(X[i]) - Y[i])^2, i, 1,
22 Y : [0, 0.5, 1, 1.25, 1.5],
23 F(x) := A/(1 + exp(-B*(x - C))),
24 lbfgs (FOM, '[A, B, C], [1, 1, 1], 1e-4, [1, 0]));
25 [A = 1.461933911464101, B = 1.601593973254801,
26 C = 2.528933072164855]$
28 block(local(F_grad, F), F(a, b, c) := (a - 5)^2 + (b - 3)^4 + (c - 2)^6,
29 define(F_grad(a, b, c),
30 map (lambda ([x], diff (F(a, b, c), x)), [a, b, c])),
32 [a, b, c], [0, 0, 0], 1e-4, [1, 0]));
33 [a = 5.000086823042934, b = 3.052395429705181,
34 c = 1.927980629919583]$
38 lbfgs ('x^2, ['x], [1], 1e-4, [-1, -1]);
41 /* should return last approximation if max function evaluations reached */
43 block ([lbfgs_nfeval_max:10], lbfgs (x^6 + y^6, [x, y], [1, 1], 1e-12, [1, 0]));
44 [x = 0.1082428019264297, y = 0.1082428019264297];
46 (reset(float_approx_equal_tolerance),0);