How can I achieve the following in sed?

Question: The original text is:
apr_array_pstrcat(anythingbutalwayshereincludingspaces,anythingbutalwayshereincludingspaces, ',')

I want to change it to:
apr_array_pstrcat(samethingasabove,samethingasabove, ", ")

I got the following sed command, but it is not working:
find . -type f -exec sed -i "s/apr_array_pstrcat\((.*),(.*),(.*)','\)/apr_array_pstrcat\($1,$2,$3\", \"\)/g" {} +

How can I do this? I am able to understand PCRE regex, but I am not sure about this sed one.
Comment: Add `-E` after `-i`
Answer: Issues with OP's attempts:

-E is needed to enable ERE, otherwise \( and ( need to be reversed with default BRE
$1, $2, etc should be \1, \2, etc
there should be only two capture groups as per given sample
also, g flag isn't needed if there can be only one match per line

sed -E "s/apr_array_pstrcat\((.*),(.*)','\)/apr_array_pstrcat\(\1,\2\", \"\)/g"

This can be simplified to:
sed -E "s/(apr_array_pstrcat\(.*),(.*)','\)/\1,\2\", \"\)/g"

# or this one, since using double quotes for entire expression can lead to
# conflict with shell double quote interpretation
sed -E 's/(apr_array_pstrcat\(.*),(.*)\x27,\x27\)/\1,\2", "\)/g'

This can be further simplified depending on what kind of data is present in the input:
# change ',' to ", " if a line contains apr_array_pstrcat(
sed '/apr_array_pstrcat(/ s/\x27,\x27/", "/'

Comment: I am using it with the find command. Please create your sed command including the find command. That might be the issue?
Comment: Full command is: `find . -type f -exec sed -iE 's/(apr_array_pstrcat\(.*),(.*)\x27,\x27\)/\1,\2", "\)/g' {} +`
Comment: you need to use `-i -E` not `-iE` .... also please experiment on a copy of your data
Comment: Yes, I am experimenting on a copy.
Comment: Also, how can I change `apr_array_pstrcat(anythingbutalwayshereincludingspaces,anythingbutalwayshereincludingspaces, 'anythinghere')` to `apr_array_pstrcat(samethingasabove,samethingasabove, "samethingasabove")`, so convert the single quotes there to double quotes.
Comment: use `([^\x27]*)` instead of `,` in the search regex and `"\3"` in replacement
Comment: So, the full command would be: `find . -type f -exec sed -iE 's/(apr_array_pstrcat\(.*),(.*)\x27([^\x27]*)\x27\)/\1,\2"\3"\)/g' {} +` ? Right?
Comment: yeah, except that it should be `-i -E` (space is important)
Comment: Oops, again I accidentally entered then -iE since I copied my old comment
Comment: Right. `find . -type f -exec sed -i -E 's/(apr_array_pstrcat\(.*),(.*)\x27([^\x27]*)\x27\)/\1,\2"\3"\)/g' {} +`
Answer: sed has the -E flag for "use extended regular expressions in the script".
I'd also match the arguments with 'anything that's not a comma': "[^,]+"
So this works for me:
sed -E "s/(apr_array_pstrcat\([^,]+, [^,]+,) ','\)/\1 \", \")/"

How can I achieve the following in sed?


how to display array in div structure in drupal 7?

Question: How can I render arrays in div structure in drupal?. I am having a select list with ajax callback.Everytime I choose option, it's fields get fetched into an array. Now how can I show that array fields value?
$nodes = array();
    $output = array();
    $i=0;
    $nids = db_select('node', 'n')
      ->fields('n', array('nid'))
      ->condition('type', 'article', '=')
      ->execute()
      ->fetchCol();
    $nodes = node_load_multiple($nids);
     foreach ($nodes as $node => $value) {
      $output[$i]['title'] = $value->title;
      $output[$i]['body'] =$value->body['und']['0']['value'];
      $i++;
    }
    return output;

If I used return theme('item_list', array('items' => $output));, it is not working for me. Please help.
Answer: After a research of 20 minutes, I came to this answer.theme('item_list', array('items' => $output)); This function follows a simple array key value structure.It doesn't support multiple idexes. so remove $i from array, and it will work.
Comment: It is explained in the docs itself. items: An array of items to be displayed in the list. If an item is a string, then it is used as is. If an item is an array, then the "data" element of the array is used as the contents of the list item. If an item is an array with a "children" element, those children are displayed in a nested list. All other elements are treated as attributes of the list item element. https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_item_list/7


How do I get the "key" of an array item in OPENJSON, when using WITH?

Question: I want to parse a json-array in my sql-server. I would like to use OPENJSON with WITH to parse specific values into columns. How can I get the index of each array item?
I know, that this works fine with JSON_VALUE and without WITH:
DECLARE @json NVARCHAR(MAX) = '[{"name":"Alpha"},{"name":"Bravo"},{"name":"Charlie"}]'

SELECT [key], JSON_VALUE(value, '$.name')
FROM OPENJSON(@json)

--  key | value
----------------------------------
--    0 | Alpha
--    1 | Bravo
--    2 | Charlie

But when I add WITH I seem to not have access to key anymore.
SELECT [key], name
FROM OPENJSON(@json)
WITH (
  [key] INT, -- does not work
  name NVARCHAR(MAX)
)

--  key | name
----------------------------------
-- NULL | Alpha
-- NULL | Bravo
-- NULL | Charlie

Answer: You need to use OPENJSON() with the default schema to get the key of each array item (as your first attempt). A note in the documentation explains:

Note: The Key, Value, and Type columns are returned only when you use
OPENJSON with the default schema and are not available with an
explicit schema.

The following statement is just another option to get the keys and parse the JSON using an explicit schema:
DECLARE @json NVARCHAR(MAX) = '[{"name":"Alpha"},{"name":"Bravo"},{"name":"Charlie"}]';

SELECT j1.[key], j2.*
FROM OPENJSON(@json) j1
CROSS APPLY OPENJSON (j1.[value]) WITH (name nvarchar(max)) j2

Result:
key name
---------
0   Alpha
1   Bravo
2   Charlie


Custom page with fixed content

Question: Me again with the noob question.
I want to achieve this:
At the url http://ROOT/something/{numeric_id_here} to get a page that lists the header and the footer of the theme and my custom content. The content is not manage-able through the admin. It depends on the numeric id.
Here is what I got so far.
I use the hook_menu for this:
function something_menu() {
    $items['something/%id_here'] = array(
        'title' => 'Some title',
        'type' => MENU_NORMAL_ITEM,
    );
    return $items;
}

I have the function that parses the url and gets the numerical value:
function id_here_load($arg) {
    $data = get my custom data from an external xml feed based on $arg; //this works nicelly - I get an array with the data I need.
    //WHAT'S NEXT?
}

Now I'm stuck. how can I pass $data to a template and render that template in the content of the page?
My question is somehow similar to this one. Just that the answers provided there don't cut it for me.
Comment: check out the hook_menu() docs https://api.drupal.org/api/drupal/modules%21system%21system.api.php/function/hook_menu/7
Comment: @AndrewWelch I've been on that page at least 5 times. Looks like half Chinese to me. I forgot to mention that my drupal experience barely adds up to 2 man-days of work. Any suggestions or pieces of code I could try?
Comment: if you want to do an ajax call in your callback check out  something like this https://www.drupal.org/node/2046693
Comment: I don't need an ajax call. I need to list in the page `http://ROOT/something/{numeric_id_here}` the header and footer of my theme and the center part must come from a certain template.
Comment: why don't you  just use views then? https://www.drupal.org/project/views it allows you to set the template and I'm sure you could rewrite the url or just use the node id
Comment: I have a good reason why I don't use it. I have no idea what it does. :). And I was hoping for a simple out of the box way of doing it. I want to involve as few third party code as possible. But I will take a look. Thanks.
Comment: Views is the out of the box way of doing it. You could always hire a web developer.
Comment: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/19011/discussion-between-andrew-welch-and-marius).
Answer: You need more in your hook_menu() like this:
function something_menu() {
  $items = array();

  $items['something/%id_here'] = array(
    'title' => 'Some title',
    'type' => MENU_NORMAL_ITEM,
    // This is the function that will return your page content.
    'page callback' => 'something_custom_page',
    // This will pass the $data variable you returned from your loader function
    // into your page callback (not the ID in the URL).
    'page arguments' => array(1),
  );

  return $items;
}

Then your load function needs to actually return what it has loaded, like this:
function id_here_load($arg) {
  // Do some checks o make sure no one can pass in bad data via the url.
  // This is an example you need to check based on your data.
  if (is_numeric($arg)) {
    $data = get my custom data from an external xml feed based on $arg; //this works nicelly - I get an array with the data I need.
    // If you get back valid data.
    // Again you need to make this relevant to your data.
    if ($data) {
      // Return the data.
      return $data;
    }
  }
  // If for any reason you didn't end up getting data return FALSE.
  // This will cause access denied for this page because of an invalid ID or something.
  return FALSE;
}

Then you need to implement your page callback function like this:
function something_custom_page($data = array()) {
  // Do something with the $data to create the page and return
  // either a string of HTML or a drupal render array.
  // Returning a render array is the preferred option.
}

See Render Arrays in Drupal 7 form more info on render arrays.
Comment: Thanks. This works. But since it's kind of the same thing that Andrew answered and he answered first, I accepted his answer. Anyway +1 from me.
Answer: Something like this. Do your hook menu with (optional) arguments. In the callback do an entityFieldQuery (or pull in your XML). Use hook_theme to specify a custom template. this code isn't tested and will need some editing / adapting for your use context.
If you prefer to pull in a feed maybe https://www.drupal.org/project/feeds is what you are looking for.
//menu
/**
     * Implements hook_menu().
     */
    function example_menu() {
      $items = array();
      $items['example_object/something/%'] = array(
        'title' => t('callback'),
        'page callback' => '_example_mystuff',
        'page arguments' => array(
          0,
          1,
          2
        ),
        'access arguments' => array(
          ''
        ),
        'type' => MENU_CALLBACK
      );
      return $items;
    }

//callback
     function _example_mystuff($arg1, $arg2, $arg3) {
        $query = new EntityFieldQuery();
//or load in your xml
        //do an entity field query to look up your items
         $results = $query->execute();
        return $results;
        }

//theme function
 function example_theme($existing, $type, $theme, $path) {
      return array(
    '_example_mystuff' => array(
          'template' => 'example-theme',
          'path' => $path . '/templates',
          'variables' => array(
            'variables' => NULL
          )
        )
    }

Comment: That's more like it. Explained for 5 year olds. Works perfectly. I needed to adjust some parameters but exactly what I was hoping for.

Custom page with fixed content


About the rotation of the ellipse

Question: I have a shader that rotates a rectangle in GLSL as shown below.
const float PI = 3.14159265359;

mat2 rotate2d (float _angle) {
    return mat2 (cos (_angle), -sin (_angle),
                sin (_angle), cos (_angle));
}

void main (void) {

    vec2 st = (gl_FragCoord.xy * 2.0 - resolution) /min(resolution.x,resolution.y);
    float p = 0.0;

   st = rotate2d (sin (time) * PI) * st;

    vec2 c = max (abs (st) - 0.2,0.0);
    p = length (c);
    p = ceil (p);

    vec3 color = vec3 (1.0-p);

    gl_FragColor = vec4 (color, 1.0);

}

I want to change the rectangle of this shader to the following ellipse and rotate it at the center point p, which is an ellipse. What should I do?
Is it multiplication of r.x, r.y in the horizontal and vertical directions of the ellipse with rotate2d (sin (time) * PI) in the rotation or multiplication over the whole?
// Center point
vec2 p = vec2 (0.0,0.0);
// radius
vec2 r = vec2 (2.0,1.0);
// oval shape
float d = (length (p / r) - 1.0) * min (r.x, r.y);

Answer: Rotate the coordinates and calculate the distance from the point to the center of the ellipse. Set the color depending on the distance:
const float PI = 3.14159265359;

mat2 rotate2d(float _angle)
{
    return mat2(cos(_angle), -sin(_angle), sin(_angle), cos(_angle));
}

void main (void)
{
    vec2 st = (gl_FragCoord.xy * 2.0 - resolution) / min(resolution.x, resolution.y);
    st = rotate2d(time * PI) * st;

    vec2 center = vec2(0.0, 0.0);
    vec2 ab = vec2(0.2, 0.1);

    vec2 e = (st - center) / vec2(0.2, 0.1);
    float d = length(e);
    vec3 color = d < 1.0 ? vec3(1.0) : vec3(0.0);

    gl_FragColor = vec4(color, 1.0);
}

About the rotation of the ellipse


Custom Search API Dashboard

Question: Since September 5th, 2018 the custom search API dashboard screens no longer works.
I get no stats, no quotas for the project that I use. The service is still running from the front end, signing in with a personal account, other then the existing one I use, I find there is a new metrics section that has been added but that is not available to the other account?  The only work around is to into billing -> reports -> SKU for the current day to figure out what the quota usage is.  Is this a bug, or is there somewhere to upgrade the existing dashboard, new way to use the custom search, anyone else having this issue?
Comment: This is now fixed, google fixed the dashboard. As of Sunday the 9th, they didn't move anything it was busted, and they added there restricted service monitoring to the quota section. Was not aware Google developers would leave something that long as an issue, hence why I thought it was my issue. Still would have loved to have know where to go to see current list of issues.
Answer: This is now fixed, google fixed the dashboard. As of Sunday the 9th, they didn't move anything it was busted, and they added there restricted service monitoring to the quota section. Was not aware Google developers would leave something that long as an issue, hence why I thought it was my issue. Still would have loved to have know where to go to see current list of issues.

Custom Search API Dashboard


How to handle credit activation codes correctly in Rails?

Question: I've got a process where user can activate a code that they've received: the activation process should do the following:

Add X credits to the user account (User.credits)
Create new creditlog item (just for history purposes)
Mark the code as activated, so that user can not activate it again.

I'm having a specific controller for this task. I created a method "code_activate", that works. But it's not ACID compliant, I believe. Should this be a method in some model (user?), or in a controller as I've done it? How would you implement it "the correct way"?
Here's the code:
<code>  def code_activate
    code = CreditCodes.find_by_code(params[:code])
    unless code
      render :json => { :success=>false, :message=>(t :codedoesnotexist)}
      return
    end

    if code.activated
      render :json => { :success=>false, :message=>(t :codealreadyactivated)}
      return
    end

    # Add credits to user
    current_user.credits += code.amount
    current_user.save

    # Save credit log record
    cl = current_user.creditlog.new
    cl.actionid = 1
    cl.amount = code.amount
    cl.save

    # Set code as activated
    code.activated = true
    code.save

    # Show success message
    render :json => { :success=>true, :message=>((t :creditsadded).gsub(/@AMOUNT@/, code.amount.to_s)) }, :status => :ok
  end
</code>
Answer: It's business logic. It belongs into the model (CreditCode most likely)
You want to put this in a transaction to ensure that adding the amount and marking the code happens all or nothing.
Assume in your CreditCode you define a activate method like this:
<code>def activate(user)
  transaction do
    # Add credits to user
    user.credits += code.amount
    user.save

    # Save credit log record
    cl = user.creditlog.new
    cl.actionid = 1
    cl.amount = amount
    cl.save

    # Set code as activated
    activated = true
    save
  end
end
</code>


how to verify $fh=h^{-1}f$ for dihedral group of order $2n$

Question:
Let $S$ be the plane, that is, $S=\{(x,y)|x,y∈R\}$ and consider $f,h\in A(S)$ defined by $f(x,y)=(−x,y)$. Let $n>2$ and let $h$ be the rotation of the plane about the origin through an angle of $\frac{2\pi}{n}$ in the counterclockwise direction. Define $G=\{f^kh^j|k=0,1;j=0,1,2,\cdots,n-1\}$ and let group operation in $G$ be the usual product of mappings. This group is called the dihedral group of order $2n$. One can verify $fh=h^{-1}f$, find a formula that expresses $(f^ih^j)*(f^sh^t)=f^ah^b$

All I know about $f$ and $g$ is,
$$f^2=h^n=\text{identity mapping}$$
And if I able to verify $fh=h^{-1}f$ then $fh^i=h^{-i}f$. And using
$f^i =$
\begin{cases}
f,  & \text{if $i$ is odd} \\
e, & \text{if $i$ is even}
\end{cases}
we can easily list out the cases of $(f^ih^j)*(f^sh^t)$. But what bother me is the $fh=h^{-1}f$.
Rotation of the plane haven't any effect on $(x,y)$ in the plane$(?)$ Before I interpret $h^{-1}f$, I have a doubt on $h^{-1}$. Does it mean the rotaion of the plane about the origin  through the same angle in the clockwise direction, because if it is then $fh$ seems not equal to $h^{-1}f$. Then how to verify that?
Answer: It is perhaps easier to visualize why $fhf=h^{-1}$ is true, which is of course exactly the same statement.
The first thing you need to believe is that reflection times rotation times reflection is a rotation. Once you believe that, then you can just check one point, which you can do with your finger on the table: the point $(1,0)$ gets mapped to $(-1,0)$, which then gets rotated clockwise (say) up into the top-left quadrant. Then reflection puts it in the top-right quadrant. But that's the opposite rotation---anti-clockwise---to the one you did.
But this applies to all points in the plane, by change of co-ordinate axes. If a symmetry acts like a rotation on all points, it is a rotation.
Another way to visualize this is to see reflection as not a reflection of the square, but moving behind the square. Draw the square on a pane of glass, like in A Beautiful Mind. Reflection is walking around the glass to the other side. Then $fhf$ is walk around, rotate the square (in the opposite direction as you are facing the other way!) and then walk back to the front.
Edit: here are some matrices:
$$\begin{pmatrix}-1&0 \\ 0&1\end{pmatrix}\begin{pmatrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\end{pmatrix} \begin{pmatrix}-1&0 \\ 0&1\end{pmatrix}=\begin{pmatrix}\cos\theta&\sin\theta\\-\sin\theta&\cos\theta\end{pmatrix}.$$
Comment: Did you mean $fhf^{-1}$ in your first line? And I really appreciate your answer but I need to verify it giving argument @David Craven
Comment: $f^2=1$ so $f=f^{-1}$. And I've given two arguments. I guess you want a string of symbols. I can edit the answer to give a string of symbols.
Answer: By the subgroup criterion, the set $G=\{1,h,h^2,\dots,h^{n-1},f,fh,fh^2,\dots,fh^{n-1}\}$ (where $o(h)=n$ and $o(f)=2$) is a group if it is closed under the multiplication in force in the supergroup. In particular:
$$h^jf\in G, \space\space\forall j \in \{1,\dots,n-1\} \tag 1$$
Lemma
$(1) \space\Longrightarrow\space \forall j\in\{1,\dots,n-1\}, \exists! k\in\{1,\dots,n-1\}$ such that:
$$h^jf=fh^k\tag 2$$
Proof.

$\exists l \in\{0,\dots,n-1\}\mid h^jf=h^l \Rightarrow f=h^{l-j\pmod n}$: contradiction, because $f\ne 1,h,h^2,\dots,h^{n-1}$;
$h^jf=f \Rightarrow h^j=1$: contradiction, because $h^j\ne 1$ for every $j\in\{1,\dots,n-1\}$.

So  we are left with $h^jf=fh^k$ for some $k\in\{1,\dots,n-1\}$. Now, suppose $\exists \bar j\in \{1,\dots,n-1\}\mid h^\bar jf=fh^k=fh^{k'}$ for some $k,k'\in \{1,\dots,n-1\}$; then, $h^k=h^{k'}$ and finally $k=k'$.
$\Box$
The Lemma can be restated as follows: every $\sigma\in S_{n-1}$ gives rise to a group with underlying set $G$, according to:
$$fh^k=h^{\sigma(k)}f, \space\space\space k=1,\dots,n-1 \tag 3$$
The dihedral group $D_n$ corresponds to choosing $\sigma \in S_{n-1}$ such that $\sigma(1)=n-1$, whence $(2)$ reads:
$$fh=h^{-1}f \tag 4$$
Therefore, $(4)$ would be a (geometrically based) assumption, likewise $h^n=1$ or $f^2=1$, not something to verify.


Create a Modal popup with buttons

Question: I am having issues opening a modal with buttons using OpenModalDialogCommand.
It says in the docs of that command, that it can take as it's 3rd param any Jquery UI option (from http://api.jqueryui.com/dialog/) and it works well, for width/height/class, but anything more advanced i hit a wall. I am trying to make a button but can't figure it out.
$response = new AjaxResponse();
$options = [
    'width' => '800',
    'height' => '300',
    'dialogClass' => 'no-close',
    'buttons' => [
      'text' => 'Proceed',
      'click' => 'function() {alert();}'
    ]
];

$response->addCommand(new OpenModalDialogCommand('Title', 'Body', $options));
return $response;

This returns a modal successfully, width is ok, height is ok, class is ok, but there is not button, i tried 3/4 variations of it with no luck.
~p.s. i know i can make a simple form with one button, and return that in the modal, but there has got to be a way to make this work.
Answer: Ok figured it out.
$options = [
    'dialogClass' => 'my-form',
    'buttons' => [
        'button1' => [
            'text' => 'Proceed',
            'id' => 'onClickDoSomething',
        ]
    ]
];

And then in the .js file just write a function which fires when clickcing on a selector with the id onClickDoSomething voila, it's working.

Create a Modal popup with buttons


Is a solution of this equation a rational number?

Question: $$\frac{1}{\sqrt{2x-1}}+\frac{1}{\sqrt[4]{4x-3}}=\frac{2}{3}$$
Are there any criteria of irreducibility of polynomials that handle this case?
Comment: Is there any way to use the rational root theorem? A quick guess is there's not a rational number solution.
Comment: @User203940 I did not try that approach but it looks like it may be helpful.
Answer: Let $y:=2x-1$. Note here that $x$ is rational if and only if $y$ is rational.
Since $4x-3=2y-1$, our equation becomes
$$\frac{1}{\sqrt{y}}+\frac{1}{\sqrt[4]{2y-1}}=\frac{2}{3}\tag1$$
We note here that both $Y=\frac{1}{\sqrt y}$ and $Y=\frac{1}{\sqrt[4]{2y-1}}$ are decreasing.
Supposing here that $y\ge 17$ gives
$$\frac 23=\frac{1}{\sqrt{y}}+\frac{1}{\sqrt[4]{2y-1}}\le\frac{1}{\sqrt{17}}+\frac{1}{\sqrt[4]{2\cdot 17-1}}\lt 0.243+0.418\lt \frac 23$$
which is impossible where
$$17\times (0.243)^2\gt 17\times 0.059=1.003\gt 1\implies \frac{1}{\sqrt{17}}\lt 0.243$$
$$33\times (0.418)^4\gt 33\times (0.1747)^2\gt 33\times 0.0305=1.0065\gt 1\implies \frac{1}{\sqrt[4]{2\cdot 17-1}}\lt 0.418$$
Also, supposing that $y\le 16$ gives
$$\frac 23=\frac{1}{\sqrt{y}}+\frac{1}{\sqrt[4]{2y-1}}\ge\frac{1}{\sqrt{16}}+\frac{1}{\sqrt[4]{2\cdot 16-1}}\gt 0.25+0.42\gt\frac 23$$
which is impossible where
$$31\times (0.42)^4\lt 31\times (0.177)^2\lt 31\times 0.032=0.992\lt 1\implies \frac{1}{\sqrt[4]{2\cdot 16-1}}\gt 0.42$$
So, we see that every real solution $y$ for $(1)$ satisfies $$16\lt y\lt 17\tag2$$

Squaring the both sides of $$\frac{1}{\sqrt[4]{2y-1}}=\frac 23-\frac{1}{\sqrt y}$$ gives
$$\frac{1}{\sqrt{2y-1}}=\frac{4y+9}{9y}-\frac{4}{3\sqrt y}$$
Squaring the both sides gives
$$\frac{1}{2y-1}=\left(\frac{4y+9}{9y}\right)^2-\frac{8(4y+9)}{27y\sqrt y}+\frac{16}{9y},$$
i.e.
$$\frac{8(4y+9)}{27y\sqrt y}=\left(\frac{4y+9}{9y}\right)^2+\frac{16}{9y}-\frac{1}{2y-1}=\frac{32y^3+335y^2-54y-81}{81y^2(2y-1)}$$
Multiplying the both sides by $81y^2(2y-1)$ gives
$$24(4y+9)(2y-1)\sqrt y=32y^3+335y^2-54y-81$$
Squaring the both sides gives
$$1024y^6-15424y^5-20255y^4-71316y^3+93798y^2-37908y+6561=0\tag3$$

Since $1024=2^{10}$ and $6561=3^{8}$, by the rational root theorem, every positive rational solution for $(3)$ is of the form
$$\frac{3^j}{2^i}\quad \text{$\quad $where $\ \ 0\le i\le 10,\ 0\le j\le 8$}$$
But none of these satisfies $(2)$ since
$$\frac{3^3}{2^1}\lt16\lt 17\lt\frac{3^3}{2^0},\qquad \frac{3^4}{2^3}\lt16\lt 17\lt\frac{3^4}{2^2},\qquad \frac{3^5}{2^4}\lt16\lt 17\lt\frac{3^5}{2^3}$$
$$\frac{3^6}{2^6}\lt16\lt 17\lt\frac{3^6}{2^5},\qquad \frac{3^7}{2^8}\lt16\lt 17\lt\frac{3^7}{2^7},\qquad \frac{3^8}{2^9}\lt16\lt 17\lt\frac{3^8}{2^8}$$
So, $(1)$ has no rational solutions.
It follows from this that our equation has no rational solutions.
Answer: First, let's move the first fraction across:
$$\frac{1}{\sqrt[4]{4x-3}} = \frac23-\frac{1}{\sqrt{2x-1}}$$
Now we can square both sides without making things worse:
$$\frac{1}{\sqrt{4x-3}} = \frac49 - \frac{4}{3\sqrt{2x-1}} + \frac{1}{2x-1}$$
$$\frac{1}{\sqrt{4x-3}} + \frac{4}{3\sqrt{2x-1}} = \frac{8x+5}{9(2x-1)}$$
Now we just have two square roots, so we square again:
$$\frac{1}{4x-3} + \frac{8}{3\sqrt{2x-1}\sqrt{4x-3}} + \frac{16}{9(2x-1)} = \frac{(8x+5)^2}{81(2x-1)^2}$$
$$\frac{8}{3\sqrt{2x-1}\sqrt{4x-3}} = \frac{64x^2 - 208x + 169}{81(2x-1)^2} - \frac{1}{4x-3}$$
$$\frac{8}{3\sqrt{(2x-1)(4x-3)}} = \frac{4 (64 x^3 - 337 x^2 + 406 x - 147)}{81(2x-1)^2(4x-3)}$$
$$\frac{2}{\sqrt{(2x-1)(4x-3)}} = \frac{64 x^3 - 337 x^2 + 406 x - 147}{27(2x-1)^2(4x-3)}$$
One more round of squaring:
$$\frac{4}{(2x-1)(4x-3)} = \frac{(64x^3 - 337x^2 + 406x - 147)^2}{729(2x-1)^4(4x-3)^2}$$
$$2916(2x-1)^3(4x-3) = (64x^3 - 337x^2 + 406x - 147)^2$$
Any root of the original equation is also a root of this polynomial, although the converse is not necessarily true. This simplifies to a lovely little sextic:
$$4096x^6 - 43136x^5 + 72225x^4 - 82508x^3 + 88954x^2 - 55212x + 12861 = 0$$
to which we can apply the rational root theorem. It has two real roots, which do not appear to be rational.
Answer: If we put $t=\sqrt[4]{4x-3}$ then we get $$4t^6-12t^5+9t^4-14t^2-12t+9=0$$
Since none of the candidates is rational root $t$ I assume that there is no rational root $x$ also.


$\sum_{n=1}^{\infty} \frac{1}{(n+1)(n+2)^3}$ using complex analysis

Question: Evaluate:
$$S = \sum_{n=1}^{\infty} \frac{1}{(n+1)(n+2)^3} \space \text{using complex analysis}$$
This my question: we need to consider a $f(z)$ such that,
$$\frac{1}{2\pi i} \cdot\oint_{C_N} f(z) dz = \text{something (maybe residue)} + \sum_{n=1}^{N} \frac{1}{(n+1)(n+2)^3}$$
How do we do this? I believe we consider, a square with vertices:

We also need to prove that as $N \to \infty$ that $\displaystyle \oint_{C_N} f(z) dz \to 0$
Can someone give me an idea?
Comment: hmmm, sounds interesting but i have unfortunately no time to get into the details today. Maybe something like $\psi^{(2)}(z)\psi^{(0)}(z)$ would be a candidate. $\psi^{(m)}(z)$ is a polygammafunction of order $m$
Comment: I guess you wanted to use something with $\pi\cot(\pi z)$, but I'm not sure that one should do so here (as in your other post on the Basel problem). After all, you will also end up with a sum over negative integers, and I see no direct symmetry... Maybe one can take care of that...
Comment: Yeah, it is a problem... What can I do?
Comment: maybe this reference will be of sum interest for you: http://projecteuclid.org/download/pdf_1/euclid.em/1047674270
Answer: Here is an unorthodox answer that needs some more work to make it rigorous.
Consider $$f(z) = \frac{\psi(-z)}{(z+1)(z+2)^3}.$$
We can certainly integrate around a circular contour as ML gives $2\pi R\times \log R/R^4.$
Now we have
$$\mathrm{Res}_{z=0} f(z) = \frac{1}{8},$$
$$\mathrm{Res}_{z=-1} f(z) = -\gamma,$$
$$\mathrm{Res}_{z=-2} f(z) = \frac{\pi^2}{6} +\zeta(3) - 3 +\gamma,$$
and finally
$$\mathrm{Res}_{z=n} f(z) = \frac{1}{(n+1)(n+2)^3},$$
This means that the sum is
$$\frac{23}{8} - \frac{\pi^2}{6} -\zeta(3).$$
Addendum.
To see how to calculate the residue of $f(z)$ at $z=-2$ use the Cauchy
Integral Formula for the series coefficients which is
$$\frac{1}{2\pi i}
\int_{|z+2|=\epsilon}
\frac{\psi(-z)}{(z+2)^{n+1}} \; dz.$$
Put $z+2 = -w$ to get
$$- \frac{(-1)^{n+1}}{2\pi i}
\int_{|w|=\epsilon}
\frac{\psi(w+2)}{w^{n+1}} \; dw$$
which is
$$\frac{(-1)^n}{2\pi i}
\int_{|w|=\epsilon}
\frac{1}{w^{n+1}}
\left(\frac{1}{w+1} + \psi(w+1)\right) \; dw$$
The first component can be evaluated to give the series
$$1+(z+2)+(z+2)^2+(z+2)^3+\cdots$$
(remember that the CIF integral gives the coefficient on $(z+2)^n.$)
The second component is
$$\frac{(-1)^n}{2\pi i}
\int_{|w|=\epsilon}
\frac{1}{w^{n+1}}
\psi(w+1) \; dw$$
The rational zeta series for the digamma function is
$$\psi(z+1) = -\gamma - \sum_{k\ge 1} \zeta(k+1) (-z)^k$$
for $|z|<1.$
It follows that the second component gives the series
$$-\gamma - \sum_{k\ge 1} \zeta(k+1) (z+2)^k.$$
This finally yields
$$\psi(-z)
= 1-\gamma + \sum_{k\ge 1} (1-\zeta(k+1)) (z+2)^k.$$
Now since
$$\frac{1}{z+1} = \frac{1}{-1+z+2}
= -\frac{1}{1-(z+2)}
= -1 - (z+2) - (z+2)^2 - (z+2)^3 -\cdots$$
The desired residue is
$$-(1-\zeta(3)) - (1-\zeta(2)) - (1-\gamma)
= -3 + \gamma + \frac{\pi^2}{6} + \zeta(3).$$
Comment: This is a great answer, I do have a few questions. Firstly, how did you compute the residue at $z=n$ for any $n$? Also arent you consider $-n$? or $\pm ni$?
Comment: Also, I dont understand how you found the coefficient at $z=-2$
Answer: This approach will not get you the sum you want.  Let's see why.
The contour $C_N$ you show encloses simple poles at all of the integers except at $z=-1$, which has a double pole, and $z=-2$, which has a quadruple pole.  I will not compute them here as I do not need to in order to make my point.
We may safely assume that the contour integral
$$\oint_{C_N} dz \frac{\pi \cot{\pi z}}{(z+1)(z+2)^3} $$
vanishes as $N \to \infty$.  By the residue theorem, however, this contour integral is $i 2 \pi$ times the sum of the residues of the poles inside $C_N$.  Thus, we have
$$\sum_{n=-\infty}^{-3} \frac1{(n+1)(n+2)^3} + \sum_{n=0}^{\infty} \frac1{(n+1)(n+2)^3} + \left [\frac{d}{dz} \frac{\pi \cot{\pi z}}{(z+2)^3} \right ]_{z=-1} + \frac1{3!}\left [\frac{d^3}{dz^3} \frac{\pi \cot{\pi z}}{z+1} \right ]_{z=-2}= 0$$
Note that the first sum does not match up with the second sum.  It is easier to see this after rewriting the first sum by subbing $n \mapsto -n$ to get
$$\sum_{n=3}^{\infty} \frac1{(n-1) (n-2)^3} = \sum_{n=0}^{\infty} \frac1{(n+1)^3 (n+2)} $$
Thus, we find that the sum of two sums is equal to the residues at the poles...blah blah blah.  But not the sum you seek.
Comment: So this complex analysis method doesnt work with odd/not odd nor even sums? Thats a bummer.
Comment: @Amad27: I would hesitate to make such a sweeping statement like that.  Maybe you could find a different $f$ with a different set of poles.  Do some research.  But the standard way of evaluating sums using residues won't work here - the $\zeta(3)$ in the answer should be a clue.
Answer: This is just a long comment. What does it mean to evaluate?
Observe that
$$\frac{1}{(n+1)(n+2)^3}=(\frac{1}{n+1}-\frac{1}{n+2})\frac{1}{(n+2)^2}$$
$$=-\frac{1}{(n+2)^3}+\frac{1}{(n+1)(n+2)}-\frac{1}{(n+2)^2}$$
So your answer will in one way or another involve $\zeta(3)$.
 I guess what you want is just an interpretation of the sum as a contour integral.
Comment: Also, $1/((n+1)(n+2))=1/(n+1)-1/(n+2)$, so that part is telescoping. But then, the complete sum is calculated without residue calculus :)


How do I map the id in sys.extended_properties to an object name

Question: When we codegen our CRUD stored procs, we add an extended property that indicates the table they are based on. I want to be able to interrogate sys.extended_properties to get a list of procs that depend on a given table, but extended_properties holds a major_id which doesn't seem to be the same as the object_id in sys.objects or sys.sysobjects.
What is the magic join I need?
Answer: MSDN for sys.extended_properties describes both major_id and minor_id.
Context depends on the class column.
Now, major_id = object_id in sys.objects when it makes sense.
I've used this before to test for extended properties so I know it works.
However, on 2nd reading of your question there is no direct link between the extended property of a stored proc and the tables that are used in the proc. You'd have to go via sys.sql_expression_dependencies to connect, if I understand you correctly
Comment: Is `sys.sql_expression_dependencies` reliable? IIRC, it's possible to `CREATE` or `ALTER` a stored procedure even if the parser can't determine all of the dependent objects. In that case wouldn't they be missing from the DMV?
Comment: @Yuck: I'm not sure off top of my head. It replaces older sys tables that were unreliable but I can't recall how accurate this one is, sorry. Edit: yep, it's better https://sqlblog.org/2008/09/09/keeping-sysdepends-up-to-date-in-sql-server-2008
Answer: From the books online entry for sys.extended_properties, major_id = object_id if the class = 1, 2, or 7.  If you run a manual query, what is the class of the property?  My guess is that the following will work:
select object_name([major_id]), [name], [value]
from sys.extended_properties

Answer: From MSDN, you have to examine the class field as well as major_id.

If class is 0, major_id is always 0.
If class is 1, 2, or 7 major_id is
  object_id.

Other classes appear to be undocumented and as such I wouldn't rely on them.  For example, class 5 appears to be for CLR assemblies (SqlAssemblyProjectRoot). In my case the major_id for one such assembly is 65673 and there isn't even a mismatched object in sys.objects for that ID.
EDIT: I wanted to add that the documented ones - 1, 2, 7 - correspond to (1) Object (e.g. table, stored procedure) or column, (2) Parameter, (7) Index. In your case it should cover what you're looking for.
Answer: Not directly answering your question, but some additional resources:
I have a presentation about using the built-in extended properties for things like documentation: http://code.google.com/p/caderoux/wiki/LeversAndTurtles
There has also been a recent series of articles on extended properties by Adam Aspin published at SQLServer Central:
http://www.sqlservercentral.com/articles/Metadata/72607/
http://www.sqlservercentral.com/articles/Metadata/72608/
http://www.sqlservercentral.com/articles/Metadata/72609/
http://www.sqlservercentral.com/articles/Metadata/72610/


Dividing 4 teachers into 3 rooms with condition of on room has to hold 2 teachers

Question: We have test that is being held in 3 rooms A B C , and we have 4 teaches P Q R S. Each teacher has to be supervision in one room. The condition is that one room will have 2 teaches as supervision and no room can remain without supervision.
We are to find the number of ways how to divide teachers inside room.
If we didnt have condition. We would just divide 4 teachers into 3 rooms which is basic combination =
$\binom{n }{ k}$ = $\binom{4}{3}$ = $\binom{4!}{(4-3)!*3!}$ = 4
But how to solve  it with this condition?
I really appreciate all explanation and help! Thanks
// edit
since the order should matter here , the amount od combinations dividing 4 teachers into 3 room should be 4 * 3 * 2
Comment: Imagine that the teachers are pigeons?
Answer: There are three ways to choose the room to which two teachers are sent.  There are $\binom{4}{2}$ ways to choose two of the four teachers to assign to that room.  There are $2!$ ways to assign the remaining teachers to the remaining rooms.  Thus, the number of ways of assigning the teachers to the rooms so that exactly one room is assigned two teachers is
$$\binom{3}{1}\binom{4}{2} \cdot 2!$$
Answer: First select three teachers out of given 4. Then send them in the three classes, one in each class, the last teacher can then be sent in any of the three classes.
The mathematical equivalent of the above procedure would be:
[(4 C 3) × (3!) × 3]/2 = 36.         (Ans.)
The division by two since you can perform the two given actions (sending three teachers first and then sending the last teacher) in any order.
Comment: the answer should be 36
Comment: as i wrote , the correct answer to this should be 36. This is from solved exercises from my school. Answer is 36 but i cannot find out why.
Comment: Its correct now...corrected couple of minor errors.
Comment: Why did you use 4 C 3 ? By sending 3 teachers into 3 rooms its 3! since order does matter here , and then the last one can be send in any of those room so * 3  but how did u got 4 C 3?
Comment: (4 C 3) for selecting three teachers out of given 4.
Comment: Then why using another 3!  ? Its either take 3 teachers and put them into 3 rooms , if order matte =   3! if not its combination 3C3 = 1 . Or am i understanding it completly wrong?
Comment: You can understand it like this: there are four distinct balls and three distinct boxes... first choose any 3 out of 4 given balls... since each box should have one ball... now put these three balls in the given three boxes in 3! ways and then put the last ball in any of the three boxes. Now since you can perform the above two actions in any order... divide the answer by two.


Convergence of a monotone sequence of bounded self-adjoint operators on a Hilbert space

Question: Let $H$ be a complex Hilbert space and $(T_n)$ a monotonically nondecreasing sequence of bounded self-adjoint operators on $H$. It is well known that if there exists a bounded self-adjoint operator $K$ on $H$ such that every $T_i$ commutes with every $T_j$ and with $K$, then there exists a bounded self-adjoint operator $T$ such that $(T_n)$ strongly convergent to $T$ and $T\leq K$ (meaning $K-T$ is a positive operator).
My question is if there is an example of such a sequence of bounded self-adjoint operators (i.e. satisfying the stated conditions) but $(T_n)$ is not norm convergent to $T$? I tried google for it but it does not seem to turn anything up.
Answer: This works even without the commutativity assumptions. In any case, here is the canonical example.
Fix an increasing sequence of subspaces $H_n$ with $\bigcup_nH_n$ dense in $H$. Let $T_n$ be the orthogonal projection onto $H_n$. Then $\{T_n\}$ is increasing, it converges strongly to $I$, but $\|I-T_n\|=1$ for all $n$.


sending data to telegraf from windows git bash

Question: How exactly can I send data to telegraf from windows command prompt / git bash?
I'm trying to send data in unix bash to telegraf.
In bash I do:
echo -e "my_db,owner=me,field=value" | nc -u4 -w1 my.telefra.host.com 1231;

Answer: You can use telegraf exec input plugin.
It allows you to execute any sort of command, including powershell, cmd, git bash etc. For instance, if I want to run powershell command,
commands = ["powershell -command <command>"]

Same can be done for git bash,
commands = ["<path>\bash.exe <command>"]


Statistical signficance of aggregated terms

Question: I work in retail analyzing the results of various marketing campaigns.  Many of them are some form of direct messaging (Email, text message, Snail Mail, etc.).  When we comb through the database and run the results we calculate a varied number of results.  We do this through a standard Treatment vs Holdout scenario, and usually deal with response rates of < 5%.
Response Rate:  (# of people who Shopped/# of people contacted)
Transactions/Person: (# of Transactions/# of people who shopped)
Average Basket: (Total Sales of people who shopped / Total Transactions)
Sales/Person: (Total Sales of people who shopped / # of people shopped)
Each of the above can be tested for statistical significance without a problem.  However, we start running into problems trying to see if the campaign as a whole had a statistically significant lift in sales.  No single average exists that we can extrapolate from, as total sales is, at it's simplest a combination of response rate and sales/person.
We entertained the idea of averaging the Total Sales by # of people sent, but once we do that we end up with a standard deviation built off of a non-normal distribution (most people did not shop so their sales are 0, and those who shopped are well above 0).
So, I'm attempting to figure out some way of determining if the total difference in sales between a test and control group is statistically significant.
Any thoughts?
Comment: You have two factors that define sales $s_i=r_i\cdot n_i$ for each campaign $i$. You know that properties of $r_i$ and $n_i$. Your problem is that you don't know how to obtain properties of $s_i$ given the above. Am I correctly capturing the essence of the issue?
Comment: Correct.  I can determine if Ri and/or Ni are signifcant, but not if Si is.  In a more general term, we have Yi = X1i*X2i*X3i.... and can determine any any X properties, but not the Y significance.
Answer: Based on your clarification, I think that your best option is Monte Carlo simulations. It's used a lot in a similar cases, e.g. operational losses modeling in finance. In this example, we have the distribution of loss severity and frequency, but are interested in the loss which is the product of frequency and severity. So, we use simulations.
The trick is to obtain the correlations between the frequency and severity, then we can use copulas or other means to produce consistent scenarios and Monte Carlo simulations. The matter is that your response rate can be correlated to your sales/person, and usually is. That's why you have to incorporate this correlation somehow, maybe with copulas.
This must be similar to your case.
Comment: Thanks for your answer.  I was hoping it wouldn't be simulation, but what can you do?  I think I can assume that the basket size is normal, I just need to now look into the proper way to simulate the potential response rate.
Comment: You'll get used to simulation, it's a standard way of handling this issue in finance. There are many benefits, such as getting the full distribution of sales not just one or two statistics.


How do you declare a TreeMap - SortedMap or Map?

Question: I have written some code that works fine but I am confused about the correct way to declare a TreeMap.
If SortedMap is a subinterface of Map then is it okay to just use Map if the code is working okay? Is SortedMap even necessary if TreeMap works fine with Map?
Should it be:
private Map<String, List <Bus>> map = new TreeMap<String, List <Bus>>();

or
private SortedMap<String, List <Bus>> map = new TreeMap<String, List <Bus>>();

Thanks.
Sorry this is so basic - I am new to Java.
Answer: I've used SortedMap to inform others that it is already sorted.  Using Map is OK too.
Comment: +1 It's best to expose the characteristics of the collection without the concrete class which implements it.
Answer: private Map<String, List <Bus>> busTimetable = new TreeMap<String, List <Bus>>();

Unless you have a good reason, always use the highest level interface you can.
Answer: The answer to your question depends on your usage. By default, you should simply program to the data type's interface (i.e. Map). If SortedMap provides methods that you will be using that aren't declared in Map, then program to SortedMap.
Answer: I agree with other commenters that you use SortedMap if you use methods that aren't in vanilla Map. Also use SortedMap if you have use in an iterator or a for-each loop if they implicitly  rely on sorted input.
If neither of these cases are true, you should also think about if you only need a vanilla Map, a HashMap may be a better choice. HashMap has O(1) access; TreeMap does not.
Answer: If you need to use specific SortedMap methods (like firstKey()/lastKey()/whatever...), it is mandatory to declare your reference as SortedMap. Otherwise, Map is the one I'd choose, if I'm only planning on using it as a Map, so I'll be able so switch implementations without any other change in the code.
Answer: It depends upon your requirement and design whenever possible use the highest level of abstraction that is Map. The reason is say you are creating a service and it consume list of data and produce an output in a Map.
some client may expect for sorted order of the data in the map and some other client may just need the data in the insertion order of the map if you use a specific interface SortedMap ; this kind of scenarion you can not handle using one service and you will end up creating two different api becuase one who is expecting sorted order you can just return an implementaion of TreeMap and one for insertion order you can use LinkedHashMap. So it's about how flexible is your program.


$\epsilon-\delta$ proof that $f(x) = x \sin(1/x)$ on $(0,1)$ is uniformly continuous

Question: I have to prove
$$
f: (0,1) \to [-1,1], \ \ f(x)=x\sin(1/x)
$$
using $\epsilon-\delta$.

Try
Fix $\epsilon >0$. I have
$$
\left|x \sin(1/x) - y \sin (1/y)\right| \le |\sin (1/x)| |x-y| + |y| |\sin (1/x) - \sin(1/y)|
$$
I can control $|\sin (1/x)| |x-y|$ part, since I can control $|x-y|$ and $|\sin(1/x)| \le 1$. But I don't know how to deal with $|y| |\sin (1/x) - \sin(1/y)|$ part.
Any help will be appreciated.
Comment: Hint: $\sin(a)-\sin(b)=2\sin\left(\dfrac{a-b}{2}\right)\cos\left(\dfrac{a+b}{2}\right)$.
Comment: Are you sure that this function is uniformly continuous?
Comment: @AndréPorto Since $g(x) = x \sin (1/x) \mathbb{1}_{x \neq 0}$, $g:[0,1] \to [-1,1]$ is continuous, it is uniformly continuous, thus $f$ is uniformly continuous
Comment: I got so frustrated with this that I Googled around and found this: http://mathhelpforum.com/differential-geometry/161946-f-x-x-sin-1-x-uniformly-continuous.html
Comment: No idea if that tricky middle step is correct, but from the result it is easy to see what to do.
Comment: Graphically, it is clearly uniformly continuous.
Answer: Using the prosthaphaereis formula
$$|y| \left|\sin \frac{1}{x} - \sin\frac{1}{y} \right| = 2|y|\left|\sin \frac{x^{-1}-y^{-1}}{2} \right| \left|\cos \frac{x^{-1}+y^{-1}}{2} \right| \leqslant 2|y|\left|\frac{x^{-1} - y^{-1}}{2} \right| \\\leqslant \frac{|x-y|}{|x|}$$
WLOG assume $x > y$ -- otherwise, work with the alternative estimate $|x| \left|\sin \frac{1}{x} - \sin\frac{1}{y} \right|$.
Note that we also have
$$|y| \left|\sin \frac{1}{x} - \sin\frac{1}{y} \right| \leqslant 2|y|$$
Suppose $|x - y| < \frac{\epsilon^2}{2}$.  Either $|y| < \frac{\epsilon}{2}$ and we have
$$|y| \left|\sin \frac{1}{x} - \sin\frac{1}{y} \right| \leqslant 2\frac{\epsilon}{2} = \epsilon,$$
or
$$|x| > |y| \geqslant \frac{\epsilon}{2},$$
and
$$|y| \left|\sin \frac{1}{x} - \sin\frac{1}{y} \right|\leqslant \frac{|x-y|}{|x|} < \frac{2}{\epsilon} \frac{\epsilon^2}{2} = \epsilon$$
Thus, $|x-y| < \frac{\epsilon^2}{2}$ implies $|y| \left|\sin \frac{1}{x} - \sin\frac{1}{y} \right|\leqslant \epsilon$ for all $x,y \in (0,1)$.
The estimate on the first line is only sharp enough to prove uniform continuity on an interval $[a,1)$ where $a > 0$.  However, we know that $x \sin \frac{1}{x} \to 0 $ as $x \to 0$ and this implies continuous extendibility to $[0,1)$ and, hence uniform continuity on $(0,1)$.  The argument above combines both of these elements into an $\epsilon - \delta$ proof.
Comment: This also is a variation on the proof that for $f \in C([0,\infty)) $, if $\lim_{x \to \infty} f(x)$ exists and  is finite, then $f$ is uniformly continuous on $[0,\infty)$.
Comment: @Moreblue: You're welcome.  The last paragraph is just some extra color. It's not essential. What I'm saying is the bound $|x-y|/|x|$ obtained at the beginning of the proof is fine for proving uniform continuity on a compact interval where $x> a>0$ since $1/|x|<1/a$ but we have a problem if $x$ can get close to $0$.   The trick I used to take care of that works because the $x \sin(1/x)$ tends to $0$.
Comment: Thx for the beautiful proof, although I have not understood the final paragraph...
Comment: Wow, this really was rather involved for a usual e-d proof. Nicely done.


Update em banco de dados no Visual Studio

Question: conseguiriam me dizer onde está o erro neste pequeno trecho de código que estou criando para um programa de orçamento com um banco de dados com 4 tabelas (somente o último objeto cmd7 não é aceito na compilação):
OleDbCommand cmd1 = new OleDbCommand("INSERT into Cliente(nome, endereco)"+"Values (@nome, @endereco)", connect); // nome e endereço do cliente
            OleDbCommand cmd2 = new OleDbCommand("INSERT INTO Orcamento(id_cliente) SELECT MAX(id) FROM Cliente", connect);//ID do cliente em Orçamento
            OleDbCommand cmd3 = new OleDbCommand("UPDATE Orcamento SET data = @data", connect);//data do Orçamento
            OleDbCommand cmd4 = new OleDbCommand("INSERT INTO Item(id_orcam) SELECT MAX(id) FROM Orcamento", connect); //ID do orçamento em Item
            OleDbCommand cmd5 = new OleDbCommand("UPDATE Item SET quantidade = @quantidade", connect);//quantidade
            OleDbCommand cmd6 = new OleDbCommand("INSERT INTO Produto(nome,preco)"+"Values (@nomeProd,@precoProd)", connect); //Nome e preço do produto
            OleDbCommand cmd7 = new OleDbCommand("UPDATE Item SET id_produto = (SELECT MAX(id) FROM Produto)", connect);
            //ESTE ÚLTIMO cmd7 NÃO FUNCIONA

            if(connect.State == ConnectionState.Open)
            {
                cmd1.Parameters.Add("@nome",OleDbType.Char,20).Value = nome;
                cmd1.Parameters.Add("@endereco",OleDbType.Char,20).Value = endereco;
                cmd2.Parameters.Add("@id_cliente", OleDbType.Char, 20);
                cmd3.Parameters.Add("@data", OleDbType.Char, 20).Value = data;
                cmd4.Parameters.Add("@id_orcam", OleDbType.Char, 20);
                cmd5.Parameters.Add("@quantidade", OleDbType.Char,20).Value = quantidade;
                cmd6.Parameters.Add("@nome", OleDbType.Char,20).Value = nomeProd;
                cmd6.Parameters.Add("@preco", OleDbType.Char, 20).Value = precoProd;
                cmd7.Parameters.Add("@id_produto", OleDbType.Char, 20);

                try
                {
                    cmd1.ExecuteNonQuery();
                    cmd2.ExecuteNonQuery();
                    cmd3.ExecuteNonQuery();
                    cmd4.ExecuteNonQuery();
                    cmd5.ExecuteNonQuery();
                    cmd6.ExecuteNonQuery();
                    cmd7.ExecuteNonQuery();

Já tentei diversas combinações de sintaxe mas parece que que ele não atualiza o o id_produto da tabela Item por causa do último insert feito na tabela Produtos. Alguém consegue enxergar uma solução.
Obs.: id_produto na tabela Item é uma chave estrangeira sendo herdada da primária da tabela Produto.
Obs2.: o banco foi criado no Access.
Obrigado.
Comment: Você consegue colocar na sua pergunta qual o erro disparado pela execução de `cmd7`?
Comment: Agora estou sem acesso ao código, mas parece que é algo assim: A operação deve usar uma consulta atualizável.
Answer: No cmd7, vc não utiliza nenhum parâmetro.
 OleDbCommand cmd7 = new OleDbCommand("UPDATE Item SET id_produto = (SELECT MAX(id) FROM Produto)", connect);

Mais vc adiciona valor ao parâmetro id_produto:
cmd7.Parameters.Add("@id_produto", OleDbType.Char, 20);

O problema deve estar neste ponto.
Comment: Achei que cmd7.Parameters.Add fosse necessário informar o tipo de dado onde diz OleDbType.Char. Vou tentar remover esta linha assim que possível. Obrigado pela ajuda.
Comment: Eu tinha imaginado que era isso também, mas as consultas de cima estão da mesma forma e funcionam.
Comment: Mais na realidade no cmd7 o SQL não tem nada como parâmetro utilizando o @ no meio, portanto isso pode estar pirando o command. E @Vanderlei não precisa definir o tipo de dados porque o SQL se encarregará disso, mais é bom verificar, pois, o id_produto tem que ter o mesmo tipo de dados do campo id da tabela produto. verifique ai e se der certo não se esqueça de aceitar a resposta
Comment: Tirei o cmd7.Parameters.Add e executei. Deus o mesmo erro. Mudei o UPDATE por INSERT, acontece o mesmo problema inicial: o id_produto vai para a linha seguinte.
Comment: @Vanderlei, o campo id_produto da tabela item e o campo id da tabela produto são do mesmo tipo de dado?
Comment: Sim. Ambos numéricos. Mas acho que não vem a ser este o problema. Os objetos cmd2 e cmd3 fazem a mesma função que deveria fazer o cmd7 (pegar a primary key e transferi-las para as foreign keys). Se existir um método mais fácil de preencher estes campos com as primary keys já me ajuda.
Comment: Consegui resolver usando "SELECT MAX(id)  FROM Tabela" e capturando o valor através do "cmd.ExecuteScalar()" para variáveis e inserindo-as como parâmetros nos objetos cmd.
Agradeço a contribuição dos amigos.
Comment: @Vanderlei, estamos ai meu caro, pena não termos encontrado a solução aqui na pergunta, mais é um prazer ajudar a comunidade.


Microsoft Teams list display of participations

Question: need help with Microsoft Teams. I want to list all the conversations I  have participated in a channel. I not interested in mentions. Is it possible?
Comment: Is it related to programming or just the question related to Microsoft teams ?
Answer: You can get all the chanel conversation using /messages Graph APIs programmatically.


Finding the maximum and minimum variance of the sum of two Bernoulli events?

Question: You are guessing the contents of two envelopes. Let $U_i$ be the event that you guess correctly. Your probability of guessing correctly for each envelope is $P(U_1) = P(U_2) = 3/4$. $U_1$ and $U_2$ may or may not be independent of each other. Let $X$ be a random variable that represents the total number of correct guesses you've made. $X$ can be $0$, $1$, or $2$.
a. Compute  $()$.
So I modeled this as a sum of two Bernoulli events; each one has $p = 0.75$, and can take on $1$ for success, or $0$ for failure.
$$E(X) = 0.75 + 0.75 = 1.5$$
b. Compute the maximum value for $\operatorname{var}()$.
c.* Compute the minimum value for $\operatorname{var}()$.
I'm unclear how to answer these two questions.

Now, I know $$\operatorname{var}(X) = \operatorname{var}(U_1 + U_2) = \operatorname{var}(U_1) + \operatorname{var}(U_2) + 2\operatorname{cov}(U_1,U_2)$$
I also know cov = $E(XY)-E(X)E(Y)$
I also know that $E(X) = p$ for a Bernoulli variable, and that $\operatorname{var}(X) = pq$ for a Bernoulli variable.

I have no idea how to calculate or rationalize an $E(XY)$ to maximize or minimize the variance. Is this in the right direction?
Does $E(XY)$ have to take on a value of either $1$ or $0$?
Now suppose there are four envelopes, $1$ through $4$. Again, let  $_$  be the event that you guess envelope i correctly.  $(U_i)=3/4$  for all  $$ . Once again, let random variable  $$  be the total number of envelopes that are correctly guessed.
d.* Compute the minimum and maximum values for $\operatorname{var}()$.
I likewise would have no idea how to do this. Following the above line of thinking, cov() with multiple variables would give a matrix. How would this be incorporated?
Comment: "$P(U_1)=P(U_2)=3/4$" makes no sense. I guess you mean
$P(U_1 = 1) = P(U_2 = 1) = 3/4.$
Comment: @BruceET Because $U_1$ and $U_2$ refer to *events,* then presuming "$P$" refers to the probability measure, expressions like $P(U_i)=3/4$ make perfect sense.  You likely meant to object to the expressions like "$\operatorname{Var}(U_1),$" which do not make sense, but evidently are just typographical errors replacing the $X_i$ with the $U_i.$
Answer: Make a table of the probabilities where $X_1$ is the indicator of $U_1$ and $X_2$ the indicator of $U_2:$
$$\begin{array}{r|cc|l}
 & X_2=0 & X_2=1 & \text{Total} \\
\hline X_1=0 & a & \frac{1}{4}-a & \frac{1}{4} \\
X_1=1 & \frac{1}{4}-a & \frac{1}{2}+a & \frac{3}{4} \\
\hline
\text{Total} & \frac{1}{4} & \frac{3}{4}
\end{array} $$
This table was constructed beginning with the row and column totals as specified by the problem, letting $a = \Pr(X_1=X_2=0),$ and applying the (obvious) probability axioms to complete the other three cells.  Since probabilities are positive, the possible values of $a$ are $0\le a \le 1/4.$
The problem supposes $E[X_1]=E[X_2]=3/4.$  Because $X_i^2 = X_i,$ their common variance is $$\operatorname{Var}(X_i) = E[X_i^2]-E[X_i]^2 = E[X_i] - E[X_i]^2 = 3/4 - (3/4)^2 = 3/16.$$
A formula for their covariance is
$$\operatorname{Cov}(X_1,X_2) = E[X_1X_2] - E[X_1]E[X_2] = \left(\frac{1}{2}+a\right) - \left(\frac{3}{4}\right)^2\tag{*}$$
because the only contribution to $E[X_1X_2]$ comes from the case $X_1X_2=1.$
Finally,
$$\eqalign{
\operatorname{Var}(X) &= \operatorname{Var}(X_1+X_2) \\
&= \operatorname{Var}(X_1) + \operatorname{Var}(X_2) + 2\operatorname{Cov}(X_1,X_2) \\
&= \frac{3}{16} + \frac{3}{16} + 2\left(\frac{1}{2}+a - \left(\frac{3}{4}\right)^2\right) \\
&= \frac{1}{4}+2a.}$$
This linear function of $a$ obviously is optimized at the extreme possible values of $a,$ equal to $1/4$ when $a=0$ and $3/4$ when $a=1/4.$

With multiple envelopes there are corresponding variables $X_1, X_2, \ldots, X_n$ and $n(n-1)/2$ possibly different covariances among them.  Their covariance matrix $\operatorname{Cov}(X_i,X_j)=(\sigma_{ij})=\Sigma$ will have values of $3/16$ on the diagonal and, off the diagonal, symmetrical entries between $-1/16$ and $3/16$ according to $(*),$ subject to being positive semidefinite.  Let's duck that issue for the moment and just compute the variance of the sum $S_n=X_1+X_2+\cdots+X_n.$  That is
$$\operatorname{Var}(S_n) = \frac{3n}{16} + \sum_{1\le i \lt j \le n} 2\sigma_{ij}.$$
Looking at the extreme possible values of the $\sigma_{ij},$ we see the variance cannot possibly be any smaller than $3n/16 - n(n-1)/16$ nor greater than $3n/16 + 3n(n-1)/16.$ In both cases it's straightforward to check that $\Sigma$ is positive semidefinite, because in each case it is a multiple of the positive semidefinite matrix $1_n^\prime 1_n$ (the $n\times n$ matrix of ones) plus a positive diagonal matrix.
When $n=4$ this gives extreme values of $12/16 - 12/16 = 0$ and $12/16 + 36/16=3.$
These variances can arise in the following ways.  In the first case (zero variance), write the vectors $(1,0,0,0),$ $(0,1,0,0),$ $(0,0,1,0),$ and $(0,0,0,1)$ on four slips of paper and put them into a hat.  Mix them and draw one out randomly.  Let $(X_1,\ldots,X_4)$ be the values you see on that slip.  Obviously $\Pr(X_i=1)=3/4$, but since the sum of the $X_i$ on each slip is always $1,$ the variance of the sum is zero.
In the second case, let the four tickets bear the values $(0,0,0,0),$ $(1,1,1,1),$ $(1,1,1,1),$ and $(1,1,1,1).$  Again $\Pr(X_i=1)=3/4$ but now the sum is four times any one of the $X_i,$ whence its variance is 16 times the common variance of the $X_i.$

For those who might think this is all trivial, note that some of the matrices $\Sigma$ just described are not positive semidefinite and therefore cannot occur as covariance matrices of the $X_i.$  For instance, let $\sigma_{ij}=0$ for $ij\in \{14,34,43,41\}$ and otherwise let $\sigma_{ij}=3/16.$  You may compute that for $y=(3,-7,3,5),$ $y\Sigma y^\prime$ is negative.
Comment: The table was fantastic in helping me understand this problem. Thanks. For the second part, it's not immediately clear to me why the covariance matrix minimum range is -1/16. Can you explain this?
Comment: Additionally, think 12/16 + 36/16 = 48/16 = 3 (trivial arithmetic error).
Comment: Thank you for spotting my division error!  The minimum covariance issue arises in many contexts: see https://stats.stackexchange.com/search?q=covariance+minimum for related threads. One useful general calculation is that when $(X_i)$ are *iid,* and therefore have common variance $\sigma^2$ and (say) covariance $\tau,$ from $0\le \operatorname{Var}(X_1+\cdots+X_n)=n \sigma^2 + n(n-1)\tau$ you obtain $\tau\ge -\sigma^2/(n-1).$
Answer: You're correct with (a). We always have the following inequality for the covariance:
$$|\operatorname{cov}(X,Y)|\leq \sqrt{\operatorname{var}(X)\operatorname{var}(Y)}$$
This means we have $|\operatorname{cov}(U_1,U_2)|\leq pq$, so $0\leq\operatorname{var}(U_1+U_2)\leq 4pq$
The upper bound occurs when $U_1=U_2$. This can give you an idea what happens in four variable case, and maximum when one equals the other three (i.e. $16pq$).
We can't reach this lower bound because $U_1+U_2$ cannot be made constant in any circumstance (as in @whuber's comment). Here, Consider making a 2x2 table of $U_1,U_2$, where $P(U_1=1,U_2=1)=x$. Then, $P(U_1=1,U_2=0)=P(U_1=0,U_2=1)=3/4-x$, and $P(U_1=0,U_2=0)=x-1/2$. The covariance is $E[U_1U_2]-E[U_1]E[U_2]$. It is minimized when $E[U_1U_2]=P(U_1=1,U_2=1)=x$ is minimum. For each probability be non-negative, we need $1/2\leq x\leq 3/4$, which yield $\min[\operatorname{cov}(U_1,U_2)]=1/2-9/16=-1/16$, and therefore minimum variance will be $1/4$.
For four variables, the variance can be $0$ (i.e. minimum) when the total is constant, i.e. $U_1+U_2+U_3+U_4=3$, which doesn't contradict with the expectations.
Comment: How can $U_1+U_2=1$ and yet $E[U_1]=E[U_2]=3/4$??
Comment: It just can't :)


Not understanding universal generalisation, and proof that uses it

Question: From $\varphi$ follows $\forall x \varphi$.
E.g., universal generalizations of the formula $Rxy \wedge \exists z Sz$ can be $\forall x (Rxy \wedge \exists z Sz)$, $\forall x \forall y \forall u(Rxy \wedge \exists z Sz)$ etc.
I can't grasp why it is possible to do this, who says that in  $\forall x (Rxy \wedge \exists z Sz)$ you just can say that it applies to all x's?
Then there is this proof:
Axiom schema's used in the proof:

1 $(\forall x (\varphi \rightarrow \psi))\rightarrow (\forall x \varphi \rightarrow \forall  x \psi)$
2 $\varphi \rightarrow \forall x \varphi$
3 $\forall x \varphi \rightarrow [t/x]\varphi$

$\Sigma = \{Sa, \forall x (Sa \rightarrow Sx)\}$. Proof $\Sigma \vdash \forall x Sx$

1 $\Sigma \vdash Sa$
2 $\Sigma \vdash \forall x (Sa \rightarrow Sx)$
3 $\vdash \forall (Sa \rightarrow Sx) \rightarrow (Sa \rightarrow Sy)$ axiom 3, t = y
4 $\Sigma \vdash Sa \rightarrow Sy$
5 $\Sigma \vdash Sy$
6 $\Sigma \vdash \forall x Sx$

Why does $(Sa \rightarrow Sx)$ need to change to $(Sa \rightarrow Sy)$ in 3? And what and why is happening at step 5 and 6? From $Sy$ to $\forall x Sx$??

Thanks to Mauro and Berci; I wish I could upvote you both!
Answer: 1) Quantifying variables not contained in the formula which is in the scope of the quantifier has no effect; see your example :

$∀x∀y∀u(Rxy∧∃zSz)$;

$u$ is not into $Rxy$ nor into $\exists z Sz$ : thus, it has no effect.
2) who says that in $∀x(Rxy∧∃zSz)$ you just can say that it applies to all $x$'s?
This question is not clear to me; the syntax of first-order logic "force us" to consider that the $x$ into the scope of a quantifier $\forall x$ must "range over" all the objects in the domain of the interpretation.
3) about your proof : in step 3, you apply Ax.3 : $∀xφ→[t/x]φ$. In the proof, we have that $\phi$ is $(Sa→Sx)$; thus $∀xφ$ is $∀x(Sa→Sx)$.
$(Sa→Sy)$ is $[y/x](Sa→Sx)$, where the variable $y$ is used as the term $t$.
Terms are : individual variables, like : $x,y,...$, individual constants, like $0$ in arithmetic), "complex terms", like $x+0$ in arithmetic.
In step 5, the proof uses modus ponens (or detachement : from $\phi$ and $\phi \rightarrow \psi$, infer $\psi$).
Thus, from 1) : $Sa$, and 4) : $Sa→Sy$, he deduces $Sy$.
Step 6 is derived form step 5 according to Ax.2 (called also Generalization rule : if $\vdash \phi$, then $\vdash \forall x \phi$).
Comment: If you have $Rxy \wedge \exists z Sz$, why not $\exists x (Rxy \wedge \exists z Sz)$? Why must it be $\forall x (Rxy \wedge \exists z Sz)$? There is nothing to my knowledge that lets my say "this applies to *all*" x's.
Comment: About 3) I understand, but to me it is not clear as to why it must be so that $x$ must be changed into $y$. The proof could just as well be done *without* doing this: $[x/x]$. Even stranger, from 5 to 6, it is changed back again to $x$!
Comment: @GarthMarenghi - "There is nothing to my knowledge that lets my say "this applies to all" x's."... It depends on you: on what you are saying... If you want to express : "all balls are black", you need : "for all x, if Ball(x), then Black(x)". If you want to say : "there is a white ball", you need : "exists an x such that Ball(x) and White(x)".
Comment: @GarthMarenghi - you are right - For all x means that you can "instantiate" it with a "name" (a *term*) whatever; thus, $y$ and $x$ and ... are all good. If you have found the proof into a textbook, I think that the author thinks that it is "more easy" to grasp if he cange the variable ... It seems not so.
Comment: Right, but universal instantiation says this: From $\varphi$ follows $\forall x \varphi$. The choice doesn't seem up to me, it is something that is ready for use.
Comment: It is from a textbook indeed, and after the third round through the book, I still can't find and still couldn't come up with a reasonable explanation.
Comment: I think the point is that $x$ is an indeterminate.
Comment: Yes, yes. See my updated answer. You can substitute anything in place of $x$.
Answer: The point is that $x$ denotes a general indeterminant (and not a constant), so if you can derive a proof of a formula, using the indeterminant $x$ in it, then the same proof will work when $x$ is replaced by anything else throughout.
A) If we think about semantics, i.e. the meaning of these formulas, then we can assign values to the variables, and a formula is said to be valid in an interpretation context ('model') if it is satisfied with respect to all possible evaluation of the variables.
This leads to the rule of universal generalisation in formal logic: $\phi(x,y)$ is regarded valid iff $\forall x,y:\phi(x,y)$ holds.
B) In step 3 we applied axiom 3 for $\varphi=\ (Sa\to Sx)$ and $t=y$, i.e. we substitute $y$ in place of $x$ in $\varphi$ (that is $[y/x]\varphi$).
The meaning of axiom 3 is that if a formula $\varphi$ holds for all $x$, then it can be specialized to anything else: whatever we write in place of $x$, the formula will be true.
From step 5 to step 6 we simply apply the generalization rule, which is axiom 2, used with variable $y$.
 Well, yes, we would obtain $\forall y Sy$ by that.
