Tag Info

0

Simplify[ConditionalExpression[-Sqrt[1 - x - x^2], 1/2 (-1 - Sqrt[5]) < x < 1/2 (-1 + Sqrt[5])], 1/2 (-1 - Sqrt[5]) < x < 1/2 (-1 + Sqrt[5])] (* -Sqrt[1 - x - x^2] *)

0

(This is basically an comment to the answer from David Carraher but I am not allowed to comment on this one.) The complexity function $$t[x_, oper_: Times] := Tr @ ((Length[#] - 1) & /@ (Extract[x, {Sequence @@ Drop[#, -1]}] & /@ Position[x, oper]))$$ has one minor problem: If the first element is a "times" operator, it ...

7

You can use Normal, ConditionalExpression is not explicitly mentioned there but documentation says it deals with special forms. p1 = y /. {First[Solve[x^2 + y^2 + x == 1, y, Reals]]} // First ConditionalExpression[-Sqrt[1 - x - x^2], 1/2 (-1 - Sqrt[5]) < x < 1/2 (-1 + Sqrt[5])] Normal @ p1 -Sqrt[1 - x - x^2]

6

You can forcely specify the condition to be True: Solve[x^2 + y^2 + x == 1, y, Reals] /. ConditionalExpression[e_, _] :> ConditionalExpression[e, True] {{y -> -Sqrt[1 - x - x^2]}, {y -> Sqrt[1 - x - x^2]}} But you should always keep it in mind that this is not an identical transformation.

0

Try this and let me know if there are cases it misses: exprs = {f[_], f, _, Blank, f[0], f[_], g[f[0]]}; taken = {}; Do[ If[! MemberQ[taken, Verbatim[i]], Print[i]]; taken = Union[{Head[i]}, Level[i, {0, Infinity}], taken]; , {i, exprs}] (* Out: f[_] f[0] g[f[0]] *)

4

Maybe TimeConstraint is helpful: y = Gamma[1 - x] Gamma[x] Sin[Pi x] + Gamma[x] Gamma[1 - x] Sin[Pi (1 - x)]; FullSimplify[y, TimeConstraint -> 0.000001] FullSimplify[y, TimeConstraint -> 0.0001] FullSimplify[y, TimeConstraint -> 0.01] Gamma[1 - x] Gamma[x] Sin[π (1 - x)] + Gamma[1 - x] Gamma[x] Sin[π x] 2 Gamma[1 - x] Gamma[x] Sin[π x] 2 π

4

The only method I can think of that will use the built-in simplification routines is to snoop on transformations using either TransformationFunctions or ComplexityFunction. Unfortunately neither of these will be restricted to the entire expression therefore what is produced may not be usable. Nevertheless as an example: FullSimplify[Gamma[1 - x] Gamma[x] ...

1

Make each result the argument of a pure function; e.g., (Sow[#]; Print[#])&[whatever], with all the functions inside a Reap. That also lets you format the printed output in a way that might be easier for a person to read but more awkward to read back into Mma.

17

The following seems to work, however I think it's not general enough: At a clean nb, enter: For[i = 0, i < 4, i++, Print[{i, {33, i}}]] For[i = 0, i < 4, i++, Print[Graphics[Circle[], ImageSize -> 20]]] And then retrieve the Print[ ] output as: c = Cases[NotebookRead /@ Cells[GeneratedCell -> True], Cell[___, "Print", ___]]; ToExpression ...

2

How about Block[{Print = Sow}, Do[Print[i], {i, 1, 1000}] // Reap ]

2

How about this? admissibleEqPat = eq_Equal /; DeleteDuplicates[ Context /@ DeleteCases[ Cases[eq, _Symbol, Infinity, Heads -> True], x]] === {"System`"}; MatchQ[x^2 + 3 x == 4 x^2/(x + 2), admissibleEqPat] (* True *) MatchQ[Sin[x] == 0, admissibleEqPat] (* True *) MatchQ[Sin[a x] == 0, admissibleEqPat] (* False *) ...

0

I suspect this happens because the expression you are trying to simplify contains machine precision floating point numbers (though without seeing your expression this remains only supposition). Would it be possible to re-express it so that it contains only exact numbers and rationals? That is, replacing quantities like 0.5 with 1/2

3

I usually set up a wrapper function that transforms if input is valid and otherwise acts like Identity: pickyTransform[expr_] := 0 helper[expr_] /; ! AtomQ[expr] && FreeQ[expr, _?NumericQ] := pickyTransform[expr] helper[expr_] := expr FullSimplify[a^3 + x^y, TransformationFunctions -> {helper}] (* a^3 *) This works fine most of the time, but ...

Top 50 recent answers are included