Error :"error LNK2019: unresolved external symbol"

Question: Im currently getting the following error when I compile my code:
1>Mapa.obj : error LNK2019: unresolved external symbol "public: void __thiscall Mapa::Collision(float,float,float,float,int,int,int,int)" (?Collision@Mapa@@QAEXMMMMHHHH@Z) referenced in function "public: void __thiscall Mapa::mapa1(float,float,int,struct ALLEGRO_BITMAP *,struct ALLEGRO_BITMAP *,int)" (?mapa1@Mapa@@QAEXMMHPAUALLEGRO_BITMAP@@0H@Z)

Heder File
    class Mapa
{
public:
    Mapa(void);
    ~Mapa(void);
    void Mapa::mapa1(float xp, float yp,int dir,ALLEGRO_BITMAP *party, ALLEGRO_BITMAP *mapa1,int moveSpeed);
    void Mapa::Collision(float xp,float yp,float ex,float ey,int width,int height,int dir,int moveSpeed);
    //const float moveSpeed;
};

And here is Function
    Mapa::Mapa(void)
{
}

Mapa::~Mapa(void)
{
}
enum Direction { DOWN, LEFT, RIGHT, UP };
int dir = DOWN;
void Collision(float xp,float yp,float ex,float ey,int width,int height,int dir,int moveSpeed)
{
    if( xp + width < ex || xp> ex+ width || yp+ height <ey || yp > ey +height)
    {
    }
    else
    {
            {
           if(dir==0)
         yp-=moveSpeed;
     else if(dir==1)
         xp+=moveSpeed;
     else if(dir==2)
         xp-=moveSpeed;
     else if(dir==3)
         yp+=moveSpeed;
    }
    }
}
void Mapa::mapa1(float xp, float yp,int dir,ALLEGRO_BITMAP *party,ALLEGRO_BITMAP *mapa1,int moveSpeed)
{

bool draw=true;
bool done=false;
bool active=false;
int sourceX,sourceY;
const float FPS = 60.0;
sourceX=0;
sourceY=0;
ALLEGRO_TIMER *timer = al_create_timer(1.0 / FPS);
ALLEGRO_KEYBOARD_STATE StatusKlawiatury1 ; // klawiatura
ALLEGRO_EVENT_QUEUE *event_queue = al_create_event_queue();
al_register_event_source(event_queue, al_get_keyboard_event_source());
al_register_event_source(event_queue, al_get_timer_event_source(timer));
    al_draw_bitmap(mapa1,0,0,0);
   al_start_timer(timer);
     while(!done)
    {
    ALLEGRO_EVENT events;
    al_wait_for_event(event_queue, &events);
    if(events.type == ALLEGRO_EVENT_KEY_UP)
        {
            switch(events.keyboard.keycode)
            {
            case ALLEGRO_KEY_ESCAPE:
                done = true;
            }
        }

    else if(events.type == ALLEGRO_EVENT_TIMER)
        {
            active=true;
            al_get_keyboard_state(&StatusKlawiatury1);
            if(al_key_down(&StatusKlawiatury1, ALLEGRO_KEY_DOWN))
            {
                yp += moveSpeed;
                dir= DOWN;
            }
            else if(al_key_down(&StatusKlawiatury1, ALLEGRO_KEY_UP))
            {
                yp -= moveSpeed;
                dir = UP;
            }
            else if(al_key_down(&StatusKlawiatury1, ALLEGRO_KEY_RIGHT))
            {
                xp += moveSpeed;
                dir= RIGHT;
            }
            else if(al_key_down(&StatusKlawiatury1, ALLEGRO_KEY_LEFT))
            {
                xp -= moveSpeed;
                dir = LEFT;
            }
            else
                active = false;
            Collision(xp,yp,0,426,627,61,dir,moveSpeed);
            Collision(xp,yp,700,273,647,53,dir,moveSpeed);
            Collision(xp,yp,0,128,695,58,dir,moveSpeed);
            Collision(xp,yp,0,0,351,20,dir,moveSpeed);
            Collision(xp,yp,770,0,351,20,dir,moveSpeed);
            Collision(xp,yp,0,0,0,600,dir,moveSpeed);
            Collision(xp,yp,800,0,10,600,dir,moveSpeed);
            Collision(xp,yp,0,595,800,10,dir,moveSpeed);
            if(active)
                sourceX+=al_get_bitmap_width(party)/2;
            else
                sourceX=20;
            if(sourceX >=al_get_bitmap_width(party))
               sourceX=0;

                draw = true;
        }

        if(draw)
        {

            draw=false;
    al_convert_mask_to_alpha(party, al_map_rgb(255,0,255));
    al_draw_bitmap_region(party,sourceX,dir*al_get_bitmap_height(party)/4,20,20,xp,yp,NULL);
    al_flip_display();
    al_draw_bitmap(mapa1,0,0,0);

        }
    }
}

I spent hours searching for solution.Both functions worked without problem when I executed them in main, but when I moved them to separate class it started showing errors. Any help would be apreciated.
Answer: The class qualifier Mapa:: is missing from the definition of the function.
void Maoa::Collision(float xp,float yp,float ex,float ey,int width,int height,int dir,int moveSpeed)

Comment: So obvious and yet I'm so blind xD Thanks.
Answer: The "LNK" part in the error tells you that the compiler succeeded, and that the problem is in the linker. C++ only requires a function declaration for code calling said function to compile, but it also requires a function definition to link.
In your case, the error tells you that the definition for Maoa::Collision is missing. And indeed there is no function definition for that member in your code, only a definition for a global function called Collision.
You need to change the function definition from
void Collision(float xp,float yp,float ex,float ey,int width,int height,int dir,int moveSpeed)

to
void Maoa::Collision(float xp,float yp,float ex,float ey,int width,int height,int dir,int moveSpeed)


What is the latest patched version of Tomcat7?

Question: I am running on tomcat version 7.0.52 , i know this is a old version. I looked into https://tomcat.apache.org/security-7.html, according to this page , the latest version is 7.0.68 , so i am in confusion, coz i am not sure if i am secure or not, since i cannot find a USN doc which tells me to upgrade my 7.0.52 tomcat7 to UPPER version.
I need to make sure that i am secure and if this upgrade to 7.0.68 is necessary or not. If it is, will it break anything?
Comment: Yeah, there are 14 known vulnerabilities (CVEs) in 7.0.52. Tomcat recommends the 8.x train anyways (and yes, if you choose to stay on the 7.x train please install 7.0.68). What are you doing running such an old version? It's a misnomer that security updates break things. What's broken is the modern system administrator and their management teams. Install yum-cron or unattended updates. You can specify only medium-risk and above security updates. Just do it!
Comment: Did you even look? https://tomcat.apache.org/security-7.html (which you mentioned yourself) lists all needed information, including the CVE.
Comment: can u just point me to the CVE , i will be upgrading the instances soon
Comment: @SteffenUllrich  yes, already did, in my question, i am more curious how can i upgrade with breaking stuff
Answer: You can start by using their GUI tool to check configuration file differences between your version and the latest (7.0.69):

and paying attention to the "noteable changes" that might be of interest between the versions, i.e.:

In 7.0.63 onwards, the meaning of value 0 for maxPostSize attribute on
  connectors was changed to mean a limit of zero rather than no limit to
  align it with maxSavePostSize and to be more intuitive.


Improve LAMP performance Ubuntu 12.0.4

Question: cpu 1.3%
mem 476/490MB
swap 347/511mb

tasks: 43, 29 thr; 1 running
load average: 0.10 0.08 0.06

via htop:

/usr/sbin/apache2 -k start (listed 8x @ 8.1% mem each)
/usr/sbin/mysqld (listed 24x @ 2.1% mem each)

