text:
# How to find $\sum_{A \subset S} (\min A)$ and $\sum_{A \subset S} (\max A)$ if $S=\{1,2,…,n\}$?

Here, $\min A$ and $\max A$ denote the minimum and maximum element respectively of the set $A$.

So I have to calculate how many subsets of S have min/max element $1$, how many subsets have min/max element $2$, ... all the way upto $n$? I am not being able to intuitively understand the problem.

I want to know if there is an elegant way to do this.

• There are $2^{n-a}$ subsets whose minimal element is $a$ -- this is the number of subsets of $\{a+1,a+2,\ldots,n\}$. – Henning Makholm Jun 30 '16 at 16:43
• But which term in the sum will correspond to $A=\varnothing$? – Henning Makholm Jun 30 '16 at 16:43
• None. $\min$ and $\max$ are not defined in tihs case. – Daniel Jun 30 '16 at 16:46
• @HenningMakholm I'm afraid you have to break it down for me. – StubbornAtom Jun 30 '16 at 16:49
• For each $A$, let $\tilde{A}$ denote $n+1-A=\left\{n+1-a\,|\,a\in A\right\}$. Then, $\max(A)=n+1-\min\left(\tilde{A}\right)$. If you know $\sum\limits_{\substack{{A\subseteq S}\\{A\neq \emptyset}}}\,\max(A)$, then $$\sum_{\substack{{A\subseteq S}\\{A\neq \emptyset}}}\,\min(A)=(n+1)\left(2^n-1\right)-\sum_{\substack{{A\subseteq S}\\{A\neq \emptyset}}}\,\max(A)\,.$$ – Batominovski Jul 1 '16 at 11:09

You can work recursively. For the minimum: Denote the sum of the minimums with $m_n$ $$m_n:=\sum_{A\subset S_n}\min A$$ where $S_n=\{1,2,\dots,n\}$. Hence $S_n$ has $2^n$ subsets. Now consider the set $S_{n+1}=\{1,2,\dots,n,n+1\}$. The set $S_{n+1}$ has $2^{n+1}=2^n+2^n$ sets. The first $2^n$ sets are exactly the subsets of $S_n$ and the other $2^n$ are exactly the sets of $S_n$ with additionally the element $n+1$. So, the sum of the minimum of the first $2^n$ sets is again $m_n$ and the sum of the second $2^n$ is $m_n+(n+1)$ since $n+1$ is the minimum only of the set $\emptyset \cup \{n+1\}=\{n+1\}$. This gives you the recurrence relation $$m_{n+1}=2m_n+n+1$$ for $n\ge 1$, with $m_0=0$. Similarly, for the maximum you obtain the relation $$M_{n+1}=M_n+2^n(n+1)$$ for $n\ge 1$ with $M_0=0$.

To solve the recurrence relations, note that both are of the form $g_{n}=c\cdot g_{n-1}+f(n)$, for $n\ge 1$ with $g(0)=0$ (in the second case $c=1$ which makes things even simpler). For a general solution, rewrite this as $$\frac1{c^n}g_n=\frac{c}{c^n}g_{n-1}+\frac{f(n)}{c^n}\implies x_n=x_{n-1}+t(n)$$ with $x_n:=\dfrac{g_n}{c^n}$ and $t(n):=\dfrac{f(n)}{c^n}$. Hence, repeated substitution leads to $$x_n=x_{n-1}+t(n)=x_{n-2}+t(n-1)+t(n)=\cdots=x_0+\sum_{k=1}^nt(k)$$ Since in both cases the initial condition is $g_0=0$ you get here $$x_n=\sum_{k=1}^nt(k)\implies g_n=c^n\sum_{k=1}^nt(k)$$ or explicitly

1. For the $\min$ $($ here $c=2, f(n)=n)$: $$m_n=2^n\sum_{k=1}^n\frac{k}{2^k}=\dots=2^{n+1}-n-2$$

2. For the $\max$ $($ here $c=1, f(n)=2^{n-1}n)$: $$M_n=\sum_{k=1}^n2^{k-1}k=\dots=2^{n}(n-1)+1$$

Note. I assume that $m(\emptyset)=0$.

Question. Consider the set $S=\{1,2,3,\dots,j\}$. Let $m(A)$ denote a maximum element of a subset $A$ of $S$. Prove that $$\sum_{A\subseteq S}m(A) = (j-1)2^j+1$$ where summation ranges over all subsets $A$ of $S$.

Solution. Let us consider the element $4$. $4$ will be maximum element if we pick elements from the set $\{1,2,3,4\}$. So basically we want to count number of subsets of the set $\{1,2,3,4\}$ which contain the element $4$. This is the same as counting the number of subsets of $\{1,2,3\}$ and for each subset of $\{1,2,3\}$ we append the element $4$ to it. There are $2^3$ subsets of $\{1,2,3\}$, namely \begin{align*} \binom30 &= \{\emptyset\} \to \{4\}=\{4\}\\ \binom31 &= \{\{1\},\{2\},\{3\}\} \to \{4\}=\{\{1,4\},\{2,4\},\{3,4\}\}\\ \binom32 &= \{\{1,2\},\{1,3\},\{2,3\}\} \to \{4\}=\{\{1,2,4\},\{1,3,4\},\{2,3,4\}\}\\ \binom33 &= \{1,2,3\} \to 4=\{1,2,3,4\} \end{align*} So this gives us a one-one correspondence between the subsets of $\{1,2,3,4\}$ containing $4$ and the subset of $\{1,2,3\}$. So in general the subset of $\{1,2,3,\dots,j\}$ containing $j$ is in one-one correspondence between the subsets of $\{1,2,3,\dots,(j-1)\}$. Therefore the sum $$\sum_{A\subseteq S}m(A) = \sum_{i=1}^j i \cdot 2^{i-1}= (j-1)2^j+1.$$ Note $1\cdot1+2\cdot2+3\cdot2^3+4\cdot2^3+\dots+n\cdot2^{n-1}= \frac{d}{dx} (x+x^2+x^3+\dots+x^n)_{x=2}$

• Even if you are "too bored to tex", I think that mentioning the source of the image would be a useful information (and it would not require too much effort on your side). I suppose it is taken from some book. – Martin Sleziak Jul 1 '16 at 6:10
• @MartinSleziak This is not taken from a book. The same question was asked in a entrance exam couple of years ago. I tried solving it and sent the .pdf file to friends to share. Unfortunately I don't have the .tex file of that. I already told, in the beginning that I solved it. Why should I mention the source?? – crskhr Jul 1 '16 at 6:25
• @sc By source I meant the book from which the screenshot was taken. Now that you clarified that it is screenshot from the pdf you created and not from a book, this is no longer relevant. (And probably the page number should help me to guess that it is not from a book, if I had looked carefully enough. However, it seemed to me very likely that if this was from your own notes, you would have TeX-source, that's why asked.) In any case, since the screenshot looked like something from the book, it shows that you have TeX-ed it very nicely. – Martin Sleziak Jul 1 '16 at 6:32
• @MartinSleziak No problem. IF I had the TeX source I wouldn't be lazy to copy paste it here ;) – crskhr Jul 1 '16 at 6:35
• I have noticed that somebody downvoted your post - I am not sure whether the downvoter did this because of the picture instead of text or whether they had other reasons. In any case, I tried to edit the post based on your screenshot. It's up to you whether you will edit the text further. – Martin Sleziak Jul 1 '16 at 8:19


text:
# Need some Calculus Help

1. Sep 13, 2006

### chowder

Hello everyone!

I'm entering my first year of university calculus, and I must say, I was never really good with math. So I have a few questions. This will seem pathetic to some of the math wizzards!

1.) Show that the identity 1+cot^2 ϑ = csc^2 ϑ

follows from

sin^2 ϑ + cos^2 ϑ = 1.

2.) Solve sec^2 x = √3 tan x + 1 on [0, π)

2. Sep 13, 2006

### quasar987

Hi chowder,

you must show some work to get help.

what have you tried? what are your thoughts, etc.

3. Sep 14, 2006

### VietDao29

In case you have no idea to start off the problem, the first problem can be done by relating the cot, and csc functions to the sin, and cos functions, since you need to use the Pythagorean Identity to prove this one.
For the second problem, can sec2x be rewritten in terms of tan(x)?
$$\ces ^ 2 x = \frac{1}{\cos ^ 2 x} = \frac{\sin ^ 2 x + \cos ^ 2 x}{\cos ^ 2 x} = ...$$
-----------------
Ok, can you go from here? :)

format: plain


text:
Documentation

## Forecast State-Space Model Using Monte-Carlo Methods

This example shows how to forecast a state-space model using Monte-Carlo methods, and to compare the Monte-Carlo forecasts to the theoretical forecasts.

Suppose that the relationship between the change in the unemployment rate (${x}_{1,t}$) and the nominal gross national product (nGNP) growth rate (${x}_{3,t}$) can be expressed in the following, state-space model form.

`$\left[\begin{array}{c}{x}_{1,t}\\ {x}_{2,t}\\ {x}_{3,t}\\ {x}_{4,t}\end{array}\right]=\left[\begin{array}{cccc}{\varphi }_{1}& {\theta }_{1}& {\gamma }_{1}& 0\\ 0& 0& 0& 0\\ {\gamma }_{2}& 0& {\varphi }_{2}& {\theta }_{2}\\ 0& 0& 0& 0\end{array}\right]\left[\begin{array}{c}{x}_{1,t-1}\\ {x}_{2,t-1}\\ {x}_{3,t-1}\\ {x}_{4,t-1}\end{array}\right]+\left[\begin{array}{cc}1& 0\\ 1& 0\\ 0& 1\\ 0& 1\end{array}\right]\left[\begin{array}{c}{u}_{1,t}\\ {u}_{2,t}\end{array}\right]$`

