Tag Info

Hot answers tagged

9

The following functions will load the expressions and erroneous cells from a notebook: notebookExpressions[path_, pattern_:_] := Cases[Import[path, "Notebook"] // First , c:Cell[_, "Input"|"Output"|"Print", ___] :> Module[{v = eval[c]}, v /; MatchQ[v, _$Failed | Hold[pattern]]] , Infinity ] eval[cell_] := Quiet @ Check[ ...


6

Will a = -3; Print[Defer[\[FormalA] x + 5 + x^2] /. \[FormalA] -> a] -3 x + 5 + x^2 work for you?


4

You can use the new (in V10) ImplicitRegion function as follows: reg = ImplicitRegion[0 <= x <= 1, {x}]; Then: ArgMax[f1[x], x ∈ reg]


4

What about Print[HoldForm[3 x + 5 + x^2]] ?


3

Please check the result by doing the following eqn = FullSimplify[ 2*a*b*n*c*Q - 3*a*b*n*p*c*Q + a*b*n*p^2*c*Q - 4*a^2*b*n*p*Q^2 - 4*a*b^2*n*p*Q^2 + 6*a^2*b*n*p^2*Q^2 + 6*a*b^2*n*p^2*Q^2 - 2*a^2*b*n*p^3*Q^2 - 2*a*b^2*n*p^3*Q^2 + a^2*b*c*Q^2 + a*b^2*c*Q^2 - 2*a^2*b*p*c*Q^2 - 2*a*b^2*p*c*Q^2 == 0] // TraditionalForm This returns ...


2

Solution If the equations always use this pattern we can simply use pattern matching: findCoefficients[expr_] := PadLeft[Cases[ expr, coeff : Except[F1[_] | F2[_] | F3[_]] :> coeff, {2} ], Length@expr, 1] findCoefficients[expr1] (* Out: {1, 4 I, -2} *) I wonder, though, how you intend to use these coefficients. I'm padding with ones to ...


2

Clear["Global`*"] g[x_] := x^3 f1[x_] := g[x^2] f2[x_] := g[x^3] Definition@f1 f1[x_] := g[x^2] FullDefinition@f1 f1[x_] := g[x^2] g[x_] := x^3 Head@f1 Symbol Information["f*"] a[1] = 1; a[2] = 2; ?a DownValues@a UpValues@a


2

Or like this: List @@ expr1 /. {F1[a_] -> 1, F2[b_] -> 1, F3[c_] -> 1} (* {4 I, -2, 1} *) List @@ expr2 /. {F1[a_] -> 1, F2[b_] -> 1, F3[c_] -> 1} (* {-I, 2, 4, -1} *)


1

What you need is Block instead of Module. It changes the extent to which the variables are localized. func[var_String] := Block[{var1, var2},var1="some words";var2="other words";ToExpression[var]]; func["var1"] (*Out[2]="some words"*)


1

I am not sure if this help or not but if you have coefficient for each term, this cloud help: ((expr /. Plus -> List) /. Times -> List)[[;; , 1]] As mentioned by Pickett, the Times and Plus are Odorless. In this case I would suggest the following: expr1 = HoldForm[ F1[0]*F2[3]*F3[2] + 4 I*F1[1]*F2[2]*F3[1] - 2*F1[0]*F2[-2]*F3[2]]; expr2 = ...



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