Derivative of a Function.

Definition & Notation.

def. Derivative of a Function y = f(x) in point x is limit to which closes the ratio of increment of a function Δy to an increment of a variable Δx, when increment of a variable Δx closes to zero.

if such limit does not exist, then function has no derivative in this point.

derivative of a function y = f(x) we can note as:

, , , , .

Geometrical interpretation.

Geometrically, a derivative of a function is equal to a tanget of angle α, between the tangent line touching the graph of the function in a point x and positive direction of
the OX axis.

Additional notes.

Finding a derivative of a function we can call 'function differentiation'.

From definition we can see that derivative of a function is a quickness of the change of a function f(x), when x changes.


Let's calculate a few of function derivatives, using definiton.

1. y = sin(x).

We've used one of trigonometrical formulas (last one, for the sines difference):

... as well, as that is:

Similarly: (cos x)' = - sin x;

2. y = ax3, where a is any constant..

We've used Newton's Formula:

3. y = xn, n - natural number.

We've used Newton's Formula again.

The same formula for derivative (xk)' = kxk-1 we can use for any k.

(an unfinished article, to be continued).


'Ola AH'; Procedures, Functions, Methods & their 'Anatomy'.


... i was taught this at Warsaw's University, when i learned Computer Sciences.

a procedure is fragment of code that can be called from other parts of the code - for code's clarity, to avoid redundancy (repetition), to use with iteration instruction, or in a recursion.

procedure does not return any value, but may take input parameters.

a function is a procedure that returns a value, of any type.

method is a procedure or a function, that is part of a Class.

for example:

public class MyClass {

  public static void main(String[] args) {
    Object arg1 = new Integer(1);
    Object arg2 = "A sample value\\n";

    int i = doSomething(arg1, arg2);

  void init() {

  int doSomething(Object arg1, Object arg2) {
     int result = 0;
     return result;

  void finalize(int intArg) {


... in an above example there are three methods; outside class definition, these would be two procedures (init & finalize), and one function (doSomething).

wherever we use word method, a procedure or function can be used as well.

a method call is this part of the code that makes program flow 'jump' to another part of the code, to the method's definition.

a method definition is part of the code where the method is elaborated - starting from a line with method's name, ending with closing bracket & an optional separator or a terminator character (;).

first line of the method's definition is called a 'method signature' - that is, the part with optional visibility & other modifiers, an optional return value type, method's name, optional parameter types & names, optional exception throw clauses, perhaps with opening bracket as well.

following parts of method definition are called a 'method body' - it's where code & perhaps return clause are contained.

... that's the anatomy of methods, procedures & functions.

'Ola AH' Programming Language.

in 'Ola AH' Programming Language methods will have following anatomy:

- optional visibility & other modifiers,
- optional return type or 'void',
- method's name,
- optional parameters tuple,
- optional throw exceptions clause, that will be similar to java's syntax for practical reasons as writing less, ... - but will be automatically converted to a tuple inside interpreter or compiler.

- opening bracket,
- instructions,
- optional return clause,
- closing bracket,
- terminator (';').

in fact a method will be an object that can be 'passed around'.

with a method object it will be possible to inspect with reflection ... for the visibility & other modifiers, a number, names & types of parameters, a return value type, exceptions thrown, method's name, instructions tree inside body.

with a method object, it will be posible to construct or change objects (class instances) dynamically (during program's run).

methods themselves will be cloneable & modifiable as well.

... see also, if You wish or need, ... : Tail Call, Selector Methods & Dynamically Created Methods in 'Ola AH' Programming Language.


Two-phase Commit Protocol.

1. Introduction.

In transaction processing, databases, and computer networking, the two-phase commit protocol (2PC) is a type of atomic commitment protocol (ACP). It is a distributed algorithm that coordinates all the processes that participate in a distributed atomic transaction on whether to commit or abort (roll back) the transaction (it is a specialized type of consensus protocol).

The protocol achieves its goal even in many cases of temporary system failure (involving either process, network node, communication, etc. failures), and is thus widely used.

However, it is not resilient to all possible failure configurations, and in rare cases, user (e.g., a system's administrator) intervention is needed to remedy an outcome.

To accommodate recovery from failure (automatic in most cases) the protocol's participants use logging of the protocol's states. Log records, which are typically slow to generate but survive failures, are used by the protocol's recovery procedures.

2. Assumptions.

The protocol works in the following manner: one node is designated the coordinator, which is the master site, and the rest of the nodes in the network are designated the cohorts. The protocol assumes that there is stable storage at each node with a write-ahead log, that no node crashes forever, that the data in the write-ahead log is never lost or corrupted in a crash, and that any two nodes can communicate with each other. The last assumption is not too restrictive, as network communication can typically be rerouted. The first two assumptions are much stronger; if a node is totally destroyed then data can be lost.

The protocol is initiated by the coordinator after the last step of the transaction has been reached. The cohorts then respond with an agreement message or an abort message depending on whether the transaction has been processed successfully at the cohort.

3. Basic algorithm.

3.1. Commit request phase (or voting phase).

The coordinator sends a query to commit message to all cohorts and waits until it has received a reply from all cohorts.

The cohorts execute the transaction up to the point where they will be asked to commit. They each write an entry to their undo log and an entry to their redo log. Each cohort replies with an agreement message (cohort votes Yes to commit), if the cohort's actions succeeded, or an abort message (cohort votes No, not to commit), if the cohort experiences a failure that will make it impossible to commit.

3.2. Commit phase (or Completion phase).

3.2.1. Success.

If the coordinator received an agreement message from all cohorts during the commit-request phase:

The coordinator sends a commit message to all the cohorts.
Each cohort completes the operation, and releases all the locks and resources held during the transaction.
Each cohort sends an acknowledgment to the coordinator.
The coordinator completes the transaction when all acknowledgments have been received.

3.2.2. Failure.

If any cohort votes No during the commit-request phase (or the coordinator's timeout expires):

The coordinator sends a rollback message to all the cohorts.
Each cohort undoes the transaction using the undo log, and releases the resources and locks held during the transaction.
Each cohort sends an acknowledgement to the coordinator.
The coordinator undoes the transaction when all acknowledgements have been received.

4. Disadvantages.

The greatest disadvantage of the two-phase commit protocol is that it is a blocking protocol. If the coordinator fails permanently, some cohorts will never resolve their transactions: After a cohort has sent an agreement message to the coordinator, it will block until a commit or rollback is received.

Source: Two-phase commit protocol on Wikipedia.