if I restart apache, pages load much quicker. after few days, page load takes much longer.
running small wordpress site with < 100 daily visits on vps with 512mb. didn't run into this problem before transfer to vps. it was previously on shared hosting.
how can i improve performance without restarting each time? where should i start looking for potential issues? if htop doesn't provide enough information, what commands should i run to provide additional details?
Comment: possible duplicate of [LAMP Server Performance Tips](http://serverfault.com/questions/11739/lamp-server-performance-tips)
Comment: @yoonix i looked at the tips you linked but it help trying to figure out if htop is indicating any potential issues with the multiple listings.
Comment: nothing to do with your hardware
Comment: @Charles Please check this answer I provided to a similar question: http://serverfault.com/questions/551727/how-much-free-memory-should-i-have-on-my-webserver/551734#551734
Answer: Problem: You are running a memory heavy web server application and a non-lightweight database on a single server with only 512M of memory and a 1:1 ratio of swap to RAM.
Solution: Get better hardware.
Comment: @Charles wordpress eats memory for breakfast and has lots of snacks on it thereafter.
Comment: are you saying that a vps with 512mb can't handle one small wordpress site with less than 100 daily visits?
Comment: WordPress is great but a memory hog. But that said, you can always performance tune Apache & MySQL to improve things without a RAM upgrade. But as the site grows it is inevitable that you will need one.

Improve LAMP performance Ubuntu 12.0.4


Flask socketio server + React socket.io-client connection refused

Question: I'm not able to connect from React frontend to python backend.
This is the error
polling-xhr.js:268 GET http://localhost:5000/socket.io/?EIO=3&transport=polling&t=NEzs39W net::ERR_CONNECTION_REFUSED

frontend side code ( listening on http://localhost:3000 ):
import React from 'react';
import { render } from 'react-dom';
import io from "socket.io-client";

class App extends React.Component {

   constructor(props) {
       super(props);

       const socket = io('http://localhost:5000');

       socket.on('connect', (error) => {
           console.log(error);
       });
   }

   render() {
       return
Hi!

   }
};

render(
   <App />,
   document.getElementById('root')
);

backend side code:
from flask_cors import CORS
from flask_socketio import SocketIO, emit

app = Flask(__name__)
cors = CORS(app, resources={r"/*":{"origins":"*"}})
socket = SocketIO(app)

if __name__ == '__main__':
    socket.run(app, host='0.0.0.0', port=5000)

What's wrong with my code?
Thank you
Answer: Here you shouldn't assign any variable to CORS:
cors = CORS(app, resources={r"/*":{"origins":"*"}})

instead try using:
 CORS(app, resources={r"/*":{"origins":"*"}})

Comment: Still not connecting after the change you suggest
Comment: No Errors. Only the same message of connection refused on the browser


Why Is Object Still In Memory Snapshot After Destructor Called

Question: I'm investigating a memory leak and am wondering why after the destructor is called the object Count and Size doesn't change in the memory snapshot. It does look like the Inclusive Size does go down, but not to zero. There are two rows as the first is a view and the second is its view model.

Can anyone explain why this happens? Thank you in advance.
EDIT: I just took another memory snapshot after writing this question up (maybe ~5 minutes later) and it seems the objects are now gone so maybe it just takes some time for everything to go away like longer than a few seconds after the destructor?
Comment: what type of object is it? theres different levels of gc. i suggest you read up on that
Comment: @DanielA.White Can you be a little more specific with regard to what you mean by "type?" Do you mean which generation or some priority property?
Comment: what size of object is it? does it have unmanaged references, etc.
Answer:
Can anyone explain why . . . the destructor is called the object Count and Size doesn't change in the memory snapshot

.NET doesn't have destructors.  It has finalizers which are only indirectly related to memory management.  An object with a finalizer cannot be garbage collected until after the finalizer is run (or you call GC.SupressFinalize).  But the object is not immediately garbage collected after its finalizer runs.
When GC finds an (otherwise) unreachable object with a finalizer a reference to the object is put on the freachable queue, and the finalizer thread runs the finalizer on all the objects that end up there.  The object will be eligible for garbage collection on the next GC run after its finalizer runs.  Note that since the object has already survived a GC it will be at least on Gen1.  And if it's on Gen2 it may be a while until it's collected.
The decision to reuse C++ destructor syntax for C# finalizers was probably a mistake.


Replace rewrite output URL aliases

Question: Is it possible to rewrite parts of taxonomy terms URL custom aliases before output, for example with something similar to the the following code?
  function replace_term_url ($term_alias) {
    // Url alias "article/first"
    $term_alias = str_replace("article", "article-sub", $term_alias);
  }

Answer: In Drupal 7 there isn't a specific hook to alter the URL associated with a taxonomy term, but you can use the generic hooks for altering URLs, which are hook_url_inbound_alter(), and hook_url_outbound_alter().
function mymodule_url_outbound_alter(&$path, &$options, $original_path) {
  if (preg_match('|^taxonomy/term/([0-9]*)|', $path, $matches)) {
    // Alter $path; $matches[1] contains the term ID.
  }
}

function mymodule_url_inbound_alter(&$path, $original_path, $path_language) {
  // Revert the change done in mymodule_url_outbound_alter().
}

hook_url_outbound_alter() is invoked for URLs output from Drupal, hook_url_inbound_alter() is invoked for URLs Drupal is receiving.
In Drupal 6, it is possible to implement hook_term_path(), but that is invoked only for the module associated with the taxonomy term. The code invoking that hook is in taxonomy_term_path().
  if ($vocabulary->module != 'taxonomy' && $path = module_invoke($vocabulary->module, 'term_path', $term)) {
    return $path;
  }

If you want to use a third-party module, then there is the Pathauto module, which allows to automatically set the alias for users, nodes, and taxonomy terms.

The Pathauto module automatically generates URL/path aliases for various kinds of content (nodes, taxonomy terms, users) without requiring the user to manually specify the path alias. This allows you to have URL aliases like /category/my-node-title instead of /node/123. The aliases are based upon a "pattern" system that uses tokens which the administrator can change.
Comment: Hi kiamlaluno, thx for your answer. i know "Pathauto" and url_inbound_alter / url_outbound_alter. But with ...alters it's possible to get an original path ( taxonomy/term/%, etc.) and not alias (category/cars, etc.). I need to replace or delete parts of alias path.
Comment: If you implement both the hooks, so that pathA is replaced with pathB in `hook_url_outbound_alter()`, and pathB is replaced with pathA in `hook_url_inbound_alter()`, then it is like having a path alias. What I reported are the only ways I know of.
Answer: You should be able to do that with the Pathauto module:
You can use it to set up automatic aliases for taxonomy terms, as well as content and other things.

Replace rewrite output URL aliases


Sufficient condition for a Markov chain with tridiagonal transition matrix to be null recurrent

Question: Consider the random walk induced by the Markov matrix
\begin{equation}
\begin{Vmatrix}P_{ij}\end{Vmatrix}=
\begin{Vmatrix}
r_0 & p_0 & 0 & 0 & \cdots \\
q_1 & r_1 & p_1 & 0 & \cdots \\
0 & q_2 & r_2 & p_2 & \cdots \\
\end{Vmatrix}
\end{equation}
Let
\begin{equation}
\pi_0=1,\pi_n=\frac{p_0p_1\cdots p_{n-1}}{q_1q_2\cdots q_n}.
\end{equation}
Assume that the Markov chain is recurrent. Show that
\begin{equation}
\sum^\infty_{i=0}\pi_i=\infty\Longrightarrow\mathrm{null\;reccurent}
\end{equation}
\begin{equation}
\sum^\infty_{i=0}\pi_i<\infty\Longrightarrow\mathrm{positive\;reccurent}
\end{equation}
I have completely no idea. Please give me a hint.
Answer: If $\lim_{n\rightarrow\infty}P^n_{ii}=b_i>0$ for one $i$ in an aperiodic recurrent class, then $b_j>0$ for all $j$ in the class of $i$. In this case, we call the class positive recurrent or strongly ergodic. If each $b_i=0$ and the class is recurrent we speak of the class as null recurrent or weakly ergodic.
Theorem In a positive recurrent aperiodic class with states $j=0,1,2,\cdots$,
\begin{equation}
\lim_{n\rightarrow\infty}P^n_{jj}=b_j=\sum^\infty_{i=0}b_iP_{ij},\;\sum^\infty_{i=0}b_i=1
\end{equation}
and the $b$'s are uniquely determined by the set of equations
\begin{equation}
b_i\geq0,\;\sum^\infty_{i=0}b_i=1,\;\mathrm{and}\;b_j=\sum^\infty_{i=0}b_iP_{ij}
\end{equation}
We investigate the existence of a stationary probability distribution, i.e., we wish to determine the positive solutions of
\begin{equation}
(p_i+q_i)x_i=\sum^\infty_{j=0}x_jP_{ji}=p_{i-1}x_{i-1}+q_{i+1}x_{i+1},\;i=0,1,\cdots,\;(1)
\end{equation}
under the normalization
\begin{equation}
\sum^\infty_{i=0}x_i=1,
\end{equation}
where $p_{-1}=0$, and thus $x_0=q_1x_1+r_0x_0$. Using Equation (1) for $i=1$, we could determine $x_2$ in terms of $x_0$. Equation (1) for $i=2$ determines $x_3$ in terms of $x_0$, etc. It is immediately verified that
\begin{equation}
x_i=\frac{p_{i-1}p_{i-2}\cdots p_0}{q_iq_{i-1}\cdots q_1}x_0=x_0\pi_i,\;i\geq1,
\end{equation}
is a solution of (1), with $x_0$ still to be determined. Now since
\begin{equation}
1=x_0+\sum^\infty_{i=1}x_0\pi_i=\sum^\infty_{i=0}x_0\pi_i,
\end{equation}
we have
\begin{equation}
x_0=\frac{1}{\sum^\infty_{i=0}x_0\pi_i}
\end{equation}
and so
\begin{equation}
x_0>0\;\mathrm{if\;and\;only\;if}\;\sum^\infty_{i=0}x_0\pi_i<\infty.
\end{equation}
Combining this result, the definition, and the theorem, we get the desired sufficient condition.


Parsing a binary tree-like JSON Object level by level in javascript

Question: I was messing around with binary tree ADT implementation of javascript and was wondering if someone could help me out with parsing this particular json object.
{"root":{"info":1,"right":{"info":3,"left":{"info":2,"count":1},"right":{"info":5,"left":{"info":4,"count":1},"count":1},"count":1},"count":1}}

A quick http://json.parser.online.fr/ online says that the output should be:
1
3
2 5
4

if I am to print the json level by level. "info" holds the data of the tree node, and "left" & "right" points to sub nodes. My printTreeByLevel,
this.printTreeByLevel = function(node){

  nodesQueue = [];
  var nodesInCurrentLevel = 1;
  var nodesInNextLevel = 0;
  nodesQueue.push(node);
  while (nodesQueue.length != 0) {
    currNode = nodesQueue[nodesQueue.length-1];
    nodesQueue.pop();
    nodesInCurrentLevel--;
    if (currNode) {
       document.getElementById("main").innerHTML =    document.getElementById("main").innerHTML + currNode.info +"   ";
      nodesQueue.push(currNode.left);
      nodesQueue.push(currNode.right);
      nodesInNextLevel += 2;
    }
    if (nodesInCurrentLevel == 0) {
      document.getElementById("main").innerHTML =    document.getElementById("main").innerHTML + "
";
      nodesInCurrentLevel = nodesInNextLevel;
      nodesInNextLevel = 0;
    }
  }
}
}

produces
1
3 5
4
2

Comment: Just a note: You have a plain-old JavaScript `object`, nothing to do with `JSON` which is a way of serializing data.
Answer: You were parsing the tree in depth-first instead of breath-first and that's why the elements did not appear in the order you wanted them.
What this means
At every iteration you were actually getting the last inserted element. This lead to you actually printing in depth instead of parsing the tree in the order it was inserted (on levels).
Here is a JSFiddle: https://jsfiddle.net/duha7tx3/
And here is the piece of wrong code:
currNode = nodesQueue[0];
nodesQueue.splice(0, 1);

What I am doing here is that I am getting the first element and then removing it from the array. Parsing the tree in this way means I am visiting all nodes on current level before going to the next one. The way you did it meant that you were visiting the nodes on the next level before visiting the ones on the current.
Hope this answers your question.


how to do cauchy product of sums

Question: For example, how to do cauchy product of $$\ln(1-x)*\ln (1-x)=\ln ^2 (1-x)$$
should it go like this?
$$\ln(1-x)=-\sum_{k=1}^{k=\infty}\frac{x^{k}}{k}$$
$$\ln ^2 (1-x)=\sum_{n=1}^{n=\infty}x^{n}\sum_{k=1}^{k=n}\frac{1}{k(n-k)}$$
Here , when n=k its 1/0 , how to fix this?
Also, for example, how ot find $$\arctan ^2(x)$$. thank you.
Answer: Cauchy product of $\sum_0^\infty a_n x^n $ with $\sum_0^\infty b_n x^n $ is $\sum_0^\infty c_n x^n $ where $c_n=\sum_{k+l=n} a_k b_l$. To apply this formula you should "pad the series" with a zero at the zeroth term:
$$\ln(1-x) = \sum_{n=0}^\infty a_n x^n, \quad a_n= \begin{cases} 0 & n=0 \\ -1/n & n>0\end{cases}.$$
Then
$ \ln^2(1-x)=\sum_{n=0}^\infty c_n x^n$ with
$$ c_n = \sum_{k+l=n} a_k a_l=\sum_{\substack{k+l=n \\ k>0\text{ and }l>0}} a_k a_l + \underbrace{\sum_{\substack{k+l=n \\ k=0\text{ or }l=0}} a_k a_l}_{=0}=\sum_{k=1}^{n-1} \frac1{k(n-k)}$$
Comment: did you mean 1/n when n>0? And, do i do such thing every time i do cauchy product? i mean, $$\sum_{k+l=n}a_{k}a_{l}=\sum_{k+l=n, k>0\land l>0}a_{k}a_{l}+\sum_{k+l=n,k=0or l=0}a_{k}a_{l}=...$$ i mean, do i decompose it into the part when both are  >0 and when one of them is 0. Also, whats the problem with the way i did it? Or is it just fine and i should fix it every time when i see it will be 1/0 with it going up to n-1 as you did.? Thank you.
Comment: Oh, its -1/n cuz its ln(1-x) , but see other things i wrote. please. thank you.
Comment: @VukStojiljkovic Cauchy product formula (at least, the one I was taught) requires that your series begins from zero. The problem is you were not careful and therefore found a 1/0. It's not enough to do that, what if the series started at $n=3$? Then you need to go to $n-3$. Better to actually learn why it is correct IMO
Answer: When doing the series multiplication we can perform the cauchy multiplication as usual, but we have to carefully consider the index limits. We obtain
\begin{align*}
\color{blue}{\ln^2(1-x)}&=\left(-\sum_{k=1}^\infty \frac{x^k}{k}\right)\tag{1}
\left(-\sum_{l=1}^\infty \frac{x^l}{l}\right)\\
&=\sum_{n=2}^\infty\left(\sum_{\substack{k+l=n\\k,l\geq 1}}\frac{1}{k}\,\frac{1}{l}\right)x^n\tag{2}\\
&\,\,\color{blue}{=\sum_{n=2}^\infty\left(\sum_{k=1}^{n-1}\frac{1}{k(n-k)}\right)x^n}\tag{3}\\
\end{align*}
Comment:

In (1) we see the  indices $k,l$ of both series start with lower limit $1$, so that $x^2$ is the term with the smallest positive exponent.

In (2) we collect the terms according to increasing powers of $n$. So, we consider indices $k+l=n$, but we also have to respect that $k,l\geq 1$ by explicitly noting it and we also start with lower index limit $n=2$.

In (3) we replace $l$ by $n-k$. Since both, $l,k\geq 1$ we have lower index limit $k=1$ and upper limit $k=n-1$.
Comment: we start with n=2 cuz we have the lowest x*x . then we need to move it to n-1 to be sure (n-k) is not zero. is that right?
Comment: @VukStojiljkovic: The upper limit $n-1$ of the inner sum follows solely from $k+l=n$ and $k,l\geq 1$. Since *both*, $k$ and $l$ are $\geq 1$ it follows from $k+l=n$ that $1\leq k\leq n-1$. We do not need to change the index $n$ of the outer sum.
Comment: but we could also say that $1<=l<= n-1$ , right? We just need to satisfy the condition?
Comment: @VukStojiljkovic: Correct. Looking at (2) we see the inner sum is symmetric with respect to $k$ and $l$. Consequently, we can replace $k$ with $l$ in (3).
Comment: thank you for your help :)
Comment: @VukStojiljkovic: You're welcome! :-)

