Fix sub to mean . If the depth-minimizing order evaluates the right operand before the left operand , the stack ends in , so ordinary sub would compute the wrong sign. Two possible instruction set architecture extensions are:
  • Add swap, with . After computing and then , use swap; sub to obtain . One general zero-address instruction handles every noncommutative binary operation and is useful elsewhere, but each reversed evaluation needs an extra instruction and extra execution time. It can be implemented without an additional operand stack slot.
  • Add reverse-operand variants, such as rsub with , and analogously reverse division and other required operations. After computing and then , a single rsub obtains . This avoids the extra executed swap, but requires more opcodes and decoder support, usually one reverse form for each affected operation.
Both preserve the same peak operand stack bound:
The first trades extra dynamic instructions for a smaller instruction set; the second trades a larger instruction set for fewer executed instructions. Neither extension makes order-sensitive side effects safe to reorder.
Let and measure the extra operand stack space required from the current base, with each evaluation leaving one result. Evaluating first uses slots. Its result occupies one slot while evaluating , so that stage uses slots. The final add reduces two slots to one. Thus
By commutativity of addition, choose the smaller of these two bounds. Evaluate the child of larger depth first. The optimum recurrence on a binary expression tree is
Assign depth one to a literal or a simple already-addressable value, and compute the child depths recursively. If , the depths are integers, so ; evaluating first therefore attains , while reversing the order needs . If the depths are equal, whichever child goes second needs the extra retained-result slot. These lower bounds prove the recurrence is optimal for evaluating each child subtree without interleaving or spilling. Apply it at every node to minimize peak operand stack occupancy for the given binary expression tree; this is optimal stack evaluation of a binary expression tree.
This changes child evaluation order, not the parenthesization. For example, a chain-shaped binary expression tree can have depth two, whereas a balanced tree of eight leaves has depth four under this model. The reordering assumes expressions have no order-sensitive side effects or observable exceptions. Reassociating floating-point addition would require additional care because it can change floating-point rounding.
A computed memory address is just another integer on the operand stack. For a pointer held at fixed address , const p; load obtains the pointed-to address; another load obtains its contents. More generally, any expression that leaves an address on top may be followed by load, or may be retained beneath a computed value for store.
For an array whose base address is and whose element size is address units, the address of entry is , where stores the index. Add zero-address instructions mul and dup, with dup mapping to . A suitable sequence is
const b
const p_i
load
const w
mul
add
dup
load
const 1
add
store
The first six instructions leave the element address . The remaining suffix evolves as
with the final effect
The address is computed once and duplicated, so both accesses refer to the same array element. For unit-sized elements omit const w; mul. If the base address is itself held in a variable, replace const b by the instructions loading that variable's value. No instruction other than const requires an explicit operand.
Use two zero-address instructions for indirect access to computer memory. Define load to replace the top memory address by the value at that address, and define store to pop a value followed by the address just beneath it:
Both have no encoded address operand; the stack supplies it. If the known fixed memory addresses of the variables are , implement the assignment with
const p_x
const p_y
load
store
The successive stack suffixes are , then , then , then empty. Hence
The surrounding stack is restored. Other store conventions are possible, but the operand order must be stated and used consistently.
A zero-address instruction has no explicit operand addresses, so its operands and result location must be implicit in the instruction set architecture. A stack machine supplies these naturally: operations remove their inputs from the top of an operand stack and push the result. A fixed-processor register design is logically possible, so “almost certainly” is appropriately weaker than a proof that only a stack machine could work.
Write the stack from bottom to top, with its top on the right. Let stand for any unchanged prefix. Suitable effects are
Thus add pops two operands and pushes one sum, reducing stack occupancy by one. The special const c instruction pushes its immediate constant and increases occupancy by one. Only const needs an explicit value in its encoding.
For the unsigned interpretation of the binary string, the set positions have weights . Thus
In 16-bit two's complement, the most significant bit is set, so subtract from that unsigned interpretation:
For a half-precision floating-point number, split the fields at their actual boundaries rather than the printed groups of four:
The sign is negative, the true exponent is , and the fraction is . It is a normal finite value, so
The smallest positive normal half-precision floating-point number uses and a zero fraction, while the largest uses and all ten fraction bits equal to one. Hence
The corresponding words are 0 00001 0000000000 and 0 11110 1111111111. The stored exponent is reserved and cannot extend the finite normal range.
For a subnormal number, and the implicit leading bit becomes zero, while the scale remains . The least positive nonzero fraction is , giving
Using scale here would be incorrect: the subnormal number convention uses the minimum normal scale, not the ordinary biased-exponent formula at .
Both signs are positive, so perform addition of the aligned significands. The true exponents are and , a difference of four. Shift the smaller significand right four places, retaining its low bits:
Add at the common exponent:
Renormalization raises the true exponent to and the biased exponent to . There are only seven fraction places to retain, so no floating-point rounding changes the result:
The complete word is 0100110000001000.
For a normal half-precision floating-point number, write the stored fields as sign , biased exponent and ten-bit fraction . The value is for . The leading one is implicit: the ten stored fraction bits give eleven significant binary digits including that one. The normalized binary representations and stored fields are
ValueNormalized binary representationSign, biased exponent, fraction
0 01110 0000000000
0 01110 0100000000
1 01100 1000000000
0 10010 1111000000
Thus the four 16-bit words are
Every conversion is exact: all four numbers have terminating binary representations within the available precision.
For an estimate, use the usual equal-device CMOS series-stack model: a -input NAND gate or NOR gate has a worst-case propagation delay approximately times that of an inverter, because a conducting path contains series transistors. An AND gate or OR gate adds an output inverter. With a 1 ns inverter this gives, for ,
For it reproduces the stated 3 ns. This is a technology estimate under equal sizing and comparable loading, not a unique physical law inferable from a single measured delay. Actual propagation delay also depends on capacitance, fan-out and transistor sizing. If instead only the supplied two-input gates were allowed, a balanced tree would have worst-case depth and delay ns; that is a different construction from a single -input gate.
For the explicit circuit in part (a), the longest combinational logic path starts at , passes through the shared inverter, either direction-match exclusive or, the AND gate, and the final exclusive or feeding :
The path takes 5 ns, the paths from or to take at most 7 ns, and takes 1 ns. Both direction-match exclusive or gates act in parallel; their delays are not added together. The 8 ns excludes clock-to-Q delay, setup time, hold time and clock-distribution effects, because the question asks only for the combinational logic delay.
Use three positive-edge-triggered D flip-flops, all driven by the same clock signal . Write the current binary representation as , with the least significant bit. The next state is the current value plus one when and minus one when , in each case modulo eight. A bit toggles under exclusive or with a one.
For upward counting, toggles when , while toggles when , the respective carry conditions. For downward counting the corresponding borrow conditions are and . Define the shared inverted direction and the two direction-match signals
Each is one exactly when : it equals for upward counting and for downward counting. Thus the Boolean functions for the three D inputs are
Implement this with two NOT gates for , four two-input exclusive or gates for , and one two-input AND gate. Connect to the D flip-flop whose output is ; feed the three outputs back into the indicated gates. All three flip-flops capture simultaneously, so each equation uses the old state.
Figure 1.
Synchronous three-bit up-down binary counter: common clock signal, explicit D inputs and feedback
. Details.
Current Next for Next for
000001111
001010000
010011001
011100010
100101011
101110100
110111101
111000110
Every three-bit state is valid. A reset may initialize the binary counter to zero if required; counting itself needs no extra state. The direction input must meet the setup time and hold time requirements at the active clock edge.
Use Gaussian elimination without row exchanges. First apply and ; then apply :
The elimination multipliers are , and . Put them below the diagonal of a unit lower triangular matrix:
To see why these multipliers reconstruct the rows, row 2 of is three times row 1 of plus row 2 of , giving . Row 3 of is twice row 1 plus row 2 plus row 3 of , giving . This directly verifies the LU factorization.
Suppose an invertible matrix has two LU factorizations, , with unit lower triangular matrices and upper triangular matrices. All four factors are invertible matrices, since their square products are invertible. Multiplication by the appropriate inverse matrices gives
By the supplied closure properties, the left side is a unit lower triangular matrix and the right side is an upper triangular matrix. A matrix of both types is diagonal; its diagonal entries are all one. Thus both sides are the identity matrix, whence
Qualification of the printed wording: this establishes uniqueness if the specified LU factorization exists. Invertibility alone does not guarantee an unpivoted LU factorization. For example is invertible, but in a product , the zero top-left entry forces , making the bottom-left entry as well, contrary to the required value one. A permutation matrix is needed in general, as in PLU factorization.

