Skip to main content
added 1326 characters in body
Source Link
Rosario
  • 1.7k
  • 5
  • 9

It is possible that I make some error and there is a number of input that generate one infinite loop because e variable in code is too little (for example I wrong the number 3.323 or if variable t or r have integer part > of input w even if t-r decrease)

I have not consider the case the number of input w is too big for variable ⎕FPC, for example when digits of number are > ⎕FPC÷3.322 (float for me has to be fixed point float because this is too tricly)

It is possible that I make some error and there is a number that generate one infinite loop because e variable in code is too little (for example I wrong the number 3.323 or if variable t or r have integer part > of input w even if t-r decrease)

It is possible that I make some error and there is a number of input that generate one infinite loop because e variable in code is too little (for example I wrong the number 3.323 or if variable t or r have integer part > of input w even if t-r decrease)

I have not consider the case the number of input w is too big for variable ⎕FPC, for example when digits of number are > ⎕FPC÷3.322 (float for me has to be fixed point float because this is too tricly)

added 1326 characters in body
Source Link
Rosario
  • 1.7k
  • 5
  • 9

APL(NARS), 8346 chars

r←q w;t;ew;t t←1v⋄e←÷10*⌊(⎕FPC-{1>∣w:0⋄1+2⍟∣w})÷3.322vt←1 →3×⍳e>∣t→3×⍳1e¯9>∣t-r←t-3÷⍨t-w÷t×t⋄t←r⋄→2 

//10+42+31=838+4+34=46

I followed the formula written in the post: https://codegolf.stackexchange.com/a/21793/120560. I think I have found the formulaIt seems is ok with test

 aaa←27 64 1 18.609625 3652264 0.001 7 2E¯13 0 q¨aaa 3 4 1 2.65 154 0.1 1.912931183 0.00005848035476 1.568328545E¯9 q¨-aaa ¯3 ¯4 ¯1 ¯2.65 ¯154 ¯0.1 ¯1.912931183 ¯0.00005848035476 1.568328545E¯9 

It seems work for min error allowable from +-*/input big float v but not work for rationals...It could be ok with operationsthe restriction of question so ok.

The problem would be find in the float point lenght xBitthis case cube root function, due the precision ismin number e affected from the lenghtthat can find all digits possibles of one float when the integer partsys has float XXXbits=⎕FPC (without generate one never ending loop for some number of the input w due the number e is too small)....

I propose this function that would break convension of return the same type of the input, it would return a v number a float according ⎕FPC variable

r←q3 w;t;e t←1v⋄e←÷10*⌊(⎕FPC-{1>∣w:0⋄3÷⍨1+2⍟∣w})÷3.323v →3×⍳e>∣t-r←t-3÷⍨t-w÷t×t⋄t←r⋄→2 

