Skip to main content
31 votes

How to enter a repeating decimal in Mathematica

Indeed, there is no direct method to input a repeating decimal. The closest you can get is to input the repeating digits into FromDigits[]: $$0.\overline{142857}$$ <...
16 votes

How to enter a repeating decimal in Mathematica

Use the ResourceFunction RepeatingDecimalToRational: ...
Bob Hanlon's user avatar
  • 160k
13 votes

Arithmetic operations on NumericArrays

It seems like no one answered this yet, so let me elaborate a little on my comment. A simple example of using FunctionCompile to add ...
Sjoerd Smit's user avatar
  • 23.9k
12 votes

How to recover Pauli matrices properties in Mathematica?

The Pauli vector: σ = Table[PauliMatrix[i], {i, 1, 3}] MatrixForm /@ σ One can define a dot product of matrices (in spaces of arbitrary dimension): ...
corey979's user avatar
  • 24k
12 votes
Accepted

Trace of -{1} expression

This is a good question for uncovering an important difference between listability and vectorization. Sometimes these terms are used interchangeably, but I would like to make a technical distinction. ...
Michael E2's user avatar
  • 239k
9 votes
Accepted

Why am I seeing what looks like a violation of operator precedence?

Consider the following: 2.84852`+3 2.85 This syntax means "write 2.84852 with 3 digits ...
C. E.'s user avatar
  • 70.9k
9 votes

Arbitrary-Precision Arithmetic behaves unexpectedly

This is at best a partial answer. I don't know in full detail what is going on with FullForm or InputForm but I will venture to ...
9 votes

Why does the Mathematica give different numerical results?

They are supposed to be different. (-y)^a /. a -> 2.99 /. y -> -2 (*7.94474*) is equivalent to 2^2.99 or ...
Bill Watts's user avatar
  • 8,237
9 votes

Recycle buying soda problem

s price of soda without bottle, b price of empty bottle, k number of drunk sodas. ...
azerbajdzan's user avatar
  • 19.9k
8 votes

Product of elements of a list

Why is there no equivalent of Total for products? There isn't an equivalent of Total for products, and I believe that there is ...
Szabolcs's user avatar
  • 236k
8 votes
Accepted

multiply two vectors, component by component

No need to do anything fancy. This is just how ordinary list multiplication works: {a1, a2, a3} {b1, b2, b3} yields ...
John Doty's user avatar
  • 13.8k
8 votes

Rounding Real number

You can use Round and specify the second argument, t = {75.34123, 80.567, 85.789}; Round[t, 0.01] (* {75.34, 80.57, 85.79} *) ...
evanb's user avatar
  • 6,161
7 votes
Accepted

How to form subgraphs from a connected graph

Update: I just noticed this comment: The constraint I have is: a node can not be in two subgraphs. This is contradictory with the rest of the problem description: need to find all possible ...
Szabolcs's user avatar
  • 236k
7 votes
Accepted

Why Divide does not give the same answer?

First, since the precedence of Divide is higher than Times, you should expect to parse ...
Carl Woll's user avatar
  • 131k
7 votes
Accepted

Improving Map Function on Lists

...
chyanog's user avatar
  • 15.6k
7 votes
Accepted

Does Mathematica simplify calculation when encounter zero?

A quick experiment shows it does not stop, but it will evaluates all expressions on RHS, even if one is zero. ...
Nasser's user avatar
  • 147k
7 votes
Accepted

Simplify expressions with modulo 2 (Boolean algebra)

You are working in a Boolean algebra (this should be stated explicitly). So there are reduction relations. We'll compute those first. ...
Daniel Lichtblau's user avatar
6 votes

Is there a difference between Divide[a,b] and a/b?

I have just a little to add to @Szabolcs' answer, and this seemed an appropriate place rather than a separate Q&A. Since there is a theorem involved (see below), it should be pointed out that this ...
Michael E2's user avatar
  • 239k
6 votes
Accepted

Why does this whole number have a recurring value?

It's a numerical artifact that is due to finite precision of computer calculations. Indeed, when one computes SetAccuracy[12.30*12, 15] 147.60000000000002 It'...
corey979's user avatar
  • 24k
6 votes
Accepted

Multiplication non-deterministic?

It's not a bug and it's not so uncommon. For an explanation have a look here. This and some related issues also appear in this MathGroup thread. Also relevant: 1 2.
Daniel Lichtblau's user avatar
6 votes

Insert $+$, $-$, $\times$, $/$, $($, $)$ into $123456789$ to make it equal to $100$

Similar to whuber's answer, we can use Groupings(introduced in version 11) to simplify the generation patterns, the number of patterns is related to the CatalanNumber, and use parallel computing, ...
chyanog's user avatar
  • 15.6k
6 votes

Countdown arithmetic solver

Improved answer (Since the contents of the original answer is contained in what follows here, the original answer is deleted.) I address the following problem: given a set of numbers and a target, ...
Fred Simons's user avatar
  • 10.2k
6 votes
Accepted

Interchanging addition and multiplication

Using With you can get a more interactive feel: ...
Anton Antonov's user avatar
6 votes

Improving Map Function on Lists

A slightly faster method uses KroneckerProduct to create a suitable matrix of offsets. Some data: ...
Carl Woll's user avatar
  • 131k
6 votes

Applying Mod on list of list with outcomes +1, -1, other

You can use -1 as the third argument of Mod: Mod[##, -1] & @@@ lis {-1, -1, 1, 2} ...
kglr's user avatar
  • 399k
6 votes

Why does the Mathematica give different numerical results?

Complex power is really a multivalued function. Consider this function, that returns all possible values of a complex number $x^y$: ...
swish's user avatar
  • 7,921
6 votes

Solving calculation puzzle

Here are all $4$ solutions to the puzzle Technique #1 heavily plagiarizing this excellent answer Apparently Groupings is the tool for the job! ...
Conor Cosnett's user avatar
6 votes

Express rational and infinite expressions in Mathematica

...
Bob Hanlon's user avatar
  • 160k
5 votes

How to find a longest word path in dictionary?

This is really a comment and suggestion, but too long to put in a comment format (so please don't down-vote this). I would speed the search by grouping words into the $26 \cdot 26$ classes that have ...
David G. Stork's user avatar
5 votes
Accepted

How can I make Mathematica agree that 0^0 = 1?

Operator overloading is one way. Unprotect[Power]; Power[0, 0] = 1; Protect[Power]; You should add also the cases like ...
Kiro's user avatar
  • 1,521

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