If we want to strictly continue to get it with $x$, apply axioms 3 and 2 again:

$\,$7. $\Sigma\vdash Sx $ by axiom 3. for $\forall y\,Sy$.
  $\,$8. $\Sigma\vdash \forall x\,Sx$ by axiom 2.
Comment: B) It is odd, I wish the authors would've mentioned anything like this in the book. As I mentioned to Mauro who also wrote an answer, the substitution could be done as well with $[x/x]$, no confusion needed!
Comment: Yes, I think, you are right. However, it is not standard to use the same variable in a bounded part and also free in the same formula.


Can you temporary grant a user permission to avoid captchas in drupal 7?

Question: I have a module which alters a webform's form. Depending on the user agent, I want to grant the current user the permission to skip captchas, so that the captcha block wont appear at the end of my webform. The problem is, within the init function of my module, if I enable the following line:
<code>if (functionWhichChecksStuff()) {
        user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('skip CAPTCHA'));
    }
</code>
the permission is being granted for ALL anons, every time since it actually grants the permission to that user role permanently.
Is there a way or function which does that dynamically and temporary?
Comment: So by "user" you mean always the anonymous user, not a logged in user?
Comment: correct, the sessioned user if you will
Answer: There are basic problems with your approach:

All anon users are one user for Drupal. They share common UID 0, so they are one user. And HTTP is a stateless protocol, so you can't decide "it's the same user" basing on connection. In Drupal 7 sessions are not guaranteed for anonymous users, so you can't use them reliably for that purpose either.
If you will try to modify $user->roles, it will add a role for current http call all right, but it will not regenerate caches, like admin/reports/status/rebuild or views caches based on roles.
hook_init docs says: This hook is not run on cached pages.

