Tag Info

New answers tagged

0

Often, it is desirable to apply Simplify or FullSimplify to parts of an expression and then recombine the parts. A particularly effective function for this purpose is Collect. For instance, Collect[expr, a^2 - b^2, Simplify] (* (4 a^2 - 3 b^2)/(a^2 - b^2)^2 - 8/(b^2 - c^2)^2 *) Although there is no need to use FullSimplify in this case, it runs much ...


4

I think the following code will do the trick: Collect[expr, Derivative[_, _][g][_, _]] If you want Mathematica to try to simplify each "coefficient", you can use this version instead: Collect[expr, Derivative[_, _][g][_, _], Simplify] I can't claim full credit for this code — there's an example in the "Scope" section of the documentation for Collect ...


5

Just to summarize my understanding: First of all, the documentation states that Simplify assumes that variables are real when they occur algebraically in inequalities. Clearly, there are no inequalities in the logical expression y == 0 && x^2 == -1, and therefore x and y should be assumed to be general complex numbers. If they were real, then the ...


5

Use ComplexExpand expr1 = E^(-2*t*g)*Sqrt[E^(4*t*(g + 2*I*l))]; expr2 = expr1 // ComplexExpand // FullSimplify[#, {l > 0, g > 0, t > 0}] & Sqrt[E^(8*Ilt)] expr1 == expr2 // FullSimplify[#, {l > 0, g > 0, t > 0}] & True


1

It's a badly written example. What it is trying to show is something like the following behavior, where the local Assumptions option overrides the global $Assumptions. $Assumptions = x == -1; FullSimplify[E^(LogGamma[x] + LogGamma[y])] FullSimplify::infd : "Expression LogGamma[x] + LogGamma[y] simplified to ∞. ∞ FullSimplify[E^(LogGamma[x] + ...


1

The following works on the two "Simple Examples" logSimplify = FullSimplify[#, (# > 0) & /@ Union@Cases[Cases[#, Log[z_] -> z, Infinity], z_Symbol -> z, Infinity]] & logSimplify[x Log[a] + x Log[b]] (* x Log[a b] *) logSimplify[x Log[a/b] + y Log[b/a]] (* (x - y) Log[a/b] *) and also on some variants logSimplify[x Log[a^2/b^3] + y ...


1

Maybe you could extract the arguments of your Logs, then turn them into a list of assumptions to feed to e.g. FullSimplify: arguments = Cases[ {(3 Log[whatever/argument + you have] + 5)/2 + some other crud / and + many Exp[4^more] Log[expressions]}, Log[a_] -> a, Infinity ]; arguments > 0 (* Out: {expressions > 0, ...


0

Will Assumptions work? Log[z^2] // FullSimplify (* Log[z^2] *) Log[z^2] // FullSimplify[#, z > 0] & (* 2 Log[z] *) Edit: Naive implementation of rules. LSimpl[f_] := f //. Log[x_*y_] -> Log[x] + Log[y] //. Log[x_^n_Integer] -> n*Log[x]; LSimpl[x Log[a/b] + y Log[b/a]] (* x (Log[a] - Log[b]) + y (-Log[a] + Log[b]) *)


1

I feel I've worked on a problem like this before. Maybe there is a similar question on the site, but I can't find it. It reminds me a little of Why does Mathematica simplify $x/x\to1$?, in which the symbolic result is generically true. Analysis The method used in the sum is Method -> "IteratedSummation" so we can examine the major steps: Sum[ ...


2

EDIT The CoefficientRules method given below won't work if one wants to collect by patterns like Log[_] or _Log (although it will work if the stuff inside the Log is explicitly given). In this case, my instinct is that Collect is then the way to go, and the method supplied by the OP will work pretty well as it is. CoefficientRules method Variables ...


4

I can see your surprise, but Mathematica seems to be behaving as you would expect according to the documentation. In particular, it may seem careless to you, but it is clearly spelled out in the documentation that any variable involved in an inequality is implicitly considered a real number. As a reference, see: the Assumptions and Domains page of the ...


1

As pointed out in the comments by "Guess who it is" and "BlacKow", the solution is to use the function ComplexExpand[], or to add ComplexExpand under Re[].


6

This function lives in the system as Simplify`SimplifyCount.


3

Based on Vladimirs solution I wanted to post a faster alternative to SimplifyCount which produces the same results as SimplifyCount, but is a factor 3 faster. This can be very significant in case of complicated functions, it is however still significantly slower then Automatic. myNumberComplexity[x_Integer] := If[Positive[x], IntegerLength[x] - 1, ...


1

Ok so I decided to change my initial code with something less hacky. I found the relevant idea on a page. I am not sure I am allowed to post the link here, so I will put the reference in a comment. The first step is now the following function. getCommonSubexpressions[expr_, OptionsPattern[]] := Block[ {vnum, modExpr, subExprs, subExpr, mapping, ...



Top 50 recent answers are included