1. bigatom in The Archive
- Posted by cargoan Dec 21, 2014
- 2054 views
Now available in The Archive:
http://rapideuphoria.com/bigatom.zip
... And if it is useful, use it, modify it, adapt it ... whatever you want.
See you soon. And thank you all. Yes to all, everyone.
Sometimes it's hard to continue, you take away the desire ... but I did not despair.
Greetings
cargoan
2. Re: bigatom in The Archive
- Posted by cargoan Dec 21, 2014
- 1904 views
Compile it into a shared library and write a wrapper would be a good idea for performance... but I know just a bit this matter
In the end I just do it to pass the time ... like tomorrow I deepened a little more in M-theory... superstrings ... some extends as a membrane ... P-branes... Two P-branes collide ... the Big Bang ! Fascinating. Too bad not knowing math! I miss many wonderful things but at least understand the concepts ... more or less.
3. Re: bigatom in The Archive
- Posted by cargoan Dec 22, 2014
- 1892 views
Also I have trigonometric functions (sin, cos, arctan), but I can not work well with my bigatoms. If someone who knows more than I want to review and perhaps find and fix.
This is what I have:
-- ##################################### -- ### FUNCIONES TRIGONOMÉTRICAS ### -- ##################################### -- -- sin(x) = x - x^3/3! + x^5/5! - x^7/7! ... override function sin(atom x) integer n = 3 atom curr = x, res = x atom nfact = 6, x2 = -x * x atom xpow = x2 * x while curr do curr = xpow / nfact res += curr n += 2 nfact *= n * n - n xpow *= x2 end while return res end function export function ba_sin(object x) if not bigatom(x) then if atom(x) then return ba_new(sin(x)) end if x = ba_new(x) end if integer n = 1 sequence curr, prev, res sequence nfact, mx2 sequence mx, xpow sequence sc = scale(SCALE + 2, 0) nfact = {1, 0, {6}} mx = x mx[SIGN] = -mx[SIGN] res = ZERO prev = ZERO curr = x mx2 = ba_multiply(mx, x) xpow = x -- ba_multiply(x, mx2) while not eu:equal(prev, curr) do -- while curr[SIGN] do prev = curr res = ba_add(res, curr) n += 2 nfact = ba_sub(ba_multiply(n, n), n) xpow = ba_multiply(xpow, mx2) curr = ba_divide(xpow, nfact) end while scale(sc) res[DIGITS] = remove(res[DIGITS], res[EXPONENT] + 2 + SCALE, length(res[DIGITS])) return normalize(res) end function -- cos(x) = 1 - x^2/2! + x^4/4! - x^6/6! + x^8/8! - ... override function cos(atom x) integer n = 2 atom curr = 1, res = x atom nfact = 2, x2 = -x * x atom xpow = x2 while curr do curr = xpow / nfact res += curr n += 2 nfact *= n * n - n xpow *= x2 end while return res end function -- sacada de bc -- Usa la fórmula: -- atan(x) = atan(c) + atan((x-c)/(1+xc)) para c pequeño (0.2 en este caso) -- Por debajo de 0.2, usa la serie: -- atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ... -- override function arctan(atom x) integer sg = 1, mult = 0, n = 3 atom curr, res, xpow, x2 atom ap2 = 0.0 if x < 0 then sg = -1 x = -x end if if x > 0.2 then ap2 = arctan(0.2) end if -- hacer x <= 0.2 while x > 0.2 do mult += 1 x = (x - 0.2) / (1 + x * 0.2) end while curr = x xpow = x res = x x2 = -x * x while curr do xpow *= x2 curr = xpow / n res += curr n += 2 end while return sg * (res + mult * ap2) end function export function ba_arctan(object x) if not bigatom(x) then if atom(x) then return ba_new(arctan(x)) end if x = ba_new(x) end if sequence sc = scale(SCALE + (SCALE + 1)/ 2, 0) integer sg = 1, mult = 0, n = 3 sequence curr, res, xpow, x2 sequence ap2 = ZERO, p2 = {1,-1,{2}} if x[SIGN] < 0 then sg = -1 x[SIGN] = -x[SIGN] end if if eu:compare(x, p2) = SG_PLUS then ap2 = ba_arctan(0.2) end if -- hacer x <= 0.2 sequence a, b while eu:compare(x, p2) = SG_PLUS do mult += 1 -- x = (x - 0.2) / (1 + x * 0.2) a = ba_sub(x, p2) b = ba_add(ONE, ba_multiply(x, p2)) x = ba_divide(a, b) end while sequence limit = {x[SIGN], -(SCALE + 1), {1}} -- ba_power({x[SIGN],1,{1}}, -(SCALE + 6)) -- sequence prev = ZERO curr = x xpow = x res = x x2 = ba_multiply(x, x) x2[SIGN] = -x2[SIGN] -- while eu:compare(curr, prev) do -- esto es interminable -- while curr[SIGN] do -- como esto, es lo mismo while eu:compare(curr, limit) > 0 do -- esto no es correcto, sale antes de tiempo -- prev = curr xpow = ba_multiply(x, x2) curr = ba_divide(xpow, n) res = ba_add(res, curr) n += 2 limit[SIGN] = -limit[SIGN] end while scale(sc) res = ba_add(res, ba_multiply(mult, ap2)) return ba_multiply(res, sg) end function --
Atoms seem to go well with, but not bigatom. I do not know more, maybe later when I learn more ... but it would be very good to include sin, cos and arctan to complete the library. (arctan is a very important function)
Greets.
cargoan
4. Re: bigatom in The Archive
- Posted by _tom (admin) Dec 22, 2014
- 1881 views
Now available in The Archive:
I have done some "cut and paste" using Google Translate along with some creole formatting.
The documentation for the library is now at:
http://openeuphoria.org/wiki/view/bigatom.e.wc
The source-code for bigatom.e is in the Pastey. (Unfortunately the file is too large; it is saved in two parts.)
As you can now see, bigatom.e is a very interesting library for doing some crazy number crunching.
Thanks to Carlos Gómez Andreu (cargoan)
_tom
5. Re: bigatom in The Archive
- Posted by cargoan Dec 22, 2014
- 1842 views
Hola _tom.
Agradezco mucho que te hayas molestado tanto, yo no habría sido capaz.
Si os interesa, yo no quiero nada, ni siquiera reconocimiento alguno, muy al contrario. Soy yo el nunca podré agradecer a los desarrolladores de Euphoria su gran trabajo y enorme esfuerzo para que podamos disfrutar de esta maravilla, llamada Euphoria.
Yo conocí Euphoria en un cd hace mucho, había un pequeño archivo zip llamado euphor14.zip, creo, en ms-dos claro. Y ponía: Lenguaje de programación sencillo y potente, me llamó la atención y probé, imprimí el manual, aunque estuviese en inglés, le eché una ojeada y... esto es lo que busco, yo no soy programador y el basic y otros lenguajes interpretados eran muy lentos si querías exprimirlos un poco y C... bueno C me gusta, pero antes era mucho más sencillo, ahora entre typedefs, macros, extensiones y... seguro que es mejor y más seguro pero para un simple aficionado al final ya no sé ni lo que estaba viendo, se me hace grande.
Como no me gustaba windows, siempre usaba msdos y Dos Navigator, y me pasé a OS/2 y estuve tanteando con derivados de pascal (Modula y Oberon), al final me pasé a linux y en cuanto ví que tenía en el repositorio una versión de 64 bits cloné el repositorio... y aquí estamos en mí Archlinux64 (liquorix+BFS) y con el repo mercurial en mi home.
Muchísimas gracias y hasta pronto.
cargoan
English:
Hello _tom.
I appreciate you've bothered you so much, I would not have been able.
If you are interested, I want nothing, not even any recognition, quite the contrary. Is I can never thank the developers Euphoria their hard work and great effort for us to enjoy this wonder called Euphoria. Euphoria
I met a cd long ago, there was a small zip file called euphor14.zip, I think, in ms-dos clear. And read: language simple and powerful programming caught my attention and I tried, I printed the manual, even if it was in English, I took a look and ... this is what I want, I'm not a programmer and basic and other languages interpreted were very slow if you wanted to squeeze a little and C ... good C I like, but it was much easier before, now between typedefs, macros, extensions and ... it sure is better and safer but for an amateur to end do not even know what I was seeing, it makes me great.
As I did not like windows, always wore msdos and Dos Navigator, and I switched to OS / 2 and was groping derived from pascal (Modula and Oberon), at the end I switched to linux and as soon as I saw that I had in the repository a 64-bit I cloned the repository ... and we're here with me Archlinux64 (liquorix+BFS) and the mercurial repo in my home.
Thank you and goodbye.
cargoan
6. Re: bigatom in The Archive
- Posted by cargoan Dec 23, 2014
- 1776 views
Revisiting code I found an wrong? declaration (object) when it is an integer and when I added shortcuts for ten powers I forgot cut the mantissa in ba_root(). Effect is that you can receive more decimal places than the current scale. It's not an important bug but is not correct.
Updated in the Euphoria archive.
Greets.
Note: and added trigonometrics functions, commented out, at end of file... if anyone is encouraged and solves it, I do not get more, convergence of arctan is very painful with these divisors.
7. Re: bigatom in The Archive
- Posted by cargoan Dec 23, 2014
- 1781 views
Revisiting code I found an wrong? declaration (object) when it is an integer and when I added shortcuts for ten powers I forgot cut the mantissa in ba_root(). Effect is that you can receive more decimal places than the current scale. It's not an important bug but is not correct.
Updated in the Euphoria archive.
Greets.
Note: and added trigonometric functions, commented out, at end of file... if anyone is encouraged and solves it, I do not get more, convergence of arctan is very painful with these divisors in the McLaurin-Taylor serie. I had to watch a few videos of classes on the matter but ... nothing. Well, nothing not, I have learned enough, never time wasted if you learn something... and as singing, yesterday spoiled, the great Joe Cocker: "with a little help from my friends..."
8. Re: bigatom in The Archive
- Posted by cargoan Dec 25, 2014
- 1740 views
Updated.
Added ba_log10() and missing license.
Greets.
9. Re: bigatom in The Archive
- Posted by cargoan Dec 27, 2014
- 1531 views
- Last edited Dec 28, 2014
Improved euler() function for speed.
Checked up to one million decimals.
┌──────────────────────────────────────────────────────[sábado, 27 de diciembre 22:45 CET] ├─[cargoan en ~cargoan/Documentos/Programación/Euphoria/bigatom-a1] └─[bash 4.3]──[$]: euc -D TEST3 bigatom.e Build directory: build-739556/ Translating code, pass: 1 2 3 4 5 6 7 8 9 10 11 generating Compiling with GCC Compiling 12% init-.c Compiling 50% bigatom.c Compiling 75% main-.c Linking 100% ../bigatom ┌──────────────────────────────────────────────────────[sábado, 27 de diciembre 22:59 CET] ├─[cargoan en ~cargoan/Documentos/Programación/Euphoria/bigatom-a1] └─[bash 4.3]──[$]: ./bigatom 'e' con 1000000 decimales en: 1105.750 seg. ┌─────────────────────────────────────────────────────[domingo, 28 de diciembre 10:08 CET] ├─[cargoan en ~cargoan/Documentos/Programación/Euphoria/bigatom-a1] └─[bash 4.3]──[$]: grep "model name" /proc/cpuinfo | sort -u | sed 's/.*: //'; cat /sys/de vices/system/cpu/cpu0/cpufreq/{scaling_governor,cpuinfo_max_freq}; uname -a; journalctl -b | grep -i smpboot | grep -i mips | sed 's/.*:*: //'; zgrep ^CONFIG.*_BFS= /proc/config.gz AMD Athlon(tm) Dual Core Processor 4450e ondemand 2300000 Linux HP-s3733es 3.18.1-1-lqx #1 ZEN SMP PREEMPT Fri Dec 26 20:47:47 CET 2014 x86_64 GNU/L inux Total of 2 processors activated (9200.18 BogoMIPS) CONFIG_SCHED_BFS=youtput in a file named "e-1millon"
Updated in the Archive.
Thanks.
10. Re: bigatom in The Archive
- Posted by ne1uno Dec 27, 2014
- 1535 views
thanks for posting the code and to _Tom too.
I have started a test file that doesn't have much in it now but you might find this is a good way to check nothing is broken as you work on the lib.
you could add more tests as you add to bigatom and see if anything fails, without needing to look through dozens of pages output by bigatom-test.ex
unittest is part of the stdlib of euphoria.
--t_bigatom.e some tests for bigatom from bigatom-text.ex include std/unittest.e include std/sequence.e include std/text.e include std/types.e include std/math.e include std/sort.e include bigatom.e as B --default namespace is bigatom sequence s, t sequence sc = scale() sc = scale(9,0) sc = scale() test_equal("set scale1 9,0", {9,0}, sc ) sc = scale(9,0) test_equal("set scale2 9,0", {9,0}, sc ) sequence fmt = "%24.7cB <==\n" -- sin zdecs (0.0000000) si no es cero sequence fmt2 = "%24.07cB <== " -- con zdecs (+/-0.0000000) sequence fmt3 = "%B\n" -- con todos los d?gitos sc = scale(50) test_equal("previous scale", {40,0}, sc ) sc = scale() test_equal("current scale", {50,0}, sc ) -- more to be converted from bigatom-test.ex ba_printf(1,"ba_logb(\"9999.99999\", 10) = %B\n", ba_logb("9999.99999", 10)) --ba_printf(1,"ba_log10(\"9999.99999\") = %B\n", ba_log10("9999.99999")) --trace(1) s = "__ -231.2345 e-12e++..--Eholae" t = { -1, -10, {2,3,1,2,3,4,5} } test_equal("ba_new("&s, t, ba_new(s)) s = "__ -231.2345e-12e++..--Eholae" test_equal("ba_new("&s, t, ba_new(s)) -- ? ba_new("") test_equal("ba_new('') ", {-2,0,{}}, ba_new("") ) test_report()
11. Re: bigatom in The Archive
- Posted by cargoan Dec 28, 2014
- 1589 views
I know the existence of unittest but only that, there it is... but it's something I have not reviewed yet ... and nor was it one of my priorities. I'm not a programmer, amateur only, then ... ...I'll have to discuss that topic.
I do not know any English, and yes is Translator but do not know English but Castilian is horrible most of the time, or is incomprehensible or gives a totally opposite to the translation.
is because as the Italians say: "traduttore, tradittore" (translator, traitor).
Greets.
Note: I checked with: http://apod.nasa.gov/htmltest/gifcity/e.1mil (Says a million but spare twenty)
[$]: diff e.1mil e-1millon 12501c12501 < 818883747115156239682713 --- > 8188
12. Re: bigatom in The Archive
- Posted by cargoan Dec 28, 2014
- 1531 views
checked with 1_200_000 decs. at: http://www.numberworld.org/digits/E/
[$]: ./bigatom 'e' with 1200000 decimal places in: 1538.790 seg. comparison (end of number): -- ... 2091326927 6668645250 6023738485 3582729778 9319587857 : euphoria euler function -- ... 2091326927 6668645250 6023738485 3582729778 9319587857 : 1,200,000
13. Re: bigatom in The Archive
- Posted by cargoan Dec 29, 2014
- 1469 views
a million and a half good
[$]: ./bigatom 'e' with 1500000 decimal places in: 2419.070 secs. [$]: tail -n3 e-1millon5 74825944780370926454043853803943744332806781271297919806419520177237478193466293 67171721860429794706831810947471135277309638919039832745908266244429554005170557 6339 ... 5277309638 9190398327 4590826624 4429554005 1705576339 : euler(1_500_000) ... 5277309638 9190398327 4590826624 4429554005 1705576339 : 1,500,000 (numberworld)
...looks like it goes well