So, this is no-go by design, and if you need to give some privileges or options by browser session, you need to implement your own solutions, like cookies. There is a list of modules that works that way, you can use their code for reference.
Comment: "In Drupal 7 sessions are not guaranteed for anonymous users, so you can't use them reliably for that purpose either." - even if this was the case, webform does provide useful and reliable information reguarding that point.
i accomplished to simply unset the captcha block and disable caching for the whole node
Comment: Should work, as long as all you want is to grant that "permission" just during one form lifetime. I assumed your question to be a tad more general - like that solution should work even when form does not exist yet, work for all/choosen forms, work even if exact requirement is other than $_SERVER value...
Comment: well in this case i have a specific nid so its always that form. thanks anyway :)


popular dentro da textarea do mysql para o formulário

Question: public function geraFormTipo1(){

    return
<<<EOT

objQuestoes->numQuestao()}" {$this->isHide}>
            {$this->label()}

            {$this->estruturaMain()}

            Justifique sua resposta
            <textarea  name="resposta{$this->objQuestoes->numQuestao()}"><?php echo \$resposta{$this->objQuestoes->numQuestao()} ?></textarea>

EOT;
}

Dei um echo na string de retorno do método geraFormTipo1() e imprimi no HTML.
Quando acessei o html após a impressão, percebi que dentro da textarea ficou populada como: <?php $respostaA ?>. A intenção era que futuramente eu iria popular os dados do banco para o html, ou seja a variável que era pra ser de retorno (do banco para o html) está sendo impressa no textarea, o que é errado.
o que devo fazer para consertar o meu código?
por exemplo:
mandei printar dentro do index.php
$formulario = $new Questionario($objQuestoes);
$formHTML = $formulario->geraFormTipo1();