how to do cauchy product of sums


Inverse Operators

Question: Let $(X,\Vert . \Vert)$ be a Banach space, assume that {${T_n}$} is a sequence of invertible operators in B(X) which converges to T $\in$ B(X). Suppose also that ${\Vert T_n ^{-1}\Vert}<1$, $\forall$ n$\in$ $\mathbb{N}$. $\\$ Show that T is invertible.
I don't even have an idea on how to go about this problem. Any help will be greatly appreciated. Thanks.
Comment: Do you mean that $\|T_n\|^{-1}<1$ for all $n$?
Comment: About the bound, is it really $\|T\|^{-1} < 1$, or is it $\|T_n\|^{-1} < 1$? Because of the $\forall n \in \mathbb{N}$ part after that.
Comment: That is how the question is given. But is see light in your observation, I think the correct thing should be  $\|T_n\|^{-1} < 1$. Thanks.
Comment: @VincentEbuka Does this question come from a book or lecture notes? I believe there is some error.
Comment: The lecturer wrote it that way on the board, as an assignment.
Answer: HINT
Try to use the data you are given to conclude that for some $n$, we have
$$\|TT^{-1}_n-1\|<1.$$
Because then by a standard argument, $TT_n^{-1}$ is invertible, and therefore $T$ is invertible with inverse $T^{-1}=T_n^{-1}(TT_n^{-1})^{-1}$.
Comment: Please where does the (-1) in $\|TT^{-1}_n-1\|<1$ come from. More explanation will be appreciated. Thanks.
Comment: We have $\|TT_n^{-1}-1\|=\|TT_n^{-1}-T_nT_n^{-1}\|\leq\|T-T_n\|\|T_n^{-1}\|$, so you want to get bounds on $\|T-T_n\|$ and $\|T_n^{-1}\|$.
Comment: Thanks for the hint. But I was thinking the expression $T^{-1}=T_n^{-1}(TT_n^{-1})^{-1}$ would be equal to Identity, $I$. Which shows that  $TT_n^{-1}$ is invertible. But instead it equals $T^{-1}$. Am I right? Thanks.
Comment: No.  If $T,S\in B(X)$ with $S$ and $TS$ invertible, then $TS(TS)^{-1}=I$, and $S(TS)^{-1}T=S(TS)^{-1}TSS^{-1}=SS^{-1}=1$, so $T$ is invertible with $T^{-1}=S(TS)^{-1}$.
Comment: Waw...Bravo. Thanks alot. I get it now. I am grateful.
Comment: Let ${c_n}$ $\in \ell^{\infty}$, and let $T_{c_n}$$\in$ B$(\ell^2)$, $\:$ be defined by $\\$

 $T_{c_n}$ ({$x_n$}) = {$c_nx_n$}. $\\$

 1. If inf {$\vert c_n \vert$: n $\in\mathbb{N}$} $\gt$ 0 , and $d_n$ = $\cfrac{1}{c_n}$ , $\\$

Show that $d_n$ $\in$ $\ell^{\infty}$, $\;$  and that $\:$ $T_{c_n}$$T_{d_n}$ = $T_{d_n}$$T_{c_n}$= I .$\\$

 2. If ${c_n}$ = $\cfrac{1}{n}$ ,$\:$ Show that $T_{c_n}$ is not invertible. $\\$

Please, can I have your take on it.
Comment: What are you having issue with?
Comment: In part (2) of the problem. Is it sufficient to say: If ${c_n} = \cfrac{1}{n}$, then ${d_n} = \cfrac{1}{c_n} = n $. And since $\ell^{\infty}$ is a space of all bounded sequence, $d_n \notin {\cal l}^{\infty}$. Thus $T_{c_n}$ is not invertible. Does it make sense and sufficient to answer the question. Thanks
Comment: You have the intuition, but I would not call that argument rigorous.  Here's one way to make it rigorous:  Assume you have an inverse $S$ of $T_{c_n}$.  Looking at how $S$ acts on the basis vectors of $\ell^2$, determine that $\|S\|>n$ for all $n\in\mathbb N$, a contradiction.
Comment: How is the $\|S\|$ greater than $n$. I don't seem to understand it. Thanks.
Comment: Because if $e_n$ denotes the $n$th standard basis vector of $\ell^2$, then $e_n=ST_{c_n}e_n=\frac{1}{n}Se_n$, so $Se_n=ne_n$.

Inverse Operators


How does Drupal display the correct time for a specific time zone?

Question: I have a custom module that displays today's date and time:
t('Today: ') . date('d F - H:i')

When I change a user's time zone on their account page the time is 'magically' outputted correctly.
How does Drupal do this?
Answer: I've never seen the code itself,  but it likely uses this: https://www.php.net/manual/en/datetime.settimezone.php
Answer: The magic comes from PHP's date_default_timezone_set():

Sets the default timezone used by all date/time functions in a script

Drupal uses it in

drupal_session_initialize()
drupal_session_regenerate()
_drupal_bootstrap_page_cache()


can we generate a random words from English letters that follow the bigram of the English language

Question: The main issue is that several research building their solution of detecting and classifying English language is based on bigram distribution. However, I would like to know if it possible to generate a random set of words that are not English (rubbish words) but still respect the bigram of the English language. Is there any idea on how we can construct that if possible?
Comment: Do you want to create a language with the same bigram or just a sequence of words without actual meaning ?
Comment: yes i want words without any meaning ...
Comment: Do you want to generate words which are surely rubbish? I mean your problem is that is expensive to check if a word is rubbish or not and you want a procedure which produces only rubbish?
Comment: Please do not change your question after it has been discussed and answered. If you have a new question, then you may begin a new thread.
Answer: Sure: run a Markov chain.
This Markov chain should begin with a letter chosen randomly from the alphabet with probabilities proportional to the letter frequencies.  In order to distinguish words, the alphabet needs to include spaces (and other word separators, if they are being tracked, such as punctuation) and the bigrams need to include the spaces.
At each step in the chain, a transition is made from the current letter to another letter with probabilities proportional to the bigram frequencies.  The relevant bigrams are only those beginning with the current letter.  Transition frequencies are conveniently (and conventionally) maintained in a square array: the current letter indexes the rows and the next letter indexes the columns.
As an example, let's read the actual question text in this post, clean it a little to remove punctuation and sequences of whitespace, compute its bigrams, and estimate a transition matrix from these bigrams.  This code uses R:
#
# Create the bigram information.
#
text <- readLines("http://stats.stackexchange.com/q/115883")
i <- grep("\"post-text\"", text)[1]         # Find the post text
j <- grep("</div", text)                    # Find where it ends
j <- min(j[j > i])
s <- paste(text[(i+1):(j-1)], collapse=" ") # Paste lines together
s <- gsub("[^[:alnum:] ]+", " ", s)         # Remove non-alpha
s <- gsub("[[:blank:]]+", " ", s)           # Remove sequences of ws
s <- tolower(s)                             # Ignore case
s <- unlist(strsplit(s, character(0), fixed=TRUE)) # Convert to vector
bigrams <-table(s[-length(s)], s[-1])       # Bigram frequencies: rows->cols
s.freq <- table(s)                          # Letter frequencies

To illustrate, the letter frequency array s.freq begins like this:
                    a          b          c          d ...
0.17934783 0.05978261 0.02717391 0.01902174 0.02717391 ...

Spaces occur 18% of the time, "a" occurs 6% of the time, "b" occurs 2.7%, and so on.  The transition array in bigrams begins like this:
                        a          b          c          d ...
    0.00000000 0.06153846 0.07692308 0.04615385 0.03076923 ...
  a 0.09090909 0.00000000 0.00000000 0.00000000 0.00000000 ...
  b 0.00000000 0.10000000 0.10000000 0.00000000 0.00000000 ...
  c 0.00000000 0.14285714 0.00000000 0.00000000 0.00000000 ...
  d 0.30000000 0.00000000 0.00000000 0.00000000 0.00000000 ...
... ...        ...        ...        ...        ...

For instance--reading across the first row--a space is followed by an "a" 6% of the time, by a "b" 7.7% of the time, and so on.  A "b" is never followed by a space, is followed by an "a" 10% of the time, and so on.
Let's run this chain for the same length as the original post:
#
# Run a Markov chain.
#
set.seed(17)
a <- sample(names(s.freq), 1, prob=s.freq)  # Select a random start
text.sim <- sapply(1:length(s), function(i) {
  a.old <- a
  a <<- sample(colnames(bigrams), 1, prob=bigrams[a, ])
  return(a.old)
})
text.sim <- paste(text.sim, collapse="")    # Put the letters together
#text.sim <- strsplit(text.sim, " ")         # Split into words

The output in text.sim is

m en ist ra lll ilderdes aguth lag por ecth i cthon ibl is tis ibinge liglds ige ore dsuthain asiso idetenglire instid w il bishagre la isetisis tiblas m isi t rdol oratist asere pony wo bbld bul g she we sh pe le ne of t ke m p s buany ralildike t tissh of s ibbbbangeve pongre blectinon m onguco we westingled buba t ing te lirdsuaruath bbutr we ilithange isp worch

It doesn't look very English-like because the post was such a specialized subset of English.  For a more realistic result I used the text of the USA Declaration of Independence, which produced this:

ntese te heigluthasiolyr fothe bl abssucher apuriven ssthe tond f ong beantin ran whel nd c o ssthourfiry of lind dirbeng plan forn tarn arsth thecto peouredur h mplie ourn fo se cheghatofirin outt pratid pr woncatuf o theyr usthan athtse med hor thed as o tondeigize fis cin wis calalie iles tubal venetrs onid arild an ath te edeo ict he d ta ie aleiour in turincke pllenodinde one ren ollame than

Clearly bigrams are not very good: they do not consistently enforce basic rules, such as requiring a vowel to appear in each word.  But this approach does produce pseudo-words of the right lengths and, by and large, the words of more than one letter bear some facsimile to English. "... o theyr usthan athtse med hor thed ..." could even be mistaken for something out of an Old English text.
Some of the generated words, like "plan" and "of", are legitimate.  That's usually not a problem when simulating words to study text-mining algorithms, but if true non-words are needed, it's a simple matter to look all the words up in a dictionary and eliminate those that have a match.  (A relational database join would make short work of this step.)
Comment: Thanks for the answer, however, the first part is very clear. the general approach is also clear. I am just confused with the last step. how do you create back the letters from the matrix? can you explain in plain english rathar than R
Comment: This question is answered in the second paragraph: each letter encountered during the Markov chain is output sequentially.


What do/did you do to remember Bayes' rule?

