aarjaneiro/planetmath huggingface dataset:
proof of Amdahl’s Law

proof of Amdahl’s Law

Suppose an

algorithm

needs

n

operations to compute the result. With 1 processor, the algorithm will take

n

time units. With

N

processors, the

(

1

-

f

)

⁢

n

parallelizable operations will take

(

1

-

f

)

⁢

n

N

time units and the remaining

f

⁢

n

non parallelizable operations will take

f

⁢

n

time units for a total running time of

f

⁢

n

+

(

1

-

f

)

⁢

n

N

time units. So the

speedup

S

is

n

f

⁢

n

+

(

1

-

f

)

⁢

n

N

=

1

f

+

1

-

f

N

.

Title

proof of Amdahl’s Law

Canonical name

ProofOfAmdahlsLaw

Date of creation

2013-03-22 13:10:36

Last modified on

2013-03-22 13:10:36

Owner

lieven (1075)

Last modified by

lieven (1075)

Numerical id

5

Author

lieven (1075)

Entry type

Proof

Classification

msc 68M20

Generated on Sat Feb 10 12:37:15 2018 by

LaTeXML
multisieve

multisieve

MultiSieve

is a computer program written by Mark Rodenkirch and designed for

primality testing

. It uses ”both

trial division

and

discrete logs

as a sieve to eliminate numbers faster,” according to Rodenkirch. It is available for Windows on the Intel x86 platform, and Rodenkirch has worked on a port for Mac OS X. According to the prime pages of the University of Tennessee at Martin, the largest prime MultiSieve has found so far is

338707

×

2

1354830

+

1

, approximately

9.97354620220965

×

10

407849

.

Title

multisieve

Canonical name

Multisieve

Date of creation

2013-03-22 16:13:33

Last modified on

2013-03-22 16:13:33

Owner

Mravinci (12996)

Last modified by

Mravinci (12996)

Numerical id

5

Author

Mravinci (12996)

Entry type

Definition

Classification

msc 68N01

Generated on Sat Feb 10 12:37:17 2018 by

LaTeXML
Planetary Project

Planetary Project

The

Planetary Project

aims to replicate the features of Noosphere (the software behind PlanetMath), using Drupal 7 and other modern technologies. (This is a testing page for people working on Planetary, please don’t delete!)

Title

Planetary Project

Canonical name

PlanetaryProject

Date of creation

2013-03-22 19:22:46

Last modified on

2013-03-22 19:22:46

Owner

jac (4316)

Last modified by

jac (4316)

Numerical id

4

Author

jac (4316)

Entry type

Topic

Classification

msc 68N01

Generated on Sat Feb 10 12:37:18 2018 by

LaTeXML
BASIC

BASIC

BASIC

(an acronym for

Beginner’s All-purpose Symbolic Instruction Code

) is a

computer

procedure-oriented programming language designed by John Kemeny and Thomas Kurtz in the 1960s to be easily learned by anyone. Over the years, various companies made their own proprietary versions and included them in their computers (and Texas Instruments made their own version, TI-BASIC, which is included in some of their

calculators

). Microsoft’s Visual Basic is the programming language of choice for in-house programming at small businesses. But in mathematics and physics, BASIC is little used outside of the classroom.

The following BASIC program takes two

integers

as inputs and outputs their

greatest common divisor

using Euclid’s algorithm:

100 REM Program Greatest Common Divisor Using Euclidean algorithm
110 INPUT "Please enter a positive integer A"; A
115 INPUT "Please enter a positive integer B"; B
120 WHILE B > 0
121 TEMPA = B
122 A = B
123 B = TEMPA MOD B
124 WEND
130 PRINT "The GCD is "; A
140 END

Title

BASIC

Canonical

name

BASIC

Date of creation

2013-03-22 16:47:18

Last modified on

2013-03-22 16:47:18

Owner

PrimeFan (13766)

Last modified by

PrimeFan (13766)

Numerical id

8

Author

PrimeFan (13766)

Entry type

Definition