echo formHTML;

<textarea name="respostaA"><?php $respostaA ?></textarea>

iria popular do banco para o html futuramente.
o campo texto da minha textarea está printando <?php $respostaA ?>
Comment: o seu arquivo tem a extensão php? Você está usando alguma framework? Qual o seu servidor, `Apache` ou `php -S`?
Comment: não estou usando framework e a extensão está em php. estou usando apache.
Comment: Está usando xampp no Windows ou instalação manual (LAMP)?
Comment: estou usando xampp no windows. tentei hospedar no site, e deu a mesma coisa, as tags estão sendo printadas na textarea
Answer: Tente dessa forma, talvez eu tenha digitado algo errado, não testei, mas da pra entender a ideia
return"
    objQuestoes->numQuestao()}' {$this->isHide}>
            {$this->label()}

            {$this->estruturaMain()}

            Justifique sua resposta
            objQuestoes->numQuestao()}'>Resposta
{$this->objQuestoes->numQuestao()}

        ";


Linear Regression and Spatial-Autocorrelation

Question: I want to predict Tree Heights in a certain area using some variables obtained through remote sensing. Like approximate Biomass, etc. I want to first use a linear regression (I know it's not the best idea but it is a must step for my project). I wanted to know how badly can spatial autocorrelation affect it and what is the easiest way to correct this if it is even possible. I'm doing everything in R by the way.
Comment: If you do see spatial autocorrelation in the residuals you can include the observations at nearby locations ("spatial lags") as predictors in the model as Sameer suggests. Another option for handling spatial autocorrelation is to model the spatial trend by including a semi-parametrically estimated function of the spatial coordinates using, for example, a generalized additive model. See [this related question](http://stats.stackexchange.com/questions/35510/why-does-including-latitude-and-longitude-in-a-gam-account-for-spatial-autocorre) for more info.
Answer: Moran's I is a diagnostic statistic that can be used to detect spatial autocorrelation in the residuals of a regression, given that you have a weight matrix $\mathbf{w}$, with entries $w_{ij}$ representing distances between observation (residuals) $X_i$ and $X_j$. You can think of it as a spatially-weighted measure of correlation. Significance of the statistic can be calculated analytically or perhaps with non-parametric re-sampling methods (e.g. jackknife). Another method for doing something similar is the Lagrange multiplier test.
If a statistically significant autocorrelation is detected in the residuals, physically proximal observations have to be included in the regression model, similar in vein to what is done in a time-series.
Luckily, for the R user, there is an Analysis of Spatial Data CRAN task view; one recommend package is the spdep, which has the requisite functions (and illustrative vignettes).
Comment: (+1) The author of `spdep` also has a nice textbook about spatial data analysis in `R` [here](http://www.springer.com/public+health/book/978-0-387-78170-9). I own this book and have found it very useful.
Comment: Just for completeness Geary's C is also a measure of spatial correlation. https://en.wikipedia.org/wiki/Geary's_C


problem in copy string for other class

Question: In my app I am sending a request to the web server and getting some results, then I am parsing this result and storing this result string into other class object string.
For example:
@interface GraphView : UIViewController<UITabBarControllerDelegate> {

NSMutableString *graphTempString;

}
@property(nonatomic,retain) NSMutableString *graphTempString;
@end

TSUClass .m
implementing NSURLConnection(),
connectionDidFinishLoading(),

-(void) parser:(NSXMLParser *) parser didStartElement:(NSString *) elementName
 namespaceURI:(NSString *) namespaceURI qualifiedName:(NSString *) qName
attributes:(NSDictionary *) attributeDict()

-(void)parser:(NSXMLParser *)parser
didEndElement:(NSString *)elementName
 namespaceURI:(NSString *)namespaceURI
qualifiedName:(NSString *)qName
{
    if( [elementName isEqualToString:@"statusTEResult"])
    {
        tempString=soapResults;
        if (grpahCall == YES) {
            graphViewController=[[GraphView alloc]init];
            graphViewController.graphTempString=tempString;

            [self.navigationController pushViewController:graphViewController animated:YES];
        }

When I am debugging I can see the value of graphViewController.graphTempString but after going to GraphView, I am not able to see the values.
I hope some one know how to solve this issue.
Comment: How do you know resultString isn't nil as well?
Comment: I tried with NSLog(resultString);and also in debugger I can see the value of reslutString
Comment: What does your property look like in your .h file for 2ndClassObj ?
Comment: also when i am copying into tempString on debugger I can see the value in tempString but when i am in 2ndClass by using   [self.navigationController pushViewController:2nClassObj animated:YES]; and i am checking value of tempSting its show "nil"
Comment: in .h file 2ndClass *2ndClassObj;
Comment: have u created the property of NSString like this @property (nonatomic, retain) NSString *tempString;
Comment: yes, @property (nonatomic, retain) NSMutableString *tempString;
Comment: make it simple NSString. i think resultstring is also NSString. it may create the peoblem.and i aslo gave esy solution to pass the value.
Comment: @DavidM - I assume that's already been done? The OP has looked at resultString in the debugger?
Comment: If resultString is an NSString and your property is an NSMutableString don't you get a compiler warning when you build your code?
Comment: i am using only NSMutableString and my resultString is also NSMutableString
Comment: OK,can you post your real code instead - there's nothing wrong with the code you've posted in the question so it must be something else!
Comment: mainClass .h file "NSUmtableString *resultStirng" then i set @property and @synthesize in .m file, also in 2ndClass file .h "NSUmtableString *tempStirng" also set @property and @synthesize in .m file then in ,main class .m file i am creating object for 2nd class 2nClassObj = [[2ndClass alloc]init];
2nClassObj.tempString = resultString;
[self.navigationController pushViewController:2nClassObj animated:YES];
Comment: 2nClassObj.tempString =[NSMutableString stringWithString:resultString];
Comment: @Pooja - you can edit your question to put the code in - and you can't start a class name with a number so that's still not your real code. The code you've put in your question is correct so the error is somewhere else in your code - without the real code we can't help you!
Comment: ok, i will do it give me 20 mins thanks for advice
Comment: what a mess... That's what happens when a question is not well formulated and/or with enough details...! :)
Comment: graphViewController.graphTempString=self.tempString;
Answer: Easy way to pass value.
[[NSUserDefaults standardUserDefaults]setObject:resultString forKey:@"resultString"];
[[NSUserDefaults standardUserDefaults] synchronize];

and in another class use this value like this
NSString *resultString=[[NSUserDefaults standardUserDefaults]valueForKey:@"resultString"];

or u may do it like this.
graphViewController.graphTempString=self.tempString;

Comment: How is this better than a property?
Comment: There's a problem with this that's not immediately obvious. What happens if you do this for every variable that you need to pass around? You will fill up your NSUserDefaults which will cause your app to startup slower etc. You also run the risk of reusing the same name for variables by mistake i.e. what if you had a 3rdClass that also wanted to pass around a 'resultString'?
Comment: i agree with deanWomboume, i tried with NSUserDefaults I feel its very slow
Comment: no way its not slow at all... u can use this value anywhere in the application. its best future. if its slow then why apple provide this kind of feature.
Comment: It's for storing values between different runs of the app. Not for just passing variables between classes. That's why @property exists!
Comment: @rkloves, NSUserDefault is working perfectly for me thank you very much but still i am eager to know why its not happening with property
Comment: @rkloves But your answer uses NSUserDefaults, something designed for a different purpose and it uses it badly. And there is obviously something wrong with the original code and you make no attempt to find it!
Comment: @deanWombourne we can save array also in NSUserDefaults. its of-course used for store value and used it whenever we want to use.. we can save username password that kind of things. we can save game state. nothing wrong in this.
Comment: @pooja i have to check your whole code. u did something else mistake. u can send me ur code to my email. or you can use NSUserDefaults its also easy way. thnx for accepting my answer.
Comment: @Rakesh Yes, between runs of the app it's perfect. (though it's not secure so perhaps not passwords!) But just to pass an NSString between two objects its absolutely the wrong thing to do :)
Answer: can you try
2nClassObj.tempString =[NSString stringWithFormat:@"%@",resultString];

good luck
Comment: did you try to nslog tempstring before pushing, is you tempstring being allocated?
Comment: i set the property, should i have to allocate too like tempString=[[NSMutableSting alloc]init];?
Comment: if you have not initialize the string then yes you have to,in your 2ndClass.m `-(id) init { if(self=[super init]) { tempString=[[NSMutabaleString alloc]init];] } return self; }` try this
Answer: @Pooja i suggest you to try doing this by making a variable in AppDelegate class give your resultString to this variable and then fetch the value from this variable in your 2ndClass or in any class you want .....you will never get null value.
Lets suppose the object of your AppDelegate class is appDelegate and the variable which of NSString type is lets stringValue. Then in your class where you are getting the resultString do like this.
appDelegate.stringValue = resultString;

And in your 2ndClass class take the value from this variable like this.
tempString =  appDelegate.stringValue;

You will get the data.....Hope you got my point.
Good Luck!
Answer: What happens if you add some NSLog statements?
    if (grpahCall == YES) {
        graphViewController=[[GraphView alloc]init];

        NSLog(@"-%@-", tempString);
        graphViewController.graphTempString=tempString;
        NSLog(@"-%@-", graphViewcontroller.graphTempString);

        [self.navigationController pushViewController:graphViewController animated:YES];
    }

I would expect to see the same thing output twice? Can you tell me what you get in the console?
Comment: application is crashed with Error : Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GraphView setGraphTempString:]: unrecognized selector sent to instance 0x6363220' after graphViewController.graphTempString=tempString;
Comment: Wow. that's not what I expected at all! It's trying to call setGraphTempString which shoudld work fine - it looks like there is something wrong with your graphTempString property - can you add GraphView .h file to the question please?
Comment: OK, that .h file looks fine. I assume you also have `@synthesize graphTempString` in your GraphView.m file?
Comment: OK, I give up - as far as I can see you are doing everything absolutely correctly. I can't think of anything else to try without actually having your code on my machine and running it myself in the debugger :( When you do find out what's going wrong can you update the question with the solution - I'm really interested to see what's going on! Thanks.
Comment: @deanWomboume, can you advice me for my Question : http://stackoverflow.com/questions/5579054/need-suggession-for-access-file

problem in copy string for other class


Let $V = \text{span}\{x_1,x_2\}$ , where $x_1 = \begin{pmatrix} 3 \\ 6 \\ 0 \end{pmatrix} $ and $x_2 = \begin{pmatrix} 1 \\ 2 \\ 2 \end{pmatrix} $ .

Question: Let $V = span\{x_1,x_2\}$ , where $$x_1 = \begin{pmatrix}
3 \\
6 \\
0
\end{pmatrix}
$$  and $$x_2 = \begin{pmatrix}
1 \\
2 \\
2
\end{pmatrix}
$$ . Then orthogonal basis $(v_1,v_2)$ for $V$ is given by

$$v_1 =\begin{pmatrix}
3 \\
6 \\
0
\end{pmatrix}
$$ , $$v_2 =\begin{pmatrix}
0 \\
0 \\
1
\end{pmatrix}
$$

$$v_1 =\begin{pmatrix}
3 \\
6 \\
0
\end{pmatrix}
$$ , $$v_2 =\begin{pmatrix}
0 \\
0 \\
2
\end{pmatrix}
$$

$$v_1 =\begin{pmatrix}
3 \\
0 \\
6
\end{pmatrix}
$$ , $$v_2 =\begin{pmatrix}
1 \\
0 \\
0
\end{pmatrix}
$$

$$v_1 =\begin{pmatrix}
3 \\
0 \\
6
\end{pmatrix}
$$,$$v_2 =\begin{pmatrix}
0 \\
0 \\
2
\end{pmatrix}
$$

We know that if $V = \{v_1,v_2,...,v_k\}$ be the set of vectors in $\Bbb R^n$ then $S$ is called an orthogonal if $v_i•v_j = 0, \forall i \neq j$. Here all options satisfy above property. I think all options are correct but I'm not sure. Please help me.
Comment: you need to verify  if $v_1,v_2$ are both linear combinations of $x_1,x_2$.
Comment: I swear the 3rd and 4th options, the vectors are not orthogonal, unless the dot product I am thinking is not the same as the one you are thinking
Comment: Could you try to be a bit clearer about what don't understand ? I do not really see your question here.
Comment: Options 1-2 are the same, meaning: the span of both vectors in 1 and in 2 is the very same.
Answer: From what I understand about the question
$V = span  \left(\begin{bmatrix}
3\\
6\\0
\end{bmatrix}, \begin{bmatrix}
1\\
2\\2
\end{bmatrix}\right) ~$  of  $~\mathbb{R}^3 $ with basis $\vec x_{1}= \begin{bmatrix}
3\\
6\\0
\end{bmatrix} $ and $\vec x_{2} = \begin{bmatrix}
1\\
2\\2
\end{bmatrix} $
Note :

Orthonormal vectors have a length of one unit

Orthonormal vectors are orthogonal to each other. Their dot product
should be zero.

Finding orthonormal basis :
$\vec u_{1} = \frac{1}{\| \mathbf{\vec x_{1}} \| } \cdot \vec x_{1} = \frac{1}{\sqrt{45}}  \begin{bmatrix}
3\\
6\\0
\end{bmatrix} $
To find $~ \vec u_{2} $ we need following equations :
$$ \vec x_{2} = \vec x^{||}_{2} + \vec x^{\perp }_{2}$$
$$ \vec x^{\perp}_{2} =  \vec x_{2} - \vec x^{||}_{2} =  \vec x_{2} - proj_{L} \vec x_{2} = \vec x_{2} - \left( \vec u_{1} \cdot \vec x_{2} \right) \vec u_{1}$$
the equations basically means, finding $ \vec x^{\perp}_{2}$  of $\vec x_{2}$ which is orthogonal to a line spanned by $\vec u_{1}$, in turn orthogonal to the $\vec u_{1}$.
$  \vec x^{\perp}_{2} =  \begin{bmatrix}
1\\
2\\2
\end{bmatrix} - \left(  \frac{1}{\sqrt{45}}  \begin{bmatrix}
3\\
6\\0
\end{bmatrix} \cdot  \begin{bmatrix}
1\\
2\\2
\end{bmatrix} \right) \frac{1}{\sqrt{45}}  \begin{bmatrix}
3\\
6\\0
\end{bmatrix} $
$  \vec x^{\perp}_{2} =   \begin{bmatrix}
1\\
2\\2
\end{bmatrix} - \frac{15}{45} \begin{bmatrix}
3\\
6\\0 \end{bmatrix} $
$  \vec x^{\perp}_{2} = \begin{bmatrix}
0\\
0\\2 \end{bmatrix} $
$\vec u_{2} = \frac{1}{\| \mathbf{\vec x^{\perp}_{2}} \| } \cdot \vec x^{\perp}_{2} = \begin{bmatrix}
0\\
0\\1 \end{bmatrix} $

$\vec u_{1} = \frac{1}{\sqrt{45}}  \begin{bmatrix}
3\\
6\\0
\end{bmatrix} ,  ~\vec u_{2} = \begin{bmatrix}
0\\
0\\1 \end{bmatrix} $
Form orthonormal basis of $V$. Their dot product is zero and their lengths  are one units


Why does this nominally divergent limit of an infinite sum of bessel functions converge

Question: The setup isn't important, but in case you're curious, this is a physically relevant thing I'm trying to calculate that should have a finite value.
This equation gives the electric field of a small patch of voltage $V$ of length $l$ on the surface of a grounded conducting cylinder of radius $R$ in the center of the cylinder:
$$
|\mathbf{E}|=\frac{Vl^2}{2\pi R^3}\lim_{\epsilon\rightarrow 0^+}\sum_{m=1}^\infty \frac{\alpha_{1m}\exp\left(-\alpha_{1m}\epsilon\right)}{J_2(\alpha_{1m})}\approx 1.77578 \frac{Vl^2}{2\pi R^3}
$$
$J_1$ is the first Bessel function of the first kind, and $\alpha_{1m}$ is it's $m$'th zero (not including the one at $x=0$). The $\approx$ comes from me evaluating this numerically.
I understand that I cannot move the limit into the sum because if I do, the sum no longer converges. What I don't understand is why it even has a well defined limit with the limit outside of the sum.
For large $m$, the zeros go toward $\alpha_{1m}\rightarrow (m+1/4)\pi$. For large inputs $J_2(x)$ asymptotes to:
$$
J_2(x)\rightarrow -\sqrt{\frac{2}{\pi}}\sin\left(x+\frac{\pi}{4}\right)\sqrt\frac{1}{x}
$$
So it seems to me that the sum for large $m$ turns into:
$$
\sum_{m=N}^\infty m^{3/2} (-1)^m\exp(-m\pi\epsilon)
$$
And even if I add even and odd terms together, I should get
$$
\sum_{m'=N/2}^\infty m'^{1/2} \exp(-2m'\pi\epsilon)
$$
So I think as $\epsilon$ goes to zero, my sum will go to infinity. Certainly the above sum diverges, so I must have done something too handwavy with limits here. Strangely though, as $\epsilon$ goes to zero, the sum goes to a finite value.
Answer: New Answer. In this answer, we derive an integral representation of the limit. Using the special case of DLMF 10.6.2,
$$ J_1'(z) = -J_2(z) + \frac{J_1(z)}{z}, $$
we may write the sum as
\begin{align*}
\sum_{m=1}^{\infty} \frac{\alpha_{1,m}e^{-\epsilon \alpha_{1,m}}}{J_2(\alpha_{1,m})}
&= -\sum_{m=1}^{\infty} \frac{\alpha_{1,m}e^{-\epsilon \alpha_{1,m}}}{J_1'(\alpha_{1,m})}
= - \frac{1}{2\pi i} \int_{\mathcal{C}} \frac{z e^{-\epsilon z}}{J_1(z)} \, \mathrm{d}z.
\end{align*}
Here, $\mathcal{C}$ denotes the Hankel contor traversed in the positive sense. Now by noting that $J_1(z)$ grows exponentially as $\operatorname{Im}(z) \to \pm\infty$ in the region $\left|\arg(z)\right| \leq \frac{\pi}{2}$, we can deform the contour $\mathcal{C}$ to the imaginary axis traversed from top to bottom. Hence,
\begin{align*}
\sum_{m=1}^{\infty} \frac{\alpha_{1,m}e^{-\epsilon \alpha_{1,m}}}{J_2(\alpha_{1,m})}
&= - \frac{1}{2\pi i} \int_{i\infty}^{-i\infty} \frac{z e^{-\epsilon z}}{J_1(z)} \, \mathrm{d}z \\
&= \frac{1}{2\pi} \int_{-\infty}^{\infty} \frac{xe^{-i\epsilon x}}{I_1(x)} \, \mathrm{d}x \\
&\to \bbox[color:blue; padding:8px; border:1px dotted navy;]{ \frac{1}{2\pi} \int_{-\infty}^{\infty} \frac{x}{I_1(x)} \, \mathrm{d}x } \quad \text{as $\epsilon \to 0^+$},
\end{align*}
where we substituted $z = ix$ in the second step and $I_1(z)$ is the modified Bessel function of the first kind and order $1$. Thanks to the exponential growth of $I_1(x)$ as $x \to \pm\infty$, this integral can be efficiently approximated, yielding the numerical value of
$$ \approx 1.7757859970218740923 $$
as observed by OP.

Old Answer. In fact, turns out that
$$ \lim_{\varepsilon \to 0^+} \sum_{n=1}^{\infty} \frac{(-1)^n}{n^s} e^{-\varepsilon n} = -(1 - 2^{1-s}) \zeta(s) \tag{1} $$
for any $s \in \mathbb{C}$. In particular, when $s = -\frac{3}{2}$, we get
$$ \lim_{\varepsilon \to 0^+} \sum_{n=1}^{\infty} (-1)^n n^{3/2} e^{-\varepsilon n} = -(1 - 2^{5/2}) \zeta(-3/2) \approx -0.118681. $$
Although I am no expert of Bessel functions, I guess an analogous behavior is occurring in OP's sum limit as well.
Finally, let me demonstrate why we expect the limit in $\text{(1)}$ to have a finite value. To this end, let us consider, for example, the sum $ \sum_{n=1}^{\infty} (-1)^n  n^2 $. Although this does not converge,
$$ \sum_{n=1}^{\infty} (-1)^n  n^2 e^{-\varepsilon n} = - \frac{(1 - e^{-\varepsilon})e^{-\varepsilon}}{(1+e^{-\varepsilon})^3}, \qquad \operatorname{Re}(\varepsilon) > 0 $$
and hence letting $\varepsilon \to 0^+$ makes this converge to a finite value, which is $0$ in this case. This shows that this "exponential regularization" (or more commonly, Abel summation) is capable of facilitating cancellations between $(-1)^n n^2$'s. A similar thing occurs when $n^2$ is replaced by any power of $n$.
Comment: From a physicist's perspective: The equation I gave is a sum-version of the derivative of the Green's function (there's a way to take a derivative of a greens function then use it to match boundary conditions instead of using it to model a point charge). There is also an integral version of the Green's function. It kind of looks like you found a way to convert from my sum version of the Green's function to the integral version. Interesting that you consider integrals to be easier to evaluate numerically - but I can see that it is more self-evidently convergent. Thanks for all your help.
Comment: I didn't phrase that correctly.  I was actually trying to show the continuity of $\operatorname{Li}_{-3/2}$ as a function on $(-\infty, 0]$ (since that's seemingly sufficient to prove that $\lim_{\epsilon \to 0^{+}}\operatorname{Li}_{-3/2}(-e^{-\epsilon})= \operatorname{Li}_{-3/2}(-1) $).  And I assume you meant $\color{red}{z}= - \sigma + i  \xi $ and $\frac{|z|}{\sqrt{\pi}} x^{-1/2}e^{\color{red}{-}x}.$
Comment: @RandomVariable, That perfectly makes sense! Also, thanks for the corrections :)
Comment: this is very helpful - thanks so much. It's nice to see this is not such a surprising behavior after all. You've also given me plenty of search terms to learn more from.
Comment: Perhaps I'm looking at this wrong, but isn't the reason why equation $(1)$ is true for $s=-\frac{3}{2}$ is because the principal branch of $\operatorname{Li}_{-3/2}(z)$ is continuous at $z=-1$?
Comment: @RandomVariable, I agree it can be interpreted in terms of the behavior of the polylogarithm. What I am less sure about is whether the continuity of $\operatorname{Li}_{-3/2}(z)$ at $z=-1$ admits an easy, intuitive explanation. In fact, I'd love to hear if there is any!
Comment: I was thinking about using the representation $$\operatorname{Li}_{-3/2}(z) = \frac{z}{\sqrt{\pi}} \int_{0}^{\infty} \frac{x^{-1/2}e^{x}(e^{x}+z)}{(e^{x}-z)^{3}} \, \mathrm dx, $$ which can be derived by performing two integrations by parts on the integral representation $$\operatorname{Li}_{s}(z) = \frac{z}{\Gamma(s)} \int_{0}^{\infty} \frac{x^{s-1}}{e^{x}-z} \, \mathrm dx. $$
Comment: @RandomVariable, Great! The integral can be used, in conjunction with the DCT, to show the continuity of $\operatorname{Li}_{-3/2}(z)$ at $z=-1$.
Comment: To show that $\operatorname{Li}_{-3/2}(z)$ is continuous along the entire negative real axis, could we restrict $z$ to values in the interval $[-r, 0]$, for some arbitrary positive value $r$, and then use   $\frac{rx^{-1/2}e^{-x}}
{\sqrt{\pi}} $ as the dominating integrable function?
Comment: @RandomVariable, That will show the continuity of $\operatorname{Li}_{-3/2}$ as a function on $(-\infty, 0]$. To show that this is continuous as a function of complex variable, a slight modification is required: For $x=-\sigma+i\xi$ with $x\geq 0$, $\sigma\geq 0$, and $\xi\in\mathbb{R}$, $$\left|\frac{z}{\sqrt{\pi}}\frac{x^{-1/2}e^x(e^x+z)}{(e^x-z)^3}\right|=\frac{|z|}{\sqrt{\pi}}\frac{x^{-1/2}e^x\sqrt{(e^x-\sigma)^2+\xi^2}}{((e^x + \sigma)^2+\xi^2)^{3/2}}\leq\frac{|z|}{\sqrt{\pi}}x^{-1/2}e^x.$$
Answer: The following is a supplement to the second part of Sangchul Lee's answer that is labeled "Old Answer."
Let $\eta(s)$ be the Dirichlet eta function, which can be defined in terms of the Riemann zeta function as $ \eta(s)= \left(1-2^{1-s} \right) \zeta(s).$
To prove that $$\lim_{\varepsilon \to 0^+} \sum_{n=1}^{\infty} (-1)^n n^{3/2} e^{-\varepsilon n} = \operatorname{Li}_{-3/2}(-1) = - \eta(-3/2), $$ we'll use the dominated convergence theorem to show that the polylogarithm function $\operatorname{Li}_{-3/2}(x)$, as a function of the real variable $x$, is a
continuous function on  $[-1, 0]$. (We can show more, but that's all that's needed here.)
An integral representation for $\operatorname{Li}_{s}(x)$ that is valid for $\Re(s) >-2$ is   $$\operatorname{Li}_{s}(x) = \frac{x}{\Gamma(s+2)} \int_{0}^{\infty} \frac{t^{s+1} e^{t}(e^{t}+x)}{(e^{t}-x)^{3}} \, \mathrm dt, \quad \Re(s)>-2, x \notin[1, \infty). \tag{$\spadesuit$}$$
This integral representation can be obtained by performing two integrations by parts on the Bose–Einstein integral $$\operatorname{Li}_{s}(x) = \frac{x}{\Gamma(s)} \int_{0}^{\infty} \frac{t^{s-1}}{e^{t}-x} \, \mathrm dt, \quad \Re(s)>0, x \notin[1, \infty).$$
At $x=-1$, $(\spadesuit)$ is an integral representation for $-\eta(s)$ for $\Re(s) >-2$.
Plugging $s= - \frac{3}{2}$ into $(\spadesuit)$ gives $$\operatorname{Li}_{-3/2}(x) = \frac{x}{\sqrt{\pi}} \int_{0}^{\infty} \frac{t^{-1/2}e^{t}(e^{t}+x)}{(e^{t}-x)^{3}} \, \mathrm dt.  $$
But for $x \in [-1,0] $, $\frac{x}{\sqrt{\pi}}\frac{t^{-1/2}e^{t}(e^{t}+x)}{(e^{t}-x)^{3}} $ is dominated by the integrable function $$\frac{t^{-1/2}e^{-t}}{\sqrt{\pi}},$$   showing that $\operatorname{Li}_{-3/2}(x)$ is a continuous function on $[-1,0]$.

More generally, $\spadesuit$ can be used to show that $\operatorname{Li}_{s}(x)$ is a continuous function on $[-1,0]$ for any fixed value of $s$ such that $\Re(s) > -2$, showing that $$\lim_{\varepsilon \to 0^+} \sum_{n=1}^{\infty} (-1)^n \frac{e^{-\varepsilon n}}{n^{s}} = \operatorname{Li}_{s}(-1) = - \eta(-s) $$ for at least $\Re(s) >-2$.
Comment: Thanks. Now that I have a formal proof (a little outside my knowledge range - I'm a physicist, but a proof nonetheless) that the sum you considered converges, my sum can be written as a sum over sums of this form. This outer sum probably converges in a more trivial way. It probably also gives a way of evaluating my sum that converges very quickly.


How to show a group is infinite group by constructing epimorphism?

Question:
Consider a group G with representation
  $$\langle a,b\mid abab^{-1}a^{-1}b^{-1}\rangle$$
  Prove that this group is an infinite group.

There is similar question here (Finding the kernel of an epimorphism onto $S_3$? ) asking how to construct an epimorphism into $S_3$ and give a representation of the kernel. I believe this is the right way to approach this problem. However, the answers the Reidemeister-Schreier algorithm.
So my question is:
1) How to give a representation of the kernel just using the basic of group theory?
2) With 1) being proved, how to use this fact to prove the group is infinite?
PS: I know this is called the braid group. However, this question is asked by one of my friends (I feel ashamed that I cannot answer his question) who just begin his journey in group theory. So I do not want to use advanced tools to perform an overkill, and I believe this is possible.
Comment: You can prove the group is infinite by computing its abelianization, which is $\mathbb{Z}$.
Comment: Computing the kernel of the epimorphism onto $S_3$ is not a sensible way to prove that the group is infinite, which is much easier to prove directly, as Qiaochu Yuan pointed out.
Comment: Also, I think it is very unlikely that there is any easier or more elementary way of computing a presentation (not "representation") of the kernel than the Reidemeister-Schreier method.
Answer:
For point 1)

Finding the presentation of a kernel is relatively easy, as there is a standard algorithm, called the Reidemeister-Schreier algorithm. This has been implemented in, for example, GAP. I gave a rough explaination of the algorithm here, where there are also links to worked examples.

For point 2)

