How to apply same VBA code to multiple files in a folder?

Question: I have an operation that I need to apply on up to 1000 files in a folder.
As output, two files will be created in a separate folder from each file which need to be processed. The code works on a single file, however, the output files come up as empty Excel tables when the code is applied on multiple files.
<code>Sub wB_postup_test_all_files()

    Dim MyFile As String, Str As String, MyDir As String, Wb As Workbook
    Dim Rws As Long, Rng As Range
    Dim Lastrow As Long
    Set Wb = ThisWorkbook

    'change the address to suite

    MyDir = "Some directory here"
    MyFile = Dir(MyDir & "*.xlsx")
    ChDir MyDir
    Application.ScreenUpdating = 0
    Application.DisplayAlerts = 0

    Do While MyFile <> ""
        Workbooks.Open (MyFile)

    'where core operation starts

    Columns(1).EntireColumn.Delete
    Columns(2).EntireColumn.Delete
    Rows(1).Insert

    Range("B1") = "=AVERAGE(B3:B4724)"
    Range("A:A").Copy Range("D:D")
    Range("B:B").Copy Range("E:E")
    Range("D1") = "prumer"
    Range("E2") = Range("B2").Value + "-prum"
    Range("E1") = ""
    Range("E3").Select

        Do Until ActiveCell.Offset(0, -4).Value = ""

        myCell0 = Range("B1").Value
        myCell1 = ActiveCell.Offset(0, -3).Value

            If IsEmpty(ActiveCell.Value) = True Then
            ActiveCell.Value = "nic"
            ActiveCell.Offset(1, 0).Select
            Else
            ActiveCell.Value = myCell1 - myCell0
            ActiveCell.Offset(1, 0).Select
            End If

        Loop

    Range("D:D").Copy Range("G:G")
    Range("E:E").Copy
    Range("H:H").PasteSpecial Paste:=xlPasteValues
    Range("H2").Select

        Do Until ActiveCell.Offset(1, -1).Value = ""

            If ActiveCell.Value = "nic" Then
            ActiveCell.Clear
            Else
            ActiveCell.Offset(1, 0).Select
            End If

        Loop

    ActiveCell.Clear

    'plotting the scatter graph

    Range("G3").Select
    Selection.End(xlDown).Select
    Range(Selection, Selection.End(xlUp)).Select
    Range("G3:H4724").Select
    Range("G4724").Activate
    ActiveSheet.Shapes.AddChart2(240, xlXYScatterLinesNoMarkers).Select
    ActiveChart.SetSourceData Source:=Range("G3:H4724")
    Application.CutCopyMode = False
    Application.CutCopyMode = False
    ActiveChart.FullSeriesCollection(1).Name = Range("H2").Value

    ActiveChart.Parent.Cut
    Range("I4712").Select
    Selection.End(xlUp).Select
    Range("I4").Select
    ActiveSheet.Paste
    Range("I3").Select

        'saving some columns as separate file

        Dim Path As String
        filename = Range("B2").Value
        Path = "Some path here"

        With Workbooks.Add
        ThisWorkbook.Sheets(1).Range("G:G").Copy .Sheets(1).Range("A1")
        ThisWorkbook.Sheets(1).Range("H:H").Copy .Sheets(1).Range("B1")
        .SaveAs filename:=Path & filename & "-prum.xlsx"
        .Close
        End With

    Sheets.Add.Name = "2"

    Sheet1.Range("G:G").Copy Worksheets("2").Range("A1")
    Sheet1.Range("H:H").Copy Worksheets("2").Range("B1")
    Worksheets("2").Activate
    Range("B1").Value = "=STDEVP(B3:B4724)"
    Range("A:A").Copy Range("D:D")
    Range("B:B").Copy Range("E:E")
    Range("D1") = "prumer"
    Range("E3").Select

        Do Until ActiveCell.Offset(0, -4).Value = ""

        myCell0 = Range("B1").Value
        myCell1 = ActiveCell.Offset(0, -3).Value

            If IsEmpty(ActiveCell.Value) = True Then
            ActiveCell.Value = "nic"
            ActiveCell.Offset(1, 0).Select
            Else
            ActiveCell.Value = myCell1 - myCell0
            ActiveCell.Offset(1, 0).Select
            End If

        Loop

    Range("D:D").Copy Range("G:G")
    Range("E:E").Copy
    Range("H:H").PasteSpecial Paste:=xlPasteValues
    Range("H2").Select

        Do Until ActiveCell.Offset(1, -1).Value = ""

            If ActiveCell.Value = "nic" Then
            ActiveCell.Clear
            Else
            ActiveCell.Offset(1, 0).Select
            End If

        Loop

    ActiveCell.Clear
    Range("E1").Clear
    Range("H1").Clear

    'plotting the scatter graph

    Range("G3").Select
    Selection.End(xlDown).Select
    Range(Selection, Selection.End(xlUp)).Select
    Range("G3:H4724").Select
    Range("G4724").Activate
    ActiveSheet.Shapes.AddChart2(240, xlXYScatterLinesNoMarkers).Select
    ActiveChart.SetSourceData Source:=Range("G3:H4724")
    Application.CutCopyMode = False
    Application.CutCopyMode = False
    ActiveChart.FullSeriesCollection(1).Name = Range("H2").Value

    ActiveChart.Parent.Cut
    Range("I4712").Select
    Selection.End(xlUp).Select
    Range("I4").Select
    ActiveSheet.Paste
    Range("I3").Select

    'saving some columns as separate file

        With Workbooks.Add
        ThisWorkbook.Sheets(1).Range("G:G").Copy .Sheets(1).Range("A1")
        ThisWorkbook.Sheets(1).Range("H:H").Copy .Sheets(1).Range("B1")
        .SaveAs filename:=Path & filename & "-prum ku SD.xlsx"
        .Close
        End With

    'where core opreation ends

    ActiveWorkbook.Save
        ActiveWorkbook.Close True
        MyFile = Dir()
    Loop

End Sub
</code>
Comment: Firstly, no need to select anything in your code. Secondly, you should fully qualify the sheets you are processing. `ChDir MyDir` is useless. The iteration between folder files works the same without it. Be sure that `Path` ends in "\". Then, `Application.ScreenUpdating = 0` and `Application.DisplayAlerts = 0` not only are useless, they do not let you see what is happening on the sheet. All used variable must previously be declared. Try using `Option Explicit` on top of the module where the code exists (in the declarations area). In this way, VBA will warn you if a variable is not declared.
Answer: Not easy to learn vba by putting the pieces together as their are so much bad examples out their.
The basic idea is to minimise the number of interactions with the sheet as these will dramatically slow down performance. VBA is on it's best when you work in memory and working in memory means learning to use arrays.
Additionally you will ease your problem solving by splitting your code in smaller pieces by using functions and subs.
Concerning your "blank" export it's maybe due to this part:
<code>    With Workbooks.Add
    ThisWorkbook.Sheets(1).Range("G:G").Copy .Sheets(1).Range("A1")
</code>
you are exporting data from the sheet in which you run the macro, not the file you edited before.
Nevertheless, if you want to learn I refactored part of your code to give you an example on how it could look like in using multiple subs/functions and arrays. only writing to the sheet when all transformations are done.
<code>    Option Explicit

    Sub files()
        'Fill in the path\folder where the files are
        Dim MyPath As String, BaseWks As Worksheet
            MyPath = ThisWorkbook.Path & "\test\"

        'open files
        Dim FilesInPath As String, mybook As Workbook
            FilesInPath = Dir(MyPath & "*.xlsx")
            Do While FilesInPath <> ""
                Set mybook = Nothing
                Set mybook = Workbooks.Open(MyPath & FilesInPath)

            'build array & close WB
               Dim arr
               arr = Data(mybook)

            'export array
                Call Export(arr)

            'reset vars
                FilesInPath = Dir()
            Loop
    End Sub

    '------------------------------------------------------------------------
    ' Supporting subs & functions of this module
    '------------------------------------------------------------------------
    Private Function Data(mybook As Workbook) As Variant 'use a function when you want the output to be returned to your main sub
        'sheets in source workbooks
            Dim SourceWs As Worksheet
            Set SourceWs = mybook.Sheets(1)

        'data from source workbooks
            Dim arr
                SourceWs.Rows(1).Insert shift:=xlShiftDown 'insert blank row
                arr = SourceWs.Range("A1").CurrentRegion.Offset(0, 2).Value2 'get data but remove col A, B

        'Modify array
            Dim j As Long
                arr(1, 2) = "=AVERAGE(B3:B4724)" 'B1 value

                For j = 1 To UBound(arr)
                    arr(j, 4) = arr(j, 1) 'cold A to D
                    arr(j, 5) = arr(j, 2) 'cold B to E
                Next j

                arr(1, 4) = "prumer" 'd1
                arr(1, 5) = "" 'e1
                arr(2, 5) = arr(2, 2) & "-prum" 'e2

        'dump to sheet
            With SourceWs
                .Range("A1").CurrentRegion.ClearContents 'clear old content
                .Range(.Cells(1, 1), .Cells(UBound(arr), UBound(arr, 2))) = arr 'dumb modified arr to sheet
            End With
            mybook.Close savechanges:=True 'close the file

        Data = arr 'return the modified array to the main sub, assuming it's this data that you want to export to a new workbook.
    End Function

    Private Sub Export(arr As Variant) 'use a sub when you just want to do something without returning output to the main sub
            Dim Newwb As Workbook, sh As Worksheet, exportArr, Filename, j As Long
                'arr
                    ReDim exportArr(1 To UBound(arr), 1 To 2) 'scale exportArr
                    Filename = "\" & CStr(arr(2, 2))
                    For j = 1 To UBound(arr)
                            exportArr(j, 1) = arr(j, 7) 'cold G to A
                            exportArr(j, 2) = arr(j, 8) 'cold H to B
                    Next j

                Set Newwb = Workbooks.Add
                With Newwb.ActiveSheet
                    .Range(.Cells(1, 1), .Cells(UBound(exportArr), UBound(exportArr, 2))).Value2 = exportArr
                    .SaveAs Filename:=ThisWorkbook.Path & Filename & "-prum2.xlsx" ', FileFormat:=xlsx, Local:=True 'save
                End With
                Newwb.Close savechanges:=False 'close the file
    End Sub
</code>
Don't hesitate if you have questions.


Sharepoint 2010 package with init.js

Question: I made several changes to sharepoint 'init.js' which located in folder:
C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\1033\init.js
and i need to create deployment package
which can replace existing init.js. How can i do this?
Answer: Ouch! Bad mistake. You should never make changes to the OOB files! Undo and redo!
You should create your own JS file and have it overload the methods you need to modify. Overloading methods in JavaScript is easy; just make sure that your JS file is loaded after init.js (or the file you want to overload functions from) and create your own versions of the JS file using the same function name and signatures.
Comment: just add a new function to your custom JS file  like this `function FixRibbonAndWorkspaceDimensions() {...}` and make sure that your JS is loaded after core.js, ows.js and init.js
Comment: Any example how can i overload method FixRibbonAndWorkspaceDimensions in init.js

Sharepoint 2010 package with init.js


git push a commit that doesn't belong to any branch

