Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
17
Task/Nth-root/Metafont/nth-root.metafont
Normal file
17
Task/Nth-root/Metafont/nth-root.metafont
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
vardef mnthroot(expr n, A) =
|
||||
x0 := A / n;
|
||||
m := n - 1;
|
||||
forever:
|
||||
x1 := (m*x0 + A/(x0 ** m)) / n;
|
||||
exitif abs(x1 - x0) < abs(x0 * 0.0001);
|
||||
x0 := x1;
|
||||
endfor;
|
||||
x1
|
||||
enddef;
|
||||
|
||||
primarydef n nthroot A = mnthroot(n, A) enddef;
|
||||
|
||||
show 5 nthroot 34; % 2.0244
|
||||
show 0.5 nthroot 7; % 49.00528
|
||||
|
||||
bye
|
||||
Loading…
Add table
Add a link
Reference in a new issue