I'll explain two ways of showing this group is infinite. Only the second uses the Reidemeister-Schreier algorithm (which is an "advanced tool" and definitely "overkill"!). The first method is better here.
Method 1.
One way to show that a group $G$ is infinite is to find an epimorphism onto a known infinite group. You can do this here by computing the abelianization, which is $\mathbb{Z}$:
$$
\begin{align*}
\langle a,b\mid abab^{-1}a^{-1}b^{-1}\rangle^{ab}
&=\langle a,b\mid abab^{-1}a^{-1}b^{-1}, [a, b]\rangle\\
&=\langle a,b\mid ab^{-1}, [a, b]\rangle\\
&\cong\langle a\mid -\rangle\\
&\cong\mathbb{Z}.
\end{align*}
$$
Method 2.
Another way to show that a group is infinite is to find an infinite subgroup. This seems to be the method which the question is getting at, but is harder in this case. The link in the question proves that for $G=\langle a,b\mid abab^{-1}a^{-1}b^{-1}\rangle$ the group here, we have that $G\twoheadrightarrow S_3$ and the kernel of this map has presentation $$\langle x,y,z \mid y^{-1}x^{-1}yzxz^{-1}, y^{-1}zxyx^{-1}z^{-1}\rangle.$$
(This is the precise example in the linked question!) As Derek Holt points out in his answer to the linked question, this is a presentation for the Pure Braid Group on $3$ strands $P_3$, which is a known infinite group.
That said, the question states that the given group is $B_3$ itself. It is relatively clear that $B_3$ is infinite, as twisting two strands corresponds to a copy of $\mathbb{Z}$...