Question: I have got a commit-id, currently it doesn't belong to any of the branch. It has got a label. How do I push this commit to server?
git show 2.0.rc10
tag 2.0.rc10
Tagger: ....
Date:   Fri Mar 29 13:38:55 2013 -0700
Release 2.0.rc10;  merged
commit f1186bfeb938081f9d57f8ac20667329b1c53111

while running
git branch -r --contains f1186bfeb938081f9d57f8ac20667329b1c53111

there is no output.
How to push this commit to server?
git push origin 2.0.rc10
remote: Tag '2.0.rc10' references unknown objects. Push commits before tags.
To
 ! [remote rejected] 2.0.rc10 -> 2.0.rc10 (pre-receive hook declined)
error: failed to push some refs to 'remote'

Comment: It looks like you have a pre-receive hook on the server that is rejecting.
Comment: Whence is the single commit you describe above?  Was it deleted at some point from a branch?
Comment: @merlin2011, yes, pre-receive hook is rejecting, the question is "how can i push such commit ids to server?" so that I can push tag later
Comment: @Tim Biegeleisen, yes, may be the branch was deleted. Since its has a tag, I want to preserve both commit-id and tag on server.
Comment: @VonC Please review this question and the answers and let us know your opinion.
Comment: @b4hand: Can't you just remove/fix the pre-receive hook?
Answer: Your problem is not Git,  but a pre-receive hook on the server that apparently checks that the commit is referenced by a branch.
Obviously, a solution is to push your branch first. I'm not sure why you would want a tag without a branch.
Comment: The empty output from `git branch -r --contains` clearly shows that this commit has no branch.
Answer: The commit in question needs to belong to a branch in order for you to commit it to the remote repository.  Assuming that the branch where you want the commit to be is called yourbranch then the following should do the trick:
git checkout yourbranch      # checkout the desired branch
git merge f1186bfe           # merge in the single commit
git push origin yourbranch   # push the branch out (with new commit) to the remote

There may be merge conflicts which you will have to resolve.  And you should establish that you really want this commit.  You can inspect it using:
git show f1186bfe

You can make sure that the tag you want is still on the commit:
git show 2.0.rc10

Verify that the SHA-1 hash matches the commit you want to save, then push out the tag to the remote via this:
git push origin 2.0.rc10

Comment: No, it's not necessary that all commits are reachable from a branch. Reachable from a tag is also good. You can push all tags using `git push --tags`, yes; not only those that are on a branch, but all of them.
Comment: yes, but your first statement is `The commit in question needs to belong to a branch in order for you to commit it to the remote repository.`, which is plain wrong, as the OP says that the commit has a tag.
Comment: Sorry, edited my comment as you were replying. As the OP says that the commit has a tag, a simple `git push origin [tagname]` would do.
Comment: is it necessary that all commits to be pushed onto server belong to a branch. What if (above case) they have only tag associated (but not branch)? I have several such tags in the code I am importing, is there a way "git push --tags" can exclude all such tags at-least?
Comment: AFAIK you cannot push a commit which has no associated branch.  By default, Git tags will not be pushed out with commits, so you don't need to do anything special to exclude tags, just don't push them.
Comment: as the [git-scm page](https://git-scm.com/book/en/v2/Git-Basics-Tagging#Sharing-Tags) says, it's not necessary for all commits to be reachable: `You will have to explicitly push tags to a shared server after you have created them. This process is just like sharing remote branches – you can run git push origin [tagname]`
Comment: @vguzmanp The primary question the OP is asking is how to push a local commit which has no branch to the server, _not_ the issue about the tag.
Comment: OK...please enlighten me by replying with the exact Git command you use to push a single commit to a remote repository which has no branch.
Comment: I don't see any mention of the *pre-receive hook* and thus I'm afraid this answer totally misses the point. Also it seems to make false claims about what Git allows and fails to show the easiest way to push a tagged commit.
Answer: git push origin 2.0.rc10

Is effectively the command to push your commit. As the commit is referenced by the tag 2.0.rc10, it is being pushed without problem.
Your error comes when the remote, before using what you sent, rejects it (pre-receive hook declined).You will need to modify your pre-receive hook or push something that your hook accepts. More info about hooks
Some tests
Recreating OP's situation:
git checkout --orphan orphan_branch
git commit -am "stray commit"
git tag -a 2.0.rc10 -m "2.0.rc10"
git checkout master
git branch -D orphan_branch

Stray commit:
git show 2.0.rc10
tag 2.0.rc10
Tagger: ...
Date:   Fri Jun 5 11:41:11 2015 +0200

2.0.rc10

commit 78e06b3a4841f88c1737ab8986fd6f3d753e1735
Author: ...
Date:   Fri Jun 5 11:41:00 2015 +0200

    stray commit

Push:
git push origin 2.0.rc10
Username for ...
Password for ...
Counting objects: 2, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (2/2), 305 bytes | 0 bytes/s, done.
Total 2 (delta 0), reused 0 (delta 0)
To ...
 * [new tag]         2.0.rc10 -> 2.0.rc10

So the commit is pushed and the tag created in the remote, as I don't have a pre-receive hook, it's pushed without a problem.
Comment: This won't get the stray commit into the remote repository.
Answer: If you can see the commit on github, create a patch (adding .patch in url) and apply it.
Comment: This gave me a 404.


jQuery sliding of div

Question: So, my code is supposed to move the pink coloured div to position 'right : 10px;' yet it is not working. here is the Fiddle for it. All replies will be appreciated.
HTML:

    About

jQuery:
function aboutShow() {
$("#aboutSector").animate({ right: "10px" }, "fast");
};

CSS:
#navBar {
width: 80%;
height: 40px;
left: 10%;
top: 0px;
position: absolute;
box-shadow: 0 2px 2px -2px black;
}

Comment: I'm really stupid. I forgot to add the link to the jQuery library.
Comment: Working fine!! http://jsfiddle.net/kesamkiran/MHSL2/1/
Comment: the point is that we dont have to follow the link just to view the code
Comment: Your fiddle doesn't include jquery. You really should post code and a fiddle together
Answer: Your code has obtrusive java script in it.  Instead of having an onclick event, I put an event listener on it.  You're fiddle also didn't have jQuery on it, so I've added that in my updated fiddle.
The HTML

    <button id="aboutButton">About</button>

The jQuery:
$(document).ready(function() {
  $("#aboutButton").click(function() {
    $("#aboutSector").animate({ right: "10px" }, "fast");
  });
});

You had an an undefined error in your original code.  If you wanted to get fancy, you can slide it back after the next click.
The jQuery
$(document).ready(function() {
    $("#aboutButton").click(function() {
      var right = $("#aboutSector").css("right"),
          shifter = (right == "10px") ? "0px" : "10px";

      $("#aboutSector").animate({ right: shifter }, "fast");
    });
});

The fiddle.

jQuery sliding of div


DAW mixing: Bass and Piano solo'd clips but not individually

Question: I got 16 channels of a jazz ensemble, sending them to groups by instrument.
My problem is that for a range here in Logic Pro 10.6.3, the base and piano groups buses (we got several microphones for the instruments) causes Stereo Out to clip by 0.3 when solo'd together, but don't when I solo them individually.
It's as if there's some kind of interaction/"additive" effect going on between these groups/tracks.
Anyone has reading/watching material or can explain what is going on?
Comment: You said it yourself. The tracks are added together or summed. That's part of what a DAW does: sums the outputs of several tracks together to make one mixed track
Comment: @Frans summing two signals doesn't double the "volume" (or "loudness") as this is not how we perceive loudness (which uses a logaritmic scale). Also, three people talking simultaneously means having three different sources of sound, which is not the same due to the way we can hear things.
Comment: Sure, this is beyond my knowledge in signal theory, or whatever it is. So mixing two audio signals is adding the wave amplitudes of them? I don't know if I can intuitively confirm that. Say, three people talking simultaneously doesn't to me appear as one person talking three times as loud/yelling. Wikipedia says "Audio mixing is the process by which multiple sounds are combined into one or more channels. In the process, a source's volume level, frequency content, dynamics, and panoramic position are manipulated or enhanced." which isn't specific.
Comment: Just because the sum of two signals isn't double the loudness doesn't mean it's not louder. But think about this: a whole crowd cheering in a stadium is **much** louder than one person cheering.
Comment: Is soloing those two busses at the same apparent level as muting all the others? [It should be on a modern DAW, but just to check you've not got something else going on]. If so, then you're going to have to pull all the group busses back, as with everything in the mix you'll be well in the red.
Comment: Yes, I think it's the same as muting all others. Thanks all!
Answer:
It's as if there's some kind of interaction/"additive" effect going on between these groups/tracks.

When you sum two channels, the resulting waveform is a sum of the two added waveforms.

three people talking simultaneously doesn't to me appear as one person talking three times as loud/yelling

Yes, this is a bit nonintuitive. If you add two exactly identical signals, the resulting signal would be louder by 6dB. However, adding two uncorrelated sources of the same volume like two different people talking, or even two instruments, even if they play in unison, results in loudness increase by 3dB. Three sources of the same volume mixed together are 5dB louder than a single source. Note here I'm speaking about averaged loudness, the peak volume may occasionally go higher, causing risk of clipping.
You may want to read about decibel scale. It's logarithmic and might be not intuitive at first.
On the contrary, what people intuitively call "twice louder" corresponds to around 10dB of difference.
Nevertheless, coming to your main question: a single source was below the clipping level, but summed with another source it went above. Possible solutions:

roll down the volume. If you are not mastering the recording, this might be the preferred way. Make sure your track doesn't clip and let the mastering engineer set the final volume of the track
apply dynamic compression or limiting either to individual tracks or to the sum. Compression automatically reduces the signal volume when it crosses a threshold you define. Compression may actually improve the sound quality if used correctly, it may also cause several damage if set wrongly, or applied excessively. There are plenty learning materials in the internet.

DAW mixing: Bass and Piano solo’d clips but not individually


#raidctl - Operation not support with volume of this level

Question: I am having problem to create a RAID volume on the internal disks of a Sun Server (Sunf Fire V440)
When I type the below command
raidctl -f -c -r 5 c1t0d0 c1t1d0 c1t2d0 c1t3d0
 it displaysOperation not support with volume of this level.
My controller is "LSI_1030"
 Help me out please
Comment: The answer here is the same as the answer to your other question. Please spend spend some time reading the documentation.
Answer: It has already been said in Setup SunFire 440 Raid Configuration that the onboard controller only supports mirroring, no raid 5.
As per http://docs.oracle.com/cd/E19088-01/v440.srvr/816-7728-10/816-7728-10.pdf :
On the Sun Fire V440 server, the Ultra-4 SCSI controller supports internal hardware disk mirroring using the Solaris operating environment raidctl utility


Need help to install php gd on ubuntu with lampp (xampp)

Question: I'm running lampp 1.7.1 on lubuntu oneiric.
I need to add extension for php_gd.

I installed php5-gd by
sudo apt-get install php5-gd

Had a look at php.ini and noticed the line
;extension=php_gd.dll

Searched for something with php_gd and found
/usr/include/php5/ext/gd/php_gd.h

Tried to copy it to
sudo cp -av '/usr/include/php5/ext/gd/php_gd.h' '/opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/php_gd.h'
sudo chmod 755 '/opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/php_gd.h'

Added to php.ini
extension=php_gd.h

Restarted lampp and got this error:
PHP Warning:  PHP Startup: Unable to load dynamic library
'/opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/php_gd.h' -
/opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/php_gd.h:
invalid ELF header in Unknown on line 0

Answer: Why you are trying to install xampp/lampp if you already have everything on your Ubuntu repository ?
Anyway to answer to your problem, you are trying to load a header file as a module. :) It will not work.
For your lampp probably you should copy /usr/lib/php5/20090626/gd.so to /opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/, but I don't know if the lampp php is compatible with Ubuntu php. Just try it.
For configuration just use:
extension=gd.so

