# Tag Info

9

One of the pitfalls new users face, especially if they have analysis (calculus) of only real functions of real variables, is that Mathematica assumes by default that variables are complex and functions are the complex functions. Power functions in particular can seem strange; even those who know it is complex sometimes forget. The cube root is a simple ...

9

There is another option, using the relatively new tensor capabilities of Mathematica. This is pretty much copied from another answer by jose, but I don't need any assumptions here: TensorExpand[KroneckerProduct[X, X] + KroneckerProduct[-X, X]] (* ==> 0 *) TensorExpand[KroneckerProduct[2 X, 3 Y]] (* ==> 6 KroneckerProduct[X, Y] *) There is a ...

8

I think you've found a bug in pattern matcher. This problem can be reduced to matching sequence of length one with named BlankSequence patterns in Orderless functions, it stopped working in v10.1. In previous versions your replacement rule works (as noted by belisarius). Minimal example of this behavior is: ClearAll[f, a] SetAttributes[f, {Orderless}] ...

7

One thing is to make sure you have all the assumptions stated properly. For instance, the first two cases can be handled by passing all the assumptions to FullSimplify FullSimplify[Power[p^(n m) q, 1/n], Assumptions -> {q > 0, p > 0, n ∈ Integers, m ∈ Integers}] p^m q^(1/n) and FullSimplify[(p^n q)/(p^m r), Assumptions -> {q > 0, p ...

6

The documentation of Assumptions says: "The assumptions can be equations, inequalities, or domain specifications, or lists or logical combinations of these." I read this as implying ForAll is not included. An approach that seems to work is the following: f[x_] > f[y_] ^:= Piecewise[{{True, x > y}}, False] f[3] > f[4] (* False *) f[4] > f[3] ...

6

Update In the interest of simplifying the code somewhat, I've modified one of the replacements. For instance, we can do expr2 = Thread[expr1, Plus] /. Plus -> Times or epxr2 = expr1 /. expT[Plus[a__]] :> Times @@ expT /@ a rather than expr2 = expr1 //. {expT[a_ + b_] :> expT[a] expT[b]} So: f[expr_] := Thread[expr /. Power[E, a_] :> ...

6

I'm not sure how well this works for more complicated expressions, but my idea is as follows: Using the option ComplexityFunction. If the domain of an intermediate expression is larger than the original expression, assign a very large penalty. Add this to Mathematica's default complexity function (Simplify`SimplifyCount). (* define domain for readability ...

5

In the first case PowerExpand comes to the rescue: PowerExpand@Power[p^(n m) q, 1/n] (* Out: p^m q^(1/n) *) Note however that "the transformations made by PowerExpand are correct in general only if $c$ is an integer or $a$ and $b$ are positive real numbers". Generally speaking, your assumptions can be listed in Reduce, Simplify, or FullSimplify using ...

4

I can't help you with functions beyond Reduce, Simplify, ... but I can offer you a tip to help with reducing errors from manual translation. In order to validate that your manual transformation is correct, one can subtract the original expression from the manual transformation and then use Simplify on that expression. Sometimes it will return zero using ...

4

You can also use the TransformationFunctions if you don't want f evaluating outside of FullSimplify. expr = f[4] > f[3]; mysimp[e_] := e /. {(Greater | GreaterEqual)[f[b_], f[a_]] /; b > a -> True, (Less | LessEqual)[f[b_], f[a_]] /; b < a -> True}; FullSimplify[expr, TransformationFunctions -> {mysimp, Automatic}] ...

4

This symmetrizes an arbitrary expression by adding it to itself with the variable names interchanged. As a result, any term in the original expression has a symmetry-related counterpart, making the expression manifestly symmetric in the only sense that can be reasonably applied to an arbitrary expression. It's a special case of my answer to What is the ...

3

It works if you exclude the singular point: Assuming[2 Pi > θ > 0, FullSimplify[1/Sqrt[1 + Abs[Cot[θ/2]]^2]]] (* Sin[θ/2] *)

3

i = 4; R2 = 0.001 // Rationalize; RL = 100000; RS = 100000000; R1 = 0.04834 // Rationalize; C1 = 8.48 // Rationalize; C2 = 3.44 // Rationalize; s = DSolve[{V1[t] == RS/(RS + R1)*V2[t] + RS*R1*i/(RS + R1), V2'[t] == 1/C1*(i R2 RL RS - (R2 RL + R1 (R2 + RL) + (R2 + RL) RS) V2[t] + RL (R1 + RS) V3[t])/(R2 RL (R1 + RS)), V3'[t] == ...

3

This expression, designated exp for convenience, can be simplified substantially as follows. num = Map[FullSimplify[#] &, Numerator[exp]]; Map[FullSimplify[#, θ[_] ∈ Reals && ϕ[_] ∈ Reals] &, Denominator[exp] /. Abs[z_]^2 :> FullSimplify[Abs[z]^2, θ[_] ∈ Reals && ϕ[_] ∈ Reals]; /. Abs[z_]^2 :> z^2] den = ...

3

I don't know what's so unacceptable about LaguerreL that anything would be acceptable in its place, but from functions.wolfram.com, we have the following transformation: simp = HoldPattern[LaguerreL[n_, λ_, z_]] :> (Gamma[λ + n + 1] HypergeometricPFQRegularized[{-n}, {λ + 1}, z])/ Gamma[n + 1]; We can apply it to the solution Assuming[U > 0 ...

3

How about: av = Array[Subscript[a, ##] &, {2}]; bv = Array[Subscript[b, ##] &, {2}]; KroneckerProduct[av, bv] + KroneckerProduct[-av, bv] {{0, 0}, {0, 0}}

2

To fix this problem on Mma 10.1 on OS X 10.10.4 I took off one of the blanks on term, i.e. ReplaceAll[a.b.c.d + a.ss.e.g.r + Transpose[a.b.c.d], {Plus[front___, term__, middle___, Transpose[term__], end___] :> Plus[front, middle, end, 2*term]}] a.b.c.d + a.ss.e.g.r + Transpose[a.b.c.d] ReplaceAll[a.b.c.d + a.ss.e.g.r + Transpose[a.b.c.d], ...

2

To address your practical examples: For the first question, you can just simplify in an additional step: Simplify[ Sqrt[Sin[x]^6 ((a^2 + r[]^2)^2 - a^2 (q^2 + a^2 - 2 m r[] + r[]^2) Sin[x]^2)^2]/((a^2 + a^2 Cos[2 x] + 2 r[]^2)^2 (-a^2 q^2 + a^4 + 2 m a^2 r[] + 3 a^2 r[]^2 + 2 r[]^4 + a^2 Cos[2 x] (q^2 + a^2 - 2 m r[] + ...

2

f[a_, b_] := a (a + b) + a b + b^2 Simplify@(f[a, b] + f[b, a])/2 or for polynomials: SymmetricReduction[a (a + b) + a b + b^2, {a, b}][[1]] $(a + b)^2$ The first approach works for functions such as: f[a_, b_] := Cos[a] + Sin[a + b] Simplify@(f[a, b] + f[b, a])/2 $1/2 (Cos[a] + Cos[b] + 2 Sin[a + b])$

2

Try this: (Normalize /@ evecs // Transpose // Assuming[0 < \[Theta] < Pi, FullSimplify[TrigToExp@#]] &) /. {(1 + Abs[Cot[\[Theta]/2]]^2)^(-1/2) -> Abs[Sin[\[Theta]/2]]} (* {{-I Cos[\[Theta]/2], I Sin[\[Theta]/2]}, {Sin[\[Theta]/2], Cos[\[Theta]/2]}} *) Edit: if theta<0, (Normalize /@ evecs // Transpose // ...

1

Try this: rule = Subscript[k, x] -> I*κ Then any expression you may treat as follows: expression/.rule. For example: expression = Subscript[k, x]^2 + Subscript[k, x] expression /. rule returns: (* Subscript[k, x] + \!$$\*SubsuperscriptBox[\(k$$, $$x$$, $$2$$]\) *) (* I κ - κ^2 *) Have fun!

Only top voted, non community-wiki answers of a minimum length are eligible