Developers Club geek daily blog

New in Wolfram Language | the Analytical solution of partial equations

1 year, 1 month ago

Transfer of a post of Devendra Kapadia "New in the Wolfram Language: Symbolic PDEs".
The code given in article can be downloaded here.
I express huge gratitude to Kirill Guzenko of KirillGuzenko for the help in transfer and preparation of the publication
.
Partial equations (UrChP) play very important role in mathematics and its applications. They can be used for modeling of the real phenomena, such as fluctuations of the tense string, distribution of a heat flow in a rod, in financial areas. The purpose of this article — to slightly open a veil to the world of UrChP (who else is not familiar to those with it) and to acquaint the reader with how it is possible to solve effectively UrChP in Wolfram Language, using new functionality for a solution of boundary value problems in DSolve, and also new DEigensystem function which appeared in version 10.3.

History UrChP goes back to works of the famous mathematicians of the eighteenth century — Euler,Dalambera,Laplace, however development of this area in the last three centuries did not stop. And therefore I will provide both classical, and modern examples of UrChP in article that will allow to consider this knowledge domain under different corners.

Let's begin with consideration of fluctuations of the tense string with a length π, fixed on both ends. Fluctuations of a string can be simulated by means of the one-dimensional wave equation given below. Here u (x, t) — vertical shift of a point of a string with coordinate x in t timepoint:


Read more »


Solution of a puzzle of Galakub on the Python

1 year, 1 month ago
For new year purchased to the nephew a puzzle of Galakub. A task to collect a cube of 4х4х4 in size from different parts. Total amount of parts, just, 4х4х4. Before to give it was necessary to collect a puzzle. The beautiful symmetric solution was found quickly enough. But there was interestingly only this solution or not. The intuition prompted that the only thing, but there was a wish to check.


I decided to notch quickly a script for search of all options. It was ideally necessary to be in time before the New Year's speech of Putin. The situation was aggravated with the fact that the code was written on Makbuk my parents. To put on it some libraries is a task more abruptly, than to write the program.

The code turned out surprisingly beautiful and clear. It is convenient to explain it. Perhaps, the text will be useful, for example, studying the Python.

Read more »


Simple algebraic data types

1 year, 1 month ago
It is the sixth article from the cycle "The Category Theory for Programmers". The previous articles were already published on Habré:
0. The category theory for programmers: preface
1. Category: composition essence
2. Types and functions
3. Categories, big and small
4. Kleysli's categories
5. Works and koproizvedeniye

In the previous article basic operations over types were considered: work and koproizvedeniye. Now we will show that the combination of these mechanisms allows to construct many of daily data structures. Such creation has essential applied relevance. For example, if we are able to check base data types for equality, and also we know how to reduce equality of work and a koproizvedeniye to equality a component, then operators of equality for composite types it is possible to display automatically. In Haskell for an extensive subset of composite types operators of equality and comparison, converting at line and back and many other operations are automatically brought.

Let's consider in more detail the place of work and a koproizvedeniye of types in programming.

Work of types


Canonical implementation of work of types in programming languages is a couple. In Haskell of steam is a primitive designer of types, and in C ++ it is rather difficult template from standard library.
Pair
Strictly speaking, work of types is not commutative: it is impossible to substitute couple of type (Int, Bool) instead of (Bool, Int), though they also contain the same data. However work is commutative to within the isomorphism set by function swap, which back to:
swap :: (a, b) -> (b, a)
swap (x, y) = (y, x)

It is possible to consider such couples as different formats of storage of the same information as big endian and little endian.

Read more »


Erlang for web development (2)-> a DB and warm;

1 year, 1 month ago

In the first article we got acquainted with the Erlang and a framework of n2o. In this part we will continue to do our blog:
  • let's add authorization through Facebook, we will cause from the client for this purpose functions on the server;
  • let's save comments and posts in NoSQL to base;
  • let's unroll our blog on DigitalOcean and we will measure performance (a spoiler — 1300 requests per second).


At code from the articles https://github.com/denys-potapov/n2o-blog-example, the ready project it is possible to look to the address http://46.101.118.21:8001/.

Read more »


Erlang for web development (1)-> Acquaintance;

1 year, 2 months ago

I begin to publish a series of articles about web development on the Erlang. Many want to try the Erlang, but face a problem that introduction courses generally concern the Erlang as functional language and are far from real projects (Learn You Some Erlang for great good! — good and detailed book). On the other hand all training materials on web development mean that the reader already well knows the Erlang.

This series of articles is calculated for developers who have an experience in web development (PHP, Ruby, Java), but have no experience of development on the Erlang.

Task will be to make the blog. At a code from the articles https://github.com/denys-potapov/n2o-blog-example, the ready project it is possible to look to the address http://46.101.118.21:8001/. Features of the project:
  • updating of comments in real time;
  • authorization through Facebook;
  • we store data in mnesia.

At the heart of the project feymvork n2o. The choice is quite subjective, but from live the Erlang of frameworks, n2o me seemed to most "erlangopodobny", in too time of ChicagoBoss is more similar to MVC frameworks in other languages.

Read more »


"Terrible" abstractions of Haskell without mathematics and without code (almost). Part I

1 year, 2 months ago
— For what monads are necessary?
— To separate pure calculations from ghost effects.
(from network discussions about the Haskell language)

