# Tag Info

23

The idea The idea is that if we have $\log(a+b),\qquad a\gg b$ , then we can equivalently write this as $\log a + \log(1 + b/a)$ and the second part will be small, so that one can first compare the first part(s). The power towers with base numbers larger than 1 naturally lead to such logarithms when we repeatedly take the $\log$ of them. So, there ...

18

We can take advantage of the fact that IntegerDigits is very fast when the base is large. But not too large: no bigger than $2^{63}-1$ on a 64-bit system or $2^{31}-1$ on a 32-bit one, because Mathematica's machine integers are signed. Additionally, non-power-of-two bases require more work to get the result than just partitioning a bit-string, and are ...

18

It's due to an implementation-dependent issue. We should try to improve on it. Has not been much clamor to do so, therefore it has not been a high priority. --- edit --- I've had a look at the code. It is quite intentional that the largest is around what you state (I see the constant being set to $7.783516108362\times 10^{12}$). It has to do with this ...

17

Actually, I believe the issue reduced to that of implementing PrimePi[]. It is easy to implement Prime[] using PrimePi[] and FindRoot[] — in fact this is done on page 134 of Bressoud and Wagon, "A Course in Computational Number Theory". So all you need is to have a fast implementation of PrimePi[]. The first efficient way was found by Legendre in 1808. The ...

16