The error in this case would be less than e←÷10*⌊(⎕FPC-{1>∣w:0⋄1+2⍟∣w0⋄3÷⍨1+2⍟∣w})÷3.322v323v where wwhere w is the input number, ⎕FPC is the lenght in bit of the float point 1+2⍟w would be the lenght in bit of integer part of w, but I have to consider the 1/3 of that number because the resul will have 1/3 of these digits...log_2(10)=3.32192809 here approximated as 3.322323 (I don't know if it is the right number, 3.322 is not right because I remember generate one never ending loop with the input 18.609625v). Test

 aaa←27q3¨aaa 3 644 1 182.60962565 3652264154 0.001 71 2E¯131.912931183 0.00005848035476 1.381590388E¯38  q¨aaaq3¨-aaa ¯3 ¯4 ¯1 ¯2.65 ¯154 ¯0.1 ¯1.912931183 ¯0.00005848035476 1.381590388E¯38 q3¨aaa×1v 3 4 1 2.65 154 0.1 1.912931183 0.00005848035476 1.381590388E¯38872107764E¯154 q¨-aaaq3¨aaa×1x ¯33 ¯44 ¯11 ¯22.65 ¯154154 ¯00.1 ¯11.912931183 ¯00.00005848035476 1.381590388E¯38872107764E¯154 
 qq3 2 1.25992105 qq3 2v 1.25992105 qq3 2x 1.25992105  q3 18.609625x 2.65 
 ⎕fpc←512 512÷3.322 154.1240217 150⍕q 2v 1.259921049894873164779198323884500528076109625698508732184198175469013575303302345933958149409424814616937169595159013873478464862408338554282464069753 150⍕q3 2v 1.259921049894873164767210607278228350570251464701507980081975112155299676513959483729396562436255094154310256035615665259399024040613737228459110304269 

note how q3 wuould be the right result, but q is right until 19th digit.

It is possible that I make some error and there is a number that generate one infinite loop because e variable in code is too little    (for example I wrong the number 3.323 or if variable tt or rr have integer integer part > of input ww even if t-rt-r decrease)

APL(NARS), 83 chars

r←q w;t;e t←1v⋄e←÷10*⌊(⎕FPC-{1>∣w:0⋄1+2⍟∣w})÷3.322v →3×⍳e>∣t-r←t-3÷⍨t-w÷t×t⋄t←r⋄→2 

//10+42+31=83

I followed the formula written in the post: https://codegolf.stackexchange.com/a/21793/120560. I think I have found the formula for min error allowable from +-*/ operations in the float point lenght xBit, due the precision is affected from the lenght of the integer part of the input number...

The error would be less than e←÷10*⌊(⎕FPC-{1>∣w:0⋄1+2⍟∣w})÷3.322v where w is the input number, ⎕FPC is the lenght in bit of the float point 1+2⍟w would be the lenght in bit of integer part of w, log_2(10)=3.32192809 here approximated as 3.322 (I don't know if it is the right number). Test

 aaa←27 64 1 18.609625 3652264 0.001 7 2E¯13 0 q¨aaa 3 4 1 2.65 154 0.1 1.912931183 0.00005848035476 1.381590388E¯38 q¨-aaa ¯3 ¯4 ¯1 ¯2.65 ¯154 ¯0.1 ¯1.912931183 ¯0.00005848035476 1.381590388E¯38 
 q 2 1.25992105 q 2v 1.25992105 q 2x 1.25992105 
 ⎕fpc←512 512÷3.322 154.1240217 150⍕q 2v 1.259921049894873164767210607278228350570251464701507980081975112155299676513959483729396562436255094154310256035615665259399024040613737228459110304269 

It is possible that I make some error and there is a number that generate one infinite loop because e variable in code is too little  (for example if variable t or r have integer part > of input w even if t-r decrease)

APL(NARS), 46 chars

r←q w;t t←1 →3×⍳1e¯9>∣t-r←t-3÷⍨t-w÷t×t⋄t←r⋄→2 

//8+4+34=46

I followed the formula written in the post: https://codegolf.stackexchange.com/a/21793/120560. It seems is ok with test

 aaa←27 64 1 18.609625 3652264 0.001 7 2E¯13 0 q¨aaa 3 4 1 2.65 154 0.1 1.912931183 0.00005848035476 1.568328545E¯9 q¨-aaa ¯3 ¯4 ¯1 ¯2.65 ¯154 ¯0.1 ¯1.912931183 ¯0.00005848035476 1.568328545E¯9 

It seems work for input big float v but not work for rationals...It could be ok with the restriction of question so ok.

The problem would be find in this case cube root function, the min number e that can find all digits possibles of one float when the sys has float XXXbits=⎕FPC (without generate one never ending loop for some number of input w due the number e is too small)....

I propose this function that would break convension of return the same type of the input, it would return a v number a float according ⎕FPC variable

r←q3 w;t;e t←1v⋄e←÷10*⌊(⎕FPC-{1>∣w:0⋄3÷⍨1+2⍟∣w})÷3.323v →3×⍳e>∣t-r←t-3÷⍨t-w÷t×t⋄t←r⋄→2 

The error in this case would be less than e←÷10*⌊(⎕FPC-{1>∣w:0⋄3÷⍨1+2⍟∣w})÷3.323v where w is the input number, ⎕FPC is the lenght in bit of the float point 1+2⍟w would be the lenght in bit of integer part of w, but I have to consider the 1/3 of that number because the resul will have 1/3 of these digits...log_2(10)=3.32192809 here approximated as 3.323 (I don't know if it is the right number, 3.322 is not right because I remember generate one never ending loop with the input 18.609625v). Test

 q3¨aaa 3 4 1 2.65 154 0.1 1.912931183 0.00005848035476 1.381590388E¯38  q3¨-aaa ¯3 ¯4 ¯1 ¯2.65 ¯154 ¯0.1 ¯1.912931183 ¯0.00005848035476 1.381590388E¯38 q3¨aaa×1v 3 4 1 2.65 154 0.1 1.912931183 0.00005848035476 1.872107764E¯154 q3¨aaa×1x 3 4 1 2.65 154 0.1 1.912931183 0.00005848035476 1.872107764E¯154 
 q3 2 1.25992105 q3 2v 1.25992105 q3 2x 1.25992105  q3 18.609625x 2.65 
 ⎕fpc←512 512÷3.322 154.1240217 150⍕q 2v 1.259921049894873164779198323884500528076109625698508732184198175469013575303302345933958149409424814616937169595159013873478464862408338554282464069753 150⍕q3 2v 1.259921049894873164767210607278228350570251464701507980081975112155299676513959483729396562436255094154310256035615665259399024040613737228459110304269 

note how q3 wuould be the right result, but q is right until 19th digit.

It is possible that I make some error and there is a number that generate one infinite loop because e variable in code is too little  (for example I wrong the number 3.323 or if variable t or r have integer part > of input w even if t-r decrease)

added 84 characters in body
Source Link
Rosario
  • 1.7k
  • 5
  • 9

APL(NARS), 83 chars

r←q w;t;e t←1v⋄e←÷10*⌊(⎕FPC-{1>∣w:0⋄1+2⍟∣w})÷3.322v →3×⍳e>∣t-r←t-3÷⍨t-w÷t×t⋄t←r⋄→2 

//10+42+31=83

I followed the formula written in the post: https://codegolf.stackexchange.com/a/21793/120560. I think I have found the formula for min error allowable from +-*/ operations in the float point lenght xBit, due the precision is affected from the lenght of the integer part of the input number...

The error would be less than e←÷10*⌊(⎕FPC-{1>∣w:0⋄1+2⍟∣w})÷3.322v where w is the input number, ⎕FPC is the lenght in bit of the float point 1+2⍟w would be the lenght in bit of integer part of w, log_2(10)=3.32192809 here approximated as 3.322 (I don't know if it is the right number). Test

 aaa←27 64 1 18.609625 3652264 0.001 7 2E¯13 0 q¨aaa 3 4 1 2.65 154 0.1 1.912931183 0.00005848035476 1.381590388E¯38 q¨-aaa ¯3 ¯4 ¯1 ¯2.65 ¯154 ¯0.1 ¯1.912931183 ¯0.00005848035476 1.381590388E¯38 

note that it seems ok even with rationals...

 q 2 1.25992105 q 2v 1.25992105 q 2x 1.25992105 

for big numbers it is possible too

 ⎕fpc←512 512÷3.322 154.1240217 150⍕q 2v 1.259921049894873164767210607278228350570251464701507980081975112155299676513959483729396562436255094154310256035615665259399024040613737228459110304269 

It is possible that I make some error and there is a number that generate one infinite loop because e variable in code is too little. (for example if variable t or r have integer part > of input w even if t-r decrease)

APL(NARS), 83 chars

r←q w;t;e t←1v⋄e←÷10*⌊(⎕FPC-{1>∣w:0⋄1+2⍟∣w})÷3.322v →3×⍳e>∣t-r←t-3÷⍨t-w÷t×t⋄t←r⋄→2 

//10+42+31=83

I followed the formula written in the post: https://codegolf.stackexchange.com/a/21793/120560. I think I have found the formula for min error allowable from +-*/ operations in the float point lenght xBit, due the precision is affected from the lenght of the integer part of the input number...

The error would be less than e←÷10*⌊(⎕FPC-{1>∣w:0⋄1+2⍟∣w})÷3.322v where w is the input number, ⎕FPC is the lenght in bit of the float point 1+2⍟w would be the lenght in bit of integer part of w, log_2(10)=3.32192809 here approximated as 3.322 (I don't know if it is the right number). Test

 aaa←27 64 1 18.609625 3652264 0.001 7 2E¯13 0 q¨aaa 3 4 1 2.65 154 0.1 1.912931183 0.00005848035476 1.381590388E¯38 q¨-aaa ¯3 ¯4 ¯1 ¯2.65 ¯154 ¯0.1 ¯1.912931183 ¯0.00005848035476 1.381590388E¯38 

note that it seems ok even with rationals...

 q 2 1.25992105 q 2v 1.25992105 q 2x 1.25992105 

for big numbers it is possible too

 ⎕fpc←512 512÷3.322 154.1240217 150⍕q 2v 1.259921049894873164767210607278228350570251464701507980081975112155299676513959483729396562436255094154310256035615665259399024040613737228459110304269 

It is possible that I make some error and there is a number that generate one infinite loop because e variable in code is too little.

APL(NARS), 83 chars

r←q w;t;e t←1v⋄e←÷10*⌊(⎕FPC-{1>∣w:0⋄1+2⍟∣w})÷3.322v →3×⍳e>∣t-r←t-3÷⍨t-w÷t×t⋄t←r⋄→2 

//10+42+31=83

I followed the formula written in the post: https://codegolf.stackexchange.com/a/21793/120560. I think I have found the formula for min error allowable from +-*/ operations in the float point lenght xBit, due the precision is affected from the lenght of the integer part of the input number...

The error would be less than e←÷10*⌊(⎕FPC-{1>∣w:0⋄1+2⍟∣w})÷3.322v where w is the input number, ⎕FPC is the lenght in bit of the float point 1+2⍟w would be the lenght in bit of integer part of w, log_2(10)=3.32192809 here approximated as 3.322 (I don't know if it is the right number). Test

 aaa←27 64 1 18.609625 3652264 0.001 7 2E¯13 0 q¨aaa 3 4 1 2.65 154 0.1 1.912931183 0.00005848035476 1.381590388E¯38 q¨-aaa ¯3 ¯4 ¯1 ¯2.65 ¯154 ¯0.1 ¯1.912931183 ¯0.00005848035476 1.381590388E¯38 

note that it seems ok even with rationals...

 q 2 1.25992105 q 2v 1.25992105 q 2x 1.25992105 

for big numbers it is possible too

 ⎕fpc←512 512÷3.322 154.1240217 150⍕q 2v 1.259921049894873164767210607278228350570251464701507980081975112155299676513959483729396562436255094154310256035615665259399024040613737228459110304269 

It is possible that I make some error and there is a number that generate one infinite loop because e variable in code is too little (for example if variable t or r have integer part > of input w even if t-r decrease)

added 136 characters in body
Source Link
Rosario
  • 1.7k
  • 5
  • 9
Loading
Source Link
Rosario
  • 1.7k
  • 5
  • 9
Loading