`$\left[\begin{array}{c}{y}_{1,t}\\ {y}_{2,t}\end{array}\right]=\left[\begin{array}{cccc}1& 0& 0& 0\\ 0& 0& 1& 0\end{array}\right]\left[\begin{array}{c}{x}_{1,t}\\ {x}_{2,t}\\ {x}_{3,t}\\ {x}_{4,t}\end{array}\right]+\left[\begin{array}{cc}{\sigma }_{1}& 0\\ 0& {\sigma }_{2}\end{array}\right]\left[\begin{array}{c}{\epsilon }_{1,t}\\ {\epsilon }_{2,t}\end{array}\right],$`

where:

• ${x}_{1,t}$ is the change in the unemployment rate at time t.

• ${x}_{2,t}$ is a dummy state for the MA(1) effect on ${x}_{1,t}$.

• ${x}_{3,t}$ is the nGNP growth rate at time t.

• ${x}_{4,t}$ is a dummy state for the MA(1) effect on ${x}_{3,t}$.

• ${y}_{1,t}$ is the observed change in the unemployment rate.

• ${y}_{2,t}$ is the observed nGNP growth rate.

• ${u}_{1,t}$ and ${u}_{2,t}$ are Gaussian series of state disturbances having mean 0 and standard deviation 1.

• ${\epsilon }_{1,t}$ is the Gaussian series of observation innovations having mean 0 and standard deviation ${\sigma }_{1}$.

• ${\epsilon }_{2,t}$ is the Gaussian series of observation innovations having mean 0 and standard deviation ${\sigma }_{2}$.

Load the Nelson-Plosser data set, which contains the unemployment rate and nGNP series, among other things.

`load Data_NelsonPlosser`

Preprocess the data by taking the natural logarithm of the nGNP series, and the first difference of each. Also, remove the starting `NaN` values from each series.

```isNaN = any(ismissing(DataTable),2); % Flag periods containing NaNs gnpn = DataTable.GNPN(~isNaN); u = DataTable.UR(~isNaN); T = size(gnpn,1); % Sample size y = zeros(T-1,2); % Preallocate y(:,1) = diff(u); y(:,2) = diff(log(gnpn));```

This example proceeds using series without `NaN` values. However, using the Kalman filter framework, the software can accommodate series containing missing values.

To determine how well the model forecasts observations, remove the last 10 observations for comparison.

```numPeriods = 10; % Forecast horizon isY = y(1:end-numPeriods,:); % In-sample observations oosY = y(end-numPeriods+1:end,:); % Out-of-sample observations```

Specify the coefficient matrices.

```A = [NaN NaN NaN 0; 0 0 0 0; NaN 0 NaN NaN; 0 0 0 0]; B = [1 0; 1 0; 0 1; 0 1]; C = [1 0 0 0; 0 0 1 0]; D = [NaN 0; 0 NaN];```

Specify the state-space model using `ssm`. Verify that the model specification is consistent with the state-space model.

`Mdl = ssm(A,B,C,D)`
```Mdl = State-space model type: ssm State vector length: 4 Observation vector length: 2 State disturbance vector length: 2 Observation innovation vector length: 2 Sample size supported by model: Unlimited Unknown parameters for estimation: 8 State variables: x1, x2,... State disturbances: u1, u2,... Observation series: y1, y2,... Observation innovations: e1, e2,... Unknown parameters: c1, c2,... State equations: x1(t) = (c1)x1(t-1) + (c3)x2(t-1) + (c4)x3(t-1) + u1(t) x2(t) = u1(t) x3(t) = (c2)x1(t-1) + (c5)x3(t-1) + (c6)x4(t-1) + u2(t) x4(t) = u2(t) Observation equations: y1(t) = x1(t) + (c7)e1(t) y2(t) = x3(t) + (c8)e2(t) Initial state distribution: Initial state means are not specified. Initial state covariance matrix is not specified. State types are not specified. ```

Estimate the model parameters, and use a random set of initial parameter values for optimization. Restrict the estimate of ${\sigma }_{1}$ and ${\sigma }_{2}$ to all positive, real numbers using the `'lb'` name-value pair argument. For numerical stability, specify the Hessian when the software computes the parameter covariance matrix, using the `'CovMethod'` name-value pair argument.

```rng(1); params0 = rand(8,1); [EstMdl,estParams] = estimate(Mdl,isY,params0,... 'lb',[-Inf -Inf -Inf -Inf -Inf -Inf 0 0],'CovMethod','hessian');```
```Method: Maximum likelihood (fmincon) Sample size: 51 Logarithmic likelihood: -170.92 Akaike info criterion: 357.84 Bayesian info criterion: 373.295 | Coeff Std Err t Stat Prob ---------------------------------------------------- c(1) | 0.06750 0.16548 0.40791 0.68334 c(2) | -0.01372 0.05887 -0.23302 0.81575 c(3) | 2.71200 0.27045 10.02772 0 c(4) | 0.83816 2.84586 0.29452 0.76836 c(5) | 0.06273 2.83471 0.02213 0.98234 c(6) | 0.05197 2.56873 0.02023 0.98386 c(7) | 0.00609 2.40759 0.00253 0.99798 c(8) | 0.00035 0.13942 0.00253 0.99798 | | Final State Std Dev t Stat Prob x(1) | -0.00000 0.00609 -0.00075 0.99941 x(2) | 0.12237 0.92954 0.13164 0.89527 x(3) | 0.04049 0.00035 114.80618 0 x(4) | 0.01183 0.00036 32.42504 0 ```

`EstMdl` is an `ssm` model, and you can access its properties using dot notation.

Filter the estimated, state-space model, and extract the filtered states and their variances from the final period.

`[~,~,Output] = filter(EstMdl,isY);`

Modify the estimated, state-space model so that the initial state means and covariances are the filtered states and their covariances of the final period. This sets up simulation over the forecast horizon.

```EstMdl1 = EstMdl; EstMdl1.Mean0 = Output(end).FilteredStates; EstMdl1.Cov0 = Output(end).FilteredStatesCov;```

Simulate `5e5` paths of observations from the fitted, state-space model `EstMdl`. Specify to simulate observations for each period.

```numPaths = 5e5; SimY = simulate(EstMdl1,10,'NumPaths',numPaths);```

`SimY` is a `10`-by- `2`-by- `numPaths` array containing the simulated observations. The rows of `SimY` correspond to periods, the columns correspond to an observation in the model, and the pages correspond to paths.

Estimate the forecasted observations and their 95% confidence intervals in the forecast horizon.

```MCFY = mean(SimY,3); CIFY = quantile(SimY,[0.025 0.975],3);```

Estimate the theoretical forecast bands.

```[Y,YMSE] = forecast(EstMdl,10,isY); Lb = Y - sqrt(YMSE)*1.96; Ub = Y + sqrt(YMSE)*1.96;```

Plot the forecasted observations with their true values and the forecast intervals.

```figure h = plot(dates(end-numPeriods-9:end),[isY(end-9:end,1);oosY(:,1)],'-k',... dates(end-numPeriods+1:end),MCFY(end-numPeriods+1:end,1),'.-r',... dates(end-numPeriods+1:end),CIFY(end-numPeriods+1:end,1,1),'-b',... dates(end-numPeriods+1:end),CIFY(end-numPeriods+1:end,1,2),'-b',... dates(end-numPeriods+1:end),Y(:,1),':c',... dates(end-numPeriods+1:end),Lb(:,1),':m',... dates(end-numPeriods+1:end),Ub(:,1),':m',... 'LineWidth',3); xlabel('Period') ylabel('Change in the unemployment rate') legend(h([1,2,4:6]),{'Observations','MC forecasts',... '95% forecast intervals','Theoretical forecasts',... '95% theoretical intervals'},'Location','Best') title('Observed and Forecasted Changes in the Unemployment Rate')```

```figure h = plot(dates(end-numPeriods-9:end),[isY(end-9:end,2);oosY(:,2)],'-k',... dates(end-numPeriods+1:end),MCFY(end-numPeriods+1:end,2),'.-r',... dates(end-numPeriods+1:end),CIFY(end-numPeriods+1:end,2,1),'-b',... dates(end-numPeriods+1:end),CIFY(end-numPeriods+1:end,2,2),'-b',... dates(end-numPeriods+1:end),Y(:,2),':c',... dates(end-numPeriods+1:end),Lb(:,2),':m',... dates(end-numPeriods+1:end),Ub(:,2),':m',... 'LineWidth',3); xlabel('Period') ylabel('nGNP growth rate') legend(h([1,2,4:6]),{'Observations','MC forecasts',... '95% MC intervals','Theoretical forecasts','95% theoretical intervals'},... 'Location','Best') title('Observed and Forecasted nGNP Growth Rates')```

Download ebook


text:
## Chapter 21Notes for the sixth week: numbers and computing

Notes also available as PDF.

What we will cover from Chapter 4:

• Numbers and digits in different bases, with historical context
• Arithmetic, digit by digit

And additionally, I’ll give a brief summary of computer arithmetic.

### 21.1 Positional Numbers

A number is a concept and not just a sequence of symbols. We will be discussing ways to express numbers.

Multiple types of numbers:

nominal
A nominal number is just an identifier (or name). In many ways these are just sequences of symbols.
ordinal
An ordinal number denotes order: 1st, 2nd, \mathop{\mathop{…}}

Adding ordinal or nominal numbers doesn’t make sense. This brings up a third type:

cardinal
Cardinal numbers count.

The name comes from the cardinality of sets.

Before our current form:

• Piles of rocks don’t work well for merchants.
• Marks on sticks, then marks on papyrus.

Marking numbers is costly. A large number becomes a large number of marks. Many marks lead to many errors. Merchants don’t like errors. So people started using symbols rather than plain marks.

An intermediate form, grouping:

• Egyptian: Different symbols for different levels of numbers: units, tens, hundreds. Grouping within the levels.
• Roman: Symbols for groups, with addition and subtraction of symbols for smaller groups.
• Greek (and Hebrew and Arabic): Similar, but using all their letters for many groups.
• Early Chinese: Denote the number of marks in the group with a number itself\mathop{\mathop{…}}

