If a company first sell its shares at 10rs per share, what would cause a sudden rise to 20rs per share? Is this price increase due to demand? How would they actually calculate that the price now should be 20rs, instead of 17, 18, etc? Is there a formula used to calculate this?
First, keep in mind that there are generally 2 ways to buy a corporation's shares:
You can buy a share directly from the corporation. This does not happen often; it usually happens at the Initial Public Offering [the first time the company becomes "public" where anyone with access to the stock exchange can become a part-owner], plus maybe a few more times during the corporations existence. In this case, the corporation is offering new ownership in exchange for a price set the corporation (or a broker hired by the corporation).
The price used for a public offering is the highest amount that the company believes it can get - this is a very complicated field, and involves many different methods of evaluating what the company should be worth. If the company sets the price too low, then they have missed out on possible value which would be earned by the previous, private shareholders (they would have gotten the same share % of a corporation which would now have more cash to spend, because of increased money paid by new shareholders). If the company sets the price too high, then the share subscription might only be partially filled, so there might not be enough cash to do what the company wanted.
You can buy a share from another shareholder. This is more common - when you see the company's share price on the stock exchange, it is this type of transaction - buying out other current shareholders. The price here is simply set based on what current owners are willing to sell at. The "Bid Price" listed by an exchange is the current highest bid that a purchaser is offering for a single share. The "Ask Price" is the current lowest offer that a seller is offering to sell a single share they currently own. When the bid price = the ask price, a share transaction happens, and the most recent stock price changes.
In the case of an "initial public offering", the brokers underwriting the share issue will look at the current earnings being generated by the company and compare these to those of other competitor companies already listed in the stock market. For example, if a new telephone company is undertaking an initial public offering, then the share price of those telephone companies which are already traded on the stock market will serve as a reference for how much investors will be willing to pay for the new company's shares. If investors are willing to pay 15 times earnings for telecom shares, then this will be the benchmark used in determining the new share price. In addition, comparative growth prospects will be taken into account. Finally, the underwriter will want to see a successful sale, so they will tend to "slightly under price" the new shares in order to make them attractive.
None of this is an exact science and we often see shares trading at a large premium to the initial offer price during the first few days of trading. More often that not, prices then settle down to something closer to the offer price. The initial price spike is usually the result of high demand for the shares by investors who believe that past examples of a price spike will repeat with this initial public offering. There will also usually be high demand for the new shares from funds that specialise in shares of the type being issued.
In the case of a "rights issue", where an existing publicly traded company wishes to raise capital by issuing new shares, the company will price the new shares at a significant discount to the current market price. The new shares will be initially offered to existing shares holders and the discounted price is intended to encourage the existing shareholders to exercise their "rights" since the new shares may have the effect of diluting the value of their shares. Any shares which are not purchased by existing share holder will then be offered for sale in the market.