Questions tagged [expression-manipulation]

How to manipulate expressions structurally, not necessarily complying with the rules of algebra.

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

How to do an arbitrary expression growth in Mathematica?

I want to write a function that can be used to grow an expression from a seed or another existing expression based on part specification. ...
6
votes
3answers
132 views

Split expression into list of terms

I'm looking for a nice way to split an expression into a list of the terms (i.e. the addends). The desired behavior in: ...
0
votes
0answers
18 views

Comparing fractions by using partial fractions or a specific factorisation?

Trying to reproduce the results of a paper I had to solve a difficult integral. I obtain: \begin{equation} A=-N\left ( \epsilon r+\log(1+r) +\frac{rx^2(1-r\tau + \tau r^2 (\tau +1))}{1+r}+\frac{ry^2(-...
1
vote
0answers
36 views

Canceling factors from numerator and denominator with complex number

I have the following expression: $\text{expr} = i \frac{\sqrt{a-b}}{\sqrt{b-a}}x$. Clearly simplifying expression gives $\text{expr}=x$ by cancelling the numerator and denominator. However, I am not ...
4
votes
0answers
29 views

Any differences between Activate[…] vs ReplaceAll[…,Inactive[f_]-f>]?

I can activate an expression with Inactive objects such as expr = Inactive[f][Inactive[f][x], y] + Inactive[f] by applying <...
-2
votes
1answer
52 views

Automatic Sign change [closed]

Can anyone help me to prevent Mathematica from changing variable signs, such as follow, (d - x + Sqrt[(d - x)^2 + y^2 + z^2]) As soon as I press enter it will ...
0
votes
1answer
47 views

Manipulate MeshRegion as normal Mathematica expression

A MeshRegion seems to function quite differently from any other Mathematica expression. One cannot take a Part of it. Nor can I ...
1
vote
1answer
55 views

How can I show that the equation holds?

Suppose we have the following data: $ r=\frac{vk}{h^2}$ $u[i,j]$ is a function of two variables with $i,j$ integers. $\frac{u[i,j+1]-u[i,j]}{k}=v\frac{u[i+1,j]-2u[i,j]+u[i-1,j]}{h^2}$ Then I would ...
6
votes
2answers
81 views

Assert no unevaluated function applications

Background Suppose I have begun a fresh kernel session, and I have defined the following function alone: F[x_, y_] := x + y; One expected use of ...
0
votes
1answer
31 views

Making substitution to an expressions with a list of numerical data [closed]

Suppose I have an expression similar to this: y=23.23*(h[x]^2)*(D[h[x],x])*(D[h[x],{x,3}])/(13.2+Cos[0.245x]) The actual expression is a lot more complicated, but ...
2
votes
3answers
76 views

Select variable and its derivatives

A simple question: I have this equation: ...
4
votes
1answer
56 views

Simplify root inside of root

xxx=(2 Sqrt[1 - 2/(1 + Sqrt[G1])] G1 + 2 Sqrt[((-1 + Sqrt[G1]) G1)/(1 + Sqrt[G1])])/(-1 + 2 G1) I have quite complicated expression. I want to simplify little ...
3
votes
3answers
90 views

isolating a specific variable to one side in an equation

I am trying to do a simple operation of manipulating an equation of multiple variables (say, $x,y,z$), so that I can get one of the these variables on the LHS and everything else on the RHS. It should ...
1
vote
3answers
49 views
16
votes
7answers
1k views

Which operation combines {f,g,h,…} and y[u,v,w,…] to get y[f[u],g[v],h[w],…]?

I have a list of functions myFuncs = {f,g,h} which I'd like to map over an expression expr = y[u,v,w] to obtain ...
13
votes
3answers
270 views

How to make arbitrary transpositions of associations and datasets

Is there a general Transpose for Dataset/Association that will transpose arbitrary levels, ...
4
votes
4answers
91 views

ReplaceList doesn't apply rules down to subparts

Somewhat related to a previous question, I'm experimenting with ReplaceList to get the list of all possible transformations we can obtain by applying a rule to an expression. But I don't manage to ...
1
vote
1answer
60 views

How to test if $ⅈ$ is in an expression?

From this answer https://mathematica.stackexchange.com/a/9773/68791 and according to the documentation: FreeQ[list,form] test whether form occurs nowhere in ...
2
votes
0answers
51 views

General rule to rewrite function and argument into a new symbol

I am trying to convert Mathematica output into equations I can plug into C. I am presently trying to convert expressions of the form Derivative[1,0,0][f][t,x,y] ...
0
votes
1answer
59 views

Collect integer and non-integer powers at the same time

Imagine we have an expression that contains both integer ($y$, $y^3$, $y^8$ etc.) and non-integer powers ($y^{1+\alpha}$, $y^{2\,\alpha}$, $y^{2+3\,\alpha}$) of the variable $y$, where $\alpha\in\...
0
votes
2answers
104 views

Expand in series an equation of two variables

I am sorry if this has been asked, I don't really know how to formulate the search to find it. We have some system of equations (that are equal to zero), for example (not sure how to enter ...
1
vote
0answers
51 views

How can I force the output of a computation to be as compact as possible, yet complete, by using functions?

I am computing some derivatives in Wolfram Mathematica 11.3. The functions that I have to differentiate (with respect to the state variables) are the equations of motion of a rocket in the atmosphere. ...
0
votes
0answers
20 views

Evaluating meta expressions of (partial) derivatives

I have created some meta expressions for many derivative calculations such as ...
0
votes
1answer
63 views

How to make a function linear

I have a linear function, say f, and an expression like f[3x^2 - 8 a y^2 + 4 z b] where I know that ...
0
votes
1answer
42 views

How can I calculate the union of a tagged set? [closed]

I want to calculate: Union[envelope[1], envelope[2], envelope[3], envelope[4], envelope[5], envelope[6], envelope[7], envelope[8], envelope[9], envelope[10]] ...
0
votes
2answers
71 views

Suppress arguments in output for pretty print

I would like to define a rule that suppress any arguments of a function for visibility. I tried: rule = f_[x__] -> f While this works well with individual ...
1
vote
1answer
41 views

Matrix multiplication of function

Suppose I had a 2-by-2 matrix with each entry a function, e.g., {{#1&,#2&},{#1 + #2 &, -#1 + #2 &}} and a vector of functions, e.g.,...
1
vote
1answer
42 views

Gradient of function with arbitrary number of variables

This link answers the question on how to express the derivative of a function with an arbitrary number of variables. However, what if I wanted the gradient? More specifically, if ...
1
vote
1answer
84 views

n derivatives on a function of n variables

I want to derive an expression with respect to each variable of a function $f: \mathbb R^n \rightarrow \mathbb R$. More precisely: $\left(\prod_{i=1}^n\frac{\partial}{\partial_{x_i}}\right) g(f(x_1,...
3
votes
1answer
36 views

Prevent argument substitution in held expression when injecting into unevaluated code

I want to write a custom sow/reap pair to wrap any piece of code in sow[code] and call reap ...
0
votes
1answer
34 views

Expression with Boole

Let us have an expression for example, this: 2 (-1 + p) (3 - 4 p + 2 p^2) Boole[\[FormalX] == 1] - 9 (1 - 2 p + p^2) Boole[\[FormalX] == 2] ... For the whole ...
0
votes
1answer
33 views

Extract variables from sum of unevaluted functions

I have sums of the form sum = a f[1,1,0] + b f[1,2,0] + c f[1,2,1] + ... It is always linear in f[a,b,c]. I would like a ...
3
votes
1answer
53 views

Output of `Subsuperscript` in TeXForm?

TeXForm can be used to convert Mathematica expressions directly to LaTeX. However, this function fails on an expression that has a sub- and a super-script: ...
0
votes
1answer
40 views

How to generate a list (or even a sequence or a string) containing {x[1]==0&&x[2]==0&&…&&x[10]==0?

I need to solve a bunch of systems of n equations in n unknowns where n varies. I can do ...
0
votes
1answer
67 views

Transform rational equations to polynomial equations

I have a list of rational equations and I would like to convert it to a list of polynomial equations. I know that none of the variables and none of the denominators could ever be 0. So far I have ...
11
votes
1answer
163 views

Conflict with hidden names

The following code hangs Mathematica 12.0.0: ...
3
votes
1answer
104 views

Strange behavior of `Apart`

Here is a piece of sad comedy based on some Apart behavior. Is there a way to make Apart do the expected step? Consider a very ...
1
vote
0answers
69 views

Is there a good reason why `Slot[]` is not an atomic expression?

Here's a good reason why I think it should be, Map[ If[AtomQ@#, #->"is an atom", #->"not an atom"]& , {"hello",Range@3, # &} , {-1} ] ...
7
votes
3answers
145 views

How to replace $x$ and $x^2$ with different value?

I have an expression now expr = x + x^2 what I want to do is to replace $x$ with $k\times p$ , and $x^2$ with $[k\times p + k\times(k - 1)\times p^2]$. The ...
2
votes
1answer
41 views

Narrowing the range of an interpolating function while keeping integral the same?

Consider an interpolating function derived from some data, e.g. ...
6
votes
1answer
78 views

Expandable summary view for a large expression

I need a convenient interface to interactively explore very large expressions. I am aware of Short and Shallow, and appreciate ...
0
votes
0answers
20 views

Expressing Numbers with Rational Denominators (Surd Form) [duplicate]

Is there a command which expresses given real numbers in surd form (when possible)? That is, a form where any rooted terms are placed in the numerator, and the denominator is rational. Here are some ...
2
votes
1answer
40 views

Replace sub-expressions matching a pattern unless located under specific heads

Suppose I have some rule, e.g. Re[x_] :> (x + Conjugate[x])/2. I want to apply it to all matching sub-expressions in some expression, excluding any sub-...
2
votes
1answer
40 views

How the terms are arranged in `CoefficientList` command?

I have an expression containing various orders (powers) of F[r]. Using CoefficientList, the output is a blue box which is ...
0
votes
2answers
73 views

Exclude the terms from determinant

i have a long determinant expression such as delta=8+2a+3b+4c+50a^2+2a^3+70b^2+80a*b+20(a^2)b+5(e^x)+a*b(e^x)+....+3e^(-x)+.. I want to exclude the expression ...
0
votes
0answers
35 views

Wrong derivative for a function that I try to define without explicitly giving number of variables

What I actually want is to define functions depending on the number of variables which will be specified during some computation. My (probably wrong) attempt is ...
14
votes
3answers
293 views

Evaluated vs. unevaluated Association

This question might have a remote connection to my older question, it is also about sameness of expressions and subtle differences observable only in certain forms. I encountered this strange ...
3
votes
2answers
118 views

Group symbols by a given partition of the occuring symbols

I have following expression $$-3 b_{\sigma _d}-3 b_{\sigma _v}-b-b_2+2 j-2 j_2-2 j_3+2 j_6+12$$ Mathematica input ...
0
votes
0answers
56 views

How to use replace for only one term in a long expression in Mathematica?

I am doing some Cauchy integration and in some intermediate steps I have something that looks like that: (..many_terms...+I*\epsilon(k1-p1))/k1 where ...
0
votes
0answers
39 views

Why does Refine not use transformation rules for a user-defined function?

I defined a transformation rule for a symbol L that takes a sequence of numbers ...

1 2 3 4 5 12