Getting better, but each system still has complex rules. The main problems are with skipping groups. We now use zero to denote an empty position, but these systems used varying amounts of space. Obviously, this could lead to trade disagreements. Once zeros were adopted, many of these systems persisted in trade for centuries.

Now into forms of positional notation, shorter and more direct:

• Babylonian:
• Two marks, tens and units.
• Now the marks are placed by the number of 60s.
• Suffers from complicated rules about zeros.
• (Using 60s persists for keeping time...)
• Mayan:
• Again, two kinds of marks for fives and units.
• Two positional types: by powers of 20, and by powers of 20 except for one power of 18.
• (Note that 18 ⋅ 20 = 360, which is much closer to a year.)
• Essentially equivalent to what we use, but subtraction in Mayan is much easier to see.
• (many other cultures adopted similar systems (e.g. Chinese rods)

Current: Hindu-Arabic numeral system

The characters differ between cultures, but the idea is the same. The characters often are similar as well. Originated in the region of India and was carried west through trade. No one knows when zero was added to the digits. The earliest firm evidence is in Arab court records regarding a visitor from India and a description of zero from around 776 AD. The first inscription found with a zero is from 876 AD in India. However, the Hindu-Arabic system was not adopted outside mathematics even in these cultures. Merchants kept to a system similar to the Greek and Hebrew systems using letters for numbers.

Leonardo Fibonacci brought the numerals to Europe in the 13th century (after 1200 AD) by translating an Arabic text to Latin. By 15th century, the numeral system was in wide use in Europe. During the 19th century, this system supplanted the rod systems in Asia.

The final value of the number is based on the positions of the digits:

 1234 = 1 ⋅ 1{0}^{3} + 2 ⋅ 1{0}^{2} + 3 ⋅ 1{0}^{1} + 4 ⋅ 1{0}^{0}.

We call ten the base. Then numbers becomes polynomials in terms of the base b,

 1234 = {b}^{3} + 2 ⋅ {b}^{2} + 3 ⋅ {b}^{1} + 4.

Here b = 10.

So we moved from marks, where 1000 would require 1000 marks, to groups, where 1000 may be a single mark but 999 may require dozens of marks. Then we moved to positional schemes where the number of symbols depends on the logarithm of the value; 1000 = 1{0}^{3} requires 4 = 3 + 1 symbols.

After looking at other bases, we will look into operations (multiplication, addition, etc.) using the base representations.

### 21.2 Converting Between Bases

Only three bases currently are in wide use: base 10 (decimal), base 2 (binary), and base 16 (hexadecimal). Occasionally base 8 (octal) is used, but that is increasingly rare. Other conversions are useful for practice and for seeing some structure in numbers. The structure will be useful for computing.

Before conversions, we need the digits to use. In base b, numbers are expressed using digits from 0 to b - 1. When b is past 10, we need to go beyond decimal numerals:

 Value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Digit: 0 1 2 3 4 5 6 7 8 9 A B C D E F

Upper- and lower-case are common.

So in hexadecimal, DECAFBAD is a perfectly good number, as is DEADBEEF. If there is a question of what base is being used, the base is denoted by a subscript. So 1{0}_{10} is a decimal ten and 1{0}_{2} is in binary.

To find values we recognize more easily, we convert to decimal. Then we will convert from decimal.

#### 21.2.1 Converting to Decimal

Converting to decimal using decimal arithmetic is straight-forward. Remember the expansion of 1234 with base b = 10,

\eqalignno{ 1234 & = 1 ⋅ 1{0}^{3} + 2 ⋅ 1{0}^{2} + 3 ⋅ 1{0}^{1} + 4 ⋅ 1{0}^{0} & & \cr & = {b}^{3} + 2 ⋅ {b}^{2} + 3 ⋅ {b}^{1} + 4. & & }

Each digit of \text{D}\text{E}\text{A}\text{D} has a value, and these values become the coefficients. Then we expand the polynomial with b = 16. In a straight-forwart way,

\eqalignno{ \text{D}\text{E}\text{A}\text{D} & = \text{D} ⋅ 1{6}^{3} + \text{E} ⋅ 1{6}^{2} + \text{A} ⋅ 1{6}^{1} + \text{D} & & \cr & = 13 ⋅ 1{6}^{3} + 14 ⋅ 1{6}^{2} + 10 ⋅ 16 + 13 & & \cr & = 13 ⋅ 4096 + 14 ⋅ 256 + 10 ⋅ 16 + 13 & & \cr & = 57005. & & }

We an use Horner’s rule to expand the polynomial in a method that often is faster,

\eqalignno{ \text{D}\text{E}\text{A}\text{D} & = ((13 ⋅ 16 + 14) ⋅ 16 + 10) ⋅ 16 + 13 & & \cr & = (222 ⋅ 16 + 10) ⋅ 16 + 13 & & \cr & = 3562 ⋅ 16 + 13 & & \cr & = 57005. & & }

Let’s try a binary example. Convert 110{1}_{2} to decimal:

\eqalignno{ 110{1}_{2} & = (((1 ⋅ 2 + 1) ⋅ 2 + 0) ⋅ 2 + 1 & & \cr & = (3 ⋅ 2 + 0) ⋅ 2 + 1 & & \cr & = 6 ⋅ 2 + 1 & & \cr & = 13. & & }

Remember the rows of a truth table for two variables? Here,

\eqalignno{ 1{1}_{2} & = 2 + 1 = 3, & & \cr 1{0}_{2} & = 2 + 0 = 2, & & \cr 0{1}_{2} & = 0 + 1 = 1,\text{ and} & & \cr 0{0}_{2} & = 0 + 0 = 0. & & }

#### 21.2.2 Converting from Decimal

To convert to binary from decimal, consider the previous example:

\eqalignno{ 13 & = 8 + \mathbf{5} & & \cr & = 8 + 4 + \mathbf{1} & & \cr & = 1 ⋅ {2}^{3} + 1 ⋅ {2}^{2} + 0 ⋅ {2}^{1} + 1 ⋅ {2}^{0} & & \cr & = 110{1}_{2}. & & }

At each step, we find the largest power of two less than the remaining number. Another example for binary:

\eqalignno{ 293 & = 256 + \mathbf{37} & & \cr & = 256 + 32 + \mathbf{5} & & \cr & = 256 + 32 + 4 + 1 & & \cr & = 1 ⋅ {2}^{8} + 1 ⋅ {2}^{5} + 1 ⋅ {2}^{2} + 1 & & \cr & = 10010010{1}_{2}. & & }

\eqalignno{ 293 & = 256 + \mathbf{37} & & \cr & = 1 ⋅ 256 + 2 ⋅ 16 + 5 & & \cr & = 12{5}_{16}. & & }

You can see why some people start remembering powers of two.

If you have no idea where to start converting, remember the relations {b}^{{\mathop{log}\nolimits }_{b}x} = x and {\mathop{log}\nolimits }_{b}x =\mathop{ log}\nolimits x∕\mathop{log}\nolimits b. Rounding {\mathop{log}\nolimits }_{b}x up to the larger whole number gives you the number of base b digits in x.

The text has another version using remainders. We will return to that in the next chapter. And conversions to and from binary will be useful when we discuss how computers manipulate numbers.

### 21.3 Operating on Numbers

Once we split a number into digits (decimal or binary), operations can be a bit easier.

We will cover multiplication, addition, and subtraction both

• to gain familiarity with positional notation, and
• to compute results more quickly and mentally.

Properties of positional notation will help when we explore number theory.

We will use two properties frequently:

• Both multiplication and addition commute (a + b = b + a) and re-associate (a + b) + c = a + (b + c).
• Multiplication distributes over addition, so a(b + c) = ab + ac.
• Multiplying powers of a common base adds exponents, so {b}^{a} ⋅ {b}^{c} = {b}^{a+c}.

#### 21.3.1 Multiplication

Consider multiplication. I once had to learn multiplication tables for 10, 11, and 12, but these are completely pointless.

Any decimal number multiplied by 10 is simply shifted over by one digit,

\eqalignno{ 123 ⋅ 10 & = (1 ⋅ 1{0}^{2} + 2 ⋅ 1{0}^{1} + 3 ⋅ 1{0}^{0}) ⋅ 10 & & \cr & = 1 ⋅ 1{0}^{3} + 2 ⋅ 1{0}^{2} + 3 ⋅ 1{0}^{1} & & \cr & = 1230. & & }

Multiplying by 11 = 1 ⋅ 10 + 1 is best accomplished by adding the other number to itself shifted,

 123 ⋅ 11 = 123 ⋅ (10 + 1) = 1230 + 123 = 1353.

And for 12 = 1 ⋅ 10 + 2, you double the number,

 123 ⋅ 12 = 123 ⋅ (10 + 2) = 1230 + 246 = 1476.

Multiplying longer numbers quickly follows the same pattern of shifting and adding. We can expand 123 ⋅ 123 = 123 ⋅ (1 ⋅ 1{0}^{2} + 2 ⋅ 10 + 3) to

 1 2 3 × 1 2 3 3 6 9 2 4 6 0 1 2 3 0 0 1 5 1 2 9

Another method expands the product of numbers as a product of polynomials, working one term at a time. This is essentially the same but not in tabular form:

\eqalignno{ 123 ⋅ 123 & = (1 ⋅ 1{0}^{2} + 2 ⋅ 10 + 3) ⋅ (1 ⋅ 1{0}^{2} + 2 ⋅ 10 + 3) & & \cr & = (1 ⋅ 1{0}^{2} + 2 ⋅ 10 + 3) ⋅ (1 ⋅ 1{0}^{2} + 2 ⋅ 10) + (1 ⋅ 1{0}^{2} + 2 ⋅ 10 + 3) ⋅ 3 & & \cr & = (1 ⋅ 1{0}^{2} + 2 ⋅ 10 + 3) ⋅ (1 ⋅ 1{0}^{2} + 2 ⋅ 10) + (3 ⋅ 1{0}^{2} + 6 ⋅ 10 + 9) & & \cr & = \mathop{\mathop{…}} & & }

This form splits the sums apart as well; we will cover that next.

Bear in mind that short-term memory is limited to seven to eight pieces of information. Structure mental arithmetic to keep as few pieces in flight as possible. One method is to break multiplication into stages. In long form, you can group the additions. For example, expanding 123 ⋅ 123 = 123 ⋅ (1 ⋅ 1{0}^{2}) + (123 ⋅ 23) = 123 ⋅ (1 ⋅ 1{0}^{2}) + (123 ⋅ 2 ⋅ 10 + 123 ⋅ 3),

 1 2 3 × 1 2 3 3 6 9 2 4 6 0 2 8 2 9 1 2 3 0 0 1 5 1 2 9

Assuming a small number uses only one slot in your short-term memory, need track only where you are in the multiplier, the current sum, the current product, and the next sum. That leaves three to four pieces of information to use while adding.

One handy trick for 15% tips: divide by ten, divide that amount by two, and add the pieces. We can use positional notation to demonstrate how that works,

\eqalignno{ x ⋅ 15% & = (x ⋅ 15)∕100 & & \cr & = ((x ⋅ (10 + 5))∕100 & & \cr & = ((x ⋅ 10) + (x ⋅ (10∕2)))∕100 & & \cr & = x∕10 + (x∕10)∕2 & & }

Digit-by-digit addition uses the commutative and associative properties:

\eqalignno{ 123 + 456 & = (1 ⋅ 1{0}^{2} + 2 ⋅ 10 + 3) + (4 ⋅ 1{0}^{2} + 5 ⋅ 10 + 6) & & \cr & = (1 + 4) ⋅ 1{0}^{2} + (2 + 5) ⋅ 10 + (3 + 6) & & \cr & = 579. & & }

Naturally, when a digit threatens to roll over ten, it carries to the next digit. Expanding the positional notation,

\eqalignno{ 123 + 987 & = (1 ⋅ 1{0}^{2} + 2 ⋅ 10 + 3) + (9 ⋅ 1{0}^{2} + 8 ⋅ 10 + 7) & & \cr & = (1 + 9) ⋅ 1{0}^{2} + (2 + 8) ⋅ 10 + (3 + 7) & & \cr & = 10 ⋅ 1{0}^{2} + 10 ⋅ 10 + 10. & & }

Because the coefficients are greater than b - 1 = 9, we expand those coefficients. Commuting and reassociating,

\eqalignno{ 123 + 987 & = 10 ⋅ 1{0}^{2} + 10 ⋅ 10 + 10 & & \cr & = (1 ⋅ 10 + 0) ⋅ 1{0}^{2} + (1 ⋅ 10 + 0) ⋅ 10 + (1 ⋅ 10 + 0) & & \cr & = 1 ⋅ 1{0}^{3} + 1 ⋅ 1{0}^{2} + 1 ⋅ 10 + 0 & & \cr & = 1110. & & }

However, when working quickly, or when the addition will be used in another operation, you do not need to expand the carries immediately. This is called a redundant representation because numbers now have multiple representations. You can represent 13 as 1 ⋅ 10 + 3 or simply as 13.

If you work that way mentally, you need to keep the intermediate results in memory. So during multiplying, you only need to work out the carries every three to four digits\mathop{\mathop{…}}

#### 21.3.3 Subtraction

In systems with signed numbers, we know that subtracting a number is the same as adding its negation: a - b = a + (-b). So we expect the digit-by-digit method to work with each digit subtracted, and it does. Because - a = -1 ⋅ a, we can distribute the sign over the digits:

\eqalignno{ 456 - 123 & = (4 ⋅ 1{0}^{2} + 5 ⋅ 10 + 6) - (1 ⋅ 1{0}^{2} + 2 ⋅ 10 + 3) & & \cr & = (4 ⋅ 1{0}^{2} + 5 ⋅ 10 + 6) + (-(1 ⋅ 1{0}^{2} + 2 ⋅ 10 + 3)) & & \cr & = (4 ⋅ 1{0}^{2} + 5 ⋅ 10 + 6) + (-1 ⋅ 1{0}^{2} + -2 ⋅ 10 + -3) & & \cr & = (4 - 1) ⋅ 1{0}^{2} + (5 - 2) ⋅ 10 + (6 - 3) & & \cr & = 333. & & }

As with carrying, borrowing occurs when a digit goes negative:

\eqalignno{ 30 - 11 & = (3 ⋅ 1{0}^{1} + 0) - (1 ⋅ 1{0}^{1} + 1) & & \cr & = (3 - 1) ⋅ 1{0}^{1} + (0 - 1) & & \cr & = 2 ⋅ 1{0}^{1} + -1 & & \cr & = 1 ⋅ 1{0}^{1} + (10 - 1) & & \cr & = 1 ⋅ 1{0}^{1} + 9 & & \cr & = 19. & & }

Again, you can use a redundant intermediate representation of 2 ⋅ 1{0}^{1} - 1 if you’re continuing to other operations. And if all the digits are negative, you can factor out - 1,

\eqalignno{ 123 - 456 & = (1 ⋅ 1{0}^{2} + 2 ⋅ 10 + 3) - (4 ⋅ 1{0}^{2} + 5 ⋅ 10 + 6) & & \cr & = (1 - 4) ⋅ 1{0}^{2} + (2 - 5) ⋅ 10 + (3 - 6) & & \cr & = (-3) ⋅ 1{0}^{2} + (-3) ⋅ 10 + (-3) & & \cr & = -(3 ⋅ 1{0}^{2} + 3 ⋅ 10 + 3) & & \cr & = -333. & & }

#### 21.3.4 Division and Square Root: Later

We will cover these later with number theory.

### 21.4 Computing with Circuits

No one can argue that computing devices (computers, calculators, medical monitors, etc.) are irrelevant to everyday life. Here we lay the groundwork for how computers compute.

Essentially, computers perform arithmetic on binary numbers. But different methods of combining the arithmetic operations produce character strings, sounds, graphics, \mathop{\mathop{…}}

While those are courses in themselves, we at least can explain the very lowest levels of computer arithmetic. Automated computing is in its relative infancy. People have been building roads, bridges, and vehicles for thousands of years. Even motors are hundreds of years old. But modern computing is less than a hundred years old and became wide-spread only 30 years ago. Before the 1970s, desktop calculators were rare. And before the 1980s, calculators were virtually unaffordable.

Maybe someday we will be able to take safe computing for granted just like we take safe bridges for granted, but not yet. It’s important at least to have heard how computing works so you can gain a sense of where limitations are. Consider an issue like the largest range of numbers you can represent exactly in a calculator, spreadsheet, or other program. Each may have different limitations that appear random but certainly are not. Having some sense of how computers compute lets you explain or (hopefully) anticipate limitations and work around them.

#### 21.4.1 Representing Signed Binary Integers

Converting non-negative numbers to binary is straight-forward. Computer representations work with a limitied number of binary digits, or bits. With 32 bits, any non-negative integer less than {2}^{33} = 8589934592 ≈ 1{0}^{9.9} can be represented exactly. With n bits, all non-negative integers less than {2}^{n+1} can be represented exactly. For example, the largest two bit number is 1{1}_{2} = 3 < {2}^{2} = 4.

Representing both positive and negative numbers, however, presents some design choices. One can use one of the bits (often the leading bit) as a sign bit. The number then becomes - {1}^{\text{sign bit}}⋅ the rest of the bits. This reduces the representable range of n bits to (-({2}^{n}),{2}^{n}) and requires treating one bit specially during operations. (The notation (a,b) is an open range, one that does not include its endpoints.) We need separate operations for a + b and a - b. Also, we need to cope with + 0 and - 0.

We can eliminate the need for separate operations and also eliminate the signed zero.

A representation named one’s complement plays a little trick with arithmetic to absorb the sign into the number. This allows using addition for subtraction\mathop{\mathop{…}}

We start by negating a number if it is negative:

 # Bits 3 0 1 1 2 0 1 0 1 0 0 1 0 0 0 0 -0 1 1 1 -1 1 1 0 -2 1 0 1 -3 1 0 0

Adding two n-digit numbers may produce an n + 1-digit result. For example, 1{1}_{2} + 1{1}_{2} = 11{0}_{2} in binary or 5 + 6 = 11 in decimal. Consider three bit addition:

 1 1 0 + 1 0 1 0 0 0

If we capture the carry bit 1 and feed it back around, then 11{0}_{2} + 1{0}_{2}\mathrel{↦}00{0}_{2} + {1}_{2} = {1}_{2}. In one’s complement, this is - 1 + 2 = 1 as expected.

So to add two numbers, positive or negative, we just add the one’s complement representation. To subtract a - b, we negate b and add it to a. We only need one operation, addition, for addition and subtraction.

But we still have given an entire bit over to the sign. We can do slightly better with two’s complement. More importantly, we can reduce the system to having only a single, unsigned zero. Having an unsigned zero is much easier to handle with multiplication and division.

To represent a negative number in two’s complement, we negate it and add one:

 # Bits 3 0 1 1 2 0 1 0 1 0 0 1 0 0 0 0 -1 1 1 1 -2 1 1 0 -3 1 0 1 -4 1 1 1

By not including -0, we have room for one more number. By the two’s complement method, it happens to fall on the end of the negative scale. Here, n bits represent all integers in [-{2}^{n},{2}^{n}). (The notation [a,b] is a closed range including a and b. Notations using square brackets on one side but not the other are half-open and include the end-point against the square bracket.)

There are other representations:

• A biased representation adds {2}^{n-1} or {2}^{n-1} - 1 to every number and then represents the result. This shifts all the negative numbers to be non-negative. This representation has an explicit sign bit but only a single zero.
• A base -2 rather than base 2 representation is bizarre, but it works. These most often are used for redundant representations inside other arithmetic operations. There are twice as many negative numbers as positive numbers, no sign bit, and only a single zero.
• Larger bases can be used by grouping bits. This also allows for more redundant representations. One representation using 1, 0, and -1 for digits is particularly interesting, but we won’t cover it here.

#### 21.4.2 Adding in Binary with Logic

Above we have reduced addition and subtraction of signed numbers into simple addition. Here we implement addition in logic and construct the half adder and full adder circuits.

Consider a truth table for a ∧ b and a ⊕ b (exclusive or):

 a b a ∧ b a ⊕ b a + b 1 1 1 0 1{0}_{2} 1 0 0 1 0{1}_{2} 0 1 0 1 0{1}_{2} 0 0 0 0 0{0}_{2}

If we append a column representing the sum of a and b in binary, we see that the first digit is a ∧ b and the second is a ⊕ b!

This is a half adder. The half adder takes two bits as input and produces a sum bit s = a ⊕ b and a carry bit c = a ∧ b.

(drawing)

A full adder takes input bits and a previous carry bit to produce an output sum and carry. We can add a + b and then (a + b) + {c}_{\text{in}}. Note that only one of those sums can generate a carry, so or-ing the carry outputs generates the final output. 1 + 1 + 1 = 3 = 1{1}_{2} < 10{0}_{2}, so the sum’s output cannot require more than two bits.

So a full adder can be constructed with two half-adders and one extra or-gate for the carry:

 a b {c}_{\text{in}} (a ⊕ b) ⊕ {c}_{\text{in}} (a ∧ b) ∨ ({c}_{\text{in}} ∧ (a ⊕ b)) 1 1 1 1 1 1 1 0 1 0 1 0 1 1 0 1 0 0 0 1 0 1 1 1 0 0 1 0 0 1 0 0 1 0 1 0 0 0 0 0

To add two n bit numbers, you start by adding the low-order bits (coefficient in front of {2}^{0}) with a half-adder. The sum is output and the carry follows into a full adder for adding the coefficients of {2}^{1}. The process continues resulting in an n-bit sum and a single carry bit.

The carry bit often is ignored, leading to overflow and wrap-around. At a low level, adding two positive integers each greater than {2}^{n-1} produces a negative number! This is terribly handy for some algorithms and detrimental to others. All architectures make the carry bit available for diagnosing overflow, but not all programming environments let users access that information.

Adding two n-bit numbers requires a minimum of one half-adder and n - 1 full adders, or 2n - 1 half-adders and n - 1 or gates, or 2n - 1 exclusive-or gates, 2n - 1 and gates, and n - 1 or gates. Because of the dependence on the previous bit sum’s carry output, it appears that each bit must be computed one at a time, or serially. There are tricks using redundant representations that allow computing the result in larger chunks, exposing more parallelism within the logic gates.

Given addition, we could implement multiplication as repeated addition. Remember the Egyptian algorithm from the text?

The binary representation of the multiplier serves as a mask. Consider multiplying the 3-bit numbers 01{1}_{2} = 3 and 10{1}_{2} = 5:

 0 1 1 ⋅ 1 0 1 1 ⋅ 0 0 1 1 ⋅ 1 0 1 1 1 1

At each step, the bits of 10{1}_{2} determine whether or not a shifted copy of 01{1}_{2} is added into the result. We can implement this by shifting and adding serially, or we can construct a multiplier array out of adders.

Again, there are optimizations related to redundant representations, but ultimately most processors dedicate a large amount of their physical size (and “power budget”) to multiplier arrays.

The problem of overflow becomes very important for multiplication. Because {2}^{n} ⋅ {2}^{n} = {2}^{2n}, the product of two n-bit numbers may require 2n bits. Most architectures deliver the result in two n-bit registers (the limited number of variables a processor has to work with).

#### 21.4.4 Decimal Arithmetic from Binary Adders

Ok, so we can add, subtract, and multiply numbers in binary. What about decimal? Alas, we lack the nifty two’s complement tricks in decimal, so all decimal units need to cope with signs differently. Most use explicit signs and always convert -0 to 0.

For integers, conversion back and forth can occur exactly as in class. With 32 bits, there are at most ⌈32 ⋅{\mathop{ log}\nolimits }_{10}2⌉ = 10 decimal digits. (The notation ⌈x⌉ rounds x to the closest integer k > x.) So software can lop off digits one at a time, often using the text’s algorithm with remainders.

There are times when you want to work directly with decimal numbers, however. Some of these are dictated by legal or engineering considerations. For example, the “cpu” of a hand-held calculator is does not really run software or store many intermediate results. There, every result is calculated in decimal often using a representation called BCD for binary coded decimal.

A decimal number is represented digit-by-digit in binary. So 29 = 2 ⋅ 10 + 9 = (1{0}_{2}) ⋅ 10 + (100{1}_{2}). This is relatively inefficient. The largest two digits 8 and 9 both require four bits, but the rest require only three. So six binary strings are not used and cannot represent digits. For example, 101{0}_{2} = 10 > 9, so 101{0}_{2} will never appear in a correct BCD digit encoding. In BCD, results mostly are computed digit-by-digit in binary and then manipulated into a correct BCD encoding.

Using four bits per digit has one major advantage; each decimal digit is a hexadecimal digit. So the hex number 159{4}_{16} is interpreted as the decimal 1594. This also allows a nifty trick for adding two BCD-encoded numbers.

Say we want to add a = 1103 and b = 328. In decimal, a + b = 1431. If we were to add these directly in hexadecimal, a + b = 142{\text{B}}_{16}. There needs to be some mechanism for carrying. We can use the six missing code points to force a carry into the next digit, and then we can compare with the exclusive-or to detect where carries actually happened.

The procedure starts by adding 6 to each BCD digit as if they were hexadecimal. So we shift each digit of a to the top of its hex range and use a + 666{6}_{16} = 776{9}_{16}. Now we compute a sum {s}_{1} = (a + 666{6}_{16}) + b = 7\text{A}9{1}_{16}. This isn’t the final sum; if we subtract 6 from every digit, 7\text{A}9{1}_{16} - 666{6}_{16} = 142{\text{B}}_{16}, we do not obtain a BCD-encoded number.

We need to subtract 6 only from those digits that did not generate a carry, 7\text{A}9{1}_{16} - 666{0}_{16} = 143{1}_{16}. This is a correct BCD number and the correct result. The carries can be detected by comparing (a + 666{6}_{16}) + b with (a + 666{6}_{16}) ⊕ b, the bitwise exclusive or. If the two results differ in the lowest bit per hex digit / BCD digit, we know there was a carry and we know where to subtract {6}_{16}.

Alas, there are no particularly nice tricks for multiplication. But if most uses include adding a list of prices and applying a tax once, it’s not so bad.

Another form that wastes far less space is called millennial encoding. Because {2}^{10} = 1024 > 1{0}^{3}, ten bits can represent all three decimal digit numbers. This wastes only 25 encoding points per three decimal digits, as opposed to wasting six points every for every single decimal digit. Arithmetic operates in binary on the chunks of ten bits and then manipulates the results.

And there are more encodings, including Tien Chi Chen and Dr. Irving T. Ho’s Chen-Ho encoding (1975), Mike Cowlishaw’s DPD encoding (densely packed decimal, 2002), and Intel’s BID encoding (binary integer decimal). These require more complicated coding techniques to explain, but the latter two (DPD and BID) are now (as of August, 2008) international standards.


text:
# How does strength work in Verilog?

I want to create an assignment which takes care of pull-ups from a port pin. I wrote the following:

module test5;

reg value;
reg output_enable;
reg pullup_enable;

wire pullup_helper;
wire value_helper;
wire outp;

assign (highz0, pull1 ) pullup_helper = pullup_enable;
assign                   value_helper = output_enable ? value : 1'bz;
assign                           outp = value_helper  + pullup_helper;

always @(pullup_helper) $display ( "pullup_helper %b", pullup_helper ); always @(value_helper)$display ( "value_helper %b", value_helper );
always @(outp) $display ( "outp %b", outp ); initial begin$display ("Start");
pullup_enable = 0;
output_enable = 0;
value = 0;
#1
$display ("1"); output_enable = 1; #1$display ("2");
value = 1;
#1
$display ("3"); value = 0; #10$display("End");
end

endmodule

I got the output:

Start
pullup_helper z
value_helper z
1
value_helper 0
2
value_helper 1
3
value_helper 0
End

Q: Why does outp never change?

EDIT: Because the full answer is related to some comments on the given answers I will summarize the results:

As with support from Greg the answer to the problem is in two steps:

The default installation on Fedora 22 is Icarus 0.9.6. This version is buggy. As Greg tested also version 0.9.7 has the same bug. I installed the latest released version v10 (changed version conventions?)

The second part is simply let drive to assign statements into one wire.

assign (pull1,pull0)  bus = pullup_en ? 1'b1 : 1'bz;
assign                bus = output_en ? value : 1'bz;

With Icarus Verilog V10 it works as expected.

• I get a compile error with 2 simulators. I think you need to change z to 1'bz. – toolic Oct 22 '15 at 17:43
• What do you expect outp to be at what times? – toolic Oct 22 '15 at 17:47
• I expect by setting output_enable that outp becomes the state of value but I always get 'x' as undefined. I can't get any kind of wire to work which can held the value of "low", "high" and "pullup" and no idea how to deal with that. I believe that my idea of a "wire" is totally wrong. It looks that it is simply impossible to drive a wire from multiple assignments. I simply can't catch the idea how the typical way in verilog is to deal with "wires". I think in the electronic way where multiple ports of a controller can added to a network. I simply have no idea how can I write that in verilog. – Klaus Oct 23 '15 at 15:03

Verilog strengths can be a bit of complicated process understand. To get the full breath of understanding read: IEEE Std 1800-2012 § 10.3, 21.2.1.5, and 28.10 through 28.16.

To print the strength of a bit in a display message, use %v instead of %b. (§ 21.2.1.5)

Verilog mostly works in the digital logic space. Verilog strength only comes into play when two or more assignments continuously drive the same net as a from of conflict resolution. The strength value does not propagate through assignment statements. The strength value can be passed through the verilog switch primitives: nmos, pmos, tranif1, tranif0, cmos, tran, plus resistive switch primitives (which weakens the strengths on pass-through). For verilog primitives switches refer to IEEE Std 1800-2012 § 28.7 through 28.9.

assign (pull1,pull0)  bus = pullup_en ? 1'b1 : 1'bz;
assign                bus = output_en ? value : 1'bz;

assign                out = bus;
assign (weak1,weak0) outw = bus;
cmos inst_name (outs, bus, 1'b1, 1'b0);

// pullup_en output_en  |  out(%v)         outw(%v)        outs(%v)
// ---------------------+----------------------------------------------
//       0         0    |  1'bx(StX)       1'bx(WeX)       1'bz(HiZ)
//       0         1    |  value(St1,St0)  value(We1/We0)  value(St1/St0)
//       1         0    |  1'b1(St1)       1'b1(We1)       1'b1(Pu1)
//       1         1    |  value(St1,St0)  value(We1/We0)  value(St1/St0)

Pullup/pulldown logic from a standard cells libraries provide by your vendor can be used for synthesis. Some synthesizers have pragmas to indicate a pullup/pulldown on a bus. Out side of that, verilog strength is typically not synthesizable. FPGAs have limited bidirectional bus support; if any. ASICs typically try to minimize the size and use of a bidirectional buses.

• I still can't understand what is going on. If I simply assign (pull0,pull1) bus = pullup_en ? 1'b1 : 1'bz;and let pullup_en= 1; the result is bus 1 St1 displayed with (%b %v) . Why the strength results in strong and not in pull up? – Klaus Oct 23 '15 at 7:55
• What is the value of output_en? Working example on edaplayground – Greg Oct 23 '15 at 15:23
• Thanks for your example. The problem is the line 'pullup_en:1 output_en:1 value:0 :: bus:x(StX) out:x(StX) outw:x(WeX) outs:x(StX)'. My expected result is simply that the output_en anables the driver and "overwrite" the pullup with 0 as in the real world. The result should be simply "0" and not "x". – Klaus Oct 23 '15 at 16:15
• I changed both assign lines in your code with the following ones: rnmos r3( bus, 1'b1, pullup_en ); nmos p4( bus, value, output_en ); This seems to work. – Klaus Oct 23 '15 at 16:23
• Curious, what simulator are your running? – Greg Oct 23 '15 at 17:16

When I view the waveforms, I see outp is always unknown (x). outp never changes because pullup_helper is always z. pullup_helper is always z because pullup_enable is always 0. You specified highz0 for when pullup_enable is 0 in your assign statement. Refer to IEEE Std 1800-2012, section 10.3.4 "Continuous assignment strengths".

• My expectation was that setting output_enable result in value_helper becomes the value of value. And then I thought the strength of value_helper is higher and outp is set correct. But outp is never set. I still can not understand what the problem here is. – Klaus Oct 23 '15 at 6:56


text:
# Tango with Him

I am not a dead-knot ribbon. I can be un-knotted.

Let me loose, let me go.

Let me breathe, let me flow.

Let me leap, let me soar.

Let me go where I’ve never been before.

Eeps! I say.

Do You mean I have to go far away?

No, no, if I may.


text:
Jaeden Frederick

2022-01-25

I cannot find how or why this,
$5\mathrm{sin}3x-1=3$
Has one of two solutions being this,
$42.99+n×{120}^{\circ }$
I am lost on how to get this solution. I have found the other one, so I will not mention it.

Emilie Booker

Expert

Note that $\mathrm{sin}3x=\mathrm{sin}\left({180}^{\circ }-3x\right)=45={\mathrm{sin}53.1}^{\circ }$, which gives two sets of solutions,
$3x={53.1}^{\circ }+n{360}^{\circ }$
$3x={\left(180-53.1\right)}^{\circ }+n{360}^{\circ }$
with n being integers. Thus, the complete sultions are

Do you have a similar question?


text:
# Calculating Differential equation RLC Circuit

Hi,
I tried to find the voltage on the capacitor as a function of time, Vc(t).
In the initial condition (t<0) the switch was closed and the current source was open circuit, so I found the initial conditions for the capacitor and the inductor ( VC(0)=65v, and IL(0)=1A).
At t=0, the switch will open and the current source connect to circuit like the picture here.
I'd tried to write the differential equation of the circuit and got something weird:

I know that the equation of RLC circuit 2d must be positive, otherwise, I will get one of the roots positive which is impossible.
Please, I need your help, what is important to me is to proof the equation so I can show the lecturer that he was wrong, but I'm not sure if what I did was right.
Here is the solution of the lecturer:
(A1 and A2 easy to find)

the decition of current in the inductor is true:

• Well, first of all, your initial conditions are wrong. – Jan Feb 9 at 20:01
• @Jan why ??? the initial condition are true, the switch is closed and there is no current source, so in s.s the capacitor is open-circuit and the inductor short circuit, the voltage across the capacitor is a voltage divider, and the current through the inductor is voltage source divided by 2 resistors (1A) – Knowledge Feb 9 at 20:06
• The schematic is not clear the current source is open circuit for t<0. Guess that is confusing – Huisman Feb 9 at 20:30
• @Huisman but i fixed it... why no one can help me – Knowledge Feb 9 at 21:50
• @Knowledge I get your lecturer's result. – jonk Feb 9 at 23:21

Since everyone seems to have been variously confused at different times about your question, let me re-draw and re-phrase it:

simulate this circuit – Schematic created using CircuitLab

(The above reflects the case after the switch opens and after the current source has been added, both at $$\t=0\$$.)

On the left is your new circuit (without initial conditions showing, as I think it is unnecessary in order to answer your question.) On the right is the same circuit through a simple, obvious Thevenin transformation about which I'm sure you agree. I prefer the right side because it makes it a little easier to answer your question about the lecturer's answer.

Let's use KCL for the node marked as $$\V_t\$$:

$$C\,\:\frac{\text{d}\,V_{\left(t\right)}}{\text{d}t}+\frac1{L}\int V_{\left(t\right)} \:\text{d}t=\frac1{L}\int V_{s\left(t\right)} \:\text{d}t$$

(I've placed out-flowing currents on the left and in-flowing currents on the right.)

Some development results in:

\begin{align*} \frac{\text{d}\,V_{\left(t\right)}}{\text{d}t}+\frac1{L\,C}\int V_{\left(t\right)} \:\text{d}t&=\frac1{L\,C}\int V_{s\left(t\right)} \:\text{d}t\\\\ \frac{\text{d}^2\,V_{\left(t\right)}}{\text{d}t^2}+\frac{V_{\left(t\right)}}{L\,C}&=\frac{V_{s\left(t\right)}}{L\,C}\\\\ \end{align*}

But we also know that the current, $$\I_{\left(t\right)}\$$, is everywhere the same throughout the right-hand circuit. So it follows that:

$$V_{s\left(t\right)}=39\:\text{V}-R\,I_{\left(t\right)} = 39\:\text{V}-R\,C\,\:\frac{\text{d}\,V_{\left(t\right)}}{\text{d}t}$$

Substituting in:

\begin{align*} \frac{\text{d}^2\,V_{\left(t\right)}}{\text{d}t^2}+\frac{V_{\left(t\right)}}{L\,C}&=\frac{1}{L\,C}\left(39\:\text{V}-R\,C\,\:\frac{\text{d}\,V_{\left(t\right)}}{\text{d}t}\right)\\\\ \frac{\text{d}^2\,V_{\left(t\right)}}{\text{d}t^2}+\frac{R}{L}\:\frac{\text{d}\,V_{\left(t\right)}}{\text{d}t}+\frac{V_{\left(t\right)}}{L\,C}&=\frac{39\:\text{V}}{L\,C} \end{align*}

Which is just a 2nd order diff-eq I'm sure you can solve.

But just looking at the characteristic equation, ($$\s^2+650\,s+1\times 10^5=0\$$), you would easily find $$\s=-400\$$ and $$\s=-250\$$. Which is a huge clue for setting up the general solution.

The lecturer's general solution is correct.

• My problem is me how to decide the direction of current in the inductor and capacitor? when the switch is closed, I agree with this that direction of current in the capacitor as what you wrote, but the current direction of the inductor, before the switch is opened, into the left side ... because the voltage source is alone in circuit and easy to see it, am i right? – Knowledge Feb 10 at 10:37
• I add another picture in the post, maybe what confuse me is to decide the direction of the currents before and after ... it always confuses me! – Knowledge Feb 10 at 10:40
• @Knowledge It's a matter of taking a convention and sticking with it during analysis. The voltage at $V_{\left(t\right)}$ rises when the current direction is down as shown in the right-side diagram. So just stay with that convention. This also sets the direction through $R$ for analysis purposes. It's pretty basic. Yes, I completely ignored your initial condition direction. But that's just a sign change in your case, when analyzing the constants of integration. It doesn't change the analysis or the characteristic equations that develop. – jonk Feb 10 at 10:42
• So this is that we were taught that the direction of the current we set before opening the circuit switch, we must continue with the same direction even after opening the circuit switch because I listened to the lecturer's instruction, the circuit analysis made that one of the signs in the equation I came up with was negative, The main problem here is the sign of one of coefficients , is that what causes problems, your opinion? – Knowledge Feb 10 at 10:51
• @Knowledge If you solve out the general equation's specific constants of integration correctly, then you will find that the current will indeed be in that direction at $t=0$ and that this particular oppositely-directed current through $R$ will indeed lead to the right initial voltage for $V_{s\left(t\right)}$, too. There is no conflict here. None at all. In fact, I recommend that you also solve out $V_{s\left(t\right)}$ so that you can see this initial direction more easily. – jonk Feb 10 at 10:55

One way to get the initial condition is through the Thevenin equivalent circuit of the current source and the resistor in parallel of it. Then, the initial DC voltage of the cap and DC current of the inductor can be solved easily, considering L1 as a short, and C1 as an open circuit.

• Don't forget that the switch opens at $t=0$. – jonk Feb 10 at 0:07
• True, but to calculate the initial condition, which is the voltage of the cap before opening the switch, the circuit is right. – X J Feb 10 at 0:11
• I think the OP already knows the initial conditions, since they are shown on the drawing already. The OP wants to confirm (or refute) the general solution provided by the lecturer after $t=0$. – jonk Feb 10 at 0:12
• Wasn't that wrong? – X J Feb 10 at 0:13
• I think the OP has the initial conditions correctly stated (though I don't care because the lecturer's solution leaves that as a detail.) And no, I do think the lecturer was right, per the development I performed here. But, of course, only the OP knows if I understood the question well enough. There seems to be a lot of confusion over the details. So I won't know until the OP responds. But the fact I get the same solution as the lecturer is ... suggestive. – jonk Feb 10 at 0:16


text:
Unlimited Plugins, WordPress themes, videos & courses! Unlimited asset downloads! From \$16.50/m

# Android Architecture Components: the Room Persistence Library

This post is part of a series called Android Architecture Components.
Android Architecture Components: LiveData

In this final article of the Android Architecture Components series, we’ll explore the Room persistence library, an excellent new resource that makes it a lot easier to work with databases in Android. It provides an abstraction layer over SQLite, compile-time checked SQL queries, and also asynchronous and observable queries. Room takes database operations on Android to another level.

Since this is the fourth part of the series, I’ll assume that you’re familiar with the concepts and components of the Architecture package, such as LiveData and LiveModel. However, if you didn’t read any of the last three articles, you’ll still be able to follow. Still, if you don’t know much about those components, take some time to read the series—you may enjoy it.

## 1. The Room Component

As mentioned, Room isn’t a new database system. It is an abstract layer that wraps the standard SQLite database adopted by Android. However, Room adds so many features to SQLite that it is almost impossible to recognize. Room simplifies all the database-related operations and also makes them much more powerful since it allows the possibility of returning observables and compile-time checked SQL queries.

Room is composed of three main components: the Database, the DAO (Data Access Objects), and the Entity. Each component has its responsibility, and all of them need to be implemented for the system to work. Fortunately, such implementation is quite simple. Thanks to the provided annotations and abstract classes, the boilerplate to implement Room is kept to a minimum.

• Entity is the class that is being saved in the Database. An exclusive database table is created for each class annotated with @Entity.
• The DAO is the interface annotated with @Dao that mediates the access to objects in the database and its tables. There are four specific annotations for the basic DAO operations: @Insert, @Update, @Delete, and @Query.
• The Database component is an abstract class annotated with @Database, which extends RoomDatabase. The class defines the list of Entities and its DAOs.

## 2. Setting Up the Environment

To use Room, add the following dependencies to the app module in Gradle:

If you’re using Kotlin, you need to apply the kapt plugin and add another dependency.

## 3. Entity, the Database Table

An Entity represents the object that is being saved in the database. Each Entity class creates a new database table, with each field representing a column. Annotations are used to configure entities, and their creation process is really simple. Notice how simple it is to set up an Entity using Kotlin data classes.

Once a class is annotated with @Entity, the Room library will automatically create a table using the class fields as columns. If you need to ignore a field, just annotate it with @Ignore. Every Entity also must define a @PrimaryKey.

### Table and Columns

Room will use the class and its field names to automatically create a table; however, you can personalize the table that's generated. To define a name for the table, use the tableName option on the @Entity annotation, and to edit the columns name, add a @ColumnInfo annotation with the name option on the field. It is important to remember that the table and column names are case sensitive.

### Indices and Uniqueness Constraints

There are some useful SQLite constraints that Room allows us to easily implement on our entities. To speed up the search queries, you can create SQLite indices at the fields that are more relevant for such queries. Indices will make search queries way faster; however, they will also make insert, delete and update queries slower, so you must use them carefully. Take a look at the SQLite documentation to understand them better.

There are two different ways to create indices in Room. You can simply set the ColumnInfo property, index, to true, letting Room set the indices for you.

Or, if you need more control, use the indices property of the @Entity annotation, listing the names of the fields that must compose the index in the value property. Notice that the order of items in value is important since it defines the sorting of the index table.

Another useful SQLite constraint is unique, which forbids the marked field to have duplicate values. Unfortunately, in version 1.0.0, Room doesn’t provide this property the way it should, directly on the entity field. But you can create an index and make it unique, achieving a similar result.

Other constraints like NOT NULL, DEFAULT, and CHECK aren’t present in Room (at least until now, in version 1.0.0), but you can create your own logic on the Entity to achieve similar results. To avoid null values on Kotlin entities, just remove the ? at the end of the variable type or, in Java, add the @NonNull annotation.

### Relationship Between Objects

Unlike most object-relational mapping libraries, Room doesn’t allow an entity to directly reference another. This means that if you have an entity called NotePad and one called Note, you can’t create a Collection of Notes inside the NotePad as you would do with many similar libraries. At first, this limitation may seem annoying, but it was a design decision to adjust the Room library to Android’s architecture limitations. To understand this decision better, take a look at Android’s explanation for their approach.

Even though Room’s object relationship is limited, it still exists. Using foreign keys, it is possible to reference parent and child objects and cascade their modifications. Notice that it's also recommended to create an index on the child object to avoid full table scans when the parent is modified.

### Embedding Objects

It is possible to embed objects inside entities using the @Embedded annotation. Once an object is embedded, all of its fields will be added as columns in the entity’s table, using the embedded object’s field names as column names. Consider the following code.

In the code above, the Location class is embedded in the Note entity. The entity’s table will have two extra columns, corresponding to fields of the embedded object. Since we’re using the prefix property on the @Embedded annotation, the columns' names will be ‘note_location_lat’ and ‘note_location_lon’, and it will be possible to reference those columns in queries.

## 4. Data Access Object

To access the Room’s Databases, a DAO object is necessary. The DAO can be defined either as an interface or an abstract class. To implement it, annotate the class or interface with @Dao and you’re good to access data. Even though it is possible to access more than one table from a DAO, it is recommended, in the name of a good architecture, to maintain the Separation of Concerns principle and create a DAO responsible for accessing each entity.

### Insert, Update, and Delete

Room provides a series of convenient annotations for the CRUD operations in the DAO: @Insert, @Update, @Delete, and @Query. The @Insert operation may receive a single entity, an array, or a List of entities as parameters. For single entities, it may return a long, representing the row of the insertion. For multiple entities as parameters, it may return a long[] or a List<Long> instead.

As you can see, there is another property to talk about: onConflict. This defines the strategy to follow in case of conflicts using OnConflictStrategy constants. The options are pretty much self-explanatory, with ABORT, FAIL, and REPLACE being the more significant possibilities.

To update entities, use the @Update annotation. It follows the same principle as @Insert, receiving single entities or multiple entities as arguments. Room will use the receiving entity to update its values, using the entity PrimaryKey as reference. However, the @Update may only return an int representing the total of table rows updated.

Again, following the same principle, the @Delete annotation may receive single or multiple entities and return an int with the total of table rows updated. It also uses the entity’s PrimaryKey to find and remove the register in the database’s table.

### Making Queries

Finally, the @Query annotation makes consultations in the database. The queries are constructed in a similar manner to SQLite queries, with the biggest difference being the possibility to receive arguments directly from the methods. But the most important characteristic is that the queries are verified at compile time, meaning that the compiler will find an error as soon as you build the project.

To create a query, annotate a method with @Query and write a SQLite query as value. We won’t pay too much attention to how to write queries since they use the standard SQLite. But generally, you'll use queries to retrieve data from the database using the SELECT command. Selections may return single or collection values.

It is really simple to pass parameters to queries. Room will infer the parameter’s name, using the method argument’s name. To access it, use :, followed by the name.

### LiveData Queries

Room was designed to work gracefully with LiveData. For a @Query to return a LiveData, just wrap up the standard return with LiveData<?> and you’re good to go.

After that, it will be possible to observe the query result and get asynchronous results quite easily. If you don’t know the power of LiveData, take some time to read our tutorial about the component.

## 5. Creating the Database

The database is created by an abstract class, annotated with @Database and extending the RoomDatabase class. Also, the entities that will be managed by the database must be passed in an array in the entities property in the @Database annotation.

Once the database class is implemented, it is time to build. It is important to stress that the database instance should ideally be built only once per session, and the best way to achieve this would be to use a dependency injection system, like Dagger. However, we won’t dive into DI now, since it is outside the scope of this tutorial.

Normally, operations on a Room database cannot be made from the UI Thread, since they are blocking and will probably create problems for the system. However, if you want to force execution on the UI Thread, add allowMainThreadQueries to the build options. In fact, there are many interesting options for how to build the database, and I advise you to read the RoomDatabase.Builder documentation to understand the possibilities.

## 6. Datatype and Data Conversion

A column Datatype is automatically defined by Room. The system will infer from the field’s type which kind of SQLite Datatype is more adequate. Keep in mind that most of Java’s POJO will be converted out of the box; however, it is necessary to create data converters to handle more complex objects not recognized by Room automatically, such as Date and Enum.

For Room to understand the data conversions, is necessary to provide TypeConverters and register those converters in Room. It is possible to make this registration taking into consideration specific context—for example, if you register the TypeConverter in the Database, all entities of the database will use the converter. If you register on an entity, only the properties of that entity may use it, and so on.

To convert a Date object directly to a Long during Room’s saving operations and then convert a Long to a Date when consulting the database, first declare a TypeConverter.

Then, register the TypeConverter in the Database, or in a more specific context if you want.

## 7. Using Room in an App

The application we've developed during this series used SharedPreferences to cache weather data. Now that we know how to use Room, we’ll use it to create a more sophisticated cache that’ll allow us to get cached data by city, and also consider the weather date during the data retrieval.

First, let’s create our entity. We’ll save all our data using only the WeatherMain class. We only need to add some annotations to the class, and we’re done.

We also need a DAO. The WeatherDAO will manage CRUD operations in our entity. Notice that all queries are returning LiveData.

Finally, it is time to create the Database.

Ok, we now have our Room database configured. All that is left to do is wire it up with Dagger and start using it. In the DataModule, let's provide the Database and the WeatherDAO.

As you should remember, we have a repository responsible for handling all data operations. Let’s continue to use this class for the app’s Room data request. But first, we need to edit the providesMainRepository method of the DataModule, to include the WeatherDAO during the class construction.

Most of the methods that we’ll add to the MainRepository are pretty straightforward. It's worth looking more closely at clearOldData(), though. This clears all data older than a day, maintaining only relevant weather data saved in the database.

The MainViewModel is responsible for making consultations to our repository. Let’s add some logic to address our operations to the Room database. First, we add a MutableLiveData, the weatherDB, which is responsible for consulting the MainRepository. Then, we remove references to SharedPreferences, making our cache rely only on the Room database.

To make our cache relevant, we’ll clear old data every time a new weather consultation is made.

Finally, we’ll save the data to the Room database every time new weather is received.

You can see the complete code in the GitHub repo for this post.

## Conclusion

Finally, we're at the conclusion of the Android Architecture Components series. These tools will be excellent companions on your Android development journey. I advise you to continue exploring the components. Try to take some time to read the documentation

And check out some of our other posts on Android app development here on Envato Tuts+!


text:
💬 👋 We’re always here. Join our Discord to connect with other students 24/7, any time, night or day.Join Here!

# Find $f'(x)$. Compare the graphs of $f$ and $f'$ and use them to explain why your answer is reasonable.$f(x) = x^5 - 2x^3 + x - 1$

Derivatives

Differentiation

### Discussion

You must be signed in to discuss.

Lectures

Join Bootcamp

### Video Transcript

hey is clear. So when you read here, so yeah of X is equal to X to the fifth minus two ex cute Klis X minus one. Me differentiated in terms of X, we got five next to the fourth, minus six X square plus one. We're gonna grass original and black and are derivative in red. Our original looks like this and are derivative will look something like this, but these two touching each other. We see that this is negative. One does this positive one. When the derivative is less than zero, the originals decreasing. And when it's bigger than zero, the originals increasing the F of X has a local extreme when the derivative of F A Becks crosses the X axis

Derivatives

Differentiation

Lectures

Join Bootcamp


text:
# Homework Help: Angular acceleration/tangential velocity

1. Oct 24, 2004

### buffgilville

Two disks, A and B, are cemented together rotating with angular velocity a . The radius of the small disk B is 2/3 the radius of the larger disk A.

a) Calculate the ratio of the tangential velocity of a point on the rim of disk A to the tangential velocity of a point on the rim of disk B?

b) If the two disks in problem a have an angular velocity of w, calculate the ratio of the kinetic energy of disk A to the kinetic energy of disk B. Assume that each disk has a mass M.

2. Oct 25, 2004

### arildno

a) How is, in general, tangential velocity at a radius "R" from the rotation axis coupled with angular velocity?
b) How is the kinetic energy of a rotating object related to the moment of inerta of the object with respect to the rotation axis and the angular velocity?
Assume that the mass distribution is equal for both disks.
(Use, for example, that each disk has a constant density in your calculations.)

Last edited: Oct 25, 2004


text:
# application of Cauchy criterion for convergence

Without using the methods of the entry determining series convergence, we show that the real-term series

 $\sum_{n=0}^{\infty}\frac{1}{n!}\;=\;1+\frac{1}{1!}+\frac{1}{2!}+\ldots$

is convergent by using Cauchy criterion for convergence, being in in $\mathbb{R}$ equipped with the usual absolute value $|.|$ as http://planetmath.org/node/1604norm.

Let $\varepsilon$ be an arbitrary positive number.  For any positive integer $n$, we have

 $\frac{1}{n!}\;\leqq\;\frac{1}{1\cdot 2\cdot 2\cdots 2}\;=\;\frac{1}{2^{n-1}},$

whence we can as follows.

 $\displaystyle\left|\frac{1}{(n\!+\!1)!}+\ldots+\frac{1}{(n\!+\!p)!}\right|$ $\displaystyle\;=\;\frac{1}{(n\!+\!1)!}+\ldots+\frac{1}{(n\!+\!p)!}$ $\displaystyle\;\leqq\;\frac{1}{2^{n}}+\ldots+\frac{1}{2^{n+p-1}}$ $\displaystyle\;=\;\frac{1}{2^{n}}\left(1+\frac{1}{2}+\ldots+\frac{1}{2^{p-1}}\right)$ $\displaystyle\;=\;\frac{1}{2^{n}}\cdot\frac{1-(1/2)^{p}}{1-1/2}$ $\displaystyle\;<\;\frac{1}{2^{n-1}}\;<\;\varepsilon$

The last inequality is true for all positive integers $p$, when  $n\;>\;1-\mbox{lb}\,{\varepsilon}$.  Thus the Cauchy criterion implies that the series converges.

Title application of Cauchy criterion for convergence ApplicationOfCauchyCriterionForConvergence 2013-03-22 19:03:22 2013-03-22 19:03:22 pahio (2872) pahio (2872) 9 pahio (2872) Example msc 40A05 RealNumber GeometricSeries LogarithmusBinaris NapiersConstant


text:
# Jordan-Wigner transformation

1. Jul 23, 2008

### yukawa

How to go from this Hamiltonian :

$$H= \sum^{N}_{j=1}[\sigma^{+}_{j}\sigma^{-}_{j+1}+\sigma^{-}_{j}\sigma^{+}_{j+1}]$$

to the following Hamiltonain:

$$H = \sum^{N-1}_{j=1}[c^{*}_{j}c_{j+1}+c^{*}_{j+1}c_{j}]-(c^{*}_{1}c_{N}+c^{*}_{N}c_{1})exp[i\pi\sum^{N}_{j=1}c^{*}_{j}c_{j}]$$

(where c* is the Hermitian conjugate of c)

using the Jordan-Wigner transformation:
$$\sigma^{+}_{j} = exp[i\pi\sum^{j-1}_{n=1}c^{*}_{n}c_{n}] c_{j}$$

$$\sigma^{-}_{j} = exp[-i\pi\sum^{j-1}_{n=1}c^{*}_{n}c_{n}] c^{*}_{j}$$

where are fermionic operators.

The following is what I have calculated, please correct my mistakes if there are.

$$\sigma^{+}_{j}\sigma^{-}_{j+1}=c_{j}exp[-i\pi c^{*}_{j}c_{j}]c^{*}_{j+1}=c_{j}(1-2c^{*}_{j}c_{j})c^{*}_{j+1}$$

$$\sigma^{-}_{j}\sigma^{+}_{j+1}=c^{*}_{j}exp[i\pi c^{*}_{j}c_{j}]c_{j+1}=c^{*}_{j}(1-2c^{*}_{j}c_{j})c_{j+1}$$

putting them into the first Hamiltonian yeilds:

$$\sum^{N}_{j=1}c_{j}(1-2c^{*}_{j}c_{j})c^{*}_{j+1}+c^{*}_{j}(1-2c^{*}_{j}c_{j})c_{j+1}$$

how to proceed further in order to arrive at the second Hamiltonian?


text:
3. Suppose that, after conducting an analysis of past stock prices, you come up with the...

1 answer below »

3.   Suppose that, after conducting an analysis of past stock prices, you come up with the following observations. Which would appear to contradict the weak form of the efﬁcient market hypothesis? Explain.

a.   The average rate of return is signiﬁcantly greater than zero.

b.   The correlation between the return during a given week and the return during the fol- lowing week is zero.

c.   One could have made superior returns by buying stock after a 10% rise in price and selling after a 10% fall.

d.   One could have made higher-than-average capital gains by holding stocks with low dividend yields.

Option c One could have made superior returns by buying stock after 10% rise in price and selling after...

Related Questions in Financial Accounting - Others

• Management Finance 4 Unit, each Unit have 20 Multiple Choice Quiz, total 80 Quiz. Please highlight..

(Solved) July 27, 2015

Management Finance 4 Unit, each Unit have 20 Multiple Choice Quiz, total 80 Quiz. Please highlight the answer. Management Finance 4 Unit, each Unit have 20 Multiple Choice Quiz, total 80 Quiz. Please highlight the answer.

Management Finance Unit 1 Question #1 The following are examples of intangible assets except: Answers: a. Building b. Trademarks c. Patents d
• investments

March 20, 2011

attached. 40 multiple choice investment questions

• 8. Which one of the following would provide evidence against the semistrong form of the...

(Solved) November 07, 2015

8. Which one of the following would provide evidence against the semistrong form of the efﬁcient market theory? a. About 50% of pension funds outperform the market in any year. b . You cannot make abnormal proﬁts by buying stocks after an announcement of strong earnings. c

1. Option D Low P/E stocks tend to have positive abnormal returns over the long run. 2. Option C Positive alphas on stocks will quickly disappear. 3
• See attachment. Looking for assistance setting up part III.

(Solved) September 03, 2016

See attachment. Looking for assistance setting up part III.

PFA the solutionPFA the solutionPFA the solutionPFA the solutionPFA the solutionPFA the solutionPFA the solutionPFA the solutionPFA the solutionPFA the solutionPFA the solutionPFA the...
• 1.Walter Industries’ current ratio is 0.5. Considered alone, which of the following actions would...

(Solved) April 25, 2015

after t = 4, i.e., what is X? a. 5.17% b . 5.44% c . 5.72% d . 6.02% e. 6.34% 9. Stock X has the following data. Assuming the stock market is efficient and the stock is in equilibrium, which of the following statements is CORRECT? Expected dividend , D 0 $3 .00 Current price$50 Expected constant...

rRF 8. Savickas Petroleum’s stock has a required return of 12%, and the stock sells for $40 per share. The firm just paid a dividend of$1.00, and the dividend is expected to grow by 30% per...