Results 1 to 3 of 3

Math Help - Mathematica - 2 Questions: Filtering & Headers

  1. #1
    Newbie
    Joined
    Oct 2008
    Posts
    5

    Mathematica - 2 Questions: Filtering & Headers

    Question 1: I am trying to make a list of all ordered pairs (x,y) with x,y<6 and then output only ones with certain attributes, e.g. I would like to output only the (x, y) s.t. x>y or y>3, etc.. Here is what I came up with to list them:

    Code:
    Tuples[Table[x, {x, 6}], 2]
    Now I just need to filter them so that I end up with a nice list of the ones I am wanting. I've scoured the Mathematica help file but I just can't seem to get it to work. I've tried With[] and Cases[] and this is the closest I've gotten:

    Code:
    Cases[Tuples[Table[x, {x, 6}], 2], {x_, y_} -> x > y]
    Also, is there a way to display the pairs with parentheses instead of brackets in the output?

    Question 2: I am trying to change the default mathematica settings for notebooks, particularly some of the printing settings. So far I have made a copy of the default.nb found in 'Mathematica.app/SystemFiles/FrontEnd/StyleSheets' and named the copy MySettings.nb. Then I have changed the settings for this notebook by opening the notebook and selecting 'File>Printing Settings>Headers and Footers...' and unselecting 'Left and Right Pages'. I also select 'No header on first page'. Then I select File>Install... and select Stylesheet and select the file MySettings.nb. After this, I opened the Options Inspector and changed the DefaultStyleDefinitions path under Global Options to be '~/Library/Mathematica/SystemFiles/FrontEnd/StyleSheets/MySettings.nb'.

    This seemed to work for the 'Left and Right Pages' setting, however, every new notebook I make has the 'No header on first page' box unselected.

    My first question about this is whether or not this is the best method in general for changing default settings? It seems pretty cumbersome and I would think there would be an easier way to change the default settings for notebooks and still allow one to revert back to the original settings if you changed something that shouldn't be changed.

    My second question is how do I get the settings to reflect what I am wanting, i.e. how do I get the 'No header on the first page' selection to stick?

    Thanks in advance. Hopefully one day I'll be able to return the favor and be answering questions on this forum instead of asking them all the time
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member
    Joined
    Aug 2008
    Posts
    903
    For the first one, you can convert it to a string then use StringReplace. Of course it's now a string. Maybe that's not what you want:

    Code:
    In[31]:=
    tlist = Tuples[Table[x, {x, 6}], 2]; 
    slist = Select[tlist, #1[[1]] > #1[[2]] & ]; 
    rlist = ToString[slist]; 
    StringReplace[rlist, {"{" -> "(", 
       "}" -> ")"}]
    
    Out[34]=
    "((2, 1), (3, 1), (3, 2), (4, 1), (4, 2), \
    (4, 3), (5, 1), (5, 2), (5, 3), (5, 4), (6, \
    1), (6, 2), (6, 3), (6, 4), (6, 5))"
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Oct 2008
    Posts
    12
    Honestly, I cant help you with your second problem. Settings in Mathematica confuse me to death. I think what you want for the first
    problem is
    Cases[Tuples[Range[6],2],{x_,y_}/;(x>y||y>3)]

    This works by selecting all of the orderd pairs for which x>
    y or y>3. In cases, the -> is for when you want to modify the form of the output. /; puts a restiction on x and y. Also instead of using table, its shorter just to use range.

    The problem of representing the ordered pairs as (a,b) is hard. The best I have done so far is
    $Post=(#/.{a: ({(_Integer|_Rational|_Real|_Complex|_Symbol)..}.. )}MatrixForm/@(List/@{a}))&
    Which converts the output of the formula above to the way it looks in the thumbnail. I cant figure out how to get a comma in between them... That code will affect all matrixes of depth 2. When you are done with it, you should clear $Post:
    $Post=.
    To insure that no unwanted sideeffects are generated. You also could use the code:
    $Post=(#/.{a: ({Repeated[_Integer|_Rational|_Real|_Complex|_Symbol,{2}]}..)}MatrixForm/@(List/@{a}))&
    If you want it to only affect lists of ordered pairs. Ill see if I can find a way to insert commas; If you really need the commas, I suggest you use standard form.
    Attached Thumbnails Attached Thumbnails Mathematica - 2 Questions: Filtering &amp; Headers-output.jpg  
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. particle filtering
    Posted in the Advanced Statistics Forum
    Replies: 0
    Last Post: December 9th 2009, 11:41 PM
  2. mathematica
    Posted in the Math Software Forum
    Replies: 0
    Last Post: October 27th 2009, 02:03 PM
  3. Kalman filtering application
    Posted in the Advanced Applied Math Forum
    Replies: 54
    Last Post: April 7th 2009, 09:08 PM
  4. Filtering the top 5% in real-time
    Posted in the Advanced Math Topics Forum
    Replies: 1
    Last Post: July 9th 2008, 07:42 AM
  5. Natural sound frequency filtering
    Posted in the Advanced Applied Math Forum
    Replies: 1
    Last Post: November 23rd 2007, 12:25 AM

Search Tags


/mathhelpforum @mathhelpforum