Roots of a function: Difference between revisions
Content added Content deleted
m (→{{header|Octave}}: lang matlab to lang octave; even since a lot of langs got messed up with the geshi update:/ (matlab too, it seems)) |
|||
Line 420: | Line 420: | ||
If the equation is a polynomial, we can put the coefficients in a vector and use ''roots'': |
If the equation is a polynomial, we can put the coefficients in a vector and use ''roots'': |
||
<lang |
<lang octave>a = [ 1, -3, 2, 0 ]; |
||
r = roots(a); |
r = roots(a); |
||
% let's print it |
% let's print it |
||
Line 435: | Line 435: | ||
{{trans|Python}} |
{{trans|Python}} |
||
<lang |
<lang octave>function y = f(x) |
||
y = x.^3 -3.*x.^2 + 2.*x; |
y = x.^3 -3.*x.^2 + 2.*x; |
||
endfunction |
endfunction |