Questions tagged [arithmetic]

Questions on arithmetic operations in Mathematica.

Filter by
Sorted by
Tagged with
0
votes
2answers
42 views

Mathematica doesn't evaluate/simplify arithmetic expression in its output [closed]

I have two matrices, A := {{1, 2, -4}, {2, -2, -2}, {-4, -2, 1}} and ...
0
votes
1answer
38 views

Generating columns in table and header for exported data file automatically

I have a code that goes like this: ...
4
votes
0answers
60 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 ...
3
votes
1answer
51 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 ...
1
vote
1answer
153 views

How to form subgraphs from a connected graph

I have a connected graph with 72 nodes and its binary adjacency matrix. I need to find all possible connected subgraphs with exactly 6 nodes, i.e., I need to find all connected subgraphs and each ...
0
votes
3answers
59 views

Roots of an algebraic expresion [duplicate]

If in WolframAlpha I put (-8)^(2/3) then it outputs the main root and 3 roots solution too (to the end in a polar graphic). How can I get the 3 root solution of <...
4
votes
1answer
167 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?...
4
votes
2answers
93 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 ...
3
votes
1answer
67 views

Machine Epsilon is not equal to $MachineEpsilon

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

How do I emulate Excel's Series AutoFill function?

I have a series of data that I would like to extrapolate out another 20 times. The data in question is: ...
-1
votes
1answer
99 views

Could this Be a Bug in V.11.1.1.0 [duplicate]

Here is an elementary third root calculation of -8 (or any negative real number) with and without parentheses, but Mathematica seems to be given different answers! ...
4
votes
3answers
120 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} } ...
1
vote
0answers
35 views

Buggy IntervalUnion with Quantities?

IntervalUnion can give wrong output when used with Quantity: ...
2
votes
1answer
117 views

Two-slot pure function [closed]

I come across this problem in many different forms when doing arithmetic in MMA and have until now just suffered along doing it the long way – having given up trying to figure it out myself – but now ...
1
vote
3answers
75 views

select, group and manipulate elements in list based on date ranges

Question from a beginner. I have data containing dates and values of the format: ...
0
votes
1answer
210 views

How to multiply a vector by a scalar?

I'm plotting a simple 2D graph derived from 4 3D vectors: ...
4
votes
2answers
293 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 \;, $$ ...
9
votes
2answers
854 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. ...
0
votes
1answer
106 views

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

Occasionally I encounter messages like Power::indet: Indeterminate expression (0. + 0. I)^0 encountered. (or just 0^0). I believe I can safely declare these to be 1 for all of my purposes. Is ...
3
votes
1answer
173 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 ...
10
votes
1answer
140 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 ...
1
vote
1answer
111 views

What is the best practice way to handle arithmetic exception in Mathematica

What is/are common way/s to handle what would be ArithmeticExceptions in Java in Mathematica/ Wolfram Language? The ugly code is the If...Continues in the innermost For Loop. How should I address this ...
0
votes
1answer
206 views

Division by an interval

I have a function: f[x_] := 1792 - 256 x - 2240 x^2 + 320 x^3 + 448 x^4 - 64 x^5 - 6 x^6 + 6 x^7 interval: ...
4
votes
2answers
307 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 ...
8
votes
1answer
182 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 ...
8
votes
4answers
634 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, ...
3
votes
0answers
100 views

How can one best implement the multiplication of octonions using the Quaternions package?

I excerpt from p. 4 of the recent paper of P. J. Forrester (https://arxiv.org/pdf/1610.08081.pdf): "Let $p_1$ and $p_2$ be quaternions. The octonion algebra consists of elements of the form $p_1+p_2 ...
8
votes
3answers
592 views

How to recover Pauli matrices properties in Mathematica?

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\...
3
votes
2answers
170 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 ...
-4
votes
1answer
253 views

Arithmetic Progression [closed]

How can I resolve these issues? I'm from Brazil and I don't have many things related to the subject here ** In an arithmetic progression of 6 Terms, the reason is 5. The product of the 1° with the ...
18
votes
6answers
2k 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. ...
15
votes
1answer
266 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  (...
0
votes
0answers
29 views

Roots in Mathematica [duplicate]

Example: x = (-8)^(1/3) Return: 2 (-1)^(1/3) How simplifying? I need an answer as x = -2 Thanks!
1
vote
1answer
192 views

Simplify the huge determinant product

I try to get the following determinant product result, ...
4
votes
0answers
108 views

Simple arithmetic with Irrationals fails [closed]

While solving a simple puzzle that asked for a few calculations in plane geometry, I ended up with this expression: $-\frac{55}{2}+\frac{\sqrt{27233}}{2}+\frac{1}{2}(55-\sqrt{27233})$ Or, in ...
2
votes
1answer
214 views

How to find the local minimum points in the multi-dimensional numerical data?

I am trying to get some local minima of an n-dimensional function (which only has numerical form). For two-dimensional function data, we can find the local minimum points from the contour plot easily. ...
1
vote
2answers
245 views

intermediate steps of a Mathematica operation

How to make a multiplication or division, the intermediate steps. The numbers can be rational - decimals? it seems the OP merely wants Mathematica to show him how to multiply and divide the way ...
7
votes
2answers
1k 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...
1
vote
1answer
153 views

Sum of Integers with a Pure Function

How would I find the sum of an argument, with the constraint that they are all integers (so if the argument contains a non-integer value, the function will not evaluate). I came up with these two: ...
0
votes
1answer
133 views

Pure Function that adds all arguments

the question asks to create a pure function that adds any number of arguments. Is the following acceptable? sum := Plus[##] & It does work, but can it be considered a pure function? I felt like ...
0
votes
1answer
94 views

Does Mathematica always return a rational number in its simplified form? [closed]

If I enter: 1/RandomInteger[10^200]+1/RandomInteger[10^200] I get (instantly) an exact fraction. Is this fraction in simplified (reduced) form? In other words is ...
4
votes
2answers
2k 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....
1
vote
1answer
110 views

Why I'm getting 9999s after decimal and how do I fix it? [duplicate]

Check the screen shot. Why I'm getting 999s? It is suppose to be 127,977.52 Thanks in advance, Quick solution: AccountingForm[58156.48 + 69821.04, 16] And thanks to Yves Klett
15
votes
8answers
711 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 ...
0
votes
1answer
62 views

A problem with getting a coefficient

I try Coefficient[E^(I a (t - b)), E^(I a t)] and expect the output E^(-I a b) but in fact I get ...
2
votes
1answer
324 views

A question about expanding complex functions of real arguments

I have the following problem. There is such an expression as: P[x_,y_] := z[y] E^(I beta x) + Conjugate[z[y] E^(I beta x)]; The variables ...
0
votes
1answer
79 views

Unexpected behavior of subtraction with approximate numbers [duplicate]

I'm using the Table command to generate a list of values: FullForm /@ Table[10. - x, {x, 2.7, 2.8, .1}] and I get the ...
2
votes
2answers
2k views

Doing arithmetic with binary numbers

How do I execute binary operations in Mathematica? I want to to multiply say 1010101011 (binary) to 1111101110 (binary) and getting the result 10100111101111111010? Then I want to add the result to ...
4
votes
2answers
1k 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 ...
109
votes
1answer
2k 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 ...