Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: Uebungen
Views: 150
Kernel: Octave
x = [1 2 3 4 5]; #vector of lenght n function f = fc(x) n = 5; f = 0; for i = 1:n for j = 1:n f = 1/(i+j-1)*x(i)*x(j) - x(i); end end f = 1/2*f; end
fc(x)
ans = -1.1111
z = [1 2 3 4 5 6 7 8 9 10]; function f = fd(x) n = 10; f = (x(1)-1)^2 + (-1/2*x(1))^2;; for i = 1:n-1 f = (x(1)-1)^2 + (x(i) - 1/2*x(i+1))^2; end f = f; end
fd(z)
ans = 16