![]() |
Huh? Ever heard of floating point numbers? All you need is 64 bits here:
(well, default pari's precision is ~200 bits, but is not significant for this discussion, you can change that using the "default" statement, which I didn't do) [CODE] gp > a=1.0; for(i=2,1000000,a*=i);a time = 139 ms. %1 = 8.263931688331240062376646092 E5565708 gp > a<2.0^20000000 time = 14 ms. %2 = 1 gp > 2.0^20000000 %3 = 8.189919327850745125930453851 E6020599 gp >[/CODE][edit, note that the third calculus is instant, there is no timing displayed, he took it from cache!] |
Yes I heard about it, but somehow it did not occurred to me to use it for this purpose, or perhaps I forgot about it.
Thank you this should be helpful. BTW we always mean a plural you and not singular you when we address you.:bow: |
Well.. actually I over-reacted a bit, and I am sorry, I just realized those are still "arbitrary precision" numbers, they are represented on ~368 bits, with an exponent on ~25 bits. That is because the IEEE754 standard would not allow such higher exponents, even in its most extended format, [URL="https://en.wikipedia.org/wiki/Octuple-precision_floating-point_format"]float-256[/URL], would only allow 19 bits of exponent (~10^500k max range, which is from 10[SUP]-262k[/SUP] to 10[SUP]+262k[/SUP], and not in 6 millions!), no talking about the double precision, where the exponent is on 11 bits only :blush:
In fact, the standard representations extend the mantissa, to increase precision, and not the exponent. Here Pari uses his own internal (arbitrary) numbers, with a short mantissa and longer exponent. So, they are still arbitrary. But I think it is ok to solve your problem, which is fact is related to the fact that you wanted to calculate that in integers, and Pari will not convert your numbers to floats by itself, losing precision, if you don't tell him that he is allowed to do so. Therefore, if you start with a float (x=1.0) instead of an integer (x=1) then all the calculus is in floats, and you don't need to allocate buckets of memory. I always use "general you", which is "plural" and "polite" :razz:. In fact, I always have problems with that in English, as my native tongue has different words for singular/plural/familiar/polite/formal/informal "you". One that you address him with the "polite you" (like a teacher, an older person, etc), has to "offer" you a "singular" or "informal" or "familiar" "you" before you can use it with him. (grrr, how the hack can I explain this in English? haha), and it is extremely impolite to address such a person using the "singular/informal/familiar" you before he allows you to do so. I feel a bit strange saying "you" in every context, so sorry if I use it wrong. |
Yes, "you" is often difficult here as well. In Dutch, we use the formal/polite form of you for God, while in French the informal/familiar form is used. e.g.
English: Your Kingdom come Dutch: Uw koninkrijk kome French: Que ton règne arrive |
[QUOTE=Nick;440026]...
French: Que ton règne arrive[/QUOTE]In France the Catholics used the "vous" form before 1966. The Protestants have used the "tu" for a longer time. (I remember having learnt the "vous" form at school, for the more precise data the wikipedia offers more.) But you and I digress. Jacob |
Well, the subject is solved anyhow, so digression is free to all :razz:
Here I remember a joke with some French diplomat who asked the British queen, during an official visit, "can I say you to you?" We also call the god "tu" (the less polite, singular form, same meaning as in French), and most Romanians are religious people (in normal limits, not extreme), and they [U]all[/U] call the god "tu", and not "vous". (taking French as example, "tu" is the same word, but "vous" is different). Some local people who are against excessive politeness use this as an argument, which has some success, due to the fact that Romanians are religious. Such people are not necessarily religious, neither atheist, but only against excessive politeness, and sometimes they are justified by the fact that our language can go to extended, comical, and ridiculous ways to achieve that politeness, or to avoid words that do not sound "well". For example the most common version of "polite you" is called "dumneavoastră", which is a contraction of "domnia voastră", i.e. "your highness", and it is very commonly used, in spite of the fact that you are getting older until you say it. Therefore, those "anti politeness" guys would argue like "who is the most closest to you? it is not your mother, not your friend/spouse, etc, but the god, because god knows everything about you, etc, etc, and when you pray to the god you call "tu doamne", and not "dumneavostră doamne"... etc, you got the idea (the last expression sounds extremely ridiculous, one can call his father or mother "dumneavostra" if he wants to be polite, or ironical, whatever, but one will never call god "dumneavoastra"). |
[QUOTE=Nick;440026]Yes, "you" is often difficult here as well. In Dutch, we use the formal/polite form of you for God, while in French the informal/familiar form is used. e.g.
English: Your Kingdom come Dutch: Uw koninkrijk kome French: Que ton règne arrive[/QUOTE] Matthew 6: 9-13 in the King James Bible has [code] 9 After this manner therefore pray ye: Our Father which art in heaven, Hallowed be thy name. 10 Thy kingdom come. Thy will be done in earth, as it is in heaven. 11 Give us this day our daily bread. 12 And forgive us our debts, as we forgive our debtors. 13 And lead us not into temptation, but deliver us from evil: For thine is the kingdom, and the power, and the glory, for ever. Amen. [/code] Note that [I]thy[/I] and [I]thine[/I] are used, not from familiarity but because it's the second person singular personal pronoun. Likewise, [I]ye[/I] is because the instruction is being given to several people and so requires the plural form. English is much poorer for mostly having lost the second person singular pronoun, though it clings on in a few northern English dialects. Yorkshire is especially noted for still using thee, thou and thy. In Liverpudlian, one occasionally comes across [I]yourn[/I] to distinguish from the plural [I]your[/I]. |
Well in my native language (Persian), as well as my mother tongue (Azary),we have singular words for "you" which is usually used for close family and friends. Everyone else is usually politely addressed in plural terms.
What I find interesting is that in my particular religion's (Bahai Faith) scripture God is addressed very politely and extremely humbly but as a singular entity. This is generally translated in English as Thou. This probably signifies emphasis on Oneness of God, perhaps to eliminate the possibility of doctrines/interpretations per Gods and Goddesses. Now my follow up question to the plural entities on this board is: *- When you enter a room, do you do so individually, or all at once?:smile: :bounce wave: |
Usually we poke our head in first to check for grues.
|
[QUOTE=a1call;439770]Is there a way to abort/quit/break a function based on time? In particular I would like to abort factor(n), and go on to the next item if n takes too long to factor.[/QUOTE]
This is the purpose of the alarm command, and indeed your use case is the example in the documentation: [code]p = nextprime(10^25); q = nextprime(10^26); N = p*q; E = alarm(1, factor(N)); type(E) print(E) alarm(10, factor(N)); \\ enough time[/code] Make sure you're using an up-to-date version here -- on older versions alarm() only worked on Linux. [QUOTE=a1call;439770]An alternative would be to limit factoring to to small primes.[/QUOTE] You can do this with [code]factor(N, 10^7)[/code] but I think this stops it from using sophisticated algorithms in favor of trial division. |
[QUOTE=a1call;440020]Say you want to know if
1000000!>2^20000000 very few significant digits is sufficient to find out since 1000000!=8.264*10^5565708 and 2^20000000=8.19x10^6020599 Try doing this comparison on Pari-GP without allocating very large amounts of memory which is quite unnecessary for the comparison. In fact like I mentioned you can painstakingly recreate the operation in Pari by truncating and keeping track of number of digits.[/QUOTE] Take logarithms: [code]lngamma(1000000+1) > 20000000*log(2)[/code] which is essentially instant (17 microseconds on my machine with 128 bits of precision). |
| All times are UTC. The time now is 06:54. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.