Sherlock Holmes and doctor Watson fly in the balloon. Get to dense fog and lose orientation. Here a small gleam — and they see on the earth of the person.
— Dear, whether you will prompt where we are?
— In a balloon basket, the sir.
Here carries them further and they see nothing again.
— It was the mathematician, – Holmes says.
— But why?
— His answer is absolutely exact, but at the same time is absolutely useless.
(joke)

When ancient Egyptians wanted to write that they counted 5 fishes, they drew 5 figures of fishes. When they wanted to write that they counted 70 people, they drew 70 figures of people. When they wanted to write that they counted in herd of 300 sheep, they … — well, generally, you understood. And ancient Egyptians until the most smart and lazy of them saw something the general in all these records suffered, and separated concept of quantity of what we count from properties of what we count. And then other smart lazy Egyptian replaced a set of sticks which people designated quantity, on much smaller quantity of signs with which short combination it was possible to replace a huge number of sticks.

What was made by these smart lazy Egyptians is called abstraction. They noticed something the general that is peculiar to all records about quantity something, and separated this general from private properties of the counted objects. If you understand sense of this abstraction which we call today numbers, and as far as it facilitated life to people, you cannot understand also abstractions of the Haskell language — all these unclear, at first sight, functors, monoides, applicative functors and monads. Despite their frightening names which came to us from the mathematical category theory it is not more difficult to understand them, than abstraction as the name "numbers". For their understanding it is not required to know either the category theory, or even mathematics in volume of high school at all (arithmeticians it is quite enough). And it is possible to explain them too, without resorting to the mathematical concepts frightening many. And sense of abstractions of the Haskell language just the same, as well as at numbers — they considerably facilitate to programmers life (and you so far do not even represent as far as!).

Read more »


Works and koproizvedeniye

1 year, 2 months ago
It is the fifth article from the cycle "The Category Theory for Programmers". The previous articles were already published on Habré in transfer Monnorochof :
0. The category theory for programmers: preface
1. Category: composition essence
2. Types and functions
3. Categories, big and small
4. Kleysli's categories

On KDPV a pig Pyotr brings on one tractor to each object of category.

Follow on shooters


The Ancient Greek playwright Euripedes wrote "Any person is similar to the environment". It is right also for the category theory. It is possible to select a certain object of category only by the description of nature of its relationship with other objects (and by itself) where the relations are morphisms.

For object definition in terms of their relationship the category theory resorts to so-called universal constructions. For this purpose it is possible to select some template, the chart from objects and morphisms of a certain form and to consider all constructions of the considered category suitable under it. If the template is rather widespread and the category is rather big, then probably the found constructions will be very much and many. The idea of universal construction consists in arranging constructions under some law and to select the most suitable.

This process can be compared to net search. The request of the user is our template. If the request is not really specific, then in reply the search engine will issue a set of suitable documents, only part of which are relevant. To exclude irrelevant answers, the user specifies request that increases search accuracy. Eventually the search engine will range coincidence and if carries, the required result will be in the list head.

Read more »


Crib of Java of the programmer 4. Java Stream API

1 year, 3 months ago


In spite of the fact that Java 8 left already for a long time, not all programmers use its new opportunities, someone is stopped that detail designs it is too difficult to transfer from Java 7 or even Java 6, someone use in the GWT projects, someone does projects under Android and does not want or cannot use third-party libraries for implementation lyambd and Stream Api. However lyambd and Stream Api for the Java programmer often demand knowledge on interviews, well and it will be just useful upon transition to the project where Java 8 is used. I would like to offer you a short crib on Stream Api with practical examples of implementation of different tasks with new functional approach. The knowledge lyambd and functional programming will not be required (I tried to give examples so that all was clear), level from the basic knowledge of Java above.

Also, as it is a crib, article can be used quickly to remember as this or that feature of Java Stream Api works. Short transfer of opportunities of basic functions is given at the beginning of article.

For those who does not know at all that such Stream Api
Stream API is new method to work with data structures in functional style. Most often by means of stream in Java 8 work with collections, but actually this mechanism can be used for the most different data.

Stream Api allows to write processing of data structures in SQL style if earlier the task to receive the sum of all odd numbers from a collection was solved the following code:
        Integer sumOddOld = 0; 
        for(Integer i: collection) {
            if(i % 2 != 0) {
                sumOddOld += i;
            }
        }

That by means of Stream Api it is possible to solve such problem in functional style:
       Integer sumOdd = collection.stream().filter(o -> o % 2 != 0).reduce((s1, s2) -> s1 + s2).orElse(0);

Moreover, Stream Api allows to solve a problem in parallel only having changed stream () to parallelStream () without any excess code, i.e.
       Integer sumOdd = collection.parallelStream().filter(o -> o % 2 != 0).reduce((s1, s2) -> s1 + s2).orElse(0);

Already does a code parallel, without any semaphores, synchronization, risks of interlocks, etc.

Read more »


Pro Parboiled (Part 4 final)

1 year, 3 months ago

Read more »


About Parboiled (Part 3)

1 year, 3 months ago
Part 3: Extraction of data

In this article we will construct the parser for already described by us before a format of configuration files. Also we implement small DSL for the simplified access to elements got a tree. From this article you learn about types of rules, operations of the parser, and also about "dark matter" Parboiled — a stack of values.

Structure of a cycle:


Read more »