Classification

msc 68N15

Synonym

Beginner’s All-purpose Symbolic Instruction Code

Generated on Sat Feb 10 12:37:20 2018 by

LaTeXML
C

C

C

is a procedural compiled programming language devised by Dennis Ritchie at the Bell Labs in New Jersey in 1972, and standardized in 1983 by ANSI and again by ISO in 1999. The original purpose of C was to write systems software for UNIX, but soon it became the most popular programming language for writing DOS applications, a popularity overshadowed only by the success of using C++ (

http://planetmath.org/C

) for Windows applications. From the beginning C provided access to certain lower level features of the computer and if that’s not enough it also had simpler mechanisms for meshing with assembly

language

; for that reason C is sometimes compared to dangerous but powerful tools like a chainsaw (Banahan et al, 1991).

The following C

program

takes two

integers

as inputs and outputs their

greatest common divisor

using Euclid’s

algorithm

.

#include <stdio.h>
#include <stdlib.h>

int GCD(int x, int y) {
int wX = x;
int wY = y;
int tempX;
while ( wY > 0 ) {
tempX = wX;
wX = wY;
wY = tempX % wY;
}
return(wX);
}

int main() {
int inputX;
int inputY;
int inputSuccess;
printf("Please enter x ");
inputSuccess = scanf("%d", &inputX);
printf("Please enter y ");
inputSuccess = scanf("%d", &inputY);
printf("GCD of %d and %d is %d\n", inputX, inputY, GCD(inputX,inputY));
exit(EXIT_SUCCESS);
}

This program was tested in Visual C++ 6.0, and it works. The compiler reported 0 errors and 0 warnings, and the program works as it should, at least as long as the inputs are both

positive integers

. For the pair 42 and

-

21

, it incorrectly reports the GCD as 42. Note that

printf

is not a reserved word of the C language, the way that

PRINT

is in BASIC or

Fortran

. We can use it because we included the standard I/O library; theoretically, we could write our own

printf

that tye-dyed the output onto a T-shirt as long as we wrote the appropriate library to take care of it.

References

1

M. Banahan, D. Brady & M. Doran,

The C book, featuring the ANSI C standard

Reading, Mass: Addison-Wesley Publishing (1991)

Title

C

Canonical name

C1

Date of creation

2013-03-22 16:51:34

Last modified on

2013-03-22 16:51:34

Owner

PrimeFan (13766)

Last modified by

PrimeFan (13766)

Numerical id

11

Author

PrimeFan (13766)

Entry type

Definition

Classification

msc 68N15

Synonym

CPL

Generated on Sat Feb 10 12:37:24 2018 by

LaTeXML
Haskell

Haskell

Haskell

is a computer programming language designed by a committee in 1990 to consolidate the best features of the many purely functional programming

languages

that were created in the late 1980s. Haskell is thus neither a procedural programming language nor an object-oriented one, although it offers monads such as

do

to

support

procedural programming and classes with inheritance to support object-oriented programming (there is also a variant of Haskell called O’Haskell which includes more support for object-oriented programming). In general, Haskell programs are most naturally written declaratively.

The standard version of the language is Haskell 98; Haskell 2007 hasn’t been released yet but is expected to be only a minor revision of Haskell 98.

The standard Haskell prelude includes the

function

gcd

, which computes the

greatest common divisor

of two

integers

. The following Haskell code is a reimplementation of the

gcd

function.

-- gcd.hs -- compute the gcd of two integers
-- View this page in TeX mode for documentation and license.

mygcd :: Int -> Int -> Int
mygcd m n
| (n < 0) = mygcd m (abs n)
| (n == 0) = m
| (m < n) = mygcd n m
| otherwise = mygcd n (mymod m n)

mydiv :: Int -> Int -> Int
mydiv m n
| (m < 0) = negate (mydiv (negate m) n)
| (n < 0) = negate (mydiv m (negate n))
| (m < n) = 0
| otherwise = 1 + mydiv (m-n) n

