simplifying expressions – Strange behavior of `Apart`

Here is a sad comedy based on some Apart behavior. Is there any way to do Apart do the expected step?

Consider a very simple expression, such as

expression = (a - b + c - d)/(a - b);

If we were to consider how to take this expression Apart to simplify it, I would say that the simplest step I can think of is to write

1+ (c – d) / (a ​​- b)

canceling the obvious a-b combination in numerator and denominator.

Now, let's see if Mathematica 11.3 in Windows 10 would produce the same result.


enter the description of the image here


field theory: how to combine symmetric tensile expressions into a single expression in xAct

Let's say I have the following expression in xAct
enter the description of the image here

where covariant derivatives are commutative, $ epsilon $ Y $ h $ they are symmetric tensioners

As we can see, this expression is equivalent to

enter the description of the image here

If we simulate it with respect to the indices $ i, j, k, l $

Is there any way to express the first expression as the second with some kind of SymmetryGroup?

simplifying expressions – Assumptions with conditions

How do you specify the assumption that a function is real for real arguments?


Simplify[Re[I f[x]],Assumptions->f[x_]∈ Reals]
Out[1]= 0


Simplify[Re[I f[x]],Assumptions->x∈ Reals&&f[x_/;x∈ Reals]∈ Reals]
Out[2]= -Im[f[x]]

How do I get zero in the second case?

Can two type expressions in different types have a subtype relationship and an equivalence relationship?

In limited quantification of higher order ($ F ^ ω _ {:), introduced in Ch31 in Types and programming languages by Pierce, its subtype and equivalence rules are:

enter the description of the image here

  1. Is there a subtyping relationship between two type expressions of the same type? Can two type expressions of different types have a subtype relationship?

  2. In the rule (S-TRANS), why is it Γ |- U :: K necessary?

  3. In the rule (S-EQ), why are they Γ |- S :: K Y Γ |- T :: K necessary? Are not involved by S ≡ T?

  4. Is there an equivalence relationship only between two type expressions of the same type? Can two types in different type expressions have the equivalence relation?

Thank you.

layout: large dynamic expressions and receptive UI

I have a ListLinePlot with 40,000 points. When displayed on the screen, the input fields do not respond (the text appears slowly long after the user finishes typing). The code looks like this:

DynamicModule({plot, var},
    Dynamic(Refresh(plot, None))
Initialization :> (plot = makePlot())

makePlot() := ListLinePlot({#, Sin(#) + RandomReal(0.1)} & /@ 
    Subdivide(0, 10, 40000), ImageSize -> 500)

So even when I use Refresh(plot, None) still causes the InputField suffer. I prefer to use TrackedSymbols :> {plot} so you can update when you need it.

I've worked around this by resampling the plot and showing fewer points. Also, rasterizing the plot works, but that's not really what I want to do. Is there a good way to control the Notebook interface so that the graphic shown does not affect other elements around it?

Mathematica does not simplify rational powers in complex expressions

I have the following expressions and I would like to obtain a final result only in the real domain.

Refine(Sqrt(-1) / Sqrt(a^3), Assumptions -> a<0)

Refine(Sqrt(-1) / a^(3/2), Assumptions -> a<0)

The first expression is simplified to

1 / (-a)^(3/2)

while the second one remains as

i / a ^ (3/2)

How can I force the first simplification?

Simplifying expressions: how to eliminate Riemann tensor derivatives using the Biancci identity?

For the third-order Lovelock severity, after varying the Lagrangian metric versus the metric, I found some derivatives of the Riemann tensor that should not appear. How can I remove them? Maybe using the identity of Baiancci.

DefManifold(M, 8, {(Alpha), (Beta), (Sigma), (Delta), (Iota), 
(Mu), (Omicron), (FinalSigma), (Tau), (Upsilon), (Chi), 
(Omega), (Nu), (Rho), (Gamma)})
DefMetric(-1, (ScriptG)(-(Alpha), -(Beta)), CD, 
 SymbolOfCovD -> {";", "(Del)"})
(Chi)4 = -EulerDensity(CD, 4) // NoScalar

(Chi)6 = -EulerDensity(CD, 6) // NoScalar
(ScriptCapitalL) = -21/l^2 + 3 (RicciScalarCD()) + 3 l^2/20 (Chi)4 +
   l^4/120 (Chi)6
em1 = VarL((ScriptG)((Alpha), (Beta)), 
       CD)((ScriptCapitalL) // ToRiemann // NoScalar) // 
     ContractCurvature // FullSimplification() // CollectTensors // 

java – Mathematical expressions like a tree of atoms (variables, constants and functions)

There are many types of mathematical expressions that involve variables, constants and functions. For example, Boolean expressions consist of variables, TRUE and FALSE constants, and functions AND, OR, NOT, IMPLY, etc. Expressions for other areas of mathematics (for example, calculus) may have other constants (PI, EULER, etc.) and other functions (MORE, TIMES, SIN, COS, etc.). Let's call the atom a constant, a function or a variable. I want to define, for a given context (sets of constants and functions), a class of expressions in this context. I want this expression to be implemented as a tree of atoms in the given context.

I have created a TreeExpr class to implement that tree. TreeExpr is a class of trees with nodes of type T.

TreeExpr public abstract class {

private Node root;

public TreeExpr(T RootData) {
    root = new Node(); = RootData;
    root.children = new ArrayList>();

public static class Node {
    private T data;
    private No parent;
    private List> children;


Now, I'm stuck on how to define a class of atoms for a given context. I am thinking of something like creating a class atom for a generic context so that each particular context has information about what are the possible atoms in that context. But I am a rookie in Java, so I need help.

simplifying expressions – How can I change? Simplify

For example in OP FullSimplify gives the desired result:

FullSimplify ((5 + 3 x)/(2 + 3 x))

1 + 3 / (2 + 3 x)

To take a different example for which none Simplify neither FullSimplify Perform the desired simplification without additional work:

expr = (5 + 2 x)/(2 + 3 x);

Simplify  @ expr

(5 + 2 x) / (2 + 3 x)

FullSimplify @ expr

(5 + 2 x) / (2 + 3 x)

"to minimize the number of occurrences of the variables" you can use a custom ComplexityFunction which penalizes multiple occurrences of symbols. For example,

cF = Simplify`SimplifyCount(#) + 100 Count(#, _Symbol, All) &;

Using it with FullSimplify

FullSimplify(expr, ComplexityFunction -> cF)

2/3 + 11 / (6 + 9 x)

With Simplify We need to do more:

Simplify(expr, ComplexityFunction -> cF)

(5 + 2 x) / (2 + 3 x)

Adding Apart to the Automatic TransformationFunctions use for Simplify gives the desired result:

Simplify(expr, ComplexityFunction -> cF, TransformationFunctions -> {Automatic, Apart})

2/3 + 11 / (6 + 9 x)

Custom notation: InterpretationBox problem with symbolic expressions

Related to this question,

Because this InterpretationBox build work when x, y Are they numbers but not indefinite symbols or more complex expressions?

foo /: MakeBoxes(c : foo(x_, y_), form : (StandardForm | TraditionalForm)) := With({boxes = SubscriptBox(x, y)}, InterpretationBox(boxes, c))



Subscript (2, 3)

Plug x inserted $CellContext:

foo(2, x)

Subscript(2, $CellContext`x)

or fails with List:

foo({1, 2}, 3)

An unknown box name (List) was sent as BoxForm for the expression.
Verify the formatting rules for the expression.