Question: I think a good way to remember the formula is to think of the formula like this:
The probability that some event A has a particular outcome given an independent event B's outcome = the probability of both outcomes occurring simultaneously / whatever we'd say the probability of event A's desired outcome would be if we didn't know event B's outcome.
As an example, consider a disease test: If we have a patient who tests positive for a disease, and we know that: 40% of diseased persons tested positive on our test; 60% of all people have this disease; and 26% of all people tested positive for this disease; then it follows that:
1) 24% of all people we sampled tested positive and had the disease, meaning 24 out of 26 people who tested positive had the disease; therefore,
2) there is a 92.3% chance that this particular patient has the disease.
Comment: Learn the **derivation**, not the equation.
Comment: *"What do/did you do to remember Bayes' rule?"* uh, it's easy: I don't. +1 to @Anony-Mousse.
Comment: I find it easiest to just re-derive it each time I need it.
Comment: posterior is proportional to likelihood times prior
prior = p(A)
likelihood = p(A|B)
posterior = p(B|A)
Answer: It may help to recall that it follows from the definition of conditional probability:
$$p(a|b) = \frac{p(a,b)}{p(b)}$$
$$p(a,b) = p(a|b)p(b) = p(b|a)p(a)$$
$$p(a|b) = \frac{p(b|a)p(a)}{p(b)}$$
In other words, if you remember how joint probabilities factor into conditional ones, you can always derive Bayes rule, should it slip your mind.
Answer: A simple way that has helped my students is to write $P(A \cap B)$ in two different ways as conditional probabilities:
$P(A \cap B)=P(A|B)P(B)$
and
$P(A \cap B)=P(B|A)P(A)$
Then
$P(A|B)P(B)=P(B|A)P(A)$
and
$P(B|A)=\frac{P(A|B)P(B)}{P(A)}$
Answer: I worry about understanding the concept behind the formula. Once you have understood a concept, the underlying simple formula is stuck in your mind. Sorry for the stand-offish answer, but that's it.
Answer: I personally think this for is just easier to remember:$$P(A|B)P(B)=P(B|A)P(A)$$
Comment: ABB BAA. (You could also think ABBA, as in the name of the famous band.)
Answer: Here's my little unorthodox (and dare I say unscientific) trick for remembering Bayes Rule.
I simply say ---

"A given B equals the reverse times A over B"

That is to say,
The probability of A given B P(A | B) equals the reverse (B | A) times A over B P(A) / P(B).
Put in full,
$$P(A | B) = \frac{P(B | A) * P(A)}{P(B)}$$
And with that I never forget it.
Answer: If you have clear which terms have to go into the equation ("it is a formula that shows a direct proportionality between $P(A|B)$ and $P(B|A)$ using $P(B)$ and $P(A)$"), there is really only one possibility of confusion:
$$
P(B|A)=\frac{P(A|B)P(B)}{P(A)} \quad \text{vs} \quad P(B|A)=\frac{P(A|B)P(A)}{P(B)}.
$$
To remember what goes into the numerator, think to what happens if the event $B$ is impossible ($P(B)=0$). You want $P(B|A)$ to be zero, too, so it must be in the numerator.
Answer: A person --> disease --> test positive (red)
A person --> disease --> test negative (yellow)
A person --> no disease --> test positive (blue)
A person --> no disease --> test negative (green)
To better remember Bayes' rule, draw the above into a tree structure and mark the edges with color. Say we want to know P(disease | test positive). Given test result being positive, two possible paths are "red" and "blue", and conditional probability of having a disease is the conditional probability of being "red", thus P(red) / (P(red) + P(blue)). Apply chain rule and we have:
P(red) = P(disease) * P(test positive | disease)
P(blue) = P(no disease) * P(test positive | no disease)
P(disease | test positive) = P(disease) * P(test positive | disease) / (P(disease) * P(test positive | disease) + P(no disease) * P(test positive | no disease)) = P(disease, test positive) / P(test positive)


Ban direct access to a php file but not for cron job

Question: I have a php file that sends curl and saves the data in the database, and I need to run this script daily, but I want only cron job to execute that PHP file, not anybody else.
I could use a piece of advice.Thanks
Comment: You could use the [php_sapi_name function](https://www.php.net/manual/en/function.php-sapi-name.php) and stop execution if the response is not `cli`.
Comment: I would probably do this too just for safety reasons.
Comment: Keep the php script outside the section of the server side file system that is published via the http server. And execute it using the php cli interface, not using the http server via a curl call. That offers a strict separation of both worlds. You need to take care of permissions though.
Answer: Assuming linux, if it's in your home dir and you are the owner, and you didn't chmod 777 it, it should be okay.
If your questions is how to prevent people from opening the php file externally from the browser, don't place it in /var/html or whatever your webserver directory is.
Comment: A file permission pattern of `0777`? For a php script? That could only make sense if you also place a shebang at the beginning of a file...
Comment: And whether "it should be ok" if the file is in someone's home folder actually depends on the setup of the http server, so the configuration. Doesn't it? Many http server setups use the use module for example to publish parts of the user's home folder. Which would make the setup "not ok"...


Modifying a.e decreasing function to an everywhere decreasing function?

Question: Let $f : \mathbb{R} \to \mathbb{R}$ be a measurable function and $g: \mathbb{R} \to [0,\infty)$ be a locally-integrable function such that
\begin{equation}
f(b)-f(a) \leq -\int_a^b g(x)dx
\end{equation}
holds for almost every $a \in \mathbb{R}$ and all $b \in (a,\infty)$.
This seems to me in a sense that $f(x)$ is monotone-decreasing "almost everywhere".
Now, my question:
is it possible to modify $f$ on a set of measure zero such that the above inequality holds for "all" $a, b \in \mathbb{R}$ such that $a<b$?
This issues looks more subtle than expected.. Could anyone please help me?
Comment: Can't we just let $A=\{a\in\mathbb{R}\mid \text{not all }b\text{ }\ldots\}$ and just modify $\tilde{f}(a)=\lim_{b\to a+, b\notin A}f(b)$ for $a\in A$?
Answer: Let $\mathcal{A} = \{ a \in \mathbb{R}: \text{ for all } b > a, f(b) - f(a) \le - \int_a^b g(x) dx\}.$
For $a \not \in \mathcal{A}$ and $b > a$ with $b \in \mathcal{A}$, define
$$
f_b^*(a) = f(b) + \int_a^b g(x) dx.
$$
Note that for $c \ge b$ with $c \in \mathcal{A}$,
$$f_c^*(a) - f_b^*(a) = f(c) - f(b) + \int_b^c g(x) dx \le 0.$$
As a result, on $\mathcal{A} \cap (a, \infty)$ the map $b \mapsto f_b^*(a)$ is decreasing.
As a result, we can define
$$
f^*(a) = \begin{cases}
f(a), a \in \mathcal{A}\\
\sup_{b \in \mathcal{A}, b> a} f_b^*(a).
\end{cases}
$$
Checking that this definition satisfies the desired inequality is essentially a lot of simple case checking. In what follows, I will always have $a < b$.
If both $a,b$ are in $\mathcal{A}$, the desired inequality is true by assumption.
If $b \in \mathcal{A}$ and $a \not \in \mathcal{A}$ then choose $c \in (a,b)$ such that $c \in \mathcal{A}$ (which is possible since the complement of $\mathcal{A}$ has measure $0$). Then
$$f^*(b) - f^*(a) = f(b) - f^*(a) \le f(b) - f_c^*(a) = f(b) - f(c) - \int_a^c g(x) dx \le - \int_a^b g(x) dx.$$
If $a \in \mathcal{A}$ and $b \not \in \mathcal{A}$ then
$$f^*(b) - f^*(a) = \sup_{c > b, c \in \mathcal{A}} f(c) - f(a) + \int_b^c g(x) dx \le \sup_{c > b} \Bigg ( - \int_a^c g(x) dx + \int_b^c g(x) dx \Bigg )$$
which implies the desired inequality.
Finally if $a \not \in \mathcal{A}$, $b \not \in \mathcal{A}$,
$$f^*(b) - f^*(a) = \sup_{c > b, c \in \mathcal{A}} \Bigg ( f(c) + \int_b^c g(x) dx \Bigg ) - \sup_{d > a, d \in \mathcal{A}} \Bigg ( f(d) + \int_a^d g(x) dx \Bigg ).$$
Pick $d \in (a,b) \cap \mathcal{A}$. Then for each $c$ in the set over which we take the first supremum on the right hand side, we have
$$ f(c) + \int_b^c g(x) dx - f(d) - \int_a^d g(x) dx \le - \int_d^c g(x) dx + \int_b^c g(x) dx - \int_a^d g(x) dx.$$
Since the right hand side is nothing but $-\int_a^b g(x) dx$ this implies the desired bound.
Comment: @Keith maybe I miss something because I haven't thought about this for a while, but isn't that just the special case $g=0$ in the above?
Comment: Thank you! If we just have $f(b) \leq f(a)$ for almost every $a \in \mathbb{R}$ and all $b \in (a,\infty)$, can we modify your argument somehow? Could you please help me once more?
Comment: Ooops... yes you are absolutely correct. Thank you!


Iterating through a Hash while Updating a Counter

Question: I have a hash:
students = {
  class1: 11,
  class2: 24,
  class3: 38,
  class4: 62
}

I want there to be four lines of output:
1) 11
2) 35 #11 + 24
3) 73 #35 + 38
4) 135 #73 + 62

It goes through each element, and adds a value to a counter, printing each iteration as it goes. I need something like:
students.each do |key, value|
  value + counter = total
  puts total
end

but I have no idea how to do it. Please advise.
Comment: This operation is called [http://en.wikipedia.org/wiki/Prefix_sum#Scan_higher_order_function](*Prefix Sum* or *Scan*), which is strangely missing from the [`Enumerable`](http://Ruby-Doc.Org/core-2.1.1/Enumerable.html) API. It is closely related to [http://wikipedia.org/wiki/Fold_(higher-order_function)](*Fold*), which is available in Ruby as [`Enumerable#inject`](http://Ruby-Doc.Org/core-2.1.1/Enumerable.html#method-i-inject)
Answer: There are many ways to do this, but I will suggest a way that will teach you a few different things about Ruby. This is also a very Ruby-like way to address this problem.
Code
students = {
class1: 11,
class2: 24,
class3: 38,
class4: 62 }

students.reduce(0) do |tot, (k,v)|
  tot += v
  puts k[/\d+/] + ") #{tot}"
  tot
end
1) 11
2) 35
3) 73
4) 135

Explanation
I've used Enumerable#reduce (a.k.a. inject) because that method is convenient for totaling a collection of numbers, using a variable  (here tot) that maintains the running total within the block.  That's just what you need.
Aside: you will learn a lot be reading the documentation for Ruby methods.  Methods are referenced like this: SomeClass#method or SomeModule#method.  Here, reduce is an instance method of the module Enumerable.  students is an instance of the class Hash, but that class "mixes-in" (includes) the instance methods of the module Enumerable.
The object tot is a Fixnum that is initialized to reduce's argument, which here is zero.  (If no initial value were given, the initial value from student--11--would be assigned to tot).  Each time the code in the block is executed the value at the end of the block is returned to the enumerator (which is why tot is there).  After all the elements of the receiver students have been enumerated, the value of tot is returned by reduce (though you will not be making use of that).
The first time the block is called the block variables are as follows:
tot => 0
k   => :class1
v   => 11

To print
1) 11

I presume you want the label 1) to be the right end of :class1.  To exact 1 from the symbol k => :class1, you can use the method Symbol#[] with the regex /\d+/, which extracts a string of one or more digits 0-9 (as many as there are).
In reading the documentation for the method Symbol#[], you will see that it converts the symbol :class1 to the string "class1" and then invokes the method String[] on that string.
Since Ruby 1.9+, many prefer to use Enumerable#each_with_object rather than reduce.  That method would be used like this:
students.each_with_object(0) do |(k,v),tot|
  tot += v
  puts k[/\d+/] + ") #{tot}"
end

Notice that with this method it is not necessary to return the value of the object (tot) to the enumerator, and that tot is at the end of the list of block variables, whereas it is at the beginning for reduce.
Answer: You were actually fairly close. You need to define the total variable outside of your block, just assign 0 to it using
total=0

this will make it stay through all the iterations. Then you just need a small change in
students.each do |key, value|
  total=total+value
  puts total
end

and it will do what you want.
Switching the order of value + counter = total is important, as assignments (through =) always assign to the variable on the left.
Answer: Using your code, made some small change:-- Try this:--
total = 0
students.each do |key, value|
     total += value
     puts total
end


Is this a legal use of global variables in Python?

Question: I've written a small script in Python for simple text manipulation, consisting of a bunch of functions. Some of these functions contain magic numbers or string constants. Is it okay to store them in global variables? I do not intent to modify them, they are more like constants.
Answer: Yes, it's legimitate use. You will encounter that in many good Python codes. Just note that the convention is to write the names of such "constants" in UPPER_CASE.
Answer: This is the preferred way of dealing with constants. At the top of the file you can easily modify them.
You could also move them to a seperate file and use the absolute or relative import.
from mypackage import constants as c # absolute -- any Python
from . import constants as c # relative -- Python 2.6+
from .constants import * # Resist any temptation to do this!

