# Questions tagged [arithmetic]

Questions on arithmetic operations in Mathematica.

97 questions
Filter by
Sorted by
Tagged with
3k views

### Why are numeric division and subtraction not handled better in Mathematica?

There is something that has been troubling me for a while. At least through version 10.0 the performance of a / b and a - b is ...
• 272k
1k views

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

In this comment it was asserted that Divide[a,b] and a/b are different, though the documentation indicates that they are the ...
• 4,959
3k views

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

Insert $+$, $-$, $\times$, $/$, $($, $)$ into $123456789$ to make it equal to $100$. Looks like a question for pupils, right? In fact, if the available math symbols are limited to addition ($+$), ...
• 67.1k
686 views

### Should 0 * 5ft be 0 or 0ft?

After playing with the new quantity system in Mathematica 9 for a while, I keep stumbling over this issue: 0 * Quantity[1, "Meters"] is not the same as ...
• 36.2k
6k views

### Puzzle with Mathematica

Hello everyone, This is a puzzle I got from someone via social media. Basically, we need to fill up the boxes with the numbers 1-9 (no repetitions) that fit the multiplication and addition operations. ...
• 347
1k views

### How to prevent reduction of a fraction into lowest terms?

I have a question about the concept of simplification. I want to explain it with an example. When I write the fraction $4/8$ in Mathematica, the output is 1/2. How ...
• 749
1k views

### How to enter a repeating decimal in Mathematica

I don't understand how to manipulate numbers with repeating decimal in Wolfram Mathematica language. For example 0.3... does not work as input and I don't see how ...
• 3,013
3k views

### Product of elements of a list

Sum is for functions; Total is for a list. Product is for a function; what is the command ...
331 views

### How does Plus work on machine precision Real arguments?

I thought Kahan's summation method would make a nice example for students to use to think about round-off error [W. Kahan, Pracniques: Further Remarks on Reducing Truncation Errors, Commun. ACM 8  (...
• 239k
12k views

### Expressing a decimal as a fraction in lowest terms

How can I express a decimal such as 0.1845095405274387 as a fraction in its lowest terms?
• 359
305 views

### Arithmetic operations on NumericArrays

Currently, NumericArrays are directly supported by the most important array-related functions, what makes them a very attractive data structure for implementing ...
176 views

### Trace of -{1} expression

I'm trying to understand Trace. Usually it doesn't repeat but it adds {-1,-1} for his simple expression after having a correct ...
• 619
857 views

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

Why is it that when I evaluate 2*2.848529281693615+3*-0.5155083247776808 I get (* -2.93688 *) which is wrong. ...
236 views

### Arbitrary-Precision Arithmetic behaves unexpectedly

I want to understand how small numerical errors propagate through a computation and may drastically change the final result. To this end, I consider a toy world in which every number is limited to ...
• 389
1k views