and it should work.
Comment: Because we have different projects developed and running on differente environments .. that means project A developed under Apache 2.2.11 with MySQL 5.1.33 and PHP 5.2.9 while project B developed under Apache 2.2.21 with MySQL 5.5.16 and PHP 5.3.8 and so on .. I'm a developer so when they ask me to modify something I need to recreate quickly the correct environment for the project to modify. If they ask me to modify project A I will install lampp 1.7.1 for example while I need to install lampp 1.7.7 to modify project B and so on. How could I install old versions using the repository otherwise?
Comment: Anyway, thank you for your tip! I havent' noticed gd.so I was searching somethig starting with php like php_gd :( shame on me for trying to use a header as a module (I'm still a beginner in linux and not a tech .. so I'm confused sometimes). I will try anyway but I think I won't be able to use it because they are build for different versions see http://serverfault.com/questions/352771/how-to-install-different-versions-of-memcache-with-different-versions-of-lampp another post of mine when I faced the same problem for memcache
Comment: I cannot use something compiled with module API=20090626 in php compiled with module API=20060613
Best would be to have old modules of memcache.so or gd.so compiled with module API=20060613 I guess .. but how?
Comment: Tried and got this error:
PHP Warning:  PHP Startup: Unable to load dynamic library '/opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/gd.so' - /opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/gd.so: undefined symbol: gdImageGifCtx in Unknown on line 0
Comment: yes. that means your lampp php is nopt compatible with gd from ubuntu. give me the output of /opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/. Run this command: ls -l /opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/*gd* and post here the result
Comment: The result is:-rwxr-xr-x 1 root root 103800 2011-12-13 20:00 /opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/gd.so .. anyway in the meanwhile I ran a phpinfo and noticed that gd comes already enabled with any version of lampp .. :) .. is there a way I can test everything is working right with it? Anyway the issue with memcache still remains
Comment: Maybe it's better to close this question, because it's related to gd .. how could it be done?
Comment: That probably means is builtin. delete the extension ( rm /opt/lampp/lib/php/extensions/no-debug-non-zts-20060613/gd.so ). Get this file from here http://www.dagondesign.com/files/gd-test.txt, rename it as php (gd-test.php) and see if is working on your server. What problem do you have with memcache ?
Comment: Everything done. Your test gives everything supported but T1Lib, XPM and JIS-mapped Japanese Font .. thank you! With memcache I've the same problem I thought to have with gd: how to install old php estensions with old versions of lampp .. please see this other question of mine presenting this problem .. maybe it's better if you answer me there, if you have any answer http://serverfault.com/questions/352771/how-to-install-different-versions-of-memcache-with-different-versions-of-lampp
Comment: I'm glad is working. I will take a look on that question asap.
Answer: You can try it by installing the lamp development package instead of php-gd
Use the link to check out for downloading the lamp development package.


Single color plotly map

Question: How can I render a plotly map with only a single color. In the example below, I would like the fill for all states to be red, or #FF0000.
library(plotly)
library(tidyverse)

dat <- data.frame(state = state.abb)

plot_ly(dat,
        type = "choropleth",
        locationmode = 'USA-states',
        locations = ~state) %>%
  add_trace(color = "red") %>%
  layout(geo = list(
    projection = list(
      type = "albers usa")))

Answer: From what I understand of the plotly documentation this is a way to achive it (cloropleth is kind of heatmap but you want one color for all):
library(plotly)

dat <- data.frame(state = state.abb)

plot_ly(dat,
        type = "scattergeo",
        mode = 'none',
        locationmode = 'USA-states',
        locations = ~state) %>%
 layout(geo = list(landcolor = "#FF0000",
                   showland = TRUE,
                   projection = list(type = "albers usa")))

Single color plotly map


Update mysql.user from non-root yet privileged account?

Question: This question might sound silly, but I wanted to make absolutely certain before I carried this out on a production MySQL instance.
Currently, I have a MySQL master->slave setup on a production environment.
Our DBA has since left the company and no one is aware of the root password. This has not been a huge deal as before he left he gave me (not a DBA) an account on the MySQL instance with full permissions, we have carried out most of the required "root" tasks via this (my) account.
However, recently the master->slave replication has broken and I would like to follow this guide: https://stackoverflow.com/questions/2366018/how-to-re-sync-the-mysql-db-if-master-and-slave-have-different-database-incase-o#3229580
Requiring me to change the root password to something I actually know.
My question is: Logged in as my escalated user, is there any detrimental effect to changing the root password via update mysql.user short of the possibility of breaking replication? Will this work or does MySQL need to be in safe-mode to make changed to the root account?
Answer: Here are the step by step instructions to reset the MySQL root password from their manual:

Stop the MySQL server if necessary, then restart it with the --skip-grant-tables option. This enables anyone to connect without a password and with all privileges, and disables account-management
  statements such as ALTER USER and SET PASSWORD. Because this is
  insecure, you might want to use --skip-grant-tables in conjunction
  with --skip-networking to prevent remote clients from connecting.
Connect to the MySQL server using the mysql client; no password is necessary because the server was started with --skip-grant-tables:
shell> mysql
In the mysql client, tell the server to reload the grant tables so that account-management statements work:
mysql> FLUSH PRIVILEGES;
Then change the 'root'@'localhost' account password. Replace the password with the password that you want to use. To change the
  password for a root account with a different host name part, modify
  the instructions to use that host name.
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';
Comment: I'm not asking how to change the root password, I can do that fine. I am asking if I can do it from an account that has permissions as I do not wish to stop the server.
Comment: @HydraIO:  From MySQL, run `ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';` and if you get an error, it means you have to follow my answer.
Comment: If your user has a `WITH GRANT OPTION` then you may be able to edit the root user password without needing a restart. `set password for 'root' = password('newpass')`
Comment: If stopping the server to fix the access is inconvenient then maybe you should consider stopping the server to implement proper high availability (master-master or multi-master replication)
Answer: run 'SHOW GRANTS FOR [your user]@[hostname you connect from];'
That will show you what permissions you have.
From that you can work out if you can change the root password within your session as opposed to doing a 'cold' reset of the password.
The safest way is to use the 'ALTER USER' command mentioned before, the show grants will indicate if you have permission to (or just try it, it can only error)


Is retract of a finitely generated Hopfian group Hopfian?

Question: A subgroup $H$ of a group $G$ is called retract of $G$ if there exists homomorphism $r:G\longrightarrow H$ so that $r\circ i=id_H$, where $i:H\hookrightarrow G$ denotes the inclusion map.  Also, recall that a group $G$ is Hopfian if every epimorphism $f :G\longrightarrow G$ is an automorphism.
''Is retract of a finitely generated Hopfian group Hopfian?''
Thanks in advance.
Comment: @DerekHolt If you're very lucky, then your favourite nonHopfian group is an infinite direct sum of cyclic groups of order two, rather than $BS(2,3)$. Then it's rather easier to prove that something is not a quotient of it!
Comment: How about a (restricted) wreath product of $A_5$ with your favourite nonHopfian group, such as the  Baumslag-Solitar group ${\rm  BS}(2,3)$? I think all  nontrivial normal subgroups contain the base group of the wreath product. ButI guess you still have to prove that this is not a quotient of ${\rm BS}(2,3)$.
Comment: On second thoughts, replace $A_5$ by an uncountable simple group.
Comment: If $G$ is Hopfian and abelian, then every retract $H$ of $G$ is also Hopfian. For this, assume that $f:H\longrightarrow H$ is an epimorphism. Since $G$ is abelian. then $H$ is a direct summand of $G$. So there is subgroup $K$ so that $G=H\oplus K$. Now define $\bar{f}:G\longrightarrow G$ by $\bar{f}(hk)=f(h)k$. Clearly, $\bar{f}$ is an epimorphism. Since $G$ is Hopfian, then $\bar{f}$ (and so $f$) is an isomorphism. It follows that $H$ is  Hopfian.
Comment: In general, if $H$ is a retract of $G$ with retraction $r:G\longrightarrow H$, then we have $G=H\ltimes Ker(r)$. If $f:H\longrightarrow H$ is an epimorphism, then I can define $\bar{f}:G\longrightarrow G$ by $\bar{f}(hx)=f(h)x$ for $h\in H$ and $x\in Ker(r)$. But I can't prove that $\bar{f}$ is a homomorphism:(
Comment: @JeremyRickard I guess I was looking for a finitely generated example, and I still have not found one!
Comment: @DerekHolt Do you know that your first suggestion (restricted wreath product of $A_5$ with $BS(2,3)$) doesn't work?
Comment: @JeremyRickard No, but I think it might be hard to prove that it does work, because you would have to consider all surjective homomorphisms $G \to G$, and then look at the images of their kernels.
Answer: An adaptation of Derek's suggestion works.
Let $I$ be a set, $S$ a non-abelian simple group, $S^{(I)}$ the restricted power.
Proposition 1: every normal subgroup of $S^{(I)}$ equals $S^{(J)}$ for some $J\subset I$.
(Proof: standard exercise)
Corollary 2: for every group $G$, the only normal subgroup of $S\wr G=S^{(G)}\rtimes G$ contained in $S^{(G)}$ are $\{1\}$ and $S^{(G)}$.
(Proof: by the proposition it should be $S^{(J)}$ for some $J\subset G$, and from the normality assumption $J$ has to be left $G$-invariant.)
Corollary 3: now fix $S$ finite. let $G$ be a group with no nontrivial normal subgroup of exponent dividing the exponent of $S$, and such that $S\wr G$ is not isomorphic to a quotient of $G$. Then $S\wr G$ is Hopfian.
(Proof: since $G$ acts faithfully on $S^{(G)}$, every nontrivial normal subgroup intersects nontrivially $S^{(G)}$, and hence any proper quotient of $S\wr G$ is a quotient of $G$, so the second assumption ensures the conclusion.)
It remains to get an example. Fix $S$ finite nonabelian simple group. Fix $p$ prime not dividing $|S|$. Consider Ph. Hall's group $G_p$, defined as the quotient of the group of matrices $$m(n,x,y,z)=\begin{pmatrix}1&x&z\\0&p^n&y\\0&0&1\end{pmatrix},\quad (n,x,y,z)\in\mathbf{Z}\times\mathbf{Z}[1/p]^3$$ by the central cyclic subgroup generated by $m(0,0,0,1)$. It's well-known that $G_p$ is non-Hopfian (hint: use conjugation by the diagonal matrix $(p,1,1)$). Also, $G_p$ is finitely generated (by $\{m(1,0,0,0),m(0,1,0,0),m(0,0,1,0)\}$). Clearly its only order of torsion is given by powers of $p$, so the first assumption of Corollary 3 (on the exponent) holds. In addition, $S\wr G_p$ is isomorphic to a quotient of $G_p$, since $G_p$ is solvable but not $S\wr G_p$.
To conclude: for every prime $p$ and every finite non-abelian simple group $S$ of order coprime to $p$, $S\wr G_p$ is a Hopfian group, while its retract $G_p$ is non-Hopfian.
Comment: @ YCor Your answer is great. Thank you for your exact explanation. Your example can be so useful for my other  works. Thank you very much.


Loop Substituir todos caracters da string por caracter da lista python

Question: O que eu quero fazer é pegar uma string e pra cada caracter da string andar tipo 3 posições atras no alfabeto e substituir na string ou criar uma nova string
Ex string = 'abcd' andando 3 posições então String seria 'xyza'
Minha ideia  de código é  a seguinte:
a = 'ab cd mnopq stvux'
b = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
c = ''
for i in a:
    for j in b:
        if(a[i] == b[i]):
            c =

Answer: Podemos usar uma collections.deque pra podermos facilmente criar uma versão "rotacionada" do alfabeto. Em seguida, basta pegar a posição de cada letra no alfabeto e aplicar a posição equivalente no alfabeto rotacionado:
import collections

alfabeto = collections.deque('abcdefghijklmnopqrstuvwxyz')
alfabeto_rotacionado = alfabeto.copy()
alfabeto_rotacionado.rotate(3)

print(alfabeto)  # deque(['a', 'b', 'c', 'd', 'e', 'f', 'g' ...
print(alfabeto_rotacionado)  # deque(['x', 'y', 'z', 'a', 'b', 'c' ...

mensagem = 'ab cd mnopq stvux'
mensagem_decifrada = ''
for letra in mensagem:
    if letra in alfabeto:
        # Se for um caractere no alfabeto...

        # Pegamos sua posição no alfabeto original
        posicao_alfabeto = alfabeto.index(letra)

        # Inserimos na mensagem decifrada o caractere equivalente no
        # alfabeto rotacionado
        mensagem_decifrada += alfabeto_rotacionado[posicao_alfabeto]
    else:
        # Se não for um caractere no alfabeto, só incluímos o mesmo caractere
        # (espaço, pontuação, dígitos, etc.)
        mensagem_decifrada += letra

print(mensagem_decifrada)  # xy za jklmn pqsru


Length of a curve without function?

Question: I need to find the length of this curve:

I don't have a function but I do have 3 sets of coordinates:
$(0, 51)$,
$(337, 674)$,  and
$(1022, 1022)$
The $(337, 674)$ set refers to the tangent and it makes the curve be equidistant.
I know nothing beyond basic math, however I'm working on this tablet pressure sensitivity thing and there's no other way out. I have to find the length of the curve or figure out the function which creates that curve.
Thank you fellas!
Comment: Plot it with the same $x,y$ axis scale and measure it with a string.
Comment: @user326547 Since the thickness of the curve is nonzero, and the image is pixelated, there are infinitely many curves that would look like "the exact same curve as the one in the image" and they can have different arc lengths.
Comment: There are many many curves which could fit this. Do you have any more restrictions on the type of curve you want? For example, it could be part of a parabola, or part of a circle.
Comment: Could you explain more about what the $(337,674)$ point means?
Comment: I don't understand what do you mean. The curve is there already. The function I'm looking for should plot the exact same curve as the one in the image I posted. I wouldn't know if it's part of a circle or parabola.
Comment: @Michael That point shows the exact half of the curve. I don't know the appropriate name for it, but think of it as the "tension" point of the curve, as it was being pulled to the upper left corner.
Comment: Is this a Bezier curve using that point off the curve for the interpolation?
Comment: @user326547 [Is this what the curve should be?](http://en.wikipedia.org/wiki/Catenary) It's what I first thought of when I read "as if it was being pulled to the upper left corner" ...
Comment: Some more information about the context could be helpful. Is this some sort of programming task? Or homework? It basically looks like a simple bezier curve, so http://math.stackexchange.com/questions/12186/arc-length-of-b%C3%A9zier-curves might be helpful, but it seems like there's hardly a "handy" closed form, and you probably should use an approximation (picking some points on the curve and adding their distances)
Answer: If you know (or can make good estimates for) other points on the curve, you can make decent approximations using triangles.
E.g. if you divide it up into 1, 2, or 4 triangles (you can use however many you want; more triangles is more accurate), it might look like this:
!!
To find the length of the curve, just add the lengths of the hypotenuses of the triangles. For each triangle, just take the $x$ length and $y$ length and plug them into $L = \sqrt{x^2 + y^2}$.
Comment: +1, but the triangles are a little superfluous. You could just say "pick a number of points on the curve, and add up the distances between them".
Answer: I'm not sure exactly what you mean when you claim not to know anything beyond "basic math," but staying on the safe side, I think your best bet is to follow copper.hat's suggestion and just use a string. It looks like your window is already square, so just measure across the square, which will give you a conversion factor between string length (in cm or whatever other physical units you like) and the abstract measure of distance employed in the diagram (you already know that the square measures 1022 across). Then, overlay a string onto the curve, cut it or mark it up, and determine its length in physical units. Then, convert that with the factor you determined earlier.
Comment: To be honest, I don't know what you mean when you say "refers to the tangent and it makes the curve be equidistant." It's unclear wording. Can you be more precise? Then I might be able to go for a more precise answer.
Comment: I see, but wouldn't there be any other way at all? A more precise way? I can't believe Math hasn't come up with a way to solve my issue.
Comment: Its mathematics, not magic :-).
Comment: @DivergentQueries I'm aware the wording is unclear. I'll do my best to explain. This set of coordinates, 337,674, is the very "crest" of the curve. And that same point divides the length of the curve in half.
Comment: @user326547 I think a more precise way to say what you're saying is that the point $(337, 674)$ is the point on the curve that is **furthest from the line connecting the other two points**, and also the point that [**bisects**](http://en.wikipedia.org/wiki/Bisection) the length of the curve. Even so, there are multiple curves that satisfy both of these requirements, and so the information you've given isn't sufficient for an exact answer.
Comment: @ZubinMukerjee Exactly! So you think there's really no way to extract a function or the curve's length just by looking at that graph an making use of the info I gave? What kind of info should I try to bring so it's enough to solve?
Comment: Honestly, if you're looking for an exact answer, then you're probably going to need to know what the function is. If, however, you're happy with an approximate length, then many of the answers already given can do that.
Comment: It actually doesn't look like the point $(337, 674)$ is on the curve at all. Isn't it the third dot on your diagram (the one not in a corner)?
Answer: Fits a quadratic function $f(x) = ax^2 + bx + c$ as follow:
$$
\begin{cases}
y_1 = f(x_1) = ax_{1}^2 + bx_1 + c\\
y_2 = f(x_2) = ax_{2}^2 + bx_2 + c\\
y_3 = f(x_3) = ax_{3}^2 + bx_3 + c\\
\end{cases}
$$
Solve the linear system to find $a$, $b$ e $c$. Then use the formula
$$
L = \int_{x_1}^{x_3}\sqrt{1 + f^{\prime}(x)^2} \ dx
$$
Note that, $f^{\prime}(x)^2 = (2ax + b)^2$. Thus,
$$
L = \int_{x_1}^{x_3}\sqrt{(2ax + b)^2 + 1} \ dx
$$
Write $2ax + b = \tan \theta$ and make the substitution of variables.
Comment: Why is it quadratic?
Comment: Inspired in the figure above, and because we have 3 points. A more efficient way is to build a network and take more points on the curve and calculate the arc length of each part and add up all the lengths.
Comment: There are curves that look very much like quadratics, but aren't. For example, [the catenary](http://en.wikipedia.org/wiki/Catenary). Many of these could fit $3$ points just as well.
Answer: Use a Riemann sum for the arc length integral, making estimates of the slope at test points.
Sorry if you are unfamiliar with that vocabulary, but you say "I can't believe Math hasn't come up with a way to solve my issue", and in fact it has, and it uses this vocabulary.
Comment: Unfortunately, vocabulary cannot change the fact that there is insufficient information. The curve could be part of a parabola. It could be part of a catenary. It could be very many things, without more information than three points and a graph (that can really only give us a rough visual). Your answer is not very helpful as it is now (-1).
Comment: @ZubinMukerjee These down votes are ridiculous. The answer says "making estimates" of the slope. No formula is necessary for that.
Comment: There is plenty of information for making an estimate of the arc length, which is all this answer purports to do, which is all any of the answers here do.
Comment: What function do you propose to use for your Riemann Sum? There is none given ... It *is* in fact the case that "math hasn't come up with a way" to solve OP's problem, because OP didn't give enough information.
Comment: @ZubinMukerjee You don't have to have a formula for $f$. You just need to estimate $f'$ at the test points. Here is a crude $n=2$ Riemann sum using left endpoints: $\int_a^b \sqrt{1+f'(x)^2}\,dx\approx \sqrt{1+(2)^2}\cdot511+\sqrt{1+(1)^2}\cdot511$. All you need to do is use the image to estimate slopes at the test points. It sounds like your understanding of Riemann sums is too closely linked to the formulaic representation of a function.
Comment: Hmm. I suppose your second paragraph made it sound as though the use of Riemann sums would both be necessary for OP to solve the problem, and would give an exact answer somehow. Neither is the case. The context in which OP made his comment about math "not having a solution" was clearly about an exact answer. In any case, I'd be happy to remove my downvote if I could.

Length of a curve without function?


Subset is open under a subset metric $d_A$

Question: I have a doubt about this question:

Let $(X,d)$ be a metric space, and let $A$ be a subset of $X$.
We shall consider $A$ with the subset metric dA.
Assume that $G \subseteq A$ is open in (X,d). Show that G is open in $(A,d_A)$.

I have been proposing in my notebook something based on the fact that if an open set is a subset of another, it continues to preserve its condition. But the fact of being subjected to this new metric makes me doubt and I don't know how to interpret it very well. Could someone help me understand what could be the incidence of being under a metric other than that of the complete space $X$?
Comment: The _true_ result is "Assume $G\subseteq X$ is open in $(X, d)$, show that $G\cap A$ is open in $(A, d_A)$". What you're asked to show is a special case.
Comment: Hint: The open sets in $(A,d_A)$ are by definitions of the form $B \cap A$ where $B$ is a open set in $(X,d)$.
Comment: @BrianBritosSimmari Not in metric spaces. There openness is not inherited from the ambient space, but induced from the inherited metric (you could argue that you inherit both openness and metric, but then you would have to prove that the two inheritances agree on what the open subsets of $A$ are, and you're back at this very exercise anyways). In topological spaces, yes, you would be right.
Comment: thanks @BrianBritosSimmari :D
Answer: The definition of an open subset of a metric space is most commonly something along these lines:

A subset $Y\subseteq X$ is open in the metric space $(X,d)$ iff, for any point $y\in Y$, there is a real number $r>0$ such that the open ball of radius $r$ centered at $y$, using the metric $d$, is contained in $Y$.

Let $g\in G$ be an arbitrary point. We want to show that there is a real number $r>0$ such that the open ball in $A$, centered at $g$ and measured according to the metric $d_A$, is contained in $G$.
We know that $G$ is open in $(X,d)$, so there is an $r>0$ such that the open ball centered at $g$ with radius $r$ according to the metric $d$ is contained in $G$.
But if we now shift to $(A, d_A)$, the open ball centered at $g$ with radius $r$ according to $d_A$ is exactly the same set as the open ball in the paragraph above. So it is necessarily still contained in $G$. This finishes our proof.


How to back-transform Std. Errors that glm() provides on the link scale?

Question: My (edited) questions are:

Does glm() provide Std.Errors for the transformed or untransformed parameters?
If Std.Errors are provided on the scale of the link function, how to obtain them for the parameters on the original (i.e. untransformed) scale?

As an example, given the dataset:
set.seed(100)
dd <- data.frame(
                group = c(rep("group1", 100),rep("group2", 100)),
                values = c(rpois(n=100, lambda=2), rpois(n=100, lambda=7))
                )

I computed the following summary statistics:
library(doBy)
logmean <- function(x){
  log(mean(x))
  }
ss <- summaryBy(values ~ group, data=dd,
            FUN=c(length, logmean, mean, var, sd)
                )
ss$SE.normal <- sqrt(ss$values.var/(ss$values.length-1))
ss$sd.Poiss <- sqrt(ss$values.mean)
ss$se.Poiss <- sqrt(ss$values.mean/ss$values.length)
ss <- cbind(ss[,"group"], round(ss[,-1],3))
names(ss) <- c("group", "N", "log.mean", "mean", "variance", "sd", "SE","sd.Poiss","se.Poiss")

Object ss looks like this:
   group   N log.mean mean variance    sd    SE sd.Poiss se.Poiss
1 group1 100    0.723 2.06    1.653 1.286 0.129    1.435    0.144
2 group2 100    1.937 6.94    8.340 2.888 0.290    2.634    0.263

I then compared these results with those computed by glm():
    glm1 <- glm(values ~ group, data=dd, family="poisson"(link = "log"))

ss$log.mean[1] coincides with glm1$coef[1] and ss$log.mean[2] coincides with glm1$coef[1] + glm1$coef[2], but the Std.Errors provided by glm() do not have any correspondence with those I calculated in table ss:
summary(glm1)$coefficients[, 2]
(Intercept) groupgroup2
 0.06967330  0.07934287

[Note: while mean = exp(log(mean)), the Std.Error of the mean does not equals to exp(summary(glm1)$coefficients[,2])].
Comment: You can use something like the delta method to get standard errors on the original scale, although for expressing uncertainty around the estimate you could also calculate CI on the log scale and the inverse link those to the original scale.
Comment: https://stats.stackexchange.com/questions/354449/backtransforming-logx1-transformed-se/354461#354461
Comment: Thank you all. As a follow-up to this question and answers, I have computed confidence intervals using standard errors calculated in three different ways and I found some discrepancies. I created a question page ad hoc: https://stats.stackexchange.com/questions/355431/discrepancies-in-the-standard-errors-calculated-in-three-different-ways-for-non. I'd like to know your thoughts. Cheers,
Answer: This can be done using the package 'emmeans'
library(emmeans)
df = emmeans (glm1,  ~ group, type = "response")
data.frame(df)[,3]

[1] 0.1435270 0.2634388


complex size error overflow

Question: <code>long int const qwerty= 500000;
double ex[qwerty];
</code>
My signal have 500k of sample. i need to have it in complex or double but always got a error 'System.StackOverflowException' occurred in Project1.exe" Why is that ?. When qwerty is lower than 20k everything works fine.
Comment: Use a std::vector (or maybe std::array).  You **could** use `double* ex=new double[qwerty]` but you shouldn't.  The overhead of `std::vector` is so small that you have no excuse for doing things the hard way.  (Someone might suggest the correct `unique_ptr` syntax as more efficient than `vector` for this use and equally safe.  But I don't think that is worth the extra thought required).
Comment: When you want a tiny C array, especially if you often access it with indexes known at compile time ( such as `ex[0]=ex[2]-ex[1];` etc.), there may be significant performance benefits to declaring it as a function local (automatic) C array.  But when it is bigger (and has access patterns typical of bigger arrays) the relative performance benefits of C arrays tend to vanish and the stack size problems arise.  So use a `vector` instead.
Comment: What does this have to do with [`std::complex`](http://en.cppreference.com/w/cpp/numeric/complex)? Also, you are unambiguously in C++/CLI, not C++.
Answer: You are creating an array of 500k on the stack. The stack has limited memory. If you want to create something that big allocate it on the heap.
Edit: Or better yet, use std::vector. source

complex size error overflow


Convex subsets and Linear functionals

Question: Let $E$ be a convex subset of a normed space $X$ and $x\in E$.
Then $x\in \overline{E}$ if and only if $\Re f(x)\geq 1$ for every $f\in X'$ such that $\Re f\geq 1$ on $E$ and $\Re f(x)\leq 1$ for every $f\in X'$ such that $\Re f\leq 1$ on $E$..
I have no idea how to start at the least..
There is another exercise that is given just before this and i think this would be useful...

Let $E$ be a closed convex subset of $X$. Then $E$ is intersection of all the real half spaces containing it. Real half space is
     $\{x\in X : t\leq Re f(x)\}$..

As $\overline{E}$ is convex, closed, we see that
$\overline{E}=\bigcap \{a\in X : t\leq \Re f(a)\}$
I have no idea how to proceed.. Please suggest something.
Comment: Hahn-Banach theorem.
Comment: @jochen... Ictried using that as well...
Answer: On one side, let $x \in \bar E$, choose a sequence $(x_n) \in E^{\mathbf N}$ such that $x_n \to x$. If now $x' \in X'$ is given such that $\Re x'|_E \ge 1$. Then, as $\Re x'$ is continuous, we have
$$ 1 \le \Re x'(x_n) \to \Re x'(x) $$
That is $\Re x'(x) \ge 1$. Along the same line we see that $\Re x'|_E \le 1$ implies $\Re x'(x) \le 1$.
For the other direction, let $x \in X \setminus \bar E$, then, by Hahn Banach, there is $x' \in X'$, such that
$$ \sup_{e \in \bar E} \Re x'(e) < \Re x'(x) $$
Choose $\alpha \in \mathbf R\setminus\{0\}$ such that
$$ \sup_{e \in \bar E} \Re x'(e) < \alpha < \Re x'(x) \tag +$$
Dividing $(+)$ by $\alpha$, we get if $\alpha > 0$:
$$ \sup_{e \in \bar E} \Re \alpha^{-1}x'(e) < 1 < \Re \alpha^{-1} x'(x) $$
and are done, if $\alpha < 0$, we get
$$ \inf_{e\in \bar E} \Re \alpha^{-1}x'(e) > 1 > \Re \alpha^{-1}x'(x). $$
Comment: Thanks... Now i see how simple this...

Convex subsets and Linear functionals


Extend validity of a OpenVPN certificate

Question: I have an openvpn server, clients authenticate using ssl certificates. Whenever a client certificate expires, a new certificate must be issued and sent to the client.
I've found that easyrsa from openvpn has a renew command but AFAIK does not really renew: Easyrsa "renew" is a misleading name · Issue #345 · OpenVPN/easy-rsa
So question is: is technically possible extend the validity of a ssl certificate regardless if it's expired or not in order to avoid sending a new file to the client user?
Comment: renew should be generating a new cert, with the same key, renew would not extend the cert itself and no you can't change the end date on a cert unless you have the private key of the issuing certificate authority...to which would be renewing it.
Comment: As I understood the question the both CA key and cert is available. The "problem" is related to "skip" the distribution of the new cert to the client... And once you have key&cert of the CA the "new" cert request could be created from the existing (even expired) cert so issuing of the new (following) certificate is not the issue from technical point of view.
Answer: This is very nice question :-).
<code>Technically : yes (at the end the client could use expired one to connect)
Easily : no
</code>
In principle it is not possible as CA sign the cert request with specific time of validity so it cannot be extended. What you can do it create new certificate and the tricky part could be in the process of issuing and in the process of checking the validity.
At the beginning it would be fair to mention that following stuff is technically related to certificates in general and I didn't test it with openvpn - if it would not pass the overall answer would be NO :-(.
In openVPN configuration there are 3 parameters related to certificates - ca, key and cert.

key : private key for the data signing. Can be used for decrypting the data encrypted by the cert.
cert : public key (derived from key) to confirm the validity of the data signed by the key. It can be used for encrypting the data for the key. This would be provided to the "other end" during secure connection negotiation. / this scenario works with the case that valid cert could be already known on remote end so sending the cert may be optional and provided expired one could be ignored /
ca : It is used to check the validity of the cert provided during secure connection negotiation.

Once the client cert is expired the case is that just cert is outdated. The key in principle is not expiring and CA should not be expired (in that case it is totally different use case ;-) ). Cert contain validity period and it is part of "envelop" signed by the CA in x.509 structure.
It is good practise to generate new key with generating new cert but there is nothing forcing this step so technically it is not problem to create CSR (Certificate Signing Request) using the same key like actually expiring certificate. In case you have available old CSR you can use it directly for new cert. Once this CSR is signed with CA the new cert is derived from the "old" key.
The tricky part is that you need (one of):

deliver this new cert to current user to replace the cert
get know the server about this certificate so it can be used instead of expired one provided by the client (this is the theory part on this use case ;-) )

What I know is that you can combine more CA certs in ca file linked in the configuration on server without issue (in PEM format). Technically "user" cert and "ca" cert differs in parameter saying if it could be used as CA. So technically you can combine CA cert with this newly generated cert into one file...
Once this file will be in place (the most probably restart of openvpn server will be needed) you can try to establish new connection. Once the client with the key would try to connect it may happen that the server will be able to "identify" the key based on hash paired with this client cert located on server and ignore the certificate provided by the client (this have to be tested). Technically (point of view of certificate as technology) it would work but I didn't try it with openVPN. As openVPN is using external library for SSL stuff it may be working approach ;-).
On client side is needed CA to proof the server side (this is not expired), key to sign and decrypt the communication (this is not expired) and own cert is not really needed for local operation so expired one is not really an issue. The cert of the server is get during SSL negotiation and checked using local CA cert so all needed is available (local key, remote cert).
The cons of this approach is that you are a little bit loosing benefit of CA as single cert for client cert validating (you need to have it listed on server side next to CA cert) but on the other side the plus would be possibility of renewing the cert...
In case you will try it feel free to provide feedback...
Good luck!

The other approach in case of planning could be issue long validity range certificate and utilise CRL (Certificate Relocation List) to revoke non valid cert during the time. But this is not a scope of this question...
Comment: While searching also for initial question I found this thread and I must say that from your  explanation you have a bigger logical problem with certificates and you should improve your knowledge to answer such questions ;-)
1)
> In principle it is not possible as CA sign the cert request with specific time
> of validity so it cannot be extended.
Even this sentence is right it has nothing to do with the question / need for a renew of the CERTIFICATE itself ?
Comment: @Reiner030 I think my understanding of the certificate topic is quite good ;-). I agree you cannot extend validity of already issued certificate. But the question was mainly related to "in order to avoid sending a new file to the client user". My logical construction was about how to renew the cert but utilize already delivered key. New cert, which is related to the existing key (from "old" certificate), is handled just on server side so on user's side you can use old key (which is not expiring) with exp. cert (which is ignored). New cert is "paired" on server side.That was question about ;-).


Boundedness in probability

Question: Suppose we have a set $M$ of random variables on a probability space. Then we defined boundedness of $M$ as,
$M$ is bounded if $\sup_{X\in M}P(|X|>N) \to 0$ as $ N \to \infty$.
This definition means that the measure of the set where the elements of $ M $ are big is very small, in fact tends to zero.
I have three questions to this definition and some further conclusions.
Now suppose we have a unbounded set. My questions are:

Unbounded would mean, that for every $N>0$ there exists an $ \epsilon >0 $ and a $ X \in M $ such that $ P(|X| > N) \ge \epsilon $. Is this conclusion right?
If theres a sequence $ (X_n) $ of random variables, unbounded and positive, then there's a subsequence $ (X_{n_k}) $ and a $\lambda>0 $ such that $ P(|(X_{n_k})| > k)\ge \lambda $ for every $ k \in \mathbb{N}$.

My observations so far to 2.
After the comment of Srivatsan (see below), we therefore have:$ \exists \epsilon > 0 $ sucht that for all $ N>0 $ exists a $ X_n $ such that $ P(X_n(\omega) > N) \ge \epsilon $ Put $ N=1 $, hence there is a $ X_{n_1} $ sucht that $ P(X_{n_1} > 1 ) \ge \epsilon$. Now put $ N=2 $, hence there is a $ X_i $ such that $ P(X_i > 2) \ge \epsilon$. Now the problem is, why do I know that $ i> n_1 $ ? Otherwise it isn't a subsequence.
Thanks for your help
hulik
Comment: "Unbounded" means that there exists an $\varepsilon > 0$ such that for all $N$, there exists $X \in M$ with $P(|X| \geqslant N) \geqslant \varepsilon$.
Comment: In the question 2, you probably meant "$P(|X_{n_k}|>k)\geq\lambda$", since with $X_k=k/2$ we get a counter-example. But what does question 3 become?
Comment: You're right, I edited that. I'm very sorry but I don't know what you mean with: " but what does question 3 become?"
Comment: If I understand well, question 3 is: do we have for almost every $\omega$, and infinitely many $k$, $|X_{n_k}(\omega)|\geq k$. It's true by Borel-Cantelli lemma if $X_{n_k}$ are independent, but not in general, for example taking $\Omega=[0,1]$ with Lebesgue measure and $X_n=(n+1)\mathbf 1_{[0,\lambda)}$.
Comment: I do not know that the $ (X_n) $ are independent. The reason for question 3 was $ (1) $. As I worte, I try to prove $ (1) $ and I do not see why this is true unless we know that for almost all $ \omega $ and infinitly man $ k$, it's true that $|X_{n_k}(\omega)| \ge k$. Since I can not assume independence, I have to find a different arguement why $ (1) $ is true.
Comment: I deleted question 3. There was a mistake! I also updated my thoughts about 2. I would appreciat it much if somone could help me.
Answer: (1) is not correct.  Let $Y$ be a single random variable such that, for every $N$, we have $P(|Y| > N) > 0$; for example, a normal random variable.  (I would call such a random variable "unbounded", but that conflicts with your terminology.)  Then let $M = \{Y\}$.  $M$ is bounded in your sense (exercise: verify this, using continuity of probability) but it is still true that for every $N$ there exists $X \in M$ (namely $X=Y$) and $\epsilon > 0$ (namely $\epsilon = \frac{1}{2}P(|Y|>N)$) such that $P(|X| > N) > \epsilon$.
Srivatsan's comment above gives a corrected statement; I just wanted to show explicitly that the statement in the original question (for every $N>0$ there exists an $\epsilon >0$ and $X \in M$ such that $P(|X|>N) \ge \epsilon$) is not correct.
Regarding (2): You know that there is an $\epsilon$ such that for any $N$ there is an $X_n$ with $P(|X_n|>N) > \epsilon$.  In fact, for any $N$ there are infinitely many such $X_n$; thus you can always choose one that occurs later in the sequence than all the ones chosen so far.  To see there must be infinitely many such $X_n$, suppose there were only finitely many and show that in fact we would have to have $\sup_n P(|X|>N) \to 0$ as $N \to \infty$.  (Warmup: what if there were only one such $X_n$?  Now what if there were only two?)
Hint: Fix a random variable $X$.  This is a measurable function $X : \Omega \to \mathbb{R}$; for every $\omega \in \Omega$, $|X(\omega)|$ is some real number, and so there is an integer (depending on $\omega$) which is greater than it.  It follows that $\bigcap_{N \in \mathbb{N}} \{|X| \ge N\} = \emptyset$.  Now "continuity from above" (which follows from countable additivity) implies that $\lim_{N \to \infty} P(|X| \ge N) = 0$.  This is the key step you need.
Comment: @hulik: I added another hint.
Comment: Thanks Nate Eldrege for you answer! with " 1 is not correct" you mean : for every $ N >0 $ there exists an $ \epsilon >0$ and $ X \in M$ such that $ P(|X|> N)\ge \epsilon $, right? As you can see in the comments above, Srivatsan corrected this already. At this point I just have trouble with 2), see also my observations so far for 2) above.
Comment: @hulik: Right.  I've edited to address this, and also your question (2).
Comment: Eldrege: Thanks for answering 2)! I have a question about that: We know it exists $ \epsilon $ such that for every $ N>0 $ there's a $ X_n $ with $ P(|X_n|>N) > \epsilon$. You claim that for every $ N $ there are infinitely many $ X_n$ with this property. So let $ N>0 $ and suppose there's just one of this $ X_n$. First it's clear: $ \mathbf1\{|X_n|>N\} \ge \mathbf1\{|X_n|>N-1\} \dots \mathbf1\{|X_n|>1\}$ So if I can prove, that there's no $ X_n $ such that for this fixed $ X_n$ : $ P(|X_n|> N ) > \epsilon $ for all $ N $ then I'm done. But I do not see why this could not be the case....
Comment: Perhaps there's a element $ \tilde{X} $ of the sequence which is on a set (with large enough measure) as big as I want. If I can prove that it doesn't hold for 1) then using induction I can prove your claim. However, I do not see how to prove this for one, aso mentioned above. Again thanks for your help!
Comment: @ Nate Eldrege: Thanks for your help! But there still some question around: The case for just one such $X$ is clear. But how could I prove the general case? Suppose there are k such $ X_i $, then I know, that $ P(|X_i|>N) \to 0 $ as $ N\to \infty$ as in the case for just one such $ X $, right? Therefore the sup over all this is $0$. This is the whole arguement for the general case, right? Or am I wrong? How else should I prove the general case?

Boundedness in probability


Sot convergence of a net

Question: The following are exercises of Conway's operator theory:
I proved both exercises, but I confused about this point that in exercise 8, $T_i\to 0$ (sot), so based on exercise 6,  $T_i^2 = T_i.T_i\to 0$ (sot) while it's not true. Is not it a counterexample for exercise 6? Thanks.
Comment: In the counterexample of Exercice 6, $(T_i)$ is not uniformly bounded.
Comment: @Etienne: because $T_i\to 0$ (sot), so it's uniformly bounded.
Comment: No. This is not a sequence.
Comment: @Etienne : For every $i$ and $\xi\in H$, we have $\|T_i\xi\|<\infty$, which shows that $\{T_i\}$ is uniformly bounded. Is not it correct?
Comment: No. Nothing tells you that $\sup_i \Vert T_i\xi\Vert<\infty$ for every $\xi$, because this is a net, not a sequence. So you cannot apply the uniform boundedness principle.
Comment: Based on      http://en.wikipedia.org/wiki/Uniform_boundedness , we can say $\{T_i\}$ is uniformly bounded. Where is my mistake?
Comment: It is exactly in what I said in my previous comment. For a general net (not a sequence) the fact that $T_i\xi\to 0$ does *not* imply that $\sup_i \Vert T_i\xi\Vert<\infty$; so UBP cannot be applied.
Comment: @Etienne:  So you mean that I can not say for $\epsilon>0$, there is a finite set $F\subset I$ such that $\|T_i\xi\|<\epsilon $ for $i\in I/F$.
Comment: Yes, this is what I mean.
Answer: The net $\{T_i\}$ in Exercise 8 does not meet the uniform boundedness hypothesis of Exercise 6, because $\|T_i\|=\sqrt{n_i}$, and the net $\{n_i\}$ is unbounded.

Sot convergence of a net


Hibernate Remote MySQL Database through SSH

Question: I will be deploying a Web Application on a JBoss server and will using JPA/Hibernate for the persistence layer. I want to connect to a Remote MySQL database which I access through SSH with a certificate.
How can I do this programatically in combination with persistence.xml
Answer: If you want connect to database via SSH tunnel I can recommend you Java implementation of SSH.
Supports authorization with certificates, port-forwarding, the connection through a proxy, etc.
See

JSch
JSch examples


Make some calculation on Viewcontroller, need show the result to another Viewcontroller

Question: I have an app, where I making some calculation, and need to transfer result of this calculation to ViewController3 and show the result there. Now I use label in same ViewController2 where I have calculation. Thank you for your help.
ViewController2.h
<code>#import <UIKit/UIKit.h>

@interface ViewController2 : UIViewController<UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UILabel *gasPrice;

@property (weak, nonatomic) IBOutlet UILabel *gasCarMileage;

@property (weak, nonatomic) IBOutlet UITextField *perGalon;

@property (weak, nonatomic) IBOutlet UITextField *miles;

@property(nonatomic, copy, readonly) NSString *result;

- (IBAction)getIt:(id)sender;

@end
</code>
ViewController2.m
<code>#import "ViewController2.h"

#import "ViewController3.h"

@interface ViewController2 ()

@end

@implementation ViewController2

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}

//Start calculation

- (IBAction)getIt:(id)sender; {

float perGalon = ([_perGalon.text floatValue]);

float miles = ([_miles.text floatValue]);

float mileCost = perGalon / miles;

[self performSegueWithIdentifier:@"viewController3" sender: nil];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"viewController3"]) {
    ViewController3 *viewController3 = [segue destinationViewController];
    viewController3.result = [[NSString alloc] initWithFormat: @"Every mile you drive
will cost you $ %f", mileCost];
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
self.perGalon.delegate = self;
self.miles.delegate = self;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    return [textField resignFirstResponder];
}
@end
</code>
ViewController3.h
<code>#import <UIKit/UIKit.h>

@interface ViewController3 : UIViewController

@property(nonatomic, copy) NSString *result;

@end
</code>
ViewController3.m
<code>#import "ViewController3.h"
#import "ViewController2.h"

@interface ViewController3 ()

@end

@interface ViewController2 ()

@property(nonatomic, copy, readwrite) NSString *result;

@end

@implementation ViewController3

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
</code>
Answer: You can define a string property in View controller 3 which you will set when you push view controller 3 from view controller 2.
ViewController3 interface declaration
<code>@interface ViewController2 ()

@property(nonatomic, copy) NSString *result;

@end
</code>
In ViewController 2, you will implement this line at the last of your getIt() method.
<code>[self performSegueWithIdentifier:@"viewController3" sender: nil]
</code>
And implement another method called prepareForSegue as follows
<code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"viewController3"]) {
        ViewController3 *viewController3 = [segue destinationViewController];
        viewController3.result = "YOUR CALCULATION RESULT HERE"
    }
}
</code>
Bear in mind, you have to set identifier for view controller 3, go to storyboard and select the view for view controller 3 and On identify inspector, specified Storyboard ID as "viewController3".
Comment: Have problems. First. In vC2.m file, when write viewController3.result = self.result.text; I got message: Incompatible pointer types assigning to 'UIlabel *' from 'NSStreeng *'
Second. When I did [self.navigationController pushViewController:viewController3]; got message:No visible @interface for 'UINavigationController' declares the selector 'pushViewController' I don't use NavContriller.
And sorry for stupid Q, I'm totally newb, where I should use @property(nonatomic, copy) NSString *result;
?
Comment: You should declare property in ViewController header file that .h file. Since you have mentioned, you are not using NavController, are you using storyboards?
Comment: Yes, I'm using storyboard to create interface. I use button getIt to Make calculation and show ViewController3 in same time. Is it wrong way?
Comment: Thanks a lot, only one issue that I have right now is Unusedvariable mileCost here: 'float mileCost = perGalon / miles;' Use of undeclared identifier mileCost here:  'viewController3.result = [[NSString alloc] initWithFormat: @"Every mile you drive will cost you $ %f", mileCost];'
Comment: where did you specify mileCost? Please show me in your code, declare it either as instance variable or properties.
Comment: I have edited my original Q and put all actual code there. Thank you!
Comment: declare float mileCost in you viewcontroller private interface instead of declaring it inside the getIt method as mileCost is unreachable from getIt method. It needs to be globally declared for the class.
Answer: Use a protocol,
In ViewController2.h
<code>@protocol ViewController2Delegate;

@property (strong, nonatomic) id<ViewController2Delegate> delegate;

@protocol BexAPIClientDelegate <NSObject>
- (void)ViewController2:(ViewController2 *)vc didCalculateCost:(CGFloat)cost;
@end

Then at the end of the getIt() call the delegate
[self.delegate viewController2:self didCalculateCost:gasCostPerMile];
</code>
You need to set ViewController3 to be ViewController2's delegate when you load it.  Also you will need to setup ViewController3 to conform to the protocol.
Using the protocol is worth the effort as it will make your code clear and easy to manage.
Comment: Thank you, will try both answers.
Answer: Retain a string in VC3. While initializing the VC3 object, set the value from VC2. Update the label in VC3(in viewDidLoad method)


What is the pattern in the modulus when applying collatz function to linear polynomials?

Question: $C(n) = \frac{n}{2}$ if $n$ is even, or $3n + 1$ if $n$ is odd
This function is normally applied to constant numbers, but it can be used on linear polynomials $ax + b$.
There are 3 possibilities of what $ax + b$ can be, it can be always even, it can be always odd, or it can vary depending on the value of $x$.
To determine whenever a $ax + b$ will be even, odd, or vary this is the process:

If $a$ is odd. then $ax + b$ vary.

otherwise, if $b$ is even, then $ax + b$ is even, or if $b$ is odd, then $ax + b$ is odd

This way, we can apply $C(n)$ to linear polynomials, when $n$ vary $C(n)$ would be undefined, as there would be $2$ possible outputs.
Examples:

$C(8x + 2) = 4x + 1$

$C(6x + 3) = 18x + 10$

$C(3x + 2)$ is undefined

Python function for $C(n)$
def collatz(a, b):
    """Apply the collatz function to ax + b"""
    # If 'a' is odd, then it has two possible outputs, so return None instead
    if a % 2 == 1:
        return None
    # If 'a' is even, then it has only one possible output
    if b % 2 == 0:
        # apply (a/2)x + (b/2)
        a //= 2
        b //= 2
    else:
        # apply 3(ax + b) + 1 = (3a)x + (3b + 1)
        a *= 3
        b = 3 * b + 1
    return a, b

You can apply the function multiple times to a linear polynomial and have a sequence (stopping once you have an undefined result)
$$8x + 5$$
$$24x + 16$$
$$12x + 8$$
$$6x + 4$$
$$3x + 2$$
as you can see, it started with $8x + 5$, and after applying the function $3$ times, the values became $6x + 4$, which is smaller than $8x + 2$, it means that for any value (positive integer) of x in $8x + 5$, it will always reach a value smaller than the seed.
This is important because if you prove that every value reach a number smaller than itself (other than seed $1$), it implies that it eventually reaches $1$.
But not all linear polynomials can be proven to reach a smaller value that way, for example:
$$6x + 3$$
$$18x + 10$$
$$9x + 5$$
As you can see, it reaches an undefined polynomial before it reaches a polynomial smaller than $6x + 3$.
This brings the question: For what values of $a$ and $b$ will $ax + b$ reach a smaller value than itself before reaching an undefined polynomial?
Python function
def check_goes_smaller(a, b):
    """Check if ax + b can be proven to reduce to a smaller value on the collatz function"""
    seed_a, seed_b = a, b
    # Start by assuming it doesn't reduce
    reduces = False
    # Once 'a' is odd, there are more than one output after applying the collatz function
    while a % 2 == 0:
        a, b = collatz(a, b)
        # Check if it's smaller than the seed
        if a < seed_a or (a == seed_a and b < seed_b):
            reduces = True
            break
    return reduces

You can discard all polynomials such that $a$ is odd, as the next value of the sequence will be undefined.
Let's check for some specific value of $a$, for what values of $b$ will $ax + b$ reach a smaller value in the collatz function?
2x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
4x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
6x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
8x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
10x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
12x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
14x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
16x + {0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, ...}
18x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
20x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
22x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
24x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
26x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
28x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
30x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
32x + {0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, ...}
34x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
36x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
38x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
40x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
42x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
44x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
46x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
48x + {0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, ...}
50x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
52x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
54x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
56x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
58x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
60x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
62x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
64x + {0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, ...}
66x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
68x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
70x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
72x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
74x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
76x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
78x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
80x + {0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, ...}
82x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
84x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
86x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
88x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
90x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
92x + {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}
94x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
96x + {0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, ...}
98x + {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, ...}
...

Using this python script
def get_values(a, length=20):
    values = []
    b = 0
    while len(values) < length:
        if check_goes_smaller(a, b):
            values.append(b)
        b += 1
    return values

for a in range(2, 100, 2):
    b_values = get_values(a)
    b_values = "{" + str(b_values)[1:-1] + ", ..." + "}"
    print(f"{a}x + {b_values}")
print("...")

If you analyze those sets, you'll notice that they can be described as numbers that are congruent to some specific values at some modulus, for example, the possible values of $b$ that reach a smaller number in $8x + b$, {0, 1, 2, 4, 5, 6, 8, 9, 10, 12, 13, 14, 16, 17, 18, 20, 21, 22, 24, 25, ...}, the values on this set are the numbers that are congruent to $0, 1$ or $2$ (mod $4$)
Here is a table of values with the set as congruence sets
2x + [congruent to [0] (mod 2)]
4x + [congruent to [0, 1, 2] (mod 4)]
6x + [congruent to [0] (mod 2)]
8x + [congruent to [0, 1, 2] (mod 4)]
10x + [congruent to [0] (mod 2)]
12x + [congruent to [0, 1, 2] (mod 4)]
14x + [congruent to [0] (mod 2)]
16x + [congruent to [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14] (mod 16)]
18x + [congruent to [0] (mod 2)]
20x + [congruent to [0, 1, 2] (mod 4)]
22x + [congruent to [0] (mod 2)]
24x + [congruent to [0, 1, 2] (mod 4)]
26x + [congruent to [0] (mod 2)]
28x + [congruent to [0, 1, 2] (mod 4)]
30x + [congruent to [0] (mod 2)]
32x + [congruent to [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30] (mod 32)]
34x + [congruent to [0] (mod 2)]
36x + [congruent to [0, 1, 2] (mod 4)]
38x + [congruent to [0] (mod 2)]
40x + [congruent to [0, 1, 2] (mod 4)]
42x + [congruent to [0] (mod 2)]
44x + [congruent to [0, 1, 2] (mod 4)]
46x + [congruent to [0] (mod 2)]
48x + [congruent to [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14] (mod 16)]
50x + [congruent to [0] (mod 2)]
52x + [congruent to [0, 1, 2] (mod 4)]
54x + [congruent to [0] (mod 2)]
56x + [congruent to [0, 1, 2] (mod 4)]
58x + [congruent to [0] (mod 2)]
60x + [congruent to [0, 1, 2] (mod 4)]
62x + [congruent to [0] (mod 2)]
64x + [congruent to [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30] (mod 32)]
66x + [congruent to [0] (mod 2)]
68x + [congruent to [0, 1, 2] (mod 4)]
70x + [congruent to [0] (mod 2)]
72x + [congruent to [0, 1, 2] (mod 4)]
74x + [congruent to [0] (mod 2)]
76x + [congruent to [0, 1, 2] (mod 4)]
78x + [congruent to [0] (mod 2)]
80x + [congruent to [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 13, 14] (mod 16)]
82x + [congruent to [0] (mod 2)]
84x + [congruent to [0, 1, 2] (mod 4)]
86x + [congruent to [0] (mod 2)]
88x + [congruent to [0, 1, 2] (mod 4)]
90x + [congruent to [0] (mod 2)]
92x + [congruent to [0, 1, 2] (mod 4)]
94x + [congruent to [0] (mod 2)]
96x + [congruent to [0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30] (mod 32)]
98x + [congruent to [0] (mod 2)]
...

The modulus that each number have generates this sequence:
2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 128, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 256, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 128, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 256, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 128, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 256, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 128, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, 4, 2, 4, 2, 16, 2, 4, 2, 4, 2, 4, 2, 32, 2, 4, 2, ...

The numbers that appear in the sequence, in the order they appear are $2, 4, 16, 32, 128, 256, 1024, 4096, 8192, ...$.
If you take log 2 of them you get
$1, 2, 4, 5, 7, 8, 10, 12, 13$
Searching this on the OEIS i get the sequence A020914: "Number of digits in the base-2 representation of 3^n."
Any ideas?

UPDATE
(obs: the discovers were done just by analysis, they still need proof)
By analysis, the possible numbers that can be a modulus are 2^{Number of digits in the base-2 representation of 3^n}, which are $2, 4, 16, 32, 128, 256, 1024, 4096, 8192, 32768, 65536, 262144, 1048576, 2097152, 8388608, 16777216, ...$
I will call this set $S$, so $S_1 = 2$, $S_2 = 4$, etc.
let $M(n)$ be the modulus of the set of possible $b$ values
e.g.
M(8) = 4, because the possible values of $b$ that goes to a smaller value on $8x + b$ are numbers that are congruent to [0, 1, 2] (mod 4)]
I've manually done some analysis, on what type of numbers have specific values of $S$ as modulus
M(n) = 2 when n = {2} mod 4
M(n) = 4 when n ≡  {4, 8, 12} mod 16
M(n) = 16 when n ≡ {16} mod 32
M(n) = 32 when n ≡ {32, 64, 96} mod 128
M(n) = 128 when n ≡ {128} mod 256
M(n) = 256 when n ≡ {256, 512, 768} mod 1024

It seems like there are two possibilities
If $k$ is odd:
$M(n) = S_k$ when $n \equiv S_k$ (mod $2 \cdot S_k$)
Ex:

$M(n) = 16$ $(S_3)$ when $n \equiv 16$ (mod $32$)

$M(n) = 128$ $(S_5)$ when $n \equiv 128$ (mod $256$)

If $k$ is even:
$M(n) = S_k$ when $n \equiv \{S_k, 2 \cdot S_k, 3 \cdot S_k\}$ (mod $4 \cdot S_k$)
Ex:

$M(n) = 4$ ($S_2$) when $n \equiv \{4, 8, 12\}$ (mod $16$)
$M(n) = 32$ ($S_4$) when $n \equiv \{23, 64, 96\}$ (mod $128$)
Comment: Anyway, I have a few thoughts on this, and am making some notes for later. Question about check_goes_smaller: the code only checks whether $a_{cur}b_{seed}$ , in which case the current polynomial's values only smaller for large $x$; is this intended? Assuming yes, I can prove valid $b$'s are periodic, always a power of 2 that divides $a$. I suspect any (large?) $a$ which gives a period of $2^k$ has the same valid $b$'s. Exact periods probably hard but some likely patterns: 2*odd is 2, 8* (and 4*) is 4, 16* is 16, 32* is 8. Improved bounds?
Comment: @EricNathanStucky That's right, fixed it
Comment: @EricNathanStucky About the check_goes_smaller function, it checks if the current polynomial is smaller than the seed polynomial for all (positive integer) values of x
Comment: Just noticed a mistake on the script I used to get the modulus and congruence set, will be fixing now
Answer: This is an extended comment.
The setup for this problem can be described in somewhat more classical terms. Let us use a (mildly) "accelerated" Collatz sequence:
$$C(n) = \begin{cases} n/2 & n \text{ even} \\ (3n+1)/2 & n \text{ odd} \end{cases}$$
Note that $C(ax+b)$ is either undefined or ($a$ is even and) it is $\alpha x + C(b)$, where $\alpha=\frac12a,\frac32a$ depending on the parity of $b$. In particular, this means that if $a=2^km$ for odd $m$, then $a$ will become odd after exactly $k$ (accelerated) steps. Moreover, the $x$-coefficient at each step $a_i$ satisfies $a_i/a =3^j/2^i$, if there have been $j$ up-steps so far. In particular, the question of whether $a_i<a$ depends only on $k$ and $b$, not on the odd factor $m$.
Therefore, the provided code is checking whether at any point in the first $k$ steps of the Collatz sequence for $b$, the corresponding $a_i$ ever drops strictly below $a$. (Note that $a_i=a$ is impossible, since each $a_i$ has fewer $2$s in its prime factorization.)
As I mentioned in the (actual) comments, this is nominally different from the stated goal of checking whether $a_ix+b_i<ax+b$ for any integer $x\geq 1$. However, I think it is approximately the same. I'm not interested in formalizing this right now, but consider the additive "bonus" for $b$ compared to $a$: from the first up-step it is $\frac12$, from the second it is $\frac14$, and so on. At any future term with $a_i<a$, these bonuses can only have reduced, and thus $b_i<b+\frac12+\frac14+\cdots<b+1$. Not sure if we can get the last +1 eliminated or if that's actually equivalent to the cycle half of Collatz. (Perhaps "only" using Baker's theorem? See Corollary 4)
In any case, this means our problem is to look through the the first $k$ steps of Collatz sequences $b=b_0,b_1,\dots, b_k$ and check whether $b_i\leq b$ for any $1\leq i\leq k$. If the above +1 issue can be resolved, we can upgrade to a strict inequality. Either way, this should be a warning that our new technology has not moved us so far away from Collatz's inherent difficulties.

Regarding the 3 Sept ~19:00 UTC update:
The "two possibilities" are slightly more complex than even/odd. For instance, the even/odd prediction runs into trouble when $n=8192$ is predicted to both give periods of $4096$ (because $S_8=4096$) and $8192$ (because $S_9=8192$). But the spirit could be right: $S_{k+1}/S_k$ is provably always either 2 or 4; use the "odd" prediction in the first case and the "even" prediction in the second?
(Note that there is no simple pattern for which $k$ give 2 and which give 4, since the number of digits of $3^k$ in binary is $1+\lfloor\log_2(3) k\rfloor$, and $\log_2(3)$ is irrational.)
I also mentioned in my comments that $2^k$ is always a period (not necessarily the minimal period!) for the $b$, or in other words that $M(2^km)|2^k$. This is because for any $j>0$, adding $2^j\ell$ does not change the parity, and thus $C(b+2^j) = C(b) + 2^{j-1}\ell$ for either $\ell=1,3$. In any case, this means that adding $2^k$ to $b$ does not change which steps are up and which are down, and therefore does not change the sequence of $x$-coefficients $a_i$. On the $k^\text{th}$ step, first step that it would change, $a_k$ is finally odd, and so the sequence terminates.
This argument suggests a potential source of counterexamples to the prediction that I made above. What it means for $2^{k-1}$ to be a period is almost surely that a lower value was already achieved before the last step: when adding $2^{k-1}$, all steps before the last will be in the same direction, but the $k^\text{th}$ step is guaranteed to be in the opposite direction. So the idea would be to find numbers $N$ and $N+2^{k-1}$ which stay above the starting value for the first $k-1$ steps, but their $(k-1)^\text{th}$ values are close enough that the change in directions changes whether the last step lands larger or smaller.
Comment: Not going to bump the thread for this, but: the reason I say this is an extended comment is that it doesn't address lower bounds for $M(n)$; the "counterexamples" paragraph is rather more vague than I thought when I was writing it. I'm interested in seeing if Eric Shumard's idea can be readily unwound to complete this computation (even if conjecturally), since it gives a rather more quantitative explanation for why things are periodic mod $2^k$.
Answer: Consider the Collatz sequence of odd integers $x_i$ where
$$x_{i+1} = \frac{3x_i + 1}{2^{n_i}}$$
where $n_i$ is the unique positive integer such that $x_{i+1}$ is odd. Define
$$N_i := \sum\limits_{j=1}^i n_j \textrm{ for } i \gt 0 \textrm{ and } N_0 := 0$$
$$\sigma = \sum\limits_{i=0}^{L-1} 3^{i}2^{N_{L - 1 - i}} = \sum\limits_{i=0}^{L-1} 3^{L - 1 - i}2^{N_{i}}$$
then starting with $x_1$, $x_{L+1}$ is given by:
$$2^{N_L} x_{L+1} - 3^L x_1 = \sigma$$
This is a linear Diophantine equation with variables $x_1$ and $x_{L+1}$ with coprime coefficients and therefore has an infinite number of integer solutions of the form:
$$(x_1,x_{L+1}) = (x'_1 + k 2^{N_L}, x'_{L+1} + k 3^L)$$
where $(x'_1,x'_{L+1})$ is any particular solution which can be found by finding a solution to
$$2^{N_L}x''_{L+1} - 3^L x''_1 = 1$$
using the Extended Euclidean Algorithm and then
$$(x'_1, x'_{L+1}) = (\sigma x''_1, \sigma x''_{L+1})$$
so that
$$(x_1,x_{L+1}) = (\sigma x''_1 + k 2^{N_L}, \sigma x''_{L+1} + k 3^L)$$
$k$ is an integer which is restricted if only positive $x$ are considered and also restricted to being even if only odd $x_{L+1}$ are considered.
So every set of $n_i > 0$ and hence $N_i$ of length $L$ corresponds to a set of $(x_1,x_{L+1})$ pairs with spacing given by $(2^{N_L},3^L)$. $N_L$ is the total number of divide by $2$'s.
So $\sigma$ corresponds to your $a$ and $k2^{N_L}$ corresponds to your b.
For $x_{L+1}$ to be less than $x_1$ we must have at least $2^{N_L} > 3^L$. The Coefficient Stopping Time Conjecture posits that $x_{L+1}$ is always less than $x_1$ whenever this condition is met but is not proven. http://www.cecm.sfu.ca/organics/papers/lagarias/paper/html/node5.html
Update to address comment by Eric Stucky:
So a question in the OP is for $ax+b$, for what integer values of $a,x$ and $b$ will repeated application of the Collatz operator result a value less than the original value. I'm only addressing $a,x$ odd and $b$ even. The answer is all $x_1$ solutions to the above Diophantine equation for all $N_L$ and $L$ with $2^{N_L} \gt 3^L$ with every possible $n_i,$ $i=1$ to $L$,  $n_i \gt 0$ and $\sum{n_i} = N_L$ where $x=x''_1$, $a=\sigma$, $b=k2^{N_L}$, and with integer $k$ such that $x_1 > 0$, at least if the Coefficient Stopping Time Conjecture is true. Even if that conjecture isn't true then all solutions are still of this form. I'm using the Syracuse form of the Collatz operator. So $L$ is the number of odd integers in the sequence starting with an odd integer. (Actually, the last integer in the sequence is even if $k$ is odd). $N_L$ is the total number of divide by 2's in the sequence, which for your formulation of the Collatz operator is the total number of integers in the sequence.
For any odd integer to become a lesser value after $L$ iterations (of the Syracuse form of the Collatz operator) then we must have $2^{N_L} > 3^L$. So a starting odd integer which has a finite stopping time must be a solution to some Diophantine equation with $2^{N_L} > 3^L$. These starting values have the form $\sigma x''_1 + k 2^{N_L}$ so we just map that onto $ax+b$. There is a correspondence between a set of $n_i$ and the set of $x_1$ which are the solutions to the Diophantine equation.
Comment: Respectfully, what? For instance, $a$ is just a parameter, but $\sigma$ depends on $L$. In what sense should I think of these as the same? Actually, I'm somewhat generally confused by $L$; this is the length of the (not mildly) accelerated collatz sequence we are considering, contextually. But what does that have to do with the OP?
Comment: See update to my answer.
Comment: Thanks for the more streamlined explanation of the notation. I would say that their $(a,x,b)$ is closer to your $(2^{N_L},k,x_1')$ rather than $(\sigma, x_1'', k2^{N_L})$. Although I see that $ax+b=x_1$ with either choice, note for instance that the OP's recursion only begins if $a$ is even, and runs for $L$ Syracuse-iterations. (I say "closer" because it's more like $a=d2^{N}$ for some divisor $d$ of $k$ and $N>N_L$? They don't demand $a$ be a power of 2 and also only ask that $x_{L+1}<x_1$ for *some* step $L$, rather than only the last one; in any case, these details seem less important.)