Answer: Yes it is okay to store constants as global variables. For example Django (a Python web framework) does this with a lot of settings in a settings.py file, which contains globals such as
LOGGER = ...
STATIC_DIR = ...

etc.


Proving $R/I \otimes_R M \cong_R M/IM$ using UMP and a biadditive map not with exact sequences.

Question: I want to Understand a paragraph of the proof of $R/I \otimes_R M \cong_R M/IM.$ in example$(8)$ on pg. 370 of Dummit and Foote (third edition)
Here is the example from Dummit & Foote:

My questions are:
1- I do not understand exactly why we need the previous observation (as stated in the book) to say that the map $N \rightarrow (R/I) \otimes_R N$ defined by $n \mapsto 1 \otimes n$ is surjective?
2-why we need $IN$ to be in the kernel?
3- why $1 \otimes a_i n_i = a_i \otimes n_i$?
4- Why the author defined $f$ by that definition?
Could anyone help me answer those questions please?
Comment: For #1, it's the observation to note that $f$ is a surjection is all.  For #2 it's not really that you "need" it in the kernel, it's that it is by definition of your map.  #3 is the bimodule structure, distributing the scalar $a_i$ to the other tensor factor.  For #4, I don't understand what you mean; it's just part of the proof.
Comment: I think the answer given below fills in the few details that aren't included in the book; the proof is very bare-bones logic+definitions, I think you just don't have some of these definitions grasped with facility yet is all.  Why don't you play with tensors a bit more, work out some examples and extra exercises?  That will do more to help your understanding than anything that will be posted here.  I don't mean it in a rude way, I got hung up on this material as well (same book).
Comment: The answers to 1-3 mostly follow from the definitions, it'd be useful if you are some more details about where exactly you need help answering those questions.
Comment: @Quimey which definitions exactly I should revise to understand them. Also, I am having hard times understanding what the author is doing in the last paragraph of the first picture I posted. If you could explain that to me I would be very grateful to that.
Comment: @JohnSamples I feel like this proof is not organized and contain sometimes ideas that can be explained by simpler ways. If you can organize this proof (with including some details)in an answer I would be very grateful for this
Comment: @JohnSamples Why $a_i \otimes n_i = 0$?Is that because $I$ is the identity?
Answer: Quick answer that could be expanded if more details are provided

You need the previous observation to prove that elements $1\otimes n$ generate the tensor product as an $R$-module, since all of them are in the image and the map is $R$ linear the claim follows.

You need that to define a map from a quotient.

By definition of tensor product over $R$, $R$-scalars can "jump" from one side to the other of the product.

It was probably easier to show the inverse than to prove than the original map is injective.
Comment: @hard, if $a_i$ is in $I,$ then $a_i \equiv 0 \text{ (mod } I).$
Comment: Can you organize the proof that is given in the book and include it (with simple explanations)in an answer?
Comment: Can you show me the details of finding the inverse?
Comment: The inverse is the function $g$ defined in the book. In order to verify that you can _explicitely_ compute $fg$ and $gf$.
Comment: All the missing details are quite straightforward as @john suggested in the comment above
Comment: Why $a_i \otimes n_i = 0$?
Answer: It could be a useful exercise for you to prove this for yourself rather than to try to follow the proof (and consequently bear the burden of filling in all of the missing details) from a textbook. Toward this end, allow me to provide you with some suggestions that you can use in your proof.

Observe that by definition, the tensor product gives an $R$-bilinear map $\tau : (R / I) \times M \to (R / I) \otimes_R M$ defined by $\tau(r + I, m) = (r + I) \otimes_R m.$ We will need also an $R$-bilinear map $\varphi : (R / I) \times M \to M/IM.$ Hint: for a module $N$ over a commutative ring $S,$ the multiplication map $S \times N \to N$ that sends $(s, n) \mapsto s \cdot n$ is always bilinear.

Once we have two $R$-bilinear maps $\tau : (R / I) \times M \to (R / I) \otimes_R M$ and $\varphi : (R / I) \times M \to M / IM,$ the universal property of the tensor product gives a unique $R$-bilinear map $\psi : (R / I) \otimes_R M \to M / IM$ such that $\psi \circ \tau = \varphi,$ i.e., we have that $\psi[(r + I) \otimes_R m] = \varphi(r + I, m)$ for all $r + I \in R / I$ and $m \in M.$