If you calculate Log[2,Log[2,$MaxNumber]], you'll get 29.999999828017338886225739 which is remarkably close to 30. Therefore I conclude that Mathematica calculates with a 31-bit exponent (1 bit for the exponent's sign). Which means that if Mathematica uses the same ordering as IEEE floats (i.e. first sign bit, then exponent, then mantissa), the first 32 ... 12 Nested WolframAlpha approach, showing the intermediate steps: numberString[a_, k_: 10] := FixedPointList[ StringReplace[#, b : (DigitCharacter ..) :> WolframAlpha["spell " <> b, {{"Result", 1}, "Plaintext"}]] &, a, k] numberString["123456"] (* ==> {"123456", "123 thousand and 456", "one hundred twenty-three \ thousand and ... 11 You are losing hugely due to a base 10 implementation. Integers are manipulated in base 2 in Mathematica. So you would want a base 2 variant to get any reasonable behavior. Here is one way to code it. There might be tweaks that improve it. fastSquare[a_] := Catch[Module[ {len = BitLength[a], len2, hi, lo, h2, l2, hl}, If[len < 100, Throw[a^2]]; ... 10 I think you underestimate how many digits this number has. Even if you used scientific notation, the exponent would overflow your PC's memory, so you'd need scientific notation for the scientific notation. I'm not sure which number format you expect to get, but I think the form it's already in is probably the most useful. But let's try to get an idea for ... 9 Messy but a working method inWords[n_] := Module[ {r, numNames = {"", " one", " two", " three", " four", " five", " six", " seven", " eight", " nine"}, teenNames = {" ten", " eleven", " twelve", " thirteen", " fourteen", " fifteen", " sixteen", " seventeen", " eighteen", " nineteen"}, tensNames = {"", " ten", " twenty", " ... 8 Never use pattern matching unless you absolutely have to. Using Cases instead of Select can make a huge difference. Vectorize operations. Use Range instead of Table if you can. Test several things at once. And[test1, test2, test3] will abort when it can for maximum efficiency ("short circuit evaluation"). Taking this into consideration your code looks ... 8 As it seems to depend on more than machine bits I'm curious what$MaxNumber various Mathematica installs have. If your setup is different please fill in system information and Log2 @ Log2 @ $MaxNumber // Round in the table below:$$\begin{array}{r|c|c|l|c} \text{OS} & \text{Bits} & \text{Version} & \text{\$MaxNumber} & \log_2\log_2\\ ...

8

There are large numbers and you need to increase $MaxExtraPrecision, as well as use non-machine arithmetic. E.g.:$MaxExtraPrecision = 8000; N[de2 /. sol /. r -> -90 /. z -> 4, 20] gives 1.4495694130768246652*10^6429 Alternatively, you could do N[Expand[de2 /. sol /. r -> -90 /. z -> 4]]

8

In Mathematica 8 you can use free form input : = Spell 15 and you get "fifteen" Or just write = thirty and you obtain 30 Since for larger numbers this approach yields expressions like {number words number, _ } one could nest this arbitrarily to obtain expressions containing only words. In fact, it is sufficient to nest only two times. For ...

8

My original answer is incorrect -- it is preserved as a record of my own hubris. :^) Simply, as Rojo points out, the calculation is still being done with 1*^1000, it's just being done at a different time. One may see this by manually observing the time taken for evaluation on an idle machine, or by setting this option which will print the total time taken ...

6

num = 1234567891234567899; triples = Reverse /@ Reverse@Partition[Reverse@IntegerDigits[num], 3, 3, 1, 0]; threePowers = {"septillion", "sextillion", "quintillion", "quadrillion", "trillion", "billion", "million", "thousand", ""}; singleRules = {0 -> "", 1 -> "one", 2 -> "two", 3 -> "three", 4 -> "four", 5 -> "five", 6 -> ...

6

This solution is similar in spirit to Prashant's. Though not particularly elegant, I avoid any calls to W|A and any other form of internet connectivity. Further down the post I also provide a solution to the inverse problem of returning the number when given English words. numberform[n_]:=With[{id=IntegerDigits@n}, ...

5

Mathematica 10 introduces IntegerName: IntegerName[n] gives a string containing the full English name of the integer n. IntegerName[n,"type"] gives a string of the specified type. Possible types include: "DigitsWords" a combination of three-digit numbers and words "Words" using only words "Approximate" the first few digits ...

4

I used the following to solve Problem 17 from Project Euler (hint hint). It's working on numbers up to 1000, but the grammar of larger numbers is trivial compared to small numbers and should easily be able to be implemented. Usage: numberToWord /@ {14, 271, 944} {"fourteen", "two hundred and seventy-one", "nine hundred and forty-four"} Source: ...

4

Preface I want to emphasis the comment of @DanielLichtblau I think the Miller-Rabin type of testing makes more sense than endless divisibility tests Furthermore, I won't go into discussing your programming style with setting global variables in Modulearized functions, using parameter-names like N which are clearly built-in symbols, etc. Solution I ...

3

Unfortunately Compile supports only machine-size integers, ruling out bignums.

3

Your first Q (since i'm a C noob): Mathematica c# and the Documentation Center Types of Numbers Your second Q; $MaxMachineNumber is the largest machine-precision number that can be used on a particular computer system.$MaxMachineNumber (* 1.79769*10^308 *) $MaxNumber gives the maximum arbitrary-precision number that can be represented on a ... 2 Many times you can solve this kind of problems using realtions such as GCD[a,b]=GCD[b,Mod[a,b]] and substituting conventional functions for modular ones more specialized. For example, instead of Mod[x^y,z] you have to use PowerMod[x,y,z] that works if z is not too big, even if x^y is huge. Coming back to your example and using different ... 2 First you must understand the difference between machine precision arithmetic (CPU floating point) and Mathematica's own arbitrary precision arithmetic. You get the first by calling N with one argument and the second by calling N with two arguments, the second being the precision you want to maintain. When using Mathematica's own arbitrary precision ... 2 You should take advantage of the fact that a^b == c^(Log[c,a] b) so that E^(E^(10^72)) == 10^(Log[10,E] E^(10^72)) == 10^(Log[10,E] 10^(Log[10,E] 10^72)) Since Log[10,E] (that is, ln(10)) is about 2.3, the number of digits in your quantity (in base 10) is ~ 2.3 10^(2.3*10^72) 2 You could simply wrap your computation in MLPutFunction(link, "ToString", 1); and convert your result to a string. After that you can use MLGetString. 2 Your first port of call should be to have a look at the documentation for$MaxNumber, which says: $MaxNumber gives the maximum arbitrary‐precision number that can be represented on a particular computer system. On my machine,$MaxNumber returns $1.605216761933662 \times 10^{1355718576299609}$. With regards to your number, $44^{6553700000000}$, I ...

2

This works fine for me (v.10.0.0 on Mac Pro): Clear[a, b] a = 44^(65537); b = 22^(65537); c = GCD[a, b]; Where all the digits of c are computed and revealed within about 2 seconds. N@c 2.265859854928417*10^87978

2

Try with Export["data_output1.txt", AA, "CSV"]

2

You could define your own definitions for formatting numbers and variables. For example WriteInput1[file_, var_, eqlist_] := Module[{text, removewhite, eq2, gg, hh, format}, format[a_?NumericQ] := Block[{Format}, ToString@NumberForm[a, 10, NumberFormat -> (Module[{man}, man = #1; If[StringTake[#1, -1] === ".", man = man ...

Only top voted, non community-wiki answers of a minimum length are eligible