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}$$
<...
Community wiki
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 ...
16
votes
How to enter a repeating decimal in Mathematica
Use the ResourceFunction RepeatingDecimalToRational:
...
14
votes
Puzzle with Mathematica
Can't think out a better method than brute force, it'll be conciser in Mathematica of course:
...
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 ...
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):
...
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. ...
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 ...
Community wiki
9
votes
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 ...
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
...
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 ...
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
...
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} *)
...
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 ...
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 ...
7
votes
Accepted
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.
...
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.
...
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 ...
Community wiki
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'...
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.
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 ...
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, ...
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, ...
6
votes
Accepted
6
votes
Improving Map Function on Lists
A slightly faster method uses KroneckerProduct to create a suitable matrix of offsets. Some data:
...
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}
...
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!
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
arithmetic × 93list-manipulation × 14
numerics × 13
core-language × 7
simplifying-expressions × 6
machine-precision × 6
matrix × 5
equation-solving × 4
functions × 4
performance-tuning × 4
evaluation × 4
complex × 4
precision-and-accuracy × 4
puzzle × 4
programming × 3
output-formatting × 3
syntax × 3
combinatorics × 3
number-theory × 3
pure-function × 3
graphs-and-networks × 2
symbolic × 2
machine-learning × 2
date-and-time × 2
memory × 2