Can you find a well-defined $R$-bilinear map $\gamma : M / IM \to (R / I) \otimes_R M$ such that $\psi \circ \gamma$ is the identity map on $M / IM$? Hint: there is a "standard" way to give a map $M \to R \otimes_R M.$ If you mimic this idea, you will find exactly what you are looking for.
Comment: Comments are not for extended discussion; this conversation has been [moved to chat](https://chat.stackexchange.com/rooms/119824/discussion-on-answer-by-carlo-proving-r-i-otimes-r-m-cong-r-m-im-using-ump-a).


Backbone route on IE

Question: I'm trying use the history backbone root but it doesn't work fine on IE (or other browsers which don't support history api).
My webapp has this map, where each module makes a request, but actions should call a function:

site/moduleA/
site/moduleA/action1/ID
site/moduleB/
site/moduleB/action1/ID

mapping:
var MyRouter = Backbone.Router.extend({
    routes: {
        "moduleA/": "homeA",
        "moduleA/action1/:id": "action1",
        // ...
    }
}

var app = new MyRouter();
Backbone.history.start({pushState: true});

I'm navigating using this:
app.navigate('moduleA/',{trigger:true});

or
app.navigate('/moduleA/action1/4334',{trigger:true});

(I'm getting links click events and calling navigate(link.href,{trigger:true}) )
Every is working fine on Chr/FF (browsers with history api support), and the url is updated in the browser and the function is call.
However, in IE the url is replaced by this hash format: site/#moduleA/
In order to solve that I've tried set the root in history.start
Backbone.history.start({pushState: true, root:'/moduleA/'});

But, now IE replace the url using this format: site/moduleA/#moduleA/ or site/moduleA/#moduleA/action1/432432.
So, Why IE is repeating the root in the url ?
How can I solve this?
Thanks in advance
Answer: By setting root to '/moduleA/' you are telling backbone to use site/moduleA as the root, this is the expected behavior.
Rememeber in backbone
routes: {
    "moduleA/": "homeA",  // #moduleA/
    "moduleA/action1/:id": "action1" // #moduleA//action1/:id
}

is different from
routes: {
    "/moduleA/": "homeA",  // #/moduleA/
    "/moduleA/action1/:id": "action1" // #/moduleA//action1/:id
}

its good to keep this in mind when using app.navigate.
Comment: Thanks Anthony for your information. I had many mistakes. I had to change all my links and remove from the href property the root part of the url. In addition, the Backbone.history.start({pushState: true, root:'/moduleA/'}); had to be different for no html5 browsers: Backbone.history.start({pushState: true, root:'/moduleA'+(Modernizr.history?'/':'')});
Since I'm setting the root property, It doesn't have to be in routes. In my example routes will be: { '/':'home', 'action1/:id': 'action1'}

Backbone route on IE


Binding Docker container created through api

Question: I have a command that creates a docker container, from a docker container and I want to bind a port to the host
exec(`curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -d '{ "Image": "strategy_baseline", "ExposedPorts": { "${PORT}/tcp": {} }, "HostConfig": { "Binds": ["strategies:/usr/src/app/strategies"], "NetworkMode": "titan_backend" }, "PortBindings": { "${PORT}/tcp": [{ "HostPort": "${PORT}" }]}, "Env": ["BOTNAME=${BOT_ID}", "PORT=${PORT}", "ASSETS=${ASSETS}"]}' -X POST http:/v1.4/containers/create?name=${BOT_ID}`,

All variables are properly defined within the file so the error is not there.
As it stands I call this command through an API endpoint, and the container gets created correctly at the correct port running docker ps outputs:
CONTAINER ID        IMAGE                       COMMAND                  CREATED             STATUS                          PORTS                                                 NAMES
ab8e28ccd50f        strategy_baseline           "docker-entrypoint.s…"   2 hours ago         Up 2 hours                      3009/tcp                                              defaultKeys

Id expect something that specifies the container port to be 0.0.0.0:3009->3009/tcp. but alas that doesn't work.
I know I can call the container by specifying its name, so from within any other container in the network I can just do  http://container_name:3009/endpoint
but ideally I should be able to do: hhtp://vps_ip:3009/endpoint which as of now I cant do.
Any pointer or help is greately appreciated, thanks in advance!!
Answer: This modification did the trick
exec(`curl --unix-socket /var/run/docker.sock -H "Content-Type: application/json" -d '{ "Image": "strategy_baseline", "ExposedPorts": { "${PORT}/tcp": {} }, "HostConfig": { "Binds": ["strategies:/usr/src/app/strategies"], "NetworkMode": "titan_backend", "PortBindings": { "${PORT}/tcp": [{ "HostPort": "${PORT}" }]}}, "Env": ["BOTNAME=${BOT_ID}", "PORT=${PORT}", "ASSETS=${ASSETS}"]}' -X POST http:/v1.4/containers/create?name=${BOT_ID}`,


Is there a specific vocal technique to sound "croaky" towards beginning of phrases?

Question: Enrique Iglesias in his song Hero, uses a vocal technique where he somehow stresses beginning of many phrases that sound especially "croaky", starting with "~~~Would you dance...", where "~~~" refers to the "croaky" sound. In fact there is a pun video tutorial where someone pokes fun at this technique. I do not agree with the video, because I think that the "croaky" sound sounds very "intense" and fits the song, but sharing it just to highlight the parts I am referring to.
The above is just an example to establish a reference. So the question is, is this a specific vocal technique that can be developed with a method ? If so, can someone elucidate the technique and the method to develop it ?
Answer: The phonetic term for this effect is "creaky voice," but it's perhaps more often referred to as "vocal fry" in musical contexts. It's not especially difficult to produce, though it is difficult to describe how to do. It's the sound that happens when you try to sing notes far below your standard vocal range. Many radio djs on NPR use creaky voice, and it's also stereotypically associated as an affectation used by a lot of younger women.
I think you just want to be careful not to strain your vocal folds when doing it. Use it sparingly and gently at first.
ETA: I should also note—as per my comment below—that this tends to be a very quiet effect. If you try to do it loudly, you really can damage your vocal folds. A crucial thing to remember is that Iglesias is able to do this so often and with such volume because of the microphone! He's making a very quiet sound here, and letting the microphone pick up the vocal subtleties. How to use and exploit a microphone is a big part of becoming a pop singer.
Comment: @icarus74 Hopefully, now that you have the term(s) for it, you can look up tutorials on it. I suspect that "vocal fry" will be the more useful search term. However, I will say that it sounds like you might be trying to do it too loudly—it's generally a very quiet effect. Remember, Iglesias is using a microphone! Actually, that's an important point I'll add to my answer.
Comment: Thanks Pat. I understand that it is perhaps difficult to express the technique in words...and I did spend sometime yesterday trying to get it. Admittedly it didn't sound half as nice but more importantly seemed to have stressed my vocal chords, as I've had cough and discomfort after that.
Comment: Many thanks Pat. That is an excellent suggestion and I did look up tutorials on how to do 'vocal fry'. Came across several (like this one: https://www.youtube.com/watch?v=WVEDc466XvI). I shall take your advise and try again keeping in mind that this is a 'quite effect', and perhaps needs a large diaphragm condensor mic in a quite studio, to get right.


Is $\int_0^\infty \vert \sin x \vert^{x^2} \ dx$ convergent?

Question: To study the question, I'm looking at the convergence of the series
$$u_k = \int_{k \pi}^{(k+1) \pi}\vert \sin x \vert^{x^2} \ dx,$$ using the inequalities
$$2 \int_0^{\frac{\pi}{2}} \sin^{(k+1)^2\pi^2} x \ dx \le u_k \le 2 \int_0^{\frac{\pi}{2}} \sin^{k^2 \pi^2} x \ dx.$$
But I'm not able to get a good approximate of
$$v_k = \int_0^{\frac{\pi}{2}} \sin^{k^2 \pi^2} x \ dx$$
Any good idea?
Answer:
But I'm not able to get a good approximate of $v_k = \int_0^{\frac{\pi}{2}} \sin^{k^2 \pi^2} x \ dx\, $     ($k \to \infty$).

Hint. One may use the Euler beta function to get
$$
\int_0^{\frac{\pi}{2}} \sin^{a} x \ dx=\frac{\sqrt{\pi}\: \Gamma\left(\frac{1+a}{2}\right)}{2 \: \Gamma\left(1+\frac{a}{2}\right)}
$$ giving, as $a \to \infty$,
$$
\int_0^{\frac{\pi}{2}} \sin^{a} x \ dx =  \sqrt{\frac{\pi}2}\frac1{\sqrt{a}}+O\left(\frac1{a^{3/2}} \right).
$$
Answer: I finally found another solution based on more basic technics.
$$\begin{align}
v_k&= \int_0^{\frac{\pi}{2}} \sin^{k^2 \pi^2} x \ dx  = \int_0^{\frac{\pi}{2}} \cos^{k^2 \pi^2} x \ dx\\
&\ge \int_0^{\frac{\sqrt{2}}{k \pi}} \cos^{k^2 \pi^2} x \ dx\\
&\ge \int_0^{\frac{\sqrt{2}}{k \pi}} (1-\frac{x^2}{2})^{k^2 \pi^2} \ dx\\
&\ge \frac{\sqrt{2}}{k\pi} \left(1-\frac{1}{k^2 \pi^2}\right)^{k^2\pi^2} \sim\frac{\sqrt{2}}{e k \pi}
\end{align}$$
Based on the inequality
$$\cos x\ge 1-\frac{x^2}{2} \text{ for } x \ge 0$$
Hence the integral diverges as the harmonic series diverges.


Count number of arguments passed to function

Question: I'm interested in counting a number of arguments passed to a function.  length can't be used for that purpose:
>> length(2,2,2,2,2)
Error in length(2, 2, 2, 2, 2) :
  5 arguments passed to 'length' which requires 1

This is obvious as length takes 1 argument so:
length(c(2,2,2,2,2))

would produce the desired result - 5.
Solution
I want to call my function like that myFunction(arg1, arg2, arg3). This can be done with use of an ellipsis:
myCount <- function(...) {length(list(...))}

myCount would produce the desired result:
>> myCount(2,2,2,2,2)
[1] 5

Problem
This is awfully inefficient. I'm calling this function on substantial number of arguments and creating lists just to count number of objects is wasteful. What's the better way of returning the number of arguments passed to a function?
Comment: 'calling with substatnial number of arguments' sounds like you're doing something weird. Function arguments are for programmers, machines should get lists too long for humans to read in a - for example - `list` :)
Comment: @Gregor Fair point, I deleted the first bit.
Comment: @liborm In a wider scheme of things I agree. In this particular case I was interested in this solution as it saves me changing the longer workflow when i cal functions by `get("sum")(arg, arg)`. From educational perspective I also wanted to see how this could be done in an efficient manner.
Answer: How about
myCount <- function(...) {length(match.call())-1}

This just inspects the passed call (and removes 1 for the function name itself)
Comment: Perfect, this is what I was looking for.
Comment: Is it possible to count the number of arguments *inside* the function as well?
Answer: nargs returns the number of arguments supplied to that function
myCount <- function(...) {
  nargs()
}

> myCount(2,2,2,2,2)
[1] 5

Reference https://stat.ethz.ch/R-manual/R-devel/library/base/html/nargs.html
Answer: Here is a somewhat elegant way using length() with purrr::lift_*() familiy functions.
Generally you are passing multiple arguments to length(), which is not working because length() takes a vector or a list as input.
So what we need is to convert the input from a vector/list to ... (dots). purrr::lift_*() family provides a series of functions that do so.
One option can be converting from vector to dots:
> lift_vd(length)(2, 2, 2, 2, 2)
[1] 5

Another option can be converting from list to dots:
> lift_ld(length)(2, 2, 2, 2, 2)
[1] 5

Both options are working perfectly well, and what you need is using one of the purrr::lift_*() functions on length() before passing spliced arguments to it.


Firefox background-attachment: fixed Nightmare

Question: I have been pulling my hair out on this one all day, and I'm hoping someone smarter than me can figure it out.
I'm working on a new design for my site, and I've run into what appears to be a Firefox bug. I am using background-attachment: fixed for a gradient on the  element and then I have a full width
 with another background image at the top of the page. Only in Firefox, there is a small white border at the top of the page and on either side of the
 background.
I've tried at least a half-dozen different ways of coding the HTML and CSS, and they all produce the same results. Also, the white gap doesn't appear to be there in earlier versions of Firefox (I noticed it in version 6). I even did a clean reinstall of Firefox without any add-ons, and I'm still seeing it. Any ideas on what's causing this? Is my code wrong in some way?
See simplified test case here: http://mygemologist.com/bg-fixed-test.html
Note: This question may be related to: Crazy CSS Issue in Firefox Only - position fixed and background color, but I'm not sure on that.
Comment: @Dominic At a guess this is https://bugzilla.mozilla.org/show_bug.cgi?id=677095 and in particular, see https://bugzilla.mozilla.org/show_bug.cgi?id=677095#c47
Comment: Did you use a CSS reset of some kind?
Comment: There's no problem in Firefox 6 for me. Have you confirmed this bug on anyone else's machine?
Comment: I'm also not seeing any issue in Firefox 6, like @da5id.
Comment: Thanks for the feedback. The only CSS reset I'm using is the universal 0 margin and padding. I have confirmed the bug on 2 machines so far, both running Firefox 6 on Windows 7. Would it be helpful if I posted a screen capture of how it's rendering for me?
Comment: Confirmed the same issue on a 3rd machine (Vista). This time, I checked that it was rendering correctly on Firefox 5 (it was) and then updated to v6 and saw the same issue. I have also updated the test case with a screen capture highlighting the problem for clarity.
Comment: Does the problem disappear if you turn off hardware acceleration?  If so, it sounds like a known bug in Firefox 6 in some Windows configurations; a fix for it should be shipping in Firefox 8, I believe.
Comment: @Boris, The problem does disappear when I turn off hardware acceleration. Thank you so much for figuring that out. So, it is a Firefox bug. Does anyone know of any work-arounds for this?
Comment: @Boris, that did it! I don't think I'm allowed to accept a comment as the solution, but that was exactly what I needed. Thank you so much.
Comment: @Dominic added the comment as an answer so other people see it more easily too.
Answer: Dominic, see https://bugzilla.mozilla.org/show_bug.cgi?id=677095 for this issue and https://bugzilla.mozilla.org/show_bug.cgi?id=677095#c47 for a possible workaround.
Comment: http://stackoverflow.com/questions/7310518/crazy-css-issue-in-firefox-only-position-fixed-and-background-color/7389005#7389005
Comment: @Boris, up for round 2? It seems the hardware acceleration bug hasn't gone away in Firefox 8. It's gotten worse. The opacity hack has pretty much no effect now. Do you know of another way to disable hardware acceleration?
Comment: @Dominic I don't know offhand.  Can you please file a bug with a testcase and add ":bz" to the cc list?  I'll make sure someone familiar with Windows graphics stuff looks...
Comment: @BorisZbarsky, ok, I filled the bug as you suggested. Just for reference, the bug is here: https://bugzilla.mozilla.org/show_bug.cgi?id=701528
Comment: @Dominic Thanks for filing that!
Comment: @Boris, I just wanted to say thank you for pointing me in the right direction, and helping to resolve this. I've been so impressed with the Firefox devs on this issue. Thanks.
Answer: Maybe use a smaller width image? It seems firefox has issues rendering it, when zooming it goes from properly displayed to having a 1-2px white border above it.
EDIT
When I change the body css to background-position: scroll the problem seems to go away
body {
  background: url("http://www.mygemologist.com/resources/bg-gradient.jpg") repeat-x scroll left top transparent;
}

Comment: I too have noticed the zooming phenomenon. Just so I understand you right. Are you suggesting a smaller width image for the `` background or the `` background?
Comment: Yes, the problem is only with background-attachment: **fixed**, unfortunately that's the look I'm trying to create with this design.


Do fewer axioms suffice to define the Moore-Penrose pseudoinverse? (motivated by least squares method and group theory)

Question: Definition of the Moore-Penrose pseudoinverse
We know that each matrix $A \in M_{m,n}(\mathbb{R})$ has a unique matrix $B \in M_{n,m}(\mathbb{R})$ that suffices the following four axioms:

$A B A = A$,
$B A B = B $,
$B A$ is symmetric,
$A B$ is symmetric.

This matrix $B$ is called the Moore-Penrose pseudoinverse of A and is often denoted by $A^+$.
The least squares method
For given $A \in M_{m,n}(\mathbb{R})$ and $y \in \mathbb{R}^m$, the least squares method says that $x^* \in \mathbb{R}^n$ is a best approximation  for the linear equation system $Ax = y$ if and only if the normal equation $A^t A x^* = A^t y$ holds.
Observation
In the literature, one often shows that a best approximation can be given by $x^* = A^+ y$. But I noticed that if we have a matrix $B$ which only satisfies the axioms 1. and 4., then $x^* = By$ is already a best approximation.
Proof: $A^t A x^* = A^t (A B) y \stackrel{4.}{=} A^t (AB)^t y = (ABA)^t y \stackrel{1.}{=} A^t y \tag*{$\blacksquare$}$ .
Question
Do we only require the axioms 1. and 4. to determine the Moore-Penrose pseudoinverse uniquely?
Other problems which I think are similar
We know that in order to define a group we only need to require the existence of a left identity element and for each element in the group the existence of a left inverse element. Then the left identity and the left inverse elements are also right indentity and right inverse elements which are also unique, so this definition is coherent with the standard definition of groups which you find in the literature most of the times.
Maybe the same thing is true for the definition of the Moore-Penrose pseudoinverse now.
Answer: A counterexample is $$A=\pmatrix {0&0\\1&1\\0&0}$$ $$B=\pmatrix{4&3&0\\-4&-2&0}$$ satisfying $1.$ and $4.$ but neither $2.$ nor $3.$
Comment: Thank you for your response. Could you please explain me how you derived this counterexample? For me, this comes out of nowhere.
Comment: @Diglett I just found it by generating random matrices with PARI/GP. Unfortunately, I have no idea why it exactly is a counterexample.


Main menu links not operational on front page when anonymous

Question: I have two links to 'published content' in main menu. This menu is displayed on all pages, including front page.
When I am logged in as admin, those links work well, but when I am logged out (=anonymous), those links are displayed, but not operational. It is as if they were plain text only.
Yet, when I access content directly with the proper URL as anonymous, those links do work properly in the corresponding page.
So, why don't they work on the front page when using anonymous mode? I have checked page source and the code is the same. I have checked permission and View published content is allowed for anonymous users.
Want could be the cause of this issue?
Update
For the records, I have also asked a question here. I tried to solve this issue with a Drupal Navigation Menu, but only the Home link works, not the other link.
To solve this issue, I have created my own menu manually. It works, but...
Update II
I am using a simple plain vanilla system with panels everywhere. The theme is Versatile. I have header, footer, left, right mini-panels + central content in a default page variant. The right mini-panel just displays an instance of Main Menu. In fact, I have not created users. The site is meant to be used by anonymous people.
Update III
The issue only happens when the following CSS is applied:
<code>.NCK_Menu {

    font-size: 103%;
    height: 240px;
    width: 120px;
    background-color: #5E88D0;
    margin: 10px 9px 10px 7px;
    padding: 7px;
    border:none;
    -webkit-border-radius: 1px;
    -moz-border-radius: 1px;
    border-radius: 1px;

}
</code>
It does not make sense !!!
Comment: The clues people gave you on the other thread are sound : z-index issue or Javascript capturing the click event on the link. If the HTML code is the same in the two use cases, it's definitely not a permission issue.
Comment: I'll try to find time to capture the click event and see if it helps solving the issue.
Answer: The most often reason when you can`t see any kind of links in menu - are permissions for users. So please double check whether all of ones connected to your links (maybe modules/content types or whatever) are enabled for anonymous user.
Comment: That's what I did, but could not find permission issues. I could not find specifics about Main menu. I have enabled all I though might be relevant...
Comment: How do you output your menu? Via page.tpl? Try that snippet. If not try to output it as a simple block

     $main_menu,
            'attributes' => array(
              'id' => 'main-menu',
              'class' => array('links', 'clearfix'),
            ),
            'heading' => array(
              'text' => t('Main menu'),
              'level' => 'h2',
              'class' => array('element-invisible'),
            ),
          )); ?>
Comment: I have updated my question with more info. I don't fiddle with templates -> Pure Drupal configuration.


default value imagefield -> get from field collection item

Question: I've got a contenttype "gallery" with an imagefield "thumbnail", used in listviews oder teaserviews. This contenttype also has a field collection with "image", "title" and "description". So what would be great now, if there's no value set for the "thumbnail" field, the default value should be the value from the first field-collection image.
any chance to realize this? Thanks for your help
EDIT:
i tried this:
That's not a solution
function channelportal_gallery_node_presave($node) {

    $galleryimage = field_get_items('node', $node, 'field_gallery_and_caption');
    $firstimageID = $galleryimage[0]['value'];

    $item = field_collection_item_load($firstimageID);
    dpm($node->field_thumbnail);

    $node->field_thumbnail = field_get_items('field_collection_item', $item, 'field_gallery_image');
    dpm($node->field_thumbnail);
}

But nothing is stored, to the field, even if the first dpm gives back an empty array and the second one containing the values it should contain. But after all, nothing is stored to the field and it's empty again...
Thanks for your answer Chad Payne
Answer: I would look in to something like
hook_node_presave
As a rough example I would have it work like this
function MY_MODULE_node_presave($node) {
     if(!isset($node->field_thumbnail)) {
          // load field collection and save that image to this image field
     }
}

I haven't tested this code but i think this would be the direction you would want to go in.


Prove that $R^{n}\setminus R^{k} \simeq S^{n} \setminus S^{k} \simeq S^{n-k-1} $

Question: $\simeq$ is homotopy equivalence space
homotopy equivalence:
Two topological spaces X and Y are homotopy equivalent if there exist continuous maps $f:X\rightarrow Y$ and $g:Y \rightarrow X$, such that the composition f degreesg is homotopic to the identity $id_Y$ on Y, and such that g degrees f is homotopic to $id_X$. Each of the maps f and g is called a homotopy equivalence, and g is said to be a homotopy inverse to f (and vice versa).
homotopy:
In topology, two continuous functions from one topological space to another are called homotopic if one can be "continuously deformed" into the other, such a deformation being called a homotopy between the two functions.
$\setminus$ is set minus (dont mistake it with quotient space)
hint: there is similar question here but its not usable for this question because first of all it proves $R^{n}\setminus R^{k} \simeq S^{n-k-1} \times R^{k+1}$
The answer tried to solved it by using induction on k,
 and the right term  $R^{k+1}$ play important roll which can not be omitted from that proof. and if I wanted to prove it by induction on k
k=0
$R^{n} \setminus R^{0} \simeq S^{n-1}$
I can prove the initial case very similar by giving the map: $x \rightarrow (x/ ||x||)$
however I have no idea for the induction step. and for the middle part of the proof which says: $\simeq S^{n} \setminus S^{k}$
Comment: I don't know what your intention in the title was exactly, but do not do line breaks in titles.
Comment: Your question confuses two related but distinct mathematical concepts.

First, two continuous *functions* $f,g : X \to Y$ are **homotopic** if there exists a continuous function $H : X \times [0,1] \to Y$ such that $H(x,0)=f(x)$ and $H(x,1)=g(x)$.

Second, two *topological spaces* $X$ and $Y$ are **homotopy equivalent** if there exists a continuous function $h : X \to Y$ and a continuous function $k : Y \to X$ such that the two functions $k \circ h : X \to X$ and $\text{Id}_X : X \to X$ are homotopic, and the two functions $h \circ k : Y \to Y$ and $\text{Id}_Y : Y \to Y$ are homotopic.
Comment: First of, the actual question should be incorporated in the question body. Second, please don't use line breaks in the title (see [here](https://math.meta.stackexchange.com/questions/9687/guidelines-for-good-use-of-rm-latex-in-question-titles/9730#9730)). Third, why is the approach not usable; please add you attempted tries with an [edit].
Comment: Keep in mind, a statement asserting that two spaces are "homotopic" has no meaning, and is an abuse of mathematical grammar and terminology.
Comment: @ Lee Mosher Thank you very much I edited it accordingly
Answer: Your question is imprecise because you do not specify how $\mathbb R^k$ is regarded a subspace of $\mathbb R^n$ (similarly for $S^k$ and $S^n$). But certainly you identity
$\mathbb R^k$ with $\{(x_1,\ldots,x_n) \in \mathbb R^n \mid x_{k+1} = \ldots = x_n = 0 \}$ and $S^k$ with $\{(x_1,\ldots,x_{n+1}) \in S^n \mid x_{k+2} = \ldots = x_{n+1} = 0 \}$.
Let $p = (1,0,\ldots,0) \in S^n$. Stereographic projection gives us a homeomorphism
$$h : S^n \setminus \{p \} \to \mathbb R^n, h(x_1,\ldots,x_{n+1}) =\left(\frac{x_2}{1-x_1},\ldots,\frac{x_{n+1}}{1-x_1}\right) .$$
We have $h(S^k \setminus \{p \}) = \mathbb R^k$, thus $h((S^n \setminus \{p \}) \setminus (S^k \setminus \{p \})) = \mathbb R^n \setminus \mathbb R^k$. But clearly $(S^n \setminus \{p \}) \setminus (S^k \setminus \{p \}) = S^n \setminus S^k$ which proves that $\mathbb R^n \setminus \mathbb R^k$ and $S^n \setminus S^k$ are homeomorphic.
As you stated in your question, $\mathbb R^n \setminus \mathbb R^k$  and $S^{n-k-1} \times \mathbb R^{k+1}$ are homotopy equivalent which implies $\mathbb R^n \setminus \mathbb R^k \simeq S^{n-k-1}$ because $\mathbb R^{k+1}$ is contractible.
Comment: @Niloofar_jz You have $\mathbb R^n \setminus \mathbb R^0 \simeq S^{n-1}$. The inductive step is $\mathbb R^{n+1} \setminus \mathbb R^{k+1} \approx (\mathbb R^n \setminus \mathbb R^k) \times \mathbb  R \simeq \mathbb R^n \setminus \mathbb R^k \simeq S^{n-k-1}$.
Comment: @name You have $\mathbb R \simeq *$ = one-point space, thus $X \times \mathbb R \simeq X \times * \approx X$ for any $X$.
Comment: thank for your answer for the one part.I didnt stated that I just wanted to explain the proof and the relation of the given similar question I am not sure you can deduct by using the fact that $R^ {k+1}$ is contractible.
Comment: yes this is the very proof. thank you. Could you explain why you say  $(R^n\setminus R^k) \times R \simeq R^n\setminus R^k$


Null pointer exception in onCreateView using FragmentTabHost

Question: I am using a FragmentTabHost which contains three tabs. I am getting a null pointer exception in onCreateView of the 1st tab where i'm trying to add a webViewClient.. I'm new to android and i'm not able to figure out what's wrong with the code...
I used to have a sidebar/hamburger drawer in my main layout file but as soon as i removed that from my activity_lest_see_main xml file.. I started getting a NullPointerException in Tab1Activity.. Please help.. I'm really stuck at this problem.
As soon as i add the sidebar/hamburger drawer back in my lest_see_main.xml file, the code starts running without any error and the app works fine.
I keep getting NullPointerException at mwebView.setWebViewClient(new HelloWebViewClient) in Tab1Activity.
This is what i get in my Logcat along with the NullPointerException at the top -
07-28 18:24:52.735: E/AndroidRuntime(6834): FATAL EXCEPTION: main
07-28 18:24:52.735: E/AndroidRuntime(6834): java.lang.NullPointerException
07-28 18:24:52.735: E/AndroidRuntime(6834):     at com.example.itslive.Tab1Activity.onCreateView(Tab1Activity.java:168)
07-28 18:24:52.735: E/AndroidRuntime(6834):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1786)
07-28 14:17:31.274: E/AndroidRuntime(29029):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:947)
07-28 14:17:31.274: E/AndroidRuntime(29029):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
07-28 14:17:31.274: E/AndroidRuntime(29029):    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
07-28 14:17:31.274: E/AndroidRuntime(29029):    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)

This is my xml file of the main Activity which extends Fragment Activity
activity_lest_see_main.xml
<RelativeLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/rev"
 android:layout_width="match_parent"
 android:layout_height = "match_parent"
 android:layout_gravity="start">

<RelativeLayout
 android:id="@+id/mainContent"
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 >
 <android.support.v4.app.FragmentTabHost
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:id="@android:id/tabhost">

  <LinearLayout
   android:id="@+id/LinearLayout01"
   android:orientation="vertical"
   android:layout_height="fill_parent"
   android:layout_width="fill_parent">

   <TabWidget
    android:id="@android:id/tabs"
    android:layout_height="wrap_content"
    android:layout_width="fill_parent">
    </TabWidget>

    <FrameLayout
     android:id="@android:id/tabcontent"
     android:layout_height="fill_parent"
     android:layout_width="fill_parent">
     </FrameLayout>

    </LinearLayout>

    </android.support.v4.app.FragmentTabHost>

    <Button
     android:id="@+id/exit"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:background="@android:color/transparent"
     android:layout_gravity="bottom"
     android:layout_alignParentBottom="true"
     android:text = "@string/exit_button"
     android:textColor="@color/blue"
     android:textSize="20sp"
     android:layout_centerHorizontal="true"/>

     </RelativeLayout>

     </RelativeLayout>

This is my MainActivity java file extending Fragmentactivity
LetsSeeMainActivity.java
public class LestSeeMainActivity extends FragmentActivity  {
private FragmentTabHost tabHost;
int flag = 0;
int n;
private static final String TAG = "LetsSeeMainActivity";
private AudioManager maudioManager;
Fragment mContent;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_lest_see_main);

        maudioManager = (AudioManager) getSystemService(AUDIO_SERVICE);

    final Button exitb = (Button)findViewById(R.id.exit);

    exitb.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            maudioManager.playSoundEffect(AudioManager.FX_KEY_CLICK);
            finish();
        }
    });

    tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
    tabHost.setup(this, getSupportFragmentManager(), android.R.id.tabcontent);

     tabHost.addTab(
                tabHost.newTabSpec("tab1").setIndicator("Tab1", null),
                Tab1Activity.class, null);
        tabHost.addTab(
                tabHost.newTabSpec("tab2").setIndicator("Tab2", null),
                Tab2Activity.class, null);
        tabHost.addTab(
                tabHost.newTabSpec("tab3").setIndicator("Tab3", null),
                Tab3Activity.class, null);
}

}
This is my 1st Fragment Activity java file's onCreateView
Tab1Activity.java
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
}

public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    if(v==null)
    {
    v = inflater.inflate(R.layout.activity_tab1, container, false);
     mwebView = (WebView) v.findViewById(R.id.wb1);
     mwebView.setWebViewClient(new HelloWebViewClient());
     registerForContextMenu(mwebView);

    }

this is my activity_tab1.xml file-
  <android.support.v4.widget.SwipeRefreshLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/swipe_refresh_layout"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

 <WebView android:id="@+id/wb1"
 android:layout_width="match_parent"
 android:layout_height="wrap_content" />

 <ProgressBar
 android:id="@+id/progressBar1"
 style="?android:attr/progressBarStyleHorizontal"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:maxHeight="5dp"
 android:minHeight="5dp"
 android:visibility="invisible"
 />

 </android.support.v4.widget.SwipeRefreshLayout>

Comment: You can check this [link](http://androhub.com/android-swiperefresh-layout/).
Comment: Thanks but this of no  help.. since my main and only problem is this nullpointerexception.
Comment: Post your complete Logcat
Comment: @AndroidBoy  just edited my question.. I've posted the complete Logcat now..you can check it out..
Comment: @VidurSingh I can't see `activity_tab1` in your xml file. Where is it defined?
Comment: Post more logcat, we can't see the NPE.
Comment: @karthik just edited my question again and re-added it.. let me know if can see it now..
Comment: @hitch.united I've edited my question now.. you'll be able to see the NPE now..
Comment: The nullpointerexception is in line 168 of your TabActivity. If you add the line numbers in your code snippet, we can see which line that is.
Comment: @Christine I have written exactly which line is giving me the nullpointerexception.. 'mwebView.setWebViewClient(new HelloWebViewClient)'...in my Tab1Actvity.java file...
Comment: Still, it's good practice if you post a stacktrace, to include line numbers.
Comment: @Christine Thanks.. will do it from next time..
Answer: Try putting
mwebView = (WebView) v.findViewById(R.id.wb1);
mwebView.setWebViewClient(new HelloWebViewClient());
registerForContextMenu(mwebView);

in onViewCreated(..).
Comment: Now its giving me nullpointerexception at mwebView.loadUrl("https://www.google.co.in/").. I'm just frustated with with this problem.. my entire project has come to a stop because of this exception


Asp.net Not geting value from javascript function in c# variable

Question: this problem has wasted much of my time. I have written a javascript function and assigned value to asp hidden field but when i run my application i am not getting the value in c# variable
please correct me if i am missing something.
thanks in advance.
here is my code
javascript function:
function sureDelete() {
            if (confirm("DELETE USER?") == true) {
                document.getElementById("hidden_yesno").setAttribute("Value", "1");
              //document.getElementById('deleteYesNo').value = 1;
            } else {
                document.getElementById("hidden_yesno").setAttribute("Value", "0");
               //document.getElementById('deleteYesNo').value = 0;
            }
            return true;
        }

my hidden field and click event
<asp:HiddenField ID="hidden_yesno" runat="server" />
<asp:ImageButton  runat="server" CssClass="pt-userDeactive help" CommandName="deleteuser"
CommandArgument='<%# Eval("user_id") %>' ImageUrl ="../TemplateS/assets/images/delete.png"
Width="25px" Height="25px" OnClick="Unnamed_Click" OnClientClick="return sureDelete()"/>

and following is the c# code
 protected void Unnamed_Click(object sender, ImageClickEventArgs e) {
            string flag = hidden_yesno.Value.ToString();
              //here i am getting the value as: ""
            if (flag == "1") {
               //do something
            } else {
                //do nothing
            }
        }

Answer: You are using asp:HiddenFeild whose ID is changed by asp.net according to ContentPlaceHolder so it is not found by javascript/jquery.
Either you need exact ID of hidden feild or you can set ClientIDMode="static" which will make sure that ID is not changed.
<asp:HiddenField ID="hidden_yesno" runat="server" ClientIDMode="Static" />


$Df(x_0)$ is one-to-one. show $f$ is one-to-one on a neighborhood of $x_0$

Question: Suppose $f:\mathbb{R}^n \to \mathbb{R}^m$ is $C^1$ and $Df(x_0)$ is one-to-one.
Show $f$ is one-to-one on a neighborhood of $x_0$.
I think it's about inverse function theorem. but i cannot prove it.
Comment: First of all, you need to have $m=n$. Write down exactly what the inverse function theorem states.
Comment: it may not be related with inverse function theorem. it's my guess.
Comment: Your guess was correct. And you must have $m=n$ or else the linear map $Df(x_0)\colon\Bbb R^n\to\Bbb R^m$ could not possibly be invertible. I see somehow has edited to change that hypothesis. Could you please verify? Assuming $m>n$ and $Df(x_0)$ is one-to-one, the result is still true, but you have to dream up a new function $F\colon\Bbb R^n\times\Bbb R^{m-n}\to\Bbb R^m$ to which to apply the Inverse Function Theorem.
Comment: there isn't any condition about $m$ and $n$.
Comment: Isn't the fact that $Df(x_0)$ is 1-1 implies, $Df(x_0)$ is non-singular ? I mean after all, $Df(x_0)$ is a linear transformation; hence we can use the lemma 8.1 given in p64 in Munkres book, which directly states in this case that $f$ is one-to-one.
Answer: HINT: By making a linear change of coordinates in $\Bbb R^m$, you may assume that
$$Df(x_0) = \begin{bmatrix} I \\ O \end{bmatrix}.$$
Now define $F\colon\Bbb R^n\times\Bbb R^{m-n}\to\Bbb R^m$ by $F(x,y) = f(x)+(0,y)$.
Comment: When $m<n$, the linear map $Df(x_0)\colon\Bbb R^n\to\Bbb R^m$ certainly cannot be one-to-one! By the way, this is why I ask questioners to tell us what they have done and what they're stuck on. You would have saved me a lot of time if you'd started with this!
Comment: i proved when except $m<n$ with this method.
i think this method doesn't work when $m<n$.
Comment: oh................thank you


Why are there so many motorsport/race series?

Question: Apparently, there are many motorsport competitions out there. I understand I can run, say, a cricket league in Russia. As long as I have enough people to compete and a lawn, I don't need much funding, be it from sponsors or spectators. What I don't understand is: How can there be so many motorsport championships, given that it's pretty expensive compared to other sports?
I'm not talking about flagship series like Formula 1, NASCAR or Rallye World Championship. I'm talking about all those weird small series at least I have never heard about. In my view, racing is expensive. You need cars, you have to rent a race track, you need mechanics, etc. How can these championships pay off if you have no or hardly media coverage and maybe a few people watching at the track? Two possible answers emerge to me.

There are plenty of motorsports fans I am just not aware of
Most of these series indeed do not pay off, but are used as a marketing vehicle (pun intended :) ) for car manufacturers.

Does somebody have some deeper information on this, preferably with some facts?
Answer: Start from the premise that there are two reasons for motorsport: for profit, and for sheer enjoyment.
At the incredibly low cost end, there are various motorsport series round the world. They are really not expensive, but there is not much prize money either - people do it for fun, for bragging rights, and loads of other social reasons, but you are right that individuals get sponsored by vehicle and spares manufacturers. This sponsorship comes because those series are very popular, and also there is a step in to higher level competitions.
At the top end you have things like Nascar and Formula 1 - incredibly high cost, but massive winnings to be made if you are successful. So as an aspiration, drivers can see the attraction of working through lower series and formula in order to gain success, fame and fortune. So there is no shortage of drivers. Quite the opposite. And by the time things get expensive, they have already invested a lot of time and money so it is just a logical progression.
And fans love motorsport. Partly it's the risk - crashes happen - but also the noise, the speed, the watching something so close to the edge that many cannot even get close to. It's an adrenaline sport.
So the simple answer is: there is money in it, and there are people who want to race. Far too many for just a small number of series.
As an example, I'll race anything with engines, a sail or wings. Yes, it's expensive, but I love it, so that's why I do it.
Comment: thanks for your answer. So one part of the answer is that in lower tier series, it's the participants themselves who fund their (relatively expensive) hobby?
Comment: Almost - I'd say it's the participants who fund their relatively inexpensive hobby, with support from sponsors, who use it for marketing/advertising


Can you obtain a list of users via ADFS?

Question: I need to implement a company website that would be accessed from the outside of the company. It is required that the users are able to login with the same credentials as they access the company network (Active Directory). I initially thought of using ADFS but it seems that I can't access information about other users. I need to be able to list other users, get what groups they belong to, etc. It is also possible that I might have the need to modify information about users in the server.
I have no experience with anyting related to Active Directory. Is using LDAP directly with  custom authentication a better alternative? Any advice or corrections?
Answer: Active Directory Federation Services (ADFS) is primarily concerned with authentication. It is not a metadirectory and can't be used to return generalized information from Active Directory.
Accessing the Active Directory through LDAP is probably the direction you want to go, as it allows you to both query the attributes of user accounts (and other objects). Be aware that correctly interoperating with a complex AD forest (particularly one with Forest Trusts) is not a trivial thing. If you're developing an internal use application that will always be running in a single-domain environment you won't have to contend with such complexity. If you're looking at building a product for sale, however, you'll do well to learn quite a bit about Active Directory and the its complex types of deployments. (I've worked with quite a number of products that claim "LDAP integration with Active Directory" only to find that they fall to pieces when dealing with a fairly common configure such as a multi-domain environment. Don't even get me started about the bad support for multi-forest environments...)


Satterthwaite approximation vs Pooled Sample Standard Error

Question: Udacity gives two equations for standard error, and calls the second (pooled) one "corrected" without proof.
At 2:30, the narrator states that the following is the Standard Error for Independent Samples, after going through some kind of informal semantic explanation:
$$SE = \sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}} $$
$s_1$ and $s_2$ are the sample standard deviations. Later in the lesson though, in a 14 second video, the narrator blithely replaces these individual sample variances with the pooled variance:
$$SE = \sqrt{\frac{s_p^2}{n_1} + \frac{s_p^2}{n_2}} $$
The narrator specifically uses the word "corrected", implying that the first is biased...? Udacity has yet to use the word "biased" though, so perhaps I'm focusing too much on specific word choice.
Some googling led me to this video which states that the first SE formulation is the Satterthwaite approximation. It states that the Satterthwaite approximation may be always used instead of the pooled variant, which makes sense to me because it is more general.
Can I ignore the word "corrected" and always use the Satterthwaite approximation?
Answer: They are the same thing.
Let's rephrase what we want to do here. We want to use two samples t-test for statistical testing, and we have two groups. Each group has it's own variance. The variance of the two groups can be anything. This makes your first formula, where you have s1 and s2. So far, we have not assumed anything other than the sample size of two groups is equal.
Now, we assume the variance of the two groups are equal. If they are assumed be equal, it can be proven that the pooled variance is an unbiased estimator. Since they are equal, we can set s1=sp and s2=sp (sorry, I don't know how to enter symbols). Next, we simply substitute the pooled variance into the first formula and this brings you to your second formula.
Summary:

Your second formula assumes equal sample size
Your second formula assumes homoscedastic (equal variance)

The Satterthwaite approximation is related to Welch's test, which assumes the variance unequal. If you can assume equal variance, the t-test becomes much easier.
Comment: Doesn't $n_1$ and $n_2$ in both equations account for unequal sample size? As a side note, you enter symbols by surrounding with dollar signs, like this `$n_1$`. Look up "MathJax" for more info.
Comment: @DharmaTurtle No. n1 and n2 are just symbols, they can be equal or not equal.
Comment: Sorry, I wasn't specific enough in my previous comment; I am talking specifically about the first point of your summary. Don't both equations NOT assume equal sample size by having $n_1$ and $n_2$? If they assumed equal sample size, the equations would just use $n$, right?
Comment: My previous question is a bit beyond the scope of this discussion, and gives Udacity too much credit. Two notes to future readers: 1) The assumption that $n_1 = n_2$ is explicitly stated here https://en.wikipedia.org/wiki/Student%27s_t-test#Independent_two-sample_t-test 2) Many agree that the Welch test is more robust than the pooled test (despite it not strictly following the t-distribution) https://youtu.be/86ss6qOTfts?t=328 https://en.wikipedia.org/wiki/Welch%27s_t-test#Advantages_and_limitations http://daniellakens.blogspot.com/2015/01/always-use-welchs-t-test-instead-of.html
Comment: @DharmaTurtle Sorry I didn't see you previous message. n1 doesn't have to be equal to n2, but it's assumed be in Udacity.