mymod :: Int -> Int -> Int
mymod m n = m - n * (mydiv m n)

Title

Haskell

Canonical name

Haskell

Date of creation

2013-03-22 16:47:13

Last modified on

2013-03-22 16:47:13

Owner

PrimeFan (13766)

Last modified by

PrimeFan (13766)

Numerical id

6

Author

PrimeFan (13766)

Entry type

Definition

Classification

msc 68N15

Generated on Sat Feb 10 12:37:26 2018 by

LaTeXML
iterator

iterator

An

iterator

is a

variable

that one by one takes on all the values (usually integers) in a given range. The letter

i

is often used for iterators (though that letter is

overloaded

as the

imaginary unit

),

j

is often used as a second iterator.

In mathematics iterators are most often used in sum and product notation. For example, in

∏

i

=

3

7

42

⁢

i

2

the iterator

i

takes on values from 3 to 7.

In

computer

programming languages iterators are often associated with the ”for” reserved word, e.g., “

FOR I = 1 TO 47

” in BASIC, “

for (i = 1; i < 48; i++)

” in C++. In

Mathematica

, iterators are often given in curly braces together with an (omittable) initial value and a required finish value separated by commas, e.g., “

Table[2^n - 1, {n, 2, 48}]

”.

Title

iterator

Canonical

name

Iterator

Date of creation

2013-03-22 16:25:16

Last modified on

2013-03-22 16:25:16

Owner

PrimeFan (13766)

Last modified by

PrimeFan (13766)

Numerical id

6

Author

PrimeFan (13766)

Entry type

Definition

Classification

msc 68N15

Generated on Sat Feb 10 12:37:27 2018 by

LaTeXML
JavaScript

JavaScript

JavaScript

(called

JScript

by Microsoft and

ECMAScript

by the WC3) is an interpreted scripting

language

primarily used on the Internet to perform basic input validation and to implement basic Web

calculators

. Other than the fact that Netscape Corporation licensed the use of the word ”Java” from Sun, that JavaScript uses Java’s C++ (

http://planetmath.org/C

)-like syntax and that JavaScript is deployed on the Internet, there is nothing in common between Java and JavaScript. The major modern Web browsers implement JavaScript: Netscape’s Navigator, of course, and also Microsoft’s Internet Explorer, Mozilla’s Mozilla and FireFox, Opera, etc.

The following JavaScript

program

takes two

integers

as inputs and outputs their

greatest common divisor

using Euclid’s

algorithm

. This is intended for Microsoft Internet Explorer 4.0 or higher; the code is placed between script tags in the head element of the HTML page, the body

element

should have a form element with appropriately labelled inputs, a span of text where the script will write the results to, and a button that calls the

calcGCD()

function

.

function calcGCD(a, b) {
wA = a;
wB = b;
while ( wB > 0 ) {
tempA = wA;
wA = wB
wB = tempA % wB;
}
return wA;
}

function goGCD() {
x = parseInt( document.forms[0].Xval.value );
y = parseInt( document.forms[0].Yval.value );
if ( isNaN( x ) || isNaN( y ) ) {
alert( "Please enter integers." );
} else {
document.all.GCDResultLine.innerText = "The greatest common divisor of " + x + " and " + y + " is " + calcGCD(x, y);
}
}

References

1

A. Danesh

Javascript in 10 Simple Steps or Less

Indianapolis: Wiley (2004)

2

D. Flannagan

JavaScript Pocket Reference

New York: O’Reilly (1998)

.1

External links

http://bobspoetry.com/eVoteDemo.html

Electronic Voting Demonstration Since this voting demo is implemented in JavaScript rather than Java, the source code may be inspected using the Web browser’s View Source command. This is not the case of Diebold voting

machines

.

http://www.btinternet.com/ se16/js/factor.htm

Henry Bottomley’s

Prime Factors

Calculator Uses

trial division

to factor input integers.

Title

JavaScript

Canonical

name

JavaScript

Date of creation

2013-03-22 16:52:13

Last modified on