Pinned article: Introduction to the OurBigBook Project

Welcome to the OurBigBook Project! Our goal is to create the perfect publishing platform for STEM subjects, and get university-level students to write the best free STEM tutorials ever.
Everyone is welcome to create an account and play with the site: ourbigbook.com/go/register. We belive that students themselves can write amazing tutorials, but teachers are welcome too. You can write about anything you want, it doesn't have to be STEM or even educational. Silly test content is very welcome and you won't be penalized in any way. Just keep it legal!
We have two killer features:
  1. topics: topics group articles by different users with the same title, e.g. here is the topic for the "Fundamental Theorem of Calculus" ourbigbook.com/go/topic/fundamental-theorem-of-calculus
    Articles of different users are sorted by upvote within each article page. This feature is a bit like:
    • a Wikipedia where each user can have their own version of each article
    • a Q&A website like Stack Overflow, where multiple people can give their views on a given topic, and the best ones are sorted by upvote. Except you don't need to wait for someone to ask first, and any topic goes, no matter how narrow or broad
    This feature makes it possible for readers to find better explanations of any topic created by other writers. And it allows writers to create an explanation in a place that readers might actually find it.
    Figure 1.
    Screenshot of the "Derivative" topic page
    . View it live at: ourbigbook.com/go/topic/derivative
  2. local editing: you can store all your personal knowledge base content locally in a plaintext markup format that can be edited locally and published either:
    This way you can be sure that even if OurBigBook.com were to go down one day (which we have no plans to do as it is quite cheap to host!), your content will still be perfectly readable as a static site.
    Figure 5. . You can also edit articles on the Web editor without installing anything locally.
    Video 3.
    Edit locally and publish demo
    . Source. This shows editing OurBigBook Markup and publishing it using the Visual Studio Code extension.
  3. https://raw.githubusercontent.com/ourbigbook/ourbigbook-media/master/feature/x/hilbert-space-arrow.png
  4. Infinitely deep tables of contents:
    Figure 6.
    Dynamic article tree with infinitely deep table of contents
    .
    Descendant pages can also show up as toplevel e.g.: ourbigbook.com/cirosantilli/chordate-subclade
All our software is open source and hosted at: github.com/ourbigbook/ourbigbook
Further documentation can be found at: docs.ourbigbook.com
Feel free to reach our to us for any help or suggestions: docs.ourbigbook.com/#contact