Linked Questions

9 votes
2 answers
1k views

How to reduce the number of operations needed to evaluate an expression? [duplicate]

For some numerical calculations in C++ I have, for example, this complicated expression to evaluate. Given as Mathematica input, in its original form it is ...
Darko Veberic's user avatar
7 votes
1 answer
728 views

How to decompose a complex expression containing repeated subexpressions? [duplicate]

Suppose I have an expression like ...
Vladimir Reshetnikov's user avatar
9 votes
1 answer
932 views

Extract common subexpressions from expressions [duplicate]

I am trying to evaluate multiple independent expressions with common parts. I would like Mathematica to somehow give me this common parts. It's probably not so clear, so let me give you an example. ...
Romain's user avatar
  • 91
1 vote
0 answers
129 views

FullSimplify, Assumptions: Replacing Complex expressions by Simpler Ones as per Leaf Count [duplicate]

I have been trying to simplify equations using Mathematica of the following basic form: $$\text{FullSimplify}\left[x^2+y^2,\text{Assumptions}\to x^2+y^2==c^2\right]$$ With the output being, $$x^2+y^2$$...
Gattu Mytraya's user avatar
1 vote
0 answers
63 views

A kind of function optimization problem [duplicate]

I have the following problem. Out of a calculation I got the four functions shown at the end of the post. These functions depends on many variables, qk, pk etc (all of them are actually scalar ...
Daniele Binosi's user avatar
0 votes
0 answers
37 views

Find repeated groups in a long algebraic expression [duplicate]

I have an algebraic output (a solution to a de) similar to, but far longer than: {y->(x+3)^2/sin(7*(x+3))+(x+3)^3/7} I'd like to get Mathematica to notice that the group x+3 appears repeatedly, ...
Eric's user avatar
  • 53
60 votes
4 answers
11k views

Can I simplify an expression into form which uses my own definitions?

This seems like a simple thing to do, but I couldn't find anything relevant from Mathematica documentation. So suppose I have an expression: a*b/(a + a*Cos[a/b]) ...
Echows's user avatar
  • 981
0 votes
3 answers
3k views

Problem with Compile Function

I am attempting to Compile this function which is used to calculate a elastic collision in two dimensions. The two first coordinates of each list are the position ...
Luis Valero's user avatar
5 votes
3 answers
509 views

How can I obtain this simplification of an expression?

I saw this question at the Maple forum. The input is ...
Nasser's user avatar
  • 150k
5 votes
3 answers
392 views

How to compile a diagonal array efficiently?

For example, if we use some functions defined prior to Compile, we usually have the main evaluators in the compiled codes, pointing to the definition of the ...
xslittlegrass's user avatar
2 votes
2 answers
917 views

Pulling out common terms when simplifying complicated equations

I have a complicated expression where common terms are apparent but Simplify[] and FullSimplify[] don't appear able, even with plenty of assumptions added, to reduce down to a simpler form with common ...
Michael Hopkins's user avatar
0 votes
2 answers
310 views

Can I tell Simplify to prefer nested polynomials?

I need to export expressions for numerical evaluations in a C codebase. Simplify often does a good job for this, and polynomial factorisation goes a long way. However, occasionally I would come ...
Saran Tunyasuvunakool's user avatar
2 votes
0 answers
386 views

Best approach for 'manual' common subexpression elimination

I have working code, but am looking for ways to make it more elegant. I have a fairly large expression with plenty of repetition and structure. A shortened toy example is ...
Åsmund Hj's user avatar
3 votes
0 answers
199 views

Computations with OptimizedExpressions without completely expanding them

I have to manipulate huge expressions that are rational functions of many (∼30) variables with integer coefficients. Storing them just as a ratio of two polynomials would be impractical. But they can ...
Vladimir Reshetnikov's user avatar