Questions tagged [mathematical-expressions]

In mathematics, an expression is a finite combination of symbols that is well-formed according to rules that depend on the context. Symbols can designate numbers (constants), variables, operations, functions, and other mathematical symbols, as well as punctuation, symbols of grouping, and other syntactic symbols.

Strings of symbols that violate the rules of syntax are not well-formed and are not valid mathematical expressions. For example:

would not be considered a mathematical expression but only a meaningless jumble.

In algebra an expression may be used to designate a value, which might depend on values assigned to variables occurring in the expression; the determination of this value depends on the semantics attached to the symbols of the expression.

These semantic rules may declare that certain expressions do not designate any value; such expressions are said to have an undefined value, but they are well-formed expressions nonetheless.

In general the meaning of expressions is not limited to designating values; for instance, an expression might designate a condition, or an equation that is to be solved, or it can be viewed as an object in its own right that can be manipulated according to certain rules. Certain expressions that designate a value simultaneously express a condition that is assumed to hold, for instance those involving the operator to designate an internal direct sum.

Being an expression is a syntactic concept; although different mathematical fields have different notions of valid expressions, the values associated to variables does not play a role. See formal language for general considerations on how expressions are constructed, and formal semantics for questions concerning attaching meaning (values) to expressions.

231 questions
636
votes
11 answers

How can I add numbers in a Bash script?

I have this Bash script and I had a problem in line 16. How can I take the previous result of line 15 and add it to the variable in line 16? #!/bin/bash num=0 metab=0 for ((i=1; i<=2; i++)); do for j in `ls output-$i-*`; do echo "$j" …
Nick
  • 6,377
  • 3
  • 12
  • 4
50
votes
1 answer

Raise to power in R

This is a beginner's question. What's the difference between ^ and **? For example: 2 ^ 10 [1] 1024 2 ** 10 [1] 1024 Is there a function such as power(x,y)?
Nick
  • 6,673
  • 8
  • 43
  • 90
18
votes
3 answers

Calculating opacity value mathematically

How is opacity calculated mathematically? There is opacity value in Photoshop, CSS etc. Actually this opacity is the transparent behavior of a layer. That we all know. But how is it calculated mathematically? Is there any equation to calculate…
spider
  • 310
  • 1
  • 2
  • 10
17
votes
3 answers

How do you judge the (real world) distance of an object in a picture?

I am building a recognition program in C++ and to make it more robust, I need to be able to find the distance of an object in an image. Say I have an image that was taken 22.3 inches away of an 8.5 x 11 picture. The system correctly identifies…
Tubbs
  • 643
  • 1
  • 6
  • 17
17
votes
3 answers

Python if-statement with variable mathematical operator

I'm trying to insert a variable mathematical operator into a if statement, an example of what I'm trying to achieve in parsing user-supplied mathematical expressions: maths_operator = "==" if "test" maths_operator "test": print "match…
15
votes
3 answers

Avoid Overflow when Calculating π by Evaluating a Series Using 16-bit Arithmetic?

I'm trying to write a program that calculates decimal digits of π to 1000 digits or more. To practice low-level programming for fun, the final program will be written in assembly, on a 8-bit CPU that has no multiplication or division, and only…
11
votes
5 answers

Evaluating mathematical expressions in Python

I want to tokenize a given mathematical expression into a parse tree like this: ((3 + 4 - 1) * 5 + 6 * -7) / 2 '/' / \ + 2 / \ …
vander
  • 113
  • 2
  • 6
10
votes
2 answers

C++ Business rule expression parser/evaluation

I'm looking for suggestions of portable lightweight libraries written in C++, that support mathematical and business rule expression and evaluation. I understand C++ doesn't provide such functionality in the STL. The basic requirement is as…
9
votes
5 answers

Testing equivalence of mathematical expressions in Python

I have got two strings in Python, A m * B s / (A m + C m) and C m * B s / (C m + A m) that are both equivalent functions of the unordered set (A, C) and the unordered set (B). m and s indicate units that can be swapped among the same but not with…
Michael Schubert
  • 2,596
  • 4
  • 24
  • 44
9
votes
1 answer

Do dynlm and dlm have same mathematical expressions?

I am currently using dynamic linear regression (dynlm) for my analysis. However, I do also find another model called dynamic linear model (dlm). I find that dlm has an official mathematical expression by West and Harrison (1989) and everywhere.…
Eric
  • 549
  • 1
  • 7
  • 22
6
votes
2 answers

Regular Expression for Extracting Operands from Mathematical Expression

No question on SO addresses my particular problem. I know very little about regular expression. I am building an expression parser in Java using Regex Class for that purpose. I want to extract Operands, Arguments, Operators, Symbols and Function…
Kamil Mahmood
  • 517
  • 11
  • 19
5
votes
2 answers

Why does Excel translate `=10**-2` to `=0.1`?

Try pasting =10**-2 into a cell in MS Excel. After pressing Enter, it turns it to =0.1. I can't seem to find any documentation for **, but it appears to be a pretty odd exponentiation-like operator that cannot be used in an Excel formula (e.g.,…
Mike T
  • 34,456
  • 15
  • 128
  • 169
5
votes
2 answers

Mathematical expression (string) to number in Java

I'm trying to find something like Java Embedding Plugin (JEP) that can evaluate a mathematical formula (string) and give back the answer. But it should also calculate a variable, for example: (25+36+x)*2 = 25 should give: x = -11 A little like…
Berty
  • 906
  • 1
  • 16
  • 44
5
votes
4 answers

FullSimply Inequalities and then rearranging them in Mathematica 7

I am using Mathematica 7 in the notebook interface and I want to rearrange an inequality so that I get a certain variable on one side. For eg. FullSimplify[x^3+L+r>3x^3+2r] Gives L > r + 2 x^3 However, I want : r < L-2x^3 Is there anyway we can…
skr
  • 393
  • 5
  • 21
5
votes
3 answers

Evaluating a mathematical expression without eval() on Python3

I'm working on a "copy-paste calculator" that detects any mathematical expressions copied to the system clipboard, evaluates them and copies the answer to the clipboard ready to be pasted. However, while the code uses the eval()-function, I'm not…
Diapolo10
  • 194
  • 2
  • 8
1
2 3
15 16