I want to do a cross or dot product involving a vector of Pauli matrices $\vec\sigma=(\sigma^1, \sigma^2, \sigma^3)$; for example, $\vec\sigma\times\vec\sigma=2\mathrm i\vec\sigma$ and $\vec\... 8 votes 3 answers 392 views ### Improving Map Function on Lists Dealing with spectral data (2D lists) where offsets (corresponding 1D list) must be removed from each individual spectrum. Looking for feedback on improvements over my current method. ... • 576 8 votes 4 answers 1k views ### Countdown arithmetic solver In the numbers game in countdown, contestants are given 6 numbers with which they must reach a seventh number with basic arithmetic. The only operations allowed are addition, subtraction, ... • 8,617 7 votes 2 answers 2k views ### How to do binary calculation？ For example,$a=0.10101$in binary representation. Then how to calculate$a^2$directly in mathematica? Is there any function turning binary into decimal? I only found its inverse... • 172 7 votes 2 answers 240 views ### Is there a way to show the details of a numerical computation? I have recently started using Mathematica as a calculator while teaching (definitely overkill, but I try to use as few tools as possible). I would like my students to be able to trace simple numerical ... • 4,372 7 votes 1 answer 177 views ### Running Mathematica in 'SpouseMode' In this previous question I looked into a deprecated capability of Mathematica from Version 2. Mathematica command that allows it to read my intentions Thanks to all for your answers. I note that ... • 7,183 6 votes 1 answer 429 views ### Why can't I remove Orderless from Plus? I am making some random algebra equations, and I want to have the ordering be random too, such that if my random equation generator makes x+1, the output stays <... • 4,742 5 votes 14 answers 2k views ### Sum of Squares without multiplication I want to sum the squares for a given number N from 1 without using Multiplication. Is it possible? • 75 5 votes 3 answers 547 views ### How to find a longest word path in dictionary? Cross post here A word path means the last character of the last word is same to the first character of the next word.And the path have no duplicated word.If I have$55$words,I can find it with this ... • 26.9k 5 votes 1 answer 249 views ### Does Mathematica simplify calculation when encounter zero? e.g. when Mathematica Calculating f[x0]=A[x0] B[x0], where A[x] & B[x] could be some complicated high dimensional function. Will Mathematica outcome 0 directly ... 4 votes 5 answers 496 views ### How to check if multiplication requires carries? For some purposes I need to know if there are there any carries in the multiplication of two numbers, especially in base-2. How can we do this in Mathematica? Thanks to all, very interesting answers! ... • 1,846 4 votes 4 answers 219 views ### Lines of intersections in a parabola To test the parabolic sieve, my intention was for the graph to show the coordinates of two points on the parabola and the value of the intersection on the y-axis. A table with this information would ... 4 votes 3 answers 3k views ### Permanently rounding numbers/values to a given number of significant figures I am searching for a simple way of rounding and setting an input to a desired number of significant figures. There are a vast number of posts that discuss similar problems, but none address this issue.... 4 votes 2 answers 397 views ### Interchanging addition and multiplication Suppose I have an expression that employs addition and multiplication, but no subtraction or division: $$2 a + 5 b x^3 + c \;.$$ I would like to change this to $$(2 + a) (5 +b + x +x +x) c \;,$$ ... • 4,751 4 votes 2 answers 207 views ### Multiplication non-deterministic? I have two vectors of 134 elements each ($mu$, and$gt$).$mu$contains Integers, and$gt$contains machine precision Reals. I execute the following simple expression multiple times without changing ... • 175 4 votes 1 answer 475 views ### multiply two vectors, component by component [closed] Would like to take two vectors and multiply components at the same index.For example {a1, a2, a3} x {b1, b2, b3} to produce {a1 b1, a2 b2, a3 b3}. The following works, but are there some alternatives?... • 1,069 4 votes 2 answers 2k views ### Floating point addition not associative Can anybody explain the following behavior? x = 0.2 + (0.3 + 0.1); y = (0.2 + 0.3) + 0.1; x == y (* -> True *) But actually the variables do not exactly ... • 637 4 votes 1 answer 143 views ### Simplify expressions with modulo 2 (Boolean algebra) Suppose I have a (Boolean algebra) expression a = p1 x^2 + p2 x (x-1) + 3 p3 + 4 p4 x where p1, ..., ... 4 votes 2 answers 127 views ### Raise a table of pre-existing data to the power of of one of the variables NOTE: I have edited this question to give a table whose first elements don't count up from 0 to 5. I'm using a sample table ... • 2,335 4 votes 3 answers 203 views ### A sudoku-like collection puzzle I have a puzzle. I'm given a collection of$n$lists, all of equal (but arbitrary) length$l$. These lists are made up of 0s and a few filled in numbers, like so: { {0, 2}, {0,0}, {6, 0}, {0,0} } ... • 3,644 4 votes 1 answer 154 views ### Machine Epsilon is not equal to$MachineEpsilon [duplicate]

I try to wrap my head around machine precision calculations in Mathematica (11.2, Linux). I do not understand the following behavior: ...
84 views

### Force computation on IEEE float/double

I'm checking two different procedures that will eventually be used with regular floating point arithmetic. I need to estimate numerical error arising from floating point arithmetic. Is there a way to ...
• 211
178 views

• 10.9k
166 views

### Solving calculation puzzle [closed]

I recently got asked how to achieve a result of 100 only using the numbers {1,7,7,7,7} (the number 1 can be used only once and ...
• 1,134
213 views

### How can I redefine multiplication?

For instance, I want 0 Infinity = 0 I tried this: Unprotect[Times];Times[Infinity,0]=0;Times[0,Infinity]=0;Protect[Times]; But ...
• 3,630
122 views

### Can I make RandomInstance use exact arithmetic?

When using RandomInstance on a GeometricScene the answer loses precision when root objects are encountered. Is there a way to ...
• 9,523
88 views

I'm working with my 6 year old on understanding and mastering addition. As a result, I want to be able to make some custom addition (and eventually multiplication) tables for her to fill out. ...
• 689
187 views

### Generating prime factorizations from an integer's digits by inserting * and ^ into the digit sequence

Problem Given a positive integer, output all possible valid prime-factorization "statements" thereof created by inserting zero or more multiplication (*) symbols and zero or more power (^) symbols ...
145 views

### Forcing divisions to be a machine-precision floating point divisions instead of multiplication by inverse

I want to imitate machine-precision, de facto IEEE division on Mathematica. On my quick trials I find this surprisingly hard to accomplish, since Mma rewrites a / b ...
• 19.1k