2013-03-22 16:52:13

Owner

PrimeFan (13766)

Last modified by

PrimeFan (13766)

Numerical id

6

Author

PrimeFan (13766)

Entry type

Definition

Classification

msc 68N15

Classification

msc 03-04

Synonym

JScript

Synonym

ECMAScript

Generated on Sat Feb 10 12:37:30 2018 by

LaTeXML
overload

overload

To assign another meaning to a symbol that already has a meaning, or a new operation to an operator that is already assigned to another operation. Perhaps the quintessential example of overloading in mathematics is the case of the Greek letter

π

. In

geometry

π

refers to the ratio between the

perimeter

and the

diameter

on a circle, while in

number theory

π

⁢

(

x

)

refers to the

prime counting function

, and not the

multiplication

of

x

by the circle perimeter/diameter ratio.

In some cases it is possible to resolve meaning purely from context. For example, if

i

occurs under a

Σ

or a

Π

it is most likely just a generic iterator. Absent those Greek letters, it could be the

imaginary unit

,

-

1

.

The + operator is often

overloaded

to be both the

addition

of numbers operator and the string concatenation operator.

In

computer

programming languages, overloading is one of the kinds of ad-hoc polymorphism, and it is argued that this helps reduce the kind of notational clutter that might ensue if every operation had to have an operator specifically designed for its type.

Title

overload

Canonical

name

Overload

Date of creation

2013-03-22 16:03:04

Last modified on

2013-03-22 16:03:04

Owner

Mravinci (12996)

Last modified by

Mravinci (12996)

Numerical id

6

Author

Mravinci (12996)

Entry type

Definition

Classification

msc 68N15

Classification

msc 00A99

Synonym

overloaded

Generated on Sat Feb 10 12:37:34 2018 by

LaTeXML
Polish notation

Polish notation

Whereas

operators

are traditionally placed between operands, with parentheses used to override

operator precedence

, it is possible to place each operator to the left of its operands, thus eliminating ambiguity and the need for parentheses, and even the need for rules of operator precedence.

This is known as

Polish notation

(after the Polish mathematician Jan Łukasiewicz who came up with it), or

prefix notation

. Polish notation is a system of notating mathematical

operations

(whether

arithmetic

, logical, etc.) where the operators precede their operands and the ambiguities of operator precedence and the need for parentheses are altogether eliminated.

For example,

2

+

3

×

15

probably means 47, but if the possibility exists that the author meant but neglected to put in parentheses, the

expression

could actually mean

(

2

+

3

)

×

15

=

75

. In Polish notation, we could define the basic arithmetic operators to all be binary, and write

+

×

2

3

15

with the confidence that it will evaluate to 21 rather than 47.

Lisp is one

computer

programming language that uses Polish notation. In Łukasiewicz’s vision, parentheses are not necessary at all, certainly not for resolving operator precedence. Lisp, however, uses parentheses to specify arity by enclosing operands affected by a single operator in a “list,” and “the only hierarchy rule [in Lisp is] … that innermost lists are evaluated before the lists that enclose them.” (Chirlian, 1986) Thus, in the Lisp expression

(

-

21

⁢

(

+

3

5 8

)

)

, the

addition

operator is ternary and the

subtraction

operator is binary.

Certain LaTeX packages, such as pstricks, also use Polish notation when used for plotting

plane curves

.

For stack-based programming languages like Adobe PostScript,

reverse Polish notation

(or postfix notation) – in which the operators are written after the operands – is often the norm. Note that it is quite common for authors to confuse Polish and reverse Polish, e.g., page 3 of Chirlian (1986) speaks of “

reverse Polish

or

prefix

notation.”

References

1

P. Chirlian,

Lisp

, Cleveland: Weber Systems pp. 3, 29 - 34 (1986)

Title

Polish notation

Canonical

name

PolishNotation

Date of creation

2013-03-22 16:09:42

Last modified on

2013-03-22 16:09:42

Owner

PrimeFan (13766)

Last modified by

PrimeFan (13766)

