New answers tagged

2

This is fairly elegant way for dealing with your example, but I don't see how to generalize it a multi-dimensional Fold, what ever that might be. p1 = a x^5 + (x + 2 y)^3 + x y z + 1; vars = {x, y, z}; cl = CoefficientList[p1, vars]; p2 = Fold[FromDigits[Reverse[#1], #2] &, cl, vars]; p1 - p2 // Expand 0 BTW, I unashamedly stole this from the 2nd ...


5

m3 = m1 /. ({#, #2, #3, _} -> {##} & @@@ Flatten[m2, 1]) { {{1, 2, 2, 3}, {1, 1, -2, 1}, {3, 2, 2, -I}, {1, 2, 0, -I}}, {{3, 4, 4, 0}, {1, 1, 4, 1}, {3, 3, 4, -1}, {1, 1, 2, I}} } So basically we create replacement rules from m2, e.g. from {1,0,2,1} we get {1,0,2,_} -> {1,0,2,1}. Then we replace it in m1, if {a,b,c,_} matches, those 3 ...


3

This is more or less directly cribbed from the help: Manipulate[Graphics[{color, Polygon[CirclePoints[sides]]}], {{sides, 3,"Number of Sides"}, 3, 17, 1}, {color, Green}]


3

I believe this is the natural and idiomatic way to do it: Manipulate[Graphics[{colour, Polygon[CirclePoints[sides]]}], {sides, 3, 17, 1}, {{colour, Orange}, {Green -> "Green", Orange -> "Orange"}} ]


3

TabView is for viewing. You can associate color changes with the second argument of TabView but it will be easier to just use what is designed for that, like SetterBar. Moreover, the less inside Dynamic the better so instead of creating whole Graphics you can just tell the FrontEnd to take care of that colour and Polygon. DynamicModule[{p = 3, colour = ...


4

As Compatibility/tutorial/Utilities/FilterOptions says: The functionality of FilterOptions is provided by the kernel function FilterRules. Although the syntax is not identical. You have to change two things in the code: BeginPackage["RiemannSum`", {"Utilities`FilterOptions`"}] to BeginPackage["RiemannSum`"] And Begin["Private`"] to ...


4

If you want to compare all to all, use Outer. Say, we have a function h with [[Span]]: h = (#1[[1 ;; -2]] == #2[[1 ;; -2]]) & Note, that -2 suits the list of any length longer than 2. Than, with your data structure: Outer[h, m1[[1]], m2[[1]], 1] // MatrixForm We may get positions of True: pos = Position[Outer[h, m1[[1]], m2[[1]], 1], _?TrueQ] (* ...


3

To index into arrays and consider more than a single element, use ;;. Thus you can deal with elements 2 through 7 of an array x with x[[2;;7]] Thus your three && lines can be replaced by If[m1[[1, i]][[1;;3]] == m2[[1, j]][[1;;3]] ... ] Please note that this is all perfectly well documented in the docs for Part.


4

This isn't a complete answer, just something to get you started. I think it would useful to think of a function, say countOpenGates, which would look something like this: countOpenGates[mat : {{(0 | 1) ..} ..}] /; MatrixQ[mat] := Total[Times @@@ mat] If "open" means "all subunits are open", i.e. have value 1, then their product is 1. And if any ...



Top 50 recent answers are included