Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
46
Task/Nth-root/Action-/nth-root.action
Normal file
46
Task/Nth-root/Action-/nth-root.action
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
INCLUDE "H6:REALMATH.ACT"
|
||||
|
||||
PROC NthRoot(REAL POINTER a,n REAL POINTER res)
|
||||
REAL n1,eps,one,tmp1,tmp2,tmp3
|
||||
|
||||
ValR("0.0001",eps)
|
||||
IntToReal(1,one)
|
||||
RealSub(n,one,n1)
|
||||
|
||||
Sqrt(a,res) ;res=sqrt(a)
|
||||
DO
|
||||
Power(res,n,tmp1) ;tmp=res^n
|
||||
RealSub(a,tmp1,tmp2) ;tmp2=a-res^n
|
||||
RealAbs(tmp2,tmp1) ;tmp1=abs(a-res^n)
|
||||
IF RealGreaterOrEqual(eps,tmp1) THEN
|
||||
RETURN
|
||||
FI
|
||||
|
||||
Power(res,n1,tmp1) ;tmp1=res^(n-1)
|
||||
RealDiv(a,tmp1,tmp2) ;tmp2=a/(res^(n-1))
|
||||
RealMult(n1,res,tmp1) ;tmp1=(n-1)*res
|
||||
RealAdd(tmp1,tmp2,tmp3) ;tmp3=((n-1)*res + a/(res^(n-1)))
|
||||
RealDiv(tmp3,n,res) ;res=((n-1)*res + a/(res^(n-1)))/n
|
||||
OD
|
||||
RETURN
|
||||
|
||||
PROC Test(CHAR ARRAY sa,sn)
|
||||
REAL a,n,res
|
||||
|
||||
ValR(sa,a)
|
||||
ValR(sn,n)
|
||||
PrintR(n) Print(" root of ")
|
||||
PrintR(a) Print(" is ")
|
||||
NthRoot(a,n,res)
|
||||
PrintRE(res)
|
||||
RETURN
|
||||
|
||||
PROC Main()
|
||||
Put(125) PutE() ;clear screen
|
||||
MathInit()
|
||||
Test("2","2")
|
||||
Test("81","4")
|
||||
Test("1024","10")
|
||||
Test("7","0.5")
|
||||
Test("12.34","56.78")
|
||||
RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue