프롬프트> octave -qi
octave:1> # Let's find roots of the equation x^2 - 5 = 0.
octave:1> c = [1, 0, -5];       # 다항식의 계수들
octave:2> roots(c)
ans =

  -2.2361
   2.2361

octave:3> x = roots(c);
octave:4> x(1)
ans = -2.2361
octave:5> x(2)
ans =  2.2361
octave:6> sqrt(5)
ans =  2.2361
octave:7> format long
octave:8> x
x =

  -2.23606797749979
   2.23606797749979


octave:9> x(1), x(2)
ans = -2.23606797749979
ans =  2.23606797749979
octave:10> sqrt(5)
ans =  2.23606797749979

 

Posted by Scripter

댓글을 달아 주세요