Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
29
Task/Nth-root/Bracmat/nth-root.bracmat
Normal file
29
Task/Nth-root/Bracmat/nth-root.bracmat
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
( ( root
|
||||
= n a d x0 x1 d2 rnd 10-d
|
||||
. ( rnd { For 'rounding' rational numbers = keep number of digits within bounds. }
|
||||
= N r
|
||||
. !arg:(?N.?r)
|
||||
& div$(!N*!r+1/2.1)*!r^-1
|
||||
)
|
||||
& !arg:(?n,?a,?d)
|
||||
& !a*!n^-1:?x0
|
||||
& 10^(-1*!d):?10-d
|
||||
& whl
|
||||
' ( ( rnd$(((!n+-1)*!x0+!a*!x0^(1+-1*!n))*!n^-1.10^!d)
|
||||
. !x0
|
||||
)
|
||||
: (?x0.?x1)
|
||||
& (!x0+-1*!x1)^2:~<!10-d { Exit loop when required precision is reached. }
|
||||
)
|
||||
& flt$(!x0,!d) { Convert rational number to floating point representation. }
|
||||
)
|
||||
& ( show
|
||||
= N A precision
|
||||
. !arg:(?N,?A,?precision)
|
||||
& out$(str$(!A "^(" !N^-1 ")=" root$(!N,!A,!precision)))
|
||||
)
|
||||
& show$(10,1024,20)
|
||||
& show$(3,27,20)
|
||||
& show$(2,2,100)
|
||||
& show$(125,5642,20)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue