Tag Info

Hot answers tagged

7

You mean like this? Times @@ Map[ Beta[First[#] + a, Last[#] + b] &, {{1, 1}, {12, 1}, {7, 9}, {10, 14}}]


7

You can generate the monomials by using CoefficientRules, like this In[55]:= monomialList[poly_, vars_] := Times @@ (vars^#) & /@ CoefficientRules[poly, vars][[All, 1]] monomialList[a x^2 + b x y + c y^2, {x, y}] Out[56]= {x^2, x y, y^2}


7

A pattern matching method: fn[x_, {var__}] := List @@ Pick[x, x, Alternatives[var]^_.] fn[a x^2 + b x y + c y^2, {x, y}] {x^2, x y, y^2} But a better approach I believe is (hopefully now corrected at last): fn2[x_, var_] := Collect[List @@ Expand @ x, var, 1 &] fn2[a x^2 + b x y + c y^2, {x, y}] {x^2, x y, y^2} fn2[x (x^2 + y^2), {x, y}] ...


5

res = Rest@Select[Subsets@pol, PolynomialMod[#, factor] == 0 &] So, out of the 8192 (== 2^13) possible "sub-polys", only these ones are divisible by factor: Grid[Join[{{"pol == Non-factored", "Plus (factor by ...)"}}, {pol - # factor // Expand, #} & /@ (PolynomialQuotient[#, factor, z] & /@ res)], Frame -> All] ...


5

f[a_, b_] := Fold[#1*Beta[#2[[1]] + a, #2[[2]] + b] &, 1, {{1, 1}, {12, 1}, {7, 9}, {10, 14}}] f[a, b] Beta[1 + a, 1 + b] Beta[7 + a, 9 + b] Beta[10 + a, 14 + b] Beta[12 + a, 1 + b]


4

This uses some undocumented functionality: poly = a x^2 + b x y + c y^2; vars = {x, y}; dl = GroebnerBasis`DistributedTermsList[poly, vars]; Inner[Power, vars, #, Times] & /@ dl[[1, All, 1]]


4

There's no single BoundedQ function that I know of, but there are several related functions: FunctionRange tries to compute the range of a function: range = FunctionRange[1/x, x, y] (* y < 0 || y > 0 *) It is clear that this is not bounded, but we can also try to get that result programmatically: BoundedRegionQ@ImplicitRegion[range, y] (* False *) ...


4

It can be done with w.a.b.r + w.c.d.r /. Dot[FRONT_, AA__, BACK_] + Dot[FRONT_, BB__, BACK_] :> Dot[FRONT, Dot[AA] + Dot[BB], BACK] w.(a.b + c.d).r However, I like function argument destructuring, so I would probably write f[Dot[w_, a__, r_] + Dot[w_, b__, r_]] := w.(Dot[a] + Dot[b]).r f[w.a.b.r + w.c.d.r] w.(a.b + c.d).r


4

pol = x^2 y + x^4 z + x^3 y z + x^6 y z^2 + x y^2 z^2 + x^5 y^2 z^2 + x^5 z^3 + x^4 y z^3 + x^3 y^3 z^3 + x^2 y^4 z^3 + x^2 y^2 z^4 + x^4 y^5 z^4 + x^3 y^4 z^5; guess = (x^2 z^3 + y x^3 z^2 + x z); FullSimplify[pol/guess]*Simplify[guess] xz(1 + x^2*yz + xz^2)* (x^2*(x + y) + (x*y)/z + y^2*z + x*y^4*z^2 - (x^2*y*(xy + z))/ ...


4

This is indeed somewhat confusing when you are new to Mathematica. In Mathematica, == stands for mathematical equality. Thus a == 0 does not evaluate to either True or to False until a is replaced by a numerical value. a is considered to be a variable that may or may not be zero. A pattern like x_ /; condition will only match if condition is explicitly ...


4

I'm not thrilled with the question since it provided no example, but there was a serious response and also a request to see an ILP approach. Here is one such. Start by creating an example. SeedRandom[1111]; n = 10; m = 4; intset = RandomInteger[100, n] (* Out[335]= {9, 78, 23, 59, 95, 51, 24, 29, 99, 68} *) Now we set up the ILP. We have our n -1/0/1 ...


4

Solution Suppose the list is list = Range[-3, 3] (* {-3, -2, -1, 0, 1, 2, -3} *) Then, the set of all subsets of, say, size 3 is sets = Subsets[list, {3}]; We define a list of signs that give all possible combinations of plusses and minuses to attach to each subset: signs = Tuples[{-1, 1}, 3] (* {{-1, -1, -1}, {-1, -1, 1}, {-1, 1, -1}, {-1, 1, 1} ...


3

To answer the question as asked, we modify the code as follows: replacementRule = Plus[ Dot[FRONT__, AA__, BACK__] , Dot[FRONT__, BB__, BACK__] ] :> Dot[FRONT, Plus[Dot[AA], Dot[BB]], BACK]}] w.a.b.r + w.c.d.r /. replacementRule First, we have changed -> (Rule) to :> (RuleDelayed) so that when the expression is re-written, it will write it ...


3

I think this is easier to do by working with strings. First write a function that will expand strings of the form "Power(x,k)" where k is an integer in "xx...x" with k - 1 ""s. f[x_, k_] := Module[{i = Abs[ToExpression[k]] - 1}, Nest[StringJoin[#, "*" <> x] &, x, i]] A couple of tests for f. f["s", 2] "s*s" f["ab", "-3"] ...


3

Accepting that in Mathematica -c/y is automatically converted to -1*c*y^-1 and permitting the result shown in Andy's answer I believe we can use a simpler approach, at least for the kind of expression given in example. Define rules that determine how a Times or Power expression should be counted, then use Cases to find all instances in you expression and ...


2

More ideas for you: in = {{1, 1}, {12, 1}, {7, 9}, {10, 14}}; Times @@ Inner[Plus, in, {a, b}, Beta] Times @@ (Beta[# + a, #2 + b] & @@@ in) Times @@ MapThread[Beta, in\[Transpose] + {a, b}]


2

Or this d = {{1, 1}, {12, 1}, {7, 9}, {10, 14}}; Times@@Beta @@@ (# + {a, b} & /@ d) Beta[1 + a, 1 + b] Beta[7 + a, 9 + b] Beta[10 + a, 14 + b] Beta[ 12 + a, 1 + b] Or if you want a,b,d and Beta all to be parameters to a function f: f[a_, b_, fn_, d_] := Times@@fn @@@ (# + {a, b} & /@ d) f[h, i, Beta, {{1, 7}, {2, 8}, {4, 5}}] ...


1

This doesn't give the result you are looking for exactly because it uses the full form of the expression you give it. SetAttributes[countTimes, HoldAll]; countTimes[expr_] := Block[{Times, Power, power, times}, power[a_, b_ /; b > 0] := Nest[times[a, #] &, a, b - 1]; power[a_, b_ /; b < 0] := 1/power[a, -b]; power[a_, 0] := 1; times[a___, ...


1

I believe you want this: Module[{count}, count[__] = 0; # -> #2 <> ToString[++count[##]] & @@@ rules ] {"A2" -> "BO1", "A2" -> "BO2", "A2" -> "BO3", "A2" -> "BO4", "A2" -> "BO5", "A2" -> "BO6", "A2" -> "BO7", "A2" -> "BO8", "A2" -> "BO9", "A2" -> "BO10", "A2" -> "BO11", "A2" -> "BO12", "A2" -> ...



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