tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
1
Task/Nth-root/Octave/nth-root-1.octave
Normal file
1
Task/Nth-root/Octave/nth-root-1.octave
Normal file
|
|
@ -0,0 +1 @@
|
|||
r = A.^(1./n)
|
||||
12
Task/Nth-root/Octave/nth-root-2.octave
Normal file
12
Task/Nth-root/Octave/nth-root-2.octave
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function r = m_nthroot(n, A)
|
||||
x0 = A / n;
|
||||
m = n - 1;
|
||||
while(1)
|
||||
x1 = (m*x0 + A./ x0 .^ m) / n;
|
||||
if ( abs(x1-x0) < abs(x0 * 1e-9) )
|
||||
r = x1;
|
||||
return
|
||||
endif
|
||||
x0 = x1;
|
||||
endwhile
|
||||
endfunction
|
||||
8
Task/Nth-root/Octave/nth-root-3.octave
Normal file
8
Task/Nth-root/Octave/nth-root-3.octave
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
function r = m_nthroot(n, A)
|
||||
r = A / n;
|
||||
m = n - 1;
|
||||
do
|
||||
d = (A ./ r .^ m - r) / n;
|
||||
r+= d;
|
||||
until (abs(d) < abs(r * 1e-9))
|
||||
endfunction
|
||||
6
Task/Nth-root/Octave/nth-root-4.octave
Normal file
6
Task/Nth-root/Octave/nth-root-4.octave
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
m_nthroot(10, 7131.5 .^ 10)
|
||||
nthroot(7131.5 .^ 10, 10)
|
||||
m_nthroot(5, 34)
|
||||
nthroot(34, 5)
|
||||
m_nthroot(0.5, 7)
|
||||
nthroot(7, .5)
|
||||
Loading…
Add table
Add a link
Reference in a new issue