Tag Info

New answers tagged

0

One way to do this is defining a function as Mconv[expre_] := Substitute[TensorExpand[Substitute[expre,NonCommutativeMultiply -> Dot]], Dot -> NonCommutativeMultiply] Using this: KroneckerProduct[a, b] ** KroneckerProduct[c, d] // Mconv we get: KroneckerProduct[a ** c, b ** d] Though I'm not sure if this is the best way to do this.


2

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] == ...


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[] + ...


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 ...


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 // ...


3

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


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!


0

Some people (see The ubiquitous Kronecker product by Van Loan) have worked on finding two matrices $A, B$ of specified size whose tensor product $A \otimes B$ is closest (in a norm) to a given (larger) matrix $C$. That is, find $A, B$ which minimize $||C-A \otimes B||$. The algorithm is based on the SVD. There is a matlab implementation somewhere. It would ...


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 ...


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], ...


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}] ...


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 ...


0

Thanks to mfvonh for the answer - using ReplaceRepeated (//.) as shown below replaces everything. myexpr //. {(mess)->u,(some other mess)->v} To those in power: I unfortunately cannot accept the answer properly because after setting up the account the question is not listed as mine (and can't leave a comment because low rep = having no rights).


0

Your have to use RuleDelayed (:>) in such a case, so that the evaluation is not done immediately: myexpr = (mess) + (someOtherMess)/((mess)^3 + (someOtherMess)^2)^(1/3) and then: myexpr /. {mess :> x, someOtherMess :> y} Then you get what you want.


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 ...


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}] ...


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] ...


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 = ...


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 ...



Top 50 recent answers are included