Numerical id

19

Author

PrimeFan (13766)

Entry type

Definition

Classification

msc 68N17

Classification

msc 03B70

Synonym

prefix notation

Synonym

Łukasiewicz notation

Synonym

Lukasiewicz notation

Related topic

ReversePolishNotation

Generated on Sat Feb 10 12:37:36 2018 by

LaTeXML
reverse Polish notation

reverse Polish notation

Whereas

operators

are traditionally placed between operands, with parentheses used to override

operator precedence

, it is possible to place operators to the right of operands, thus eliminating ambiguity and the need for parentheses, and even the need for rules of operator precedence. This is known as

reverse Polish notation

(after the Polish mathematician Jan Łukasiewicz who came up with

Polish notation

, abbreviated

RPN

), or

postfix notation

. Invented by Australian philosopher Charles Hamblin, reverse Polish notation requires that the number of operands of a given operator be defined in advance.

For example,

3

×

16

-

1

probably means 47, but if the possibility exists that the author meant but neglected to put in parentheses, the

expression

could actually mean

3

×

(

16

-

1

)

=

45

. In reverse Polish notation, we could define the basic

arithmetic

operators to all be binary, and write

3

16

×

1

-

with the confidence that it will evaluate to 47 and not 45.

Reverse Polish notation is particularly advantageous for stack-based programming languages like Forth and Adobe PostScript. Most Hewlett-Packard

calculators

use reverse Polish notation (though a few, such as the HP-38G, use the sort of

infix notation

conventional to most calculators). Some beginning programming language courses give as an exercise to the student the implementation of an RPN calculator. Instead of having to remember multiple addresses for different

variables

and

constants

, most RPN implementations use a stack and a stack pointer to keep track of data.

The

factorial

notation (e.g.,

n

!

) is a fairly common use of postfix notation in mostly infix

contexts

. (Most unary operators in C++ are prefix).

To convert from standard infix notation to reverse Polish notation, the Dutch

computer

programmer Edsger Dijkstra came up with the

shunting yard algorithm

.

Title

reverse Polish notation

Canonical

name

ReversePolishNotation

Date of creation

2013-03-22 16:10:04

Last modified on

2013-03-22 16:10:04

Owner

Mravinci (12996)

Last modified by

Mravinci (12996)

Numerical id

6

Author

Mravinci (12996)

Entry type

Definition

Classification

msc 68N17

Classification

msc 03B70

Synonym

postfix notation

Synonym

RPN

Synonym

Zciweisakul notation

Synonym

reverse-Polish

Synonym

reverse-Polish notation

Related topic

PolishNotation

Generated on Sat Feb 10 12:37:38 2018 by

LaTeXML
shunting yard algorithm

shunting yard algorithm

To convert from standard

infix notation

to

reverse Polish notation

, the Dutch

computer

programmer Edsger Dijkstra came up with the

shunting yard algorithm

.

Given a string of tokens, a token reader that ignores whitespace (except to delimit numbers), a number stack, an

operator

stack and an output queue execute the following steps:

1. Read the tokens in order until end of line. Put number tokens on the output queue. Put operator tokens on the operator stack: if an operator is associative, and has lesser precedence than the operator below it on the operator stack, pop the lower operator off the operator stack and put it on the output queue. If the operator is a left parenthesis, push it onto the operator stack. If the operator is a right parenthesis, start popping operators off the operator stack and onto the output queue until a left parenthesis is encountered. If no left parenthesis is found, throw a mismatched parenthesis exception.
2. At end of line, pop all operators off the operator stack and onto the output queue. If a left parenthesis is encountered during this process, throw a mismatched parenthesis exception.
3. Send the contents of the output queue to the appropriate output device.

What the mismatched parenthesis exception does depends on the device. In the case of a palm

calculator

, the exception might just turn on the error ”E” and ignore input until the error clear key is pressed. In the case of a calculator implemented on a computer, the exception could give an appropriate message and ask the user to try again.

Title

shunting yard algorithm

