30 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}$$ <...
23 votes
Accepted

Puzzle with Mathematica

A non brute-force approach is the following, similar to my answer for the Zebra Puzzle. Both puzzles are examples of constrainst satisfaction problems, that can be solved with ...
unlikely's user avatar
  • 7,043
16 votes

How to enter a repeating decimal in Mathematica

Use the ResourceFunction RepeatingDecimalToRational: ...
Bob Hanlon's user avatar
  • 149k
14 votes

Puzzle with Mathematica

Can't think out a better method than brute force, it'll be conciser in Mathematica of course: ...
xzczd's user avatar
  • 62.9k
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
  • 21.6k
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
  • 23.6k
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
  • 233k
11 votes

Puzzle with Mathematica

To make the brute force solution a bit more pleasant for the eye of the observer: ...
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

Puzzle with Mathematica

...
xiang's user avatar
  • 366
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
  • 69.8k
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
  • 7,907
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
  • 232k
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.6k
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
  • 5,864
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
  • 232k
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
  • 129k
7 votes
Accepted

Improving Map Function on Lists

...
chyanog's user avatar
  • 15k
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
  • 135k
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

intermediate steps of a Mathematica operation

I feel like I should be prefacing this answer with three confessions, considering that this is an arithmetic question. First, I had a hard time with the multiplication tables until I was nine years ...
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
  • 23.6k
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

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
  • 233k
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
  • 15k
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.1k
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
  • 129k
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
  • 378k
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's user avatar
  • 7,349

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