Canonical

name

ShuntingYardAlgorithm

Date of creation

2013-03-22 16:10:16

Last modified on

2013-03-22 16:10:16

Owner

Mravinci (12996)

Last modified by

Mravinci (12996)

Numerical id

4

Author

Mravinci (12996)

Entry type

Algorithm

Classification

msc 68N17

Classification

msc 03B70

Generated on Sat Feb 10 12:37:39 2018 by

LaTeXML
Horn clause

Horn clause

In logic, a

Horn clause

is a clause (a

disjunction

of

literals

) with at most one positive literal. A Horn clause with exactly one positive literal is a

definite clause

; a Horn clause with no positive literals is sometimes called a goal clause, especially in logic programming. A Horn

formula

is a

conjunctive normal form

formula whose clauses are all Horn; in other words, it is a

conjunction

of Horn clauses. A

dual-Horn clause

is a clause with at most one negative literal. Horn clauses play a basic role in logic programming and are important for constructive logic.

The following is an example of a (definite) Horn clause:

¬

⁢

p

∨

¬

⁢

q

∨

⋯

∨

¬

⁢

t

∨

u

Such a formula can be rewritten in the following form, which is more common in logic programming and

similar

fields:

(

p

∧

q

∧

⋯

∧

t

)

→

u

The relevance of Horn clauses to

theorem

proving by first-order

resolution

is that the resolution of two Horn clauses is a Horn clause. Moreover, the resolution of a goal clause and a definite clause is again a goal clause. In automated theorem proving, this can lead to greater

efficiencies

in proving a theorem (represented as a goal clause). In fact, Prolog is a programming language based on Horn clauses (Prolog also includes constructs such as the cut that cannot be easily expressed in logic).

Horn clauses are also of interest in computational complexity, where the problem of finding a set of variable assignments to make a conjunction of Horn clauses true is a P-complete problem, sometimes called HORNSAT. This is P’s version of the boolean satisfiability problem, a

central

NP-complete problem

.

The name ”Horn clause” comes from the logician Alfred Horn, who first pointed out the significance of such clauses in 1951, in the article ”On

sentences

which are true of direct unions of algebras”,

Journal of Symbolic Logic

,

16

, 14 - 21.

This entry was adapted from the Wikipedia article

http://en.wikipedia.org/wiki/Horn_clause

Horn clause as of December 19, 2006.

Title

Horn clause

Canonical name

HornClause

Date of creation

2013-03-22 16:28:34

Last modified on

2013-03-22 16:28:34

Owner

PrimeFan (13766)

Last modified by

PrimeFan (13766)

Numerical id

6

Author

PrimeFan (13766)

Entry type

Definition

Classification

msc 68N30

Defines

dual-Horn clause

Generated on Sat Feb 10 12:37:41 2018 by

LaTeXML
not a number

not a number

In a

computer

,

not a number

(usually abbreviated

NaN

) indicates that an arithmetical operation has resulted in a value that is not a number understood (or representable) by the computer.

Division by zero

is one frequent cause of a result being NaN. Asking for the

square root

of a

negative number

is another operation that can result in NaN (unless the computer has been programmed to recognize

imaginary numbers

).

NaN is not a specific value that can be tested for with the usual comparison operators. The programmer is advised to test for NaN with a

special function

provided by the programming language (such as

isNaN(x)

in

JavaScript

.

Generally,

computer algebra systems

do not report NaN results even if they do display an error message for a given operation.

References

1

David Flanagan,

JavaScript the Definitive Guide: The Definitive Guide

. New York: O’Reilly (2006): 24

Title

not a number

Canonical

name

NotANumber

Date of creation

2013-03-22 18:14:09

Last modified on

2013-03-22 18:14:09

Owner

PrimeFan (13766)

Last modified by

PrimeFan (13766)

Numerical id

4

Author

PrimeFan (13766)

Entry type

Definition

Classification

msc 68P01

Generated on Sat Feb 10 12:37:43 2018 by

LaTeXML