text:
# scmutils

In order to run the SICM code, you need to install the scmutils library. Just go to the official page to download the library and follow the official instructions to install it in a Linux operating system.

When you try to run it, your system may give the following error message:

/usr/local/bin/mechanics: line 16: exec: xterm: not found

If so, you should install the program xterm first.

.

Also, in case you like to use Emacs as editor, you can:

Just include the following in your .emacs file:

(defun mechanics ()
(interactive)
(run-scheme
"ROOT/mit-scheme/bin/scheme --library ROOT/mit-scheme/lib"
))

Replace ROOT with the directory in which you installed the scmutils software. (Remember to replace it in both places. If it is installed differently on your system, just make sure the string has the form “/path/to/mit-scheme --library /path/to/scmutils-library“.) Restart emacs (or use C-x C-e to evaluate the mechanics defun), and launch the environment with the command M-x mechanics.

— Using GNU Emacs With SCMUtils

— Aaron Maxwell

.

In my Ubuntu 18.04, the paths are:

(defun mechanics()
(interactive)
(run-scheme
"/usr/local/scmutils/mit-scheme/bin/scheme --library
/usr/local/scmutils/mit-scheme/lib"
))

— Me@2019-04-07 02:52:50 PM

.

.

# Finding trajectories that minimize the action

We have used the variational principle to determine if a given trajectory is realizable. We can also use the variational principle to find trajectories. Given a set of trajectories that are specified by a finite number of parameters, we can search the parameter space looking for the trajectory in the set that best approximates the real trajectory by finding one that minimizes the action. By choosing a good set of approximating functions we can get arbitrarily close to the real trajectory.

— Structure and Interpretation of Classical Mechanics

.

We have used the variational principle to determine if a given trajectory is realizable.

How?

— Me@2019-03-29 04:23:36 PM

.

Check if the action of that given trajectory is stationary or not.

— Me@2019-03-29 04:25:45 PM

.

.

# Lagrangians in generalized coordinates

The function $\displaystyle{S_\chi}$ takes a coordinate path; the function $\displaystyle{\mathcal{S}}$ takes a configuration path.

\displaystyle{\begin{aligned} \mathcal{S} [\gamma] (t_1, t_2) &= \int_{t_1}^{t_2} \mathcal{L} \circ \mathcal{T} [\gamma] \\ S_\chi [q] (t_1, t_2) &= \int_{t_1}^{t_2} L_\chi \circ \Gamma [q] \\ \end{aligned}}

\displaystyle{\begin{aligned} \mathcal{S} [\gamma] (t_1, t_2) &= S_\chi [\chi \circ \gamma] (t_1, t_2) \\ \end{aligned}}

# Computing Actions

$\displaystyle{\texttt{literal-function}}$ makes a procedure that represents a function of one argument that has no known properties other than the given symbolic name.

The method of computing the action from the coordinate representation of a Lagrangian and a coordinate path does not depend on the coordinate system.

# Exercise 1.4. Lagrangian actions

For a free particle an appropriate Lagrangian is

\displaystyle{\begin{aligned} L(t,x,v) &= \frac{1}{2} m v^2 \\ \end{aligned}}

Suppose that $x$ is the constant-velocity straight-line path of a free particle, such that $x_a = x(t_a)$ and $x_b = x(t_b)$. Show that the action on the solution path is

\displaystyle{\begin{aligned} \frac{m}{2} \frac{(x_b - x_a)^2}{t_b - t_a} \\ \end{aligned}}

— Structure and Interpretation of Classical Mechanics

.

\displaystyle{\begin{aligned} L(t,x,v) &= \frac{1}{2} m v^2 \\ \end{aligned}}

\displaystyle{\begin{aligned} S_\chi [\gamma] (t_1, t_2) &= \int_{t_1}^{t_2} L_\chi (t, q(t), Dq(t)) dt \\ &= \int_{t_2}^{t_1} \frac{1}{2} m v^2 dt \\ &= \frac{1}{2} m v^2 \int_{t_2}^{t_1} dt \\ &= \frac{1}{2} m v^2 (t_2 - t_1) \\ &= \frac{1}{2} m (\frac{x_2 - x_1}{t_2 - t_1})^2 (t_2 - t_1) \\ &= \frac{1}{2} m \frac{(x_2 - x_1)^2}{t_2 - t_1} \\ \end{aligned}}

— Me@2006-2008

— Me@2019-03-10 11:08:29 PM

.

.

# Configuration Spaces

The set of all configurations of the system that can be assumed is called the configuration space of the system.

## Generalized Coordinates

1. In order to be able to talk about specific configurations we need to have a set of parameters that label the configurations. The parameters used to specify the configuration of the system are called the generalized coordinates.

2. The $\displaystyle{n}$-dimensional configuration space can be parameterized by choosing a coordinate function $\displaystyle{\chi}$ that maps elements of the configuration space to $n$-tuples of real numbers.

3. The motion of the system can be described by a configuration path $\displaystyle{\gamma}$ mapping time to configuration-space points.

4. Corresponding to the configuration path is a coordinate path $\displaystyle{q = \chi \circ \gamma}$ mapping time to tuples of generalized coordinates.

The function $\displaystyle{\Xi \chi}$ takes the coordinate-free local tuple $\displaystyle{( t, \gamma (t), \mathcal{D} \gamma (t), ... )}$ and gives a coordinate representation as a tuple of the time, the value of the coordinate path function at that time, and the values of as many derivatives of the coordinate path function as are needed.

\displaystyle{ \begin{aligned} \text{generalized coordinate representation} &= \Xi (\text{local tuple}) \\ (t, q(t), Dq(t), ...) &= \Xi_\chi (t, \gamma(t), \mathcal{D} \gamma(t), ...) \\ \end{aligned} }

\displaystyle{ \begin{aligned} \text{generalized coordinates} &= q \\ &= \chi \circ \gamma \\ \\ q(t) &= \chi(\gamma(t)) \\ \end{aligned} }

\displaystyle{ \begin{aligned} t &\to \gamma: \text{configuration path} \to \chi: \text{generalized coordinates} = q \\ \end{aligned} }

\displaystyle{ \begin{aligned} (t, q(t), Dq(t), ...) &= \Xi_\chi (t, \gamma(t), \mathcal{D} \gamma(t), ...) \\ \\ \Gamma[q](t) &= (t, q(t), Dq(t), ...) \\ \Gamma[q] &= \Xi_\chi \circ \mathcal{T}[\gamma] \\ \end{aligned} }

— 1.2 Configuration Spaces

— Structure and Interpretation of Classical Mechanics

— Me@2019-03-01 03:09:25 PM

.

.

2019.03.01 Friday ACHK

# Path-distinguishing function, 2

$\displaystyle{\gamma(t)}$ = configuration path function

$\displaystyle{\mathcal{F} [\gamma]}$ = a function of time that measures some local property of the path

……….It may depend upon the value of the function $\displaystyle{\gamma}$ at that time

……….and the value of any derivatives of $\displaystyle{\gamma}$ at that time.

.

We can decompose $\mathcal{F} [\gamma]$ into two parts:

1. a part that measures some property of a local description

and

2. a part that extracts a local description of the path from the path function.

.

— 1.3 The Principle of Stationary Action

— Structure and Interpretation of Classical Mechanics

.

1. The function that measures the local property of the system depends on the particular physical system;

2. the method of construction of a local description of a path from a path is the same for any system.

.

\displaystyle{ \begin{aligned} \mathcal{F} [\gamma] &= \mathcal{L} \circ \mathcal{T}[\gamma] \\ \mathcal{T} [\gamma] &= (t, \gamma (t), \mathcal{D} \gamma (t), ...) \end{aligned}}

.

— 1.3 The Principle of Stationary Action

— Structure and Interpretation of Classical Mechanics

— Me@2019-02-22 11:46:50 PM

.

.

2019.02.24 Sunday ACHK

# Path-distinguishing function

So we will try to arrange that the path-distinguishing function, constructed as an integral of a local property along the path, assumes a stationary value for any realizable path. Such a path-distinguishing function is traditionally called an action for the system. We use the word “action” to be consistent with common usage. Perhaps it would be clearer to continue to call it “path-distinguishing function,” but then it would be more difficult for others to know what we were talking about.

— 1.3 The Principle of Stationary Action

— Structure and Interpretation of Classical Mechanics

.

.

2019.02.17 Sunday ACHK

# SICM

Structure and Interpretation of Classical Mechanics (SICM) is a classical mechanics textbook written by Gerald Jay Sussman and Jack Wisdom with Meinhard E. Mayer. The first edition was published by MIT Press in 2001, and [the] second edition was released in 2015. The book is used at the Massachusetts Institute of Technology to teach a class in advanced classical mechanics, starting with Lagrange’s equations and proceeding through canonical perturbation theory.

— Wikipedia on Structure and Interpretation of Classical Mechanics

.

.

2019.02.02 Saturday ACHK

# DO

While DOLIST and DOTIMES are convenient and easy to use, they aren’t flexible enough to use for all loops. For instance, what if you want to step multiple variables in parallel?

(do (variable-definition*)
(end-test-form result-form*)
statement*)

— Practical Common Lisp

— Peter Seibel

.

(defun split-if (fn lst)
(let ((acc nil))
(do ((src lst (cdr src)))
((or (null src) (funcall fn (car src)))
(values (nreverse acc) src))
(push (car src) acc))))

 >(split-if #'(lambda (x) (> x 4)) '(1 2 3 4 5 6 7 8 9 10))

(1 2 3 4) (5 6 7 8 9 10)

— p.50

— On Lisp

— Paul Graham

.

Exercise 4.5

Implement the function split-if without using the macro do.

— Me@2019-01-30 09:58:30 PM

.

.

2019.01.30 Wednesday ACHK

# duplicate

If (member o l) finds o in the list l, it also returns the cdr of l beginning with o. This return value can be used, for example, to test for duplication. If o is duplicated in l, then it will also be found in the cdr of the list returned by member. This idiom is embodied in the next utility, duplicate:
 >(duplicate ’a ’(a b c a d)) (A D)

(defun duplicate (obj lst &key (test #’eql))
(member obj (cdr (member obj lst :test test))
:test test))

— p.51

— On Lisp

— Paul Graham

.

Exercise 4.4

Without using the existing function member, define duplicate as in
 >(duplicate ’a ’(a b c a d)) (A D)

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

— This answer is my guess. —

(defun my-member (obj lst)
(cond ((not lst) NIL)
((eq obj (car lst)) lst)
(t (my-member obj (cdr lst)))))

— This answer is my guess. —

— Me@2019-01-21 06:34:46 AM

.

.

# Equality Predicates

6.3. Equality Predicates

Common Lisp provides a spectrum of predicates for testing for equality of two objects: eq (the most specific), eql, equal, and equalp (the most general).

eq and equal have the meanings traditional in Lisp.

eql was added because it is frequently needed, and equalp was added primarily in order to have a version of equal that would ignore type differences when comparing numbers and case differences when comparing characters.

If two objects satisfy any one of these equality predicates, then they also satisfy all those that are more general.

.

[Function]
eq x y

(eq x y) is true if and only if x and y are the same identical object. (Implementationally, x and y are usually eq if and only if they address the same identical memory location.)

.

The predicate eql is the same as eq, except that if the arguments are characters or numbers of the same type then their values are compared. Thus eql tells whether two objects are conceptually the same, whereas eq tells whether two objects are implementationally identical. It is for this reason that eql, not eq, is the default comparison predicate for the sequence functions defined in chapter 14.

.

[Function]
eql x y

The eql predicate is true if its arguments are eq, or if they are numbers of the same type with the same value, or if they are character objects that represent the same character.

.

[Function]
equal x y

The equal predicate is true if its arguments are structurally similar (isomorphic) objects. A rough rule of thumb is that two objects are equal if and only if their printed representations are the same.

Numbers and characters are compared as for eql. Symbols are compared as for eq. This method of comparing symbols can violate the rule of thumb for equal and printed representations, but only in the infrequently occurring case of two distinct symbols with the same print name.

.

[Function]
equalp x y

Two objects are equalp if they are equal; if they are characters and satisfy char-equal, which ignores alphabetic case and certain other attributes of characters; if they are numbers and have the same numerical value, even if they are of different types; or if they have components that are all equalp.

— Common Lisp the Language, 2nd Edition

— Guy L. Steele Jr.

.

Conrad’s Rule of Thumb for Comparing Stuff:

1. Use eq to compare symbols

2. Use equal for everything else

— Land of Lisp, p.63

.

.

2019.01.16 Wednesday ACHK

# Clasp

Overview

Clasp is a new Common Lisp implementation that seamlessly interoperates with C++ libraries and programs using LLVM for compilation to native code. This allows Clasp to take advantage of a vast array of preexisting libraries and programs, such as out of the scientific computing ecosystem. Embedding them in a Common Lisp environment allows you to make use of rapid prototyping, incremental development, and other capabilities that make it a powerful language.

.

I followed the official instructions to build Clasp:

The building process had been going on for about an hour; and then I got this error:

— Me@2019-01-04 10:11:43 PM

.

.

# Build cross-compiled ECL for Android, 3

EQL5-Android | Common Lisp for Android App Development 2018

.

After successfully running the command ./1-make-ecl-host.sh, when I tried to run the command ./2-make-ecl-android.sh, I got the following errors:

— Me@2018-12-29 11:21:46 PM

.

.

# Build cross-compiled ECL for Android, 2

EQL5-Android | Common Lisp for Android App Development 2018

.

The step 2 is to “build cross-compiled ECL for Android”. It should have been straightforward to follow the instructions in the README page of the EQL5-Android project.

However, when trying to run the command ./1-make-ecl-host.sh, I got the following error messages:

The error was caused by the fact that my Ubuntu 18.04’s 64-bit gcc toolchain could not compile any source code to create 32-bit executables.

The solution is to run the following command to install the 32-bit gcc toolchain first:

sudo apt-get install g++-multilib libc6-dev-i386

— Me@2018-12-25 09:51:02 PM

.

.

# Build cross-compiled ECL for Android

EQL5-Android | Common Lisp for Android App Development 2018

.

The step 2 is to “build cross-compiled ECL for Android”. It should have been straightforward to follow the instructions in the README page of the EQL5-Android project.

However, when trying to run the command ./1-make-ecl-host.sh, I got the following error messages:

A more serious problem was that I could not even locate the error log file config.log.

.

Another abnormality was that while the process claimed that it was

Creating directory 'build',

the directory build was actually not created at all.

So I manually created that directory before running the command ./1-make-ecl-host.sh again. Only then, I could find the error log file config.log in the build directory, after the failure of the compilation.

— Me@2018-12-19 10:50:31 PM

.

.

# The Android NDK Tools

EQL5-Android | Common Lisp for Android App Development 2018

.

After installing the Android SDK Tools by installing Android Studio, originally, you would be able to install the Android NDK through Android Studio’s SDK Manager.

However, since EQL5-Android requires an old version of the NDK (version 10e), you have to download the NDK from the Android’s official NDK webpage.

In Ubuntu, move the file android-ndk-r10e-linux-x86_64.zip to the same location as the Android SDK and then unzip it.

— Me@2018-12-16 09:25:10 PM

.

.

# The Android SDK Tools

EQL5-Android | Common Lisp for Android App Development 2018

.

After installing Qt, check whether its version is 5.9 or later.

If so, install the Android SDK Tools by installing Android Studio.

If you use Ubuntu 18.04 or later, you can use the snap command to install Android Studio.

Besides installing Android Studio, it also automatically updates Android Studio regularly.

— Me@2018-12-12 02:21:45 PM

.

.

# EQL5-Android

Common Lisp for Android App Development 2018

.

The first step to set up EQL5-Android is to install Qt.

In Ubuntu, if you do not need the most updated Qt, you can just install the Qt-Creator using apt-get.

— Me@2018-12-08 09:18:19 PM

.

.

# Common Lisp for Android App Development 2018

An REPL called “CL REPL” is available in the Google Play Store. But itself is not for developing standalone Android apps, unless those apps are Common Lisp source code files only.

However, “CL REPL” itself is an open source GUI app using Common Lisp and Qt. So by learning and using its source, in principle, we can create other Android apps using Common Lisp with Qt.

The library that “CL REPL” uses is EQL5-Android.

— Me@2018-11-23 04:07:54 PM

.

.

# defmacro, 2

Defining the defmacro function using only LISP primitives?

.

McCarthy’s Elementary S-functions and predicates were

atom, eq, car, cdr, cons

.

He then went on to add to his basic notation, to enable writing what he called S-functions:

quote, cond, lambda, label

.

On that basis, we’ll call these “the LISP primitives”…

How would you define the defmacro function using only these primitives in the LISP of your choice?

edited Aug 21 ’10 at 2:47
Isaac

asked Aug 21 ’10 at 2:02
hawkeye

.

Every macro in Lisp is just a symbol bound to a lambda with a little flag set somewhere, somehow, that eval checks and that, if set, causes eval to call the lambda at macro expansion time and substitute the form with its return value. If you look at the defmacro macro itself, you can see that all it’s doing is rearranging things so you get a def of a var to have a fn as its value, and then a call to .setMacro on that var, just like core.clj is doing on defmacro itself, manually, since it doesn’t have defmacro to use to define defmacro yet.

– dreish Aug 22 ’10 at 1:40

.

.

# defmacro

SLIME, 2

.

Alt + Up/Down

Switch between the editor and the REPL

— Me@2018-11-07 05:57:54 AM

~~~

defmacro

.

(defmacro our-expander (name) (get ,name 'expander))

(defmacro our-defmacro (name parms &body body)
(let ((g (gensym)))
(progn
(setf (our-expander ',name)
#'(lambda (,g)
(block ,name
(destructuring-bind ,parms (cdr ,g)
,@body))))
',name)))

(defun our-macroexpand-1 (expr)
(if (and (consp expr) (our-expander (car expr)))
(funcall (our-expander (car expr)) expr)
expr))

.

A formal description of what macros do would be long and confusing. Experienced programmers do not carry such a description in their heads anyway. It’s more convenient to remember what defmacro does by imagining how it would be defined.

The definition in Figure 7.6 gives a fairly accurate impression of what macros do, but like any sketch it is incomplete. It wouldn’t handle the &whole keyword properly. And what defmacro really stores as the macro-function of its first argument is a function of two arguments: the macro call, and the lexical environment in which it occurs.

— p.95

— A MODEL OF MACROS

— On Lisp

— Paul Graham

.

(our-defmacro sq (x)
(* ,x ,x))

After using our-defmacro to define the macro sq, if we use it directly,

(sq 2)

we will get an error.

The function COMMON-LISP-USER::SQ is undefined. [Condition of type UNDEFINED-FUNCTION]

Instead, we should use (eval (our-macroexpand-1 ':

(eval (our-macroexpand-1 '(sq 2)))

`

— Me@2018-11-07 02:12:47 PM

.

.


text:
Index
Blog

# Programs Are Data Structures

We’ve seen repeatedly that the result of parsing an expression is an AST. An interpreter is a program that consumes that data structure and produces a value. A type checker is a program that consumes that data structure and produces a type. Both are programs that manipulate AST structures and produce different kinds of results. Let’s take this concept further and look at another kind of program that manipulates programs.

## Optimization

Most if not all modern compilers and interpreters perform some kind of optimization on programs they process. Such optimizations range from simple function inlining and elimination of constant calculations to sophisticated variable elimination and loop unrolling.

This simple example will take a BBAE program and perform zero elimination on numerical calculations. Specifically, both plus and minus operations have cases involving 0 where a term can be eliminated:

Let’s define an optimization that replaces each expression on the left with the corresponding expression on the right.

## Implementation

Implementation of the optimization involves writing an interpreter.

The signature of the optimizer accepts a BBAE and produces a BBAE:

The constant number vale cannot be optimized and is thus left alone:

We add two cases corresponding to addition of 0 to any value. In both cases the sum is eliminated and replaced with the non-zero term. In each case the resulting term is recursively optimized. The third case involving sums with no zero-valued terms remains the same following optimization:

Optimizing subtraction works similarly. However, we will only eliminate zero in the righthand term:

Optimization of all non-numeric terms is achieved by optimizing terms and reassembling the term. For example, if is optimized by optimizing each of the three terms in the AST structure and reassembling them in a new If construct. Following are cases for remaining BBAE constructs:

An interpreter tht composes the optimization function with the other language parsing elements is expressed as:

## Testing

Optimizations must be extensively tested and verified. We can use roughly the same QuickCheck function to ensure correctness that we used earlier:

Here we compare the result evaluating directly, eval [], with the result of optimizing before evaluating, eval [] . optimize. Testing 10000 cases gives evidence that the optimization is correct.

## Discussion

Eliminating math operations over 0 is a trivial optimization. However, it serves to demonstrate how an AST is just a data structure. We wrote an operation over BBAE that simply transforms one program into another. Both eval and typeof do the same thing, but are more traditionally associated with processing programs.

Also note the structure of the optimize function. It is essentially the same as the interpreter and type checker. Recursive function over the structure of an expression share a common for that we will see over and over again throughout this study. Perhaps we can abstract that pattern out of these functions and use it directly.

## Exercises

1. Write an optimizer for the Boolean operation and similar to that for numerical operations dealing with constants true and false.
2. Write an optimizer for the If expression that deals with constant true and false values in the conditional.
3. Define an optimization for Leq and write an optimizer for it. Show using QuickCheck that your optimization is correct.

format: plain


text:
•      Sign In
• Create Account

### #ActualNyssa

Posted 28 January 2013 - 08:59 PM

Vector2 position(0.0, 0.0);
Vector2 velocity(0.0, 0.0);
Vector2 force(0.0, 0.0);
float mass = 1.0;
float gravity = -9.8;
float damping = 0.001f;

while(true)
{
float dt = 0.016;//time elapse per frame in seconds

//Do game logic here

position = position + velocity * dt;

//adds fake friction
velocity *= 1.0 - (damping * dt);

//adds gravity based on mass
force.y += mass * gravity;

velocity = velocity + (force / mass) * dt;
force = 0;
}

1. When pressing the jump button, do not jump to the maximum height immediately. Instead, you have to hold the jump button to jump higher(and respect a limit). This feature would allow short-jumps and give you more control over your character.

To the algorithm above, add some value to force.y once. If you hold down a key then continue to add a force over multiple frames.

2. Activate gravity if you walked down from a cliff for example(i e, you are in the air without have jumped)

The algorithm above with handle this automatically with gravity. Change the gravity value to increase the acceleration.

3. After you released your jump button, you can not jump again until you hit the ground.

For this you'll need to add collision detection and response, and may get tricky.

### #3Nyssa

Posted 28 January 2013 - 07:23 PM

Vector2 position(0.0, 0.0);
Vector2 velocity(0.0, 0.0);
Vector2 force(0.0, 0.0);
float mass = 1.0;
float gravity = -9.8;
float damping = 0.001f;

while(true)
{
float dt = 0.016;//time elapse per frame in seconds

//Do game logic here

position = position + velocity * dt;

//adds fake friction
velocity *= 1.0 - (damping * dt);

//adds gravity - f = ma
force.y += mass * gravity;

velocity = velocity + (force / mass) * dt;
force = 0;
}

1. When pressing the jump button, do not jump to the maximum height immediately. Instead, you have to hold the jump button to jump higher(and respect a limit). This feature would allow short-jumps and give you more control over your character.

To the algorithm above, add some value to force.y once. If you hold down a key then continue to add a force over multiple frames.

2. Activate gravity if you walked down from a cliff for example(i e, you are in the air without have jumped)

The algorithm above with handle this automatically with gravity. Change the gravity value to increase the acceleration.

3. After you released your jump button, you can not jump again until you hit the ground.

For this you'll need to add collision detection and response, and may get tricky.

### #2Nyssa

Posted 28 January 2013 - 07:08 PM

Vector2 position(0.0, 0.0);
Vector2 velocity(0.0, 0.0);
Vector2 force(0.0, 0.0);
float mass = 1.0;
float gravity = -9.8;

while(true)
{
float dt = 0.016;//time elapse per frame in seconds

//Do game logic here

position = position + velocity * dt;

//adds gravity - f = ma
force.y += mass * gravity;

velocity = velocity + (force / mass) * dt;
}

1. When pressing the jump button, do not jump to the maximum height immediately. Instead, you have to hold the jump button to jump higher(and respect a limit). This feature would allow short-jumps and give you more control over your character.

To the algorithm above, add some value to force.y once. If you hold down a key then continue to add a force over multiple frames.

2. Activate gravity if you walked down from a cliff for example(i e, you are in the air without have jumped)

The algorithm above with handle this automatically with gravity. Change the gravity value to increase the acceleration.

3. After you released your jump button, you can not jump again until you hit the ground.

For this you'll need to add collision detection and response, and may get tricky.

### #1Nyssa

Posted 28 January 2013 - 07:04 PM

Vector2 position(0.0, 0.0);
Vector2 velocity(0.0, 0.0);
Vector2 force(0.0, 0.0);
float mass = 1.0;
float gravity = -9.8;

while(true)
{
float dt = time elapse per frame in seconds

//Do game logic here

position = position + velocity * dt;

//adds gravity - f = ma
force.y += mass * gravity;

velocity = velocity + (force / mass) * dt;
}

1. When pressing the jump button, do not jump to the maximum height immediately. Instead, you have to hold the jump button to jump higher(and respect a limit). This feature would allow short-jumps and give you more control over your character.

To the algorithm above, add some value to force.y once. If you hold down a key then continue to add a force over multiple frames.

2. Activate gravity if you walked down from a cliff for example(i e, you are in the air without have jumped)

The algorithm above with handle this automatically with gravity. Change the gravity value to increase the acceleration.

3. After you released your jump button, you can not jump again until you hit the ground.

For this you'll need to add collision detection and response, and may get tricky.

PARTNERS


text:
# Find $\epsilon'$ s.t $L_\epsilon$ is $\mathsf{NP}$-hard for any $\epsilon<\epsilon'$

Let $L_\epsilon$ be the language of all $2$-CNF formulas $\varphi$, such that at least $(\frac{1}{2}+\epsilon)$ of $\varphi$'s clauses can be satisfied.

I need to prove that there exists $\epsilon'$ s.t $L_\epsilon$ is $\mathsf{NP}$-hard for any $\epsilon<\epsilon'$.

We know that $\text{Max}2\text{Sat}$ can be approximate to $\frac{55}{56}$ precent of the clauses from a $\text{Max}3\text{Sat}$ reduction. How should I solve this one?

-

In his famous paper, Håstad shows that it is NP-hard to approximate MAX2SAT better than $21/22$. This likely means that is is NP-hard to distinguish instances which are $\leq \alpha$ satisfiable and instances which are $\geq (22/21) \alpha$ satisfiable, for some $\alpha \geq 1/2$. Now imagine padding an instance so that it becomes a $p$-fraction of a new instance, the rest of which is exactly $1/2$-satisfiable (say it consists of groups of clauses of the form $a \land \lnot a$). The numbers now become $1/2 + p (\alpha - 1/2)$ and $1/2 + p((22/21)\alpha - 1/2)$. The latter number can be made as close to $1/2$ as we want.

-
 Does your method works when ε is an arbitrary (but sufficiently small) real number? I cannot figure out how to choose the appropriate number of clauses to use for padding unless I assume something about ε. (Note that ε is not part of the input, and therefore it is well-defined to consider real number ε.) – Tsuyoshi Ito Dec 22 '12 at 23:10 That's where the gap between $1/2+p(\alpha-1/2)$ and $1/2+p((22/21)\alpha-1/2)$ could be useful. Assuming $\alpha$ is rational, take some rational $p$, and you should do fine. – Yuval Filmus Dec 23 '12 at 1:04 Aha, somehow I thought that that method did not work when I tried it first, but now I see how it works. Thanks! – Tsuyoshi Ito Dec 23 '12 at 1:26

If you know that ε is a rational number, then you do not need inapproximability for Max-2-SAT to prove your statement. A typical proof of the NP-hardness of Max-2-SAT (e.g., the one in the textbook Computational Complexity by Papadimitriou) actually proves the NP-completeness of L1/5. To prove the NP-hardness of Lε for positive rational numbers ε<1/5, we can reduce L1/5 to Lε as follows: given a 2CNF formula φ (an instance for L1/5), let m be the number of clauses in it. Let r and s be positive integers such that (1/5−ε)mr = 2εs holds. Then construct a 2CNF formula (an instance for Lε) by repeating φ for r times and adding s pairs of contradicting clauses. A simple calculation shows that this is indeed a reduction from L1/5 to Lε.

This reduction clearly works only if ε is rational, because otherwise r and s cannot be taken as integers. The general case where ε is not necessarily rational seems to require inapproximability, as Yuval Filmus wrote in his answer.

-


text:
# Seminars & Events for 2011-2012

November 16, 2011
2:00pm - 3:00pm
##### A microscopic derivation of Ginzburg-Landau theory of superconductivity
###### Statistical Mechanics Seminar

We describe the first rigorous derivation of the celebrated Ginzburg-Landau (GL) theory, starting from the microscopic Bardeen-Cooper-Schrieffer (BCS) model. Close to the critical temperature, GL arises as an effective theory on the macroscopic scale.

Speaker: Rupert Frank, Princeton University
Location:
Fine Hall 224
November 16, 2011
4:30pm - 5:30pm
##### On the Ma-Trudinger-Wang condition
###### Department Colloquium

The Ma-Trudinger-Wang condition, first introduced to prove regularity of optimal transport maps for general cost functions, has turned out to be a useful tool for: - Obtaining geometric informations on the underlying manifold. - Making the principal-agent problem theoretically and computationally tractable, allowing to derive uniqueness and stability of the principal's optimum strategy.

Speaker: Alessio Figalli, University of Texas-Austin
Location:
Fine Hall 314
November 17, 2011
2:15pm - 3:15pm
##### Noisy interpolation of sparse polynomials, and applications
###### Discrete Mathematics Seminar

Let f in $F_q[x]$ be a polynomial of degree $d < q/2$. It is well-known that f can be uniquely recovered from its values at some 2d points even after some small fraction of the values are corrupted. In this talk we will establish a similar result for sparse polynomials.

Speaker: Shubhangi Saraf, MIT
Location:
Fine Hall 224
November 17, 2011
3:00pm - 4:00pm
##### A parametrized version of Gromov's waist of the sphere theorem
###### Algebraic Topology Seminar

Gromov, Memarian, and Karasev--Volovikov proved that any map $f$ from an n-sphere to a k-manifold $(n>=k)$ has a preimage $f^{-1}(z)$ whose epsilon-neighborhoods are at least as large as the epsilon-neighborhoods of the equator $S^{n-k}$, assuming that the degree of f is even in case $n=k$. We present a parametrized generalization.

Speaker: Benjamin Matschke, IAS
Location:
Fine Hall 214
November 17, 2011
4:30pm - 5:30pm
##### Towards cornered Floer homology
###### Topology Seminar

As part of the bordered Floer homology package, Lipshitz, Ozsvath and D. Thurston have associated to a parametrized oriented surface a certain differential graded algebra. I will describe a decomposition theorem for this algebra, corresponding to cutting the surface along a circle.

Speaker: Ciprian Manolescu, UCLA
Location:
Fine Hall 314
November 17, 2011
4:30pm - 5:30pm
##### Arithmetic inner product formula
###### Princeton University/IAS Number Theory Seminar

I will introduce an arithmetic version of the classical Rallis' inner product formula for unitary groups, which generalizes the previous works of Kudla, Kudla-Rapoport-Yang and Bruinier-Yang. As Rallis' formula concerns the central L-values of automorphic representations with certain epsilon factor 1.

Speaker: Yifeng Liu, Columbia University
Location:
IAS Room S-101
November 18, 2011
3:00pm - 4:00pm
##### $W^{2,1}$ regularity for the Monge-Ampère equation
###### Differential Geometry & Geometric Analysis Seminar

The Monge-Ampère equation arises in connections with several problems from geometry and analysis (optimal transport, the Minkowski problem, the affine sphere problem, etc.) The regularity theory for this equation has been widely studied.

Speaker: Alessio Figalli, University of Texas, Austin
Location:
Fine Hall 314
November 18, 2011
4:30pm - 5:30pm
##### Morse Theory and Invariants of (almost) Symplectic Manifolds
###### Joint PU/IAS Symplectic Geometry Seminar

I will discuss two of my current projects which have different aims but use similar techniques. The first aims to understand the equivariant K-theory of symplectic orbifolds. The second is about the topology of toric origami manifolds. Neither space is a symplectic manifold, but each is almost.

Speaker: Tara Holm, Cornell University
Location:
Fine Hall 322
November 21, 2011
4:00pm - 5:00pm
##### Modulation invariant bilinear T(1) theorem
###### Analysis Seminar

We discuss a T(1) theorem for bilinear singular integral operators with a one-dimensional modulation symmetry.

Speaker: Arpad Benyi, Western Washington University
Location:
Fine Hall 314
November 21, 2011
4:30pm - 6:30pm
##### Prolates on the sphere, Extensions and Applications: Slepian functions for geophysical and cosmological signal estimation and spectral analysis
###### PACM/Applied Mathematics Colloquium

Functions that are timelimited (or spacelimited) cannot be simultaneously bandlimited (in frequency). Yet the finite precision of measurement and computation unavoidably bandlimits our observation and modeling scientific data, and we often only have access to, or are only interested in, a study area that is temporally or spatially bounded.

Speaker: Frederik Simons, Princeton University
Location:
Fine Hall 214
November 22, 2011
4:30pm - 5:30pm
##### Random natural frequencies, active dynamics and coherence stability in populations of coupled rotators
###### Mathematical Physics Seminar

The Kuramoto synchronization model is the reference model for synchronization phenomena in biology (and, to a certain extent, also in other fields). The model is formulated as a dynamical system of interacting plane rotators. Variations of it provide basic models of phenomena beyond synchronization, such as noise induced coherent oscillations.

Speaker: Giambattista Giacomin, Université Paris Diderot
Location:
November 22, 2011
4:30pm - 5:30pm
##### Two gifts from complexity theory: $P$ v. $NP$ and matrix multiplication
###### Algebraic Geometry Seminar

I will discuss how the Geometric Complexity Theory of Mulmuley-Sohoni and the problem of determining the complexity of matrix multiplication lead to beautiful questions in algebraic geometry and representation theory.

Speaker: J. M. Landsberg, Texas A&M University
Location:
Fine Hall 322
November 23, 2011
2:00pm - 3:00pm
##### The thermodynamic limit of disordered quantum Coulomb systems
###### Statistical Mechanics Seminar

In this talk I will explain how to prove the existence of the thermodynamic limit for a many-body quantum crystal in which the electrons are quantum and the nuclei are classical point particles, with disordered charges and locations around a lattice. This is a collaboration with Xavier Blanc, based on previous work with Christian Hainzl and Jan Philip Solovej.

Speaker: M. Lewin, Universite de Cergy-Pontoise
Location:
Fine Hall 224
November 28, 2011
4:30pm - 5:30pm
##### Sharp Thresholds in Statistical Estimation
###### PACM/Applied Mathematics Colloquium

Sharp thresholds are ubiquitous high-dimensional combinatorial structures. The oldest example is probably the sudden emergence of the giant component in random graphs, first discovered by Erdos an Renyi.

Speaker: Andrea Montanari, Stanford University
Location:
Fine Hall 214
November 29, 2011
4:30pm - 5:30pm
##### Macdonald Processes and Some Applications in Probability and Integrable Systems
###### Mathematical Physics Seminar

Macdonald processes are probability measures on sequences of partitions defined in terms of nonnegative specializations of the Macdonald symmetric functions and two parameters $q$, $t$ in [0,1). Utilizing the Macdonald difference operators we prove several results about observables these processes, including Fredholm determinant formulas for q-Laplace transforms.

Speaker: Ivan Corwin, Courant Inst. NYU
Location:
IAS Room S-101
November 30, 2011
2:00pm - 3:00pm
##### Interacting Bosons in Random Potentials
###### Statistical Mechanics Seminar

In contrast to the cases of single particle Schrödinger operators and ideal Bose gases the effects of random external potentials on many-body systems of interacting particles is still poorly understood.

Speaker: J. Yngvason, University of Vienna
Location:
Fine Hall 224
December 1, 2011
2:15pm - 3:15pm
##### The chromatic number of random Cayley graphs
###### Discrete Mathematics Seminar

The study of random Cayley graphs of finite groups is related to the investigation of expanders and to problems in combinatorial number theory and in information theory. I will discuss this topic, focusing on the question of estimating the chromatic number of a random Cayley graph of a given group with a prescribed number of generators.

Speaker: Noga Alon, Tel Aviv University
Location:
Fine Hall 224
December 1, 2011
3:00pm - 4:00pm
##### Axioms for Differential Cohomology
###### Algebraic Topology Seminar

A differential cohomology theory (DCT) is a type of refinement of a cohomology theory (restricted to the category of smooth manifolds with corners) that contains information that is not homotopy invariant. A detailed definition of a DCT will be given, as well as axioms for a category larger than that of smooth manifolds with corners.

Speaker: Andrew Stimpson, IAS
Location:
Fine Hall 214
December 1, 2011
4:30pm - 5:30pm
##### A second main term for counting cubic fields, and biases in arithmetic progressions
###### Princeton University/IAS Number Theory Seminar

We prove the existence of second main term of order $X^{5/6}$ for the function counting cubic fields. This confirms a conjecture of Datskovsky-Wright and Roberts. We also prove a variety of generalizations, including to arithmetic progressions, where we discover a curious bias in the secondary term. Roberts' conjecture has also been proved independently by Bhargava, Shankar, and Tsimerman.

Speaker: Takashi Taniguchi, Princeton University and Kobe University
Location:
IAS Room S-101
December 2, 2011
2:00pm - 3:00pm
##### Effective dynamics of a non-linear wave equation
###### Analysis Seminar

We consider the non-linear wave equation on the real line $i u_t-|D|u=|u|^2u$. Its resonant dynamics is given by the Szego equation, which is a completely integrable non-dispersive non-linear equation. We show that the solution of the wave equation can be approximated by that of the resonant dynamics for a long time.

Speaker: Oana Pocovnicu, Imperial College, London
Location:
Fine Hall 314


text:
## Wednesday, June 07, 2006

### Hep-th papers on Wednesday

Ioannis Papadimitriou constructs new domain-wall-like solutions that are asymptotic to the near-horizon geometry of M2-branes, namely "AdS4 x S7" (supergravity in four noncompact dimensions). He uses the method of "fake supergravity".

Han-Xin He claims that he or she has calculated the full, exact three-point function of two fermionic fields and one gauge field in QED, just by algebraic manipulations with the Ward-Takahishi identities. An anonymous reader has pointed out that the resulting formula depends on the full non-perturbative fermionic propagator, so it is not quite a "free lunch", but it still seems nontrivial. The result has been checked up to one-loop level but it seems that it is being argued that it is valid up to all orders. This sounded like an extraordinary statement, especially because the formulae didn't seem to have the complexity and transcendentality of the higher-loop contributions, but I am not able to say what's wrong with it. If it's correct, it means that all the complexities of the fermion propagator and the three-point function are isomorphic. Comments will be certainly welcome.

Shinji Tsukikawa studies how the higher-derivative corrections to general relativity arising from string theory may regulate the Big Bang singularity and generate various bouncing, ekpyrotic, and other solutions. Topics of this kind were very popular five years ago. Do you remember papers such as Seiberg's paper on the Big Bounce?

Shibaji Roy and Harvendra Singh propose a technique to generate accelerating cosmological solutions from "S-branes" of another kind that has not yet been used. I have not understood how can one decide whether something is an S-brane or not. S-branes seem to be a label for rather general time-dependent solutions, unlike D-branes that are the lowest energy states in a given charge sector. This makes it difficult for me to understand why a solution should become important just because it is connected with the term "S-brane". The only meaningful purely spacelike counterpart of D-branes is a D-instanton or D-brane-instanton which is just a continuation of the usual D-branes to a Euclidean spacetime. S-branes are supposed to be something else but I don't think there is any room for something else.

Giuseppe Bimonte, Enrico Calloni, Giampiero Esposito, and Luigi Rosa include the first-order corrections from a gravitational field to a conventional calculation of the Casimir effect. They must be computing the first subleading correction, I think. Up to the leading order, the Casimir force and the gravitational force are simply added together. They argue that the Casimir force becomes a little bit stronger if you add acceleration (or gravity).

T.Khachidze, A. Khelashvili, T.Nadareishvili only offer a PDF file, and they argue that the Dirac equation does not reduce to the usual non-relativistic equation in the appropriate limit. They say that it has extra solutions - maybe hydrinos? :-) - and some new qualitative features. I am convinced that their paper is based on elementary errors. For example, when they square the Dirac Hamiltonian, they only keep the "V^2" terms but omit the main term proportional to "V" that actually survives in the Schrödinger limit. The "V^2" term is only a relativistic correction, analogous to the "p^4" corrections to the kinetic energy. The authors are recommended to study the derivation of the non-relativistic limit of the Dirac equation from one of the standard textbooks.

Daniel Litim promotes the idea that the UV fixed point of general relativity exists. An ultraviolet fixed point is the hypothetical scale-invariant theory valid at the sub-Planckian distances whose relevant deformation turns flows to general relativity at long distances. Its existence could make quantized general relativity predictive but it is believed that such a fixed point does not exist. Litim admits that classically, such a scale-invariant theory only exists in the critical dimension "d=2". We know purely field-theoretical gravitational theories in this spacetime dimension; the most useful two-dimensional field-theoretical gravity in "d=2" is called the string worldsheet. However, Litim claims that a fixed point of the renormalization group exists in every dimension. To support this claim, he considers the cosmological constant (Lambda) and the Einstein-Hilbert term (G) only, and studies the evolution of "Lambda,G" under the RG flow. With an appropriately chosen anomalous dimensions of the operators, he can find a fixed point in every dimension. I find this argument unconvincing because in the sub-Planckian distance regime, gravity is strongly coupled and it is not justified to neglect all other terms except for "Lambda,G". Equivalently, we can see that the "Lambda,G" approximation is bad because the anomalous dimensions of the fields are greater than one. It is unsurprising that whenever we include a few couplings only, we will formally find some fixed points, but those that appear in strongly coupled regions of the parameter space can't be quite trusted, unless a more complete argument is found.

Itzhak Bars continues in his provoking research of physics with two time coordinates. Today, he considers the Standard Model derived from a 4+2-dimensional starting point. In the past, Bars has argued that one can obtain very different physical systems - such as the Hydrogen atom and the harmonic oscillator - by different gauge-fixing choices applied to the same double-temporal starting point with an Sp(2,R) gauge symmetry. I don't understand how can one ever get different physics by choosing a gauge-fixing condition. Gauge symmetry and gauge-fixing choices should not affect observable physics, by definition. This is why I can't quite understand either of Bars' two-time papers. Nevertheless, if someone can do better than me, this paper constructs the Standard Model from a 4+2-dimensional starting point. Not only that, it explains the strong CP-problem because the "F /\ F" term cannot arise in this framework.

Martin Land discusses aspects of generalized D-dimensional Dirac magnetic monopole. I feel 85% certain that if you know Maxwell's equations in D dimensions and the simple power law solutions for electric and magnetic point-like sources, you won't find anything new in this paper.

Gottfried Curio and Vera Spillner jump into a seemingly random place of the KKLT landscape. They start with the elliptic Calabi-Yau manifold called P_{11169}[18] - known from "building a better racetrack" - and write down all relevant terms in the superpotential that is usually used in the context of flux compactifications, coming from fluxes and gaugino condensation. They modify the usual wisdoms by an unexpected dependence on the dilaton "tau". They seem to argue that the superpotential "W(tau)" itself is not holomorphic which I misunderstand because superpotentials should be holomophic. But because they seem to be really powerful technologically, I am inclined to believe that the paper makes a perfect sense.

Kazumi Okuyama studies the topological partition sum on the conifold - both in the A-model (the math of melting crystals) as well as B-model (Chern-Simons matrix model). He or she finds a very interesting integral transform that transform one to the other. The integral transform involves an integral over matrices with a Gaussian measure.

U. Gran, J. Gutowski, G. Papadopoulos, D. Roest argue that there are no configurations with exactly 31 supercharges in type IIB supergravity. More precisely, if you give them one with 31 supercharges, they are able to find the 32nd supercharge, proving that the background is maximally supersymmetric. It is analogous to "N=7" theories in "d=4" that are automatically "N=8", too. Their finding, if correct, invalidates the type IIB version of the "preon" speculation. These "preons", in the SUGRA context, were proposed to preserve 31 supercharges. Their central charge was hypothesized to be a "32 x 32" matrix whose rank equals one (instead of more usual values such as 16) which could turn them into basic building blocks of other systems that preserve a smaller number of supercharges. Such a bizarre rank-one central charge would clearly be a combination of central charges associated with branes of all possible dimensions, and this paper shows that this can't work at the level of type IIB supergravity.


text:
# Conservation of momentum at interface

For applications involving thin film evaporation and condensation, the effects of surface tension and disjoining pressure will create additional forces on the interface. The momentum balance at the interface is

$\begin{array}{l} \left( {{{{\mathbf{\tau '}}}_\ell } - {{{\mathbf{\tau '}}}_v}} \right) \cdot {\mathbf{n}} + \sigma (T)\left( {\frac{1}{{{R_I}}} + \frac{1}{{{R_{II}}}}} \right){\mathbf{n}} - {p_d}{\mathbf{n}} \\ - \left( {\frac{{d\sigma }}{{dT}}} \right)(\nabla {T_\delta } \cdot {\mathbf{t}}){\mathbf{t}} = {{\dot m''}_\delta }({{\mathbf{V}}_\ell } - {{\mathbf{V}}_v}) \\ \end{array} \qquad \qquad(1)$

On the left-hand side, the first term is the stress tensor, the second term is the capillary pressure, the third term is the disjoining pressure, and the fourth term is the Marangoni stress (Faghri and Zhang 2006). The right-hand side is the momentum transfer due to inertia. In this equation, the tangential direction, t, can either be t1 or t2. The stress tensor is:

$\tau ' = - p{\mathbf{I}} + 2\mu {\mathbf{D}} - \frac{2}{3}\mu \left( {\nabla \cdot {\mathbf{V}}} \right){\mathbf{I}} \qquad \qquad(2)$

The deformation tensor can be written for a reference frame that is adjusted to the interface:

${\mathbf{D}} = \frac{1}{2}\left[ {\nabla {\mathbf{V}} + {{\left( {\nabla {\mathbf{V}}} \right)}^T}} \right] = \left[ {\begin{array}{*{20}{c}} {\frac{{\partial {V_{\mathbf{n}}}}}{{\partial {x_{\mathbf{n}}}}}} & {\frac{1}{2}\left( {\frac{{\partial {V_{\mathbf{n}}}}}{{\partial {x_{{{\mathbf{t}}_1}}}}} + \frac{{\partial {V_{{{\mathbf{t}}_1}}}}}{{\partial {x_{\mathbf{n}}}}}} \right)} & {\frac{1}{2}\left( {\frac{{\partial {V_{\mathbf{n}}}}}{{\partial {x_{{{\mathbf{t}}_2}}}}} + \frac{{\partial {V_{{{\mathbf{t}}_2}}}}}{{\partial {x_{\mathbf{n}}}}}} \right)} \\ {\frac{1}{2}\left( {\frac{{\partial {V_{\mathbf{n}}}}}{{\partial {x_{{{\mathbf{t}}_1}}}}} + \frac{{\partial {V_{{{\mathbf{t}}_1}}}}}{{\partial {x_{\mathbf{n}}}}}} \right)} & {\frac{{\partial {V_{{{\mathbf{t}}_1}}}}}{{\partial {x_{{{\mathbf{t}}_1}}}}}} & {\frac{1}{2}\left( {\frac{{\partial {V_{{{\mathbf{t}}_1}}}}}{{\partial {x_{{{\mathbf{t}}_2}}}}} + \frac{{\partial {V_{{{\mathbf{t}}_2}}}}}{{\partial {x_{{{\mathbf{t}}_1}}}}}} \right)} \\ {\frac{1}{2}\left( {\frac{{\partial {V_{\mathbf{n}}}}}{{\partial {x_{{{\mathbf{t}}_2}}}}} + \frac{{\partial {V_{{{\mathbf{t}}_2}}}}}{{\partial {x_{\mathbf{n}}}}}} \right)} & {\frac{1}{2}\left( {\frac{{\partial {V_{{{\mathbf{t}}_1}}}}}{{\partial {x_{{{\mathbf{t}}_2}}}}} + \frac{{\partial {V_{{{\mathbf{t}}_2}}}}}{{\partial {x_{{{\mathbf{t}}_1}}}}}} \right)} & {\frac{{\partial {V_{{{\mathbf{t}}_2}}}}}{{\partial {x_{{{\mathbf{t}}_2}}}}}} \\ \end{array}} \right] \qquad \qquad(3)$

The normal direction of the interface is [1 0 0], the first tangential direction is [0 1 0] and the second tangential direction is [0 0 1]. Therefore,

$\begin{array}{l} \tau ' \cdot {\mathbf{n}} = \left[ { - \begin{array}{*{20}{c}} p & 0 & 0 \\ \end{array}} \right] + \\ 2\mu \left[ {\begin{array}{*{20}{c}} {\frac{{\partial {V_{\mathbf{n}}}}}{{\partial {x_{\mathbf{n}}}}}} & {\frac{1}{2}\left( {\frac{{\partial {V_{\mathbf{n}}}}}{{\partial {x_{{{\mathbf{t}}_1}}}}} + \frac{{\partial {V_{{{\mathbf{t}}_1}}}}}{{\partial {x_{\mathbf{n}}}}}} \right)} & {\frac{1}{2}\left( {\frac{{\partial {V_{\mathbf{n}}}}}{{\partial {x_{{{\mathbf{t}}_2}}}}} + \frac{{\partial {V_{{{\mathbf{t}}_2}}}}}{{\partial {x_{\mathbf{n}}}}}} \right)} \\ \end{array}} \right] - \frac{2}{3}\mu \left[ {\begin{array}{*{20}{c}} {\nabla \cdot {\mathbf{V}}} & 0 & 0 \\ \end{array}} \right] \\ \end{array} \qquad \qquad(4)$

This can be reduced to the three components to obtain:

$\tau ' \cdot {\mathbf{n}} \cdot {\mathbf{n}} = - p + 2\mu \frac{{\partial {V_{\mathbf{n}}}}}{{\partial {x_{\mathbf{n}}}}} - \frac{2}{3}\mu \nabla \cdot {\mathbf{V}} = - p + \frac{4}{3}\mu \frac{{\partial {V_{\mathbf{n}}}}}{{\partial {x_{\mathbf{n}}}}} - \frac{2}{3}\mu \left( {\frac{{\partial {V_{{{\mathbf{t}}_1}}}}}{{\partial {x_{{{\mathbf{t}}_1}}}}} + \frac{{\partial {V_{{{\mathbf{t}}_2}}}}}{{\partial {x_{{{\mathbf{t}}_2}}}}}} \right) \qquad \qquad(5)$
$\tau ' \cdot {\mathbf{n}} \cdot {{\mathbf{t}}_1} = \mu \left( {\frac{{\partial {V_{\mathbf{n}}}}}{{\partial {x_{{{\mathbf{t}}_1}}}}} + \frac{{\partial {V_{{{\mathbf{t}}_1}}}}}{{\partial {x_{\mathbf{n}}}}}} \right) \qquad \qquad(6)$
$\tau ' \cdot {\mathbf{n}} \cdot {{\mathbf{t}}_2} = \mu \left( {\frac{{\partial {V_{\mathbf{n}}}}}{{\partial {x_{{{\mathbf{t}}_2}}}}} + \frac{{\partial {V_{{{\mathbf{t}}_2}}}}}{{\partial {x_{\mathbf{n}}}}}} \right) \qquad \qquad(7)$

The momentum equation balance at the interface is then broken into its three components, as follows:

Normal Direction

$\begin{array}{l} - {p_\ell } + {p_v} + \frac{4}{3}\left( {{\mu _\ell }\frac{{\partial {V_{\ell ,{\mathbf{n}}}}}}{{\partial {x_{\ell ,{\mathbf{n}}}}}} - {\mu _v}\frac{{\partial {V_{v,{\mathbf{n}}}}}}{{\partial {x_{v,{\mathbf{n}}}}}}} \right) \\ - \frac{2}{3}\left[ {{\mu _\ell }\left( {\frac{{\partial {V_{\ell ,{{\mathbf{t}}_1}}}}}{{\partial {x_{{{\mathbf{t}}_1}}}}} + \frac{{\partial {V_{\ell ,{{\mathbf{t}}_2}}}}}{{\partial {x_{{{\mathbf{t}}_2}}}}}} \right) - {\mu _v}\left( {\frac{{\partial {V_{v,{{\mathbf{t}}_1}}}}}{{\partial {x_{{{\mathbf{t}}_1}}}}} + \frac{{\partial {V_{v,{{\mathbf{t}}_2}}}}}{{\partial {x_{{{\mathbf{t}}_2}}}}}} \right)} \right] \\ + \sigma \left( {\frac{1}{{{R_I}}} + \frac{1}{{{R_{II}}}}} \right) - {p_d} = {{\dot m''}_\delta }\left( {{V_{\ell ,{\mathbf{n}}}} - {V_{v,{\mathbf{n}}}}} \right) \\ \end{array} \qquad \qquad(8)$

Tangential 1

${\mu _\ell }\left( {\frac{{\partial {V_{\ell ,{\mathbf{n}}}}}}{{\partial {x_{{{\mathbf{t}}_1}}}}} + \frac{{\partial {V_{\ell ,{{\mathbf{t}}_1}}}}}{{\partial {x_{\mathbf{n}}}}}} \right) - {\mu _v}\left( {\frac{{\partial {V_{v,{\mathbf{n}}}}}}{{\partial {x_{{{\mathbf{t}}_1}}}}} + \frac{{\partial {V_{v,{{\mathbf{t}}_1}}}}}{{\partial {x_{\mathbf{n}}}}}} \right) - \left( {\frac{{d\sigma }}{{dT}}} \right)\left( {\frac{{\partial {T_\delta }}}{{\partial {x_{{{\mathbf{t}}_1}}}}}} \right) = {\dot m''_\delta }\left( {{V_{\ell ,{{\mathbf{t}}_1}}} - {V_{v,{{\mathbf{t}}_1}}}} \right) \qquad \qquad(9)$

Tangential 2

${\mu _\ell }\left( {\frac{{\partial {V_{\ell ,{\mathbf{n}}}}}}{{\partial {x_{{{\mathbf{t}}_2}}}}} + \frac{{\partial {V_{\ell ,{{\mathbf{t}}_2}}}}}{{\partial {x_{\mathbf{n}}}}}} \right) - {\mu _v}\left( {\frac{{\partial {V_{v,{\mathbf{n}}}}}}{{\partial {x_{{{\mathbf{t}}_2}}}}} + \frac{{\partial {V_{v,{{\mathbf{t}}_2}}}}}{{\partial {x_{\mathbf{n}}}}}} \right) - \left( {\frac{{d\sigma }}{{dT}}} \right)\left( {\frac{{\partial {T_\delta }}}{{\partial {x_{{{\mathbf{t}}_2}}}}}} \right) = {\dot m''_\delta }\left( {{V_{\ell ,{{\mathbf{t}}_2}}} - {V_{v,{{\mathbf{t}}_2}}}} \right) \qquad \qquad(10)$

The non-slip condition at the liquid-vapor interface requires that ${V_{\ell ,{{\mathbf{t}}_1}}} = {V_{v,{{\mathbf{t}}_1}}}$ and ${V_{\ell ,{{\mathbf{t}}_2}}} = {V_{v,{{\mathbf{t}}_2}}}.$ The momentum balance at the tangential directions becomes

${\mu _\ell }\left( {\frac{{\partial {V_{\ell ,{\mathbf{n}}}}}}{{\partial {x_{{{\mathbf{t}}_1}}}}} + \frac{{\partial {V_{\ell ,{{\mathbf{t}}_1}}}}}{{\partial {x_{\mathbf{n}}}}}} \right) = {\mu _v}\left( {\frac{{\partial {V_{v,{\mathbf{n}}}}}}{{\partial {x_{{{\mathbf{t}}_1}}}}} + \frac{{\partial {V_{v,{{\mathbf{t}}_1}}}}}{{\partial {x_{\mathbf{n}}}}}} \right) + \left( {\frac{{d\sigma }}{{dT}}} \right)\left( {\frac{{\partial {T_\delta }}}{{\partial {x_{{{\mathbf{t}}_1}}}}}} \right) \qquad \qquad(11)$
${\mu _\ell }\left( {\frac{{\partial {V_{\ell ,{\mathbf{n}}}}}}{{\partial {x_{{{\mathbf{t}}_2}}}}} + \frac{{\partial {V_{\ell ,{{\mathbf{t}}_2}}}}}{{\partial {x_{\mathbf{n}}}}}} \right) = {\mu _v}\left( {\frac{{\partial {V_{v,{\mathbf{n}}}}}}{{\partial {x_{{{\mathbf{t}}_2}}}}} + \frac{{\partial {V_{v,{{\mathbf{t}}_2}}}}}{{\partial {x_{\mathbf{n}}}}}} \right) + \left( {\frac{{d\sigma }}{{dT}}} \right)\left( {\frac{{\partial {T_\delta }}}{{\partial {x_{{{\mathbf{t}}_2}}}}}} \right) \qquad \qquad(12)$

For most applications, the evaporation or condensation rate –${\dot m''_\delta }$– is not very high; therefore, it can be assumed that ${\dot m''_\delta }({V_{\ell}} - {V_v}) = 0$. If the liquid and vapor phases are further assumed to be inviscid (${{\tau}_{\ell}} = {{\tau}_v} = 0$), the momentum equation at the interface can be reduced to

${p_v} - {p_\ell } = \sigma (T)\left( {\frac{1}{{{R_I}}} + \frac{1}{{{R_{II}}}}} \right) - {p_d} \qquad \qquad(13)$

## References

Faghri, A., and Zhang, Y., 2006, Transport Phenomena in Multiphase Systems, Elsevier, Burlington, MA
Faghri, A., Zhang, Y., and Howell, J. R., 2010, Advanced Heat and Mass Transfer, Global Digital Press, Columbia, MO.


text:
# Dimensional regularization - Expansion of powers of $\epsilon$ turns into logarithms

Looking into Schwartz's book on QFT at the appendices, it seems that when doing a dimensional regularization, one expands around $$\epsilon=0$$ and usually obtains $$x^\epsilon=\log x+O(\epsilon),$$ or in an example $$\bigg(\frac{4\pi\mu^2}{\Delta}\bigg)^\epsilon=\log4\pi+\log\mu^2-log\Delta+O(\epsilon)=\log\bigg(\frac{4\pi\mu^2}{\Delta}\bigg)+O(\epsilon)$$ How is that?

I was looking around for the answer in the book and it seems to not be given anywhere as to why. Note: I'm not exactly sure if there are other terms of order $$\epsilon$$ as there are on the $$\Gamma(\epsilon)$$ and the $$log$$'s terms may have been mixed with the $$\Gamma(\epsilon)$$ so I just added them here just in case.

Hint: $$x^\epsilon = e^{\log x^\epsilon} = e^{\epsilon \log x},$$ then proceed in expansion of the exponential for small $$\epsilon$$.

Note the expressions in OP are not quite correct.

The usual way to do it is to write the quantity like $$x^\epsilon$$. Then use the relation that

$$x^\epsilon = e^{\epsilon \ln(x)}$$

and then use the usual exponential expansion so that

$$e^{\epsilon \ln(x)} = 1 + \epsilon\ln(x) + \mathcal{O}(\epsilon^2)$$

• Where did the factor of $\epsilon$ go though? Dec 28 '18 at 6:45
• What do you mean Dec 28 '18 at 6:51
• like $x^\epsilon=1+\epsilon\log x$ to first order, there is a factor of $\epsilon$ in the log which makes sense, but then in Schwarz's (or any other books featuring regularization) there isn't a factor of $\epsilon$ in the log. Dec 28 '18 at 7:16
• That's because they usually expand, not just what you wrote, but the product of other factors multiplying what you wrote (all of which have $\epsilon$s). The expansion I've written is correct. Write out the full expression and expand each of them in $\epsilon$. As mentioned in @CAF's answer the original expression you wrote down isn't correct. There will be powers of $\frac{1}{\epsilon}$ in your expansion as well and so you'll see the cancellations you're looking for. Dec 28 '18 at 7:20


text:
# Scale to fixed width of tikzpicture [duplicate]

After looking for something like that here and searching the site. I haven't found something that works (may be I skipped something important).

I would like an automated way of telling tikz the final size of the tikzpicture.

I want to draw something and I want tikz to calculate automatically the scale to show me the maximum possible. Something like \begin{tikzpicture}[scale to width = \textwidth] will scale the figure so the final tikzpicture has a width of \textwidth. The cool thing would be to make also something like scale to height = …, with both forms keeping the original ratio of the tikzpicture. But if both are issued at the same time there should be a way of having the final size fixed.

I would like this to work within tikzpicture (and not with scalebox or resizebox) so that the resulting image has the correct font size and line width.

Example:

\documentclass{scrartcl}
\usepackage{tikz}
…% Some magic code
\begin{document}

\begin{tikzpicture}
\draw (0,0) rectangle (1,1);
\draw (0.5,0.5) node {Center};
\end{tikzpicture}% This should be a square of 1cm x 1cm.

\begin{tikzpicture}[scale to with = 10cm]
\draw (0,0) rectangle (1,1);
\draw (0.5,0.5) node {Center};
\end{tikzpicture}% This should be a square of 10cm x 10cm with the word in correct size

\begin{tikzpicture}[scale to height = 8cm]
\draw (0,0) rectangle (1,1);
\draw (0.5,0.5) node {Center};
\end{tikzpicture}% This should be a square of 8cm x 8cm with the word in a correct size

\begin{tikzpicture}[scale to with = 10cm, scale to height = 6cm]
\draw (0,0) rectangle (1,1);
\draw (0.5,0.5) node {Center};
\end{tikzpicture}% This should be a rectangle of 10cm x 6cm with the word in a correct size/shape

\end{document}

-

## marked as duplicate by Jake, Martin Schröder, Manuel, Benedikt Bauer, JesseFeb 20 '14 at 11:28

This is where the tikzscale package comes in handy. See (How to scale tikz drawing to paperwidth?). –  Jake Feb 20 '14 at 10:51
I saw it in the tags. But that's NOT handy (in my opinion). Should I move all my figures to external .tikz files and then use \includegraphics[width=10cm]{figure.tikz}? I think that's far from handy. It would be much better to have that option inside the tikzpicture options. –  Manuel Feb 20 '14 at 10:54
@UlrikeFischer Okey. Fair enough. Then this question is can be closed (as a duplicate, may be). EDIT Isn't a possible way of having an option in tikzpicture which does exactly that: process the complete image to get the size, then calculate the scale factor and then reprocess it? –  Manuel Feb 20 '14 at 11:12
@Manuel: You can define a new environment manuelstikzpicture that wraps around the process described in Ulrike's answer (or you could redefine tikzpicture to do the same). –  Jake Feb 20 '14 at 11:31


text:
# Independent Pseudo Random Generators

Is it sufficient to seed a pseudo-random number generator (PRNG) with two different values to be able to claim that we now have two independent PRNGs? Or is it that we have to use two functionally different generators for that?

• I guess this will depend on what you mean with "independent". Of course with a secure PRNG and two different seeds they would run independently. However, you might still have to take into account that you can reach a cycle. Usually that would be computationally impossible because the size of the cycles are huge due to the size of the state - but that doesn't make it theoretically independent. And when it comes to functional different: how much different do they need to be? Just XOR'ing all the output bits with 1 doesn't seem enough to me. – Maarten Bodewes Jan 21 '18 at 16:45

The standard crypto engineering approximation of a pseudorandom generator (PRG) $f\colon \{0,1\}^k \to \{0,1\}^n$ for $k \lll n$ is that if you pick two independent uniform random keys $K_0$ and $K_1$, then the outputs $f(K_0)$ and $f(K_1)$ are independent uniform random bit strings too.

This applies to, e.g., the AES-CTR pseudorandom generator $$f(K) = \operatorname{AES256}_K(0) \mathbin\Vert \operatorname{AES256}_K(1) \mathbin\Vert \cdots,$$ provided $n \lll 2^{72}$ to avoid birthday distinguishers. However, it is not the case that simply picking two distinct keys $K_0$ and $K_1$ gives an approximation to two independent uniform random $n$-bit strings $f(K_0)$ and $f(K_1)$ at the expected security level, first because if the adversary knows the keys $K_0$ and $K_1$ then there's nothing random to the adversary, but also because even if the two keys merely have a relation known to the adversary, then the standard AES-256 related-key attacks of Biryukov and Khovratovich may apply to enable an attacker to distinguish $f(K_0)$ and $f(K_1)$ from two independent uniform random $n$-bit strings faster than generic attacks.

On the other hand, you can often use a pseudorandom function family (PRF) instead of a pseudorandom generator to get multiple independent strings out of a single key. For example, you can split the input to AES256 in the above construction into a 64-bit string index $i$ and a 64-bit block counter, and define $$F(K, i) = \operatorname{AES256}_K(i \mathbin\Vert 0) \mathbin\Vert \operatorname{AES256}_K(i \mathbin\Vert 1) \mathbin\Vert \cdots.$$ Then, as long as the total volume of data you generate from $F$ with a single key is much less than $2^{72}$ bits, $F(K, 0)$ and $F(K, 1)$ are approximately independent uniform random bit strings, as long as $K$ is a uniform random $k$-bit string not used for anything except an $F$ key.

All this depends on $f$ or $F$ actually being cryptographically secure, of course. If you use a linear congruential generator, or the Mersenne twister, you're dead in the water. But standard PRFs like ChaCha or KMAC, or PRPs (pseudorandom permutation families) like AES, are conjectured to be secure for the above ‘CTR mode’ construction of $f$ and $F$.

Obviously, in a strict probabilistic interpretation, it is not possible to get two independent uniform random strings of $n > k$ bits as a deterministic function of a uniform random string of $k$ bits. To formalize this (in the concrete setting), we quantify the adversarial advantage of a random algorithm $A\colon \{0,1\}^n \to \{0,1\}$ that tries to tell whether its input was drawn from the output of $f$ or not, defined as $$\operatorname{Adv}^{\operatorname{PRG}}_f(A) = |\Pr[A(f(K)) = 1] - \Pr[A(U) = 1]|,$$ where $K$ is a uniform random $k$-bit string and $U$ is a uniform random $n$-bit string. We then try to set a very small upper bound on $\operatorname{Adv}^{\operatorname{PRG}}_f(A)$ for all $A$, either by conjecturing it of $f$ as a primitive and enticing a lot of cryptanalysts to spend effort on it, or by building $f$ out of a primitive that cryptanalysts have already spent effort on and showing how a distinguisher for $f$ as a PRG can be used to construct an efficient algorithm to break the primitive.

(To extend this to the asymptotic setting where complexity theorists like to hang out, we consider a family of functions $f_k\colon \{0,1\}^k \to \{0,1\}^{p(k)}$ for some polynomial $p$, and try to show that $\operatorname{Adv}^{\operatorname{PRG}}_{f_k}(A) < \epsilon(k)$ for some negligible function $\epsilon$.)

If you are using a cryptographicly secure PRNG with a sufficiently large seed. Then it is expected to be infeasible to detect a relationship between the random stream output. If you find two carefully crafted seeds where the output streams then have some clear relationship it would be considered a (mild) weakness in the PRNG, and much more so with random seeds.

• Is there a criteria for "sufficiently large" and "carefully crafted" seeds for a cryptographically secure PRNG to be producing samples that are independent across the two streams? – robinw Jan 21 '18 at 4:46
• Large enough for it to be infeasible to brute force. If the inner state is large enough we can ignore birthday paradox and depending on strength of attacker I would recommend at least 100 bits. Possibly more for a nation-state actor brute-forcing your random seed. – Meir Maor Jan 21 '18 at 4:53
• By carefully crafted, I said it is possible a PRNG could have a weakness where related weak seeds produce related streams but this would be weakness requiring carefull cryptanalysis to find. I don't actually know of such an example. – Meir Maor Jan 21 '18 at 4:55

Yes this is done all the time with one generator. After all there are only a few good /recommended generators out there for cryptographic purposes.

There's a bioinfomatics paper that might be of interest. Good Practice in (Pseudo) Random Number Generation for Bioinformatics Applications suggests some values to the maximum run length of a PRNG. Not strictly crypto, but I've not seen anything else. Again not crypto, but there might be more guidance at CERN regarding their generators. There's a lot of stuff on that site.

In summary, it says that Knuth recommends a max. output of states /1000. However there is also a much more conservative limit of (states)^(1/3). Some some cryptographers have suggested using half of the bits of state as long as that is still of the order of 128 bits to prevent a brute force recovery of the seed. Although that seems to be creeping up to 256 bits, or even recommended by NIST these days.

Using the most conservative estimates from above (cube root of state), we get maximum runs of /dev/random's (ChaCha20) output of ~10^51 and CryptGenRandom's (RC4 + SHA1) output of ~10^205.

In conclusion there doesn't seem to be a firm best practice. This question seems to be a form of how random is random? That's always going to be difficult to answer.

• The maximum run length shouldn't apply to ChaCha20 since it uses a PRF and not a PRP. – forest Jan 8 '19 at 9:25


text:
# Calculus Course/Differentiation

## DerivativeEdit

A derivative is a mathematical operation to find the rate of change of a function.

## FormulaEdit

For a non linear function ${\displaystyle f(x)=y}$  . The rate of change of ${\displaystyle f(x)}$  correspond to change of ${\displaystyle x}$  is equal to the ratio of change in ${\displaystyle f(x)}$  over change in ${\displaystyle x}$

${\displaystyle {\frac {\Delta f(x)}{\Delta x}}={\frac {\Delta y}{\Delta x}}}$

Then the Derivative of the function is defined as

${\displaystyle {\frac {d}{dx}}f(x)=\lim _{\Delta x\to 0}\sum {\frac {\Delta f(x)}{\Delta x}}=\lim _{\Delta x\to 0}\sum {\frac {y}{x}}}$

but the derivative must exist uniquely at the point x. Seemingly well-behaved functions might not have derivatives at certain points. As examples, ${\displaystyle f(x)={\frac {1}{x}}}$  has no derivative at ${\displaystyle x=0}$  ; ${\displaystyle F(x)=|x|}$  has two possible results at ${\displaystyle x=0}$  (-1 for any value for which ${\displaystyle x<0}$  and 1 for any value for which ${\displaystyle x>0}$ ) On the other side, a function might have no value at ${\displaystyle x}$  but a derivative of ${\displaystyle x}$  , for example ${\displaystyle f(x)={\frac {x}{x}}}$  at ${\displaystyle x=0}$  . The function is undefined at ${\displaystyle x=0}$  , but the derivative is 0 at ${\displaystyle x=0}$  as for any other value of ${\displaystyle x}$  .

Practically all rules result, directly or indirectly, from a generalized treatment of the function.

## Table of DerivativeEdit

### General RulesEdit

${\displaystyle {\frac {d}{dx}}(f+g)={\frac {df}{dx}}+{\frac {dg}{dx}}}$

${\displaystyle {\frac {d}{dx}}(c\cdot f)=c\cdot {\frac {df}{dx}}}$

${\displaystyle {\frac {d}{dx}}(f\cdot g)=f\cdot {\frac {dg}{dx}}+g\cdot {\frac {df}{dx}}}$

${\displaystyle {\frac {d}{dx}}\left({\frac {f}{g}}\right)={\frac {g\cdot {\frac {df}{dx}}-f\cdot {\frac {dg}{dx}}}{g^{2}}}}$

### Powers and PolynomialsEdit

${\displaystyle {\frac {d}{dx}}(c)=0}$

${\displaystyle {\frac {d}{dx}}x=1}$

${\displaystyle {\frac {d}{dx}}x^{n}=nx^{n-1}}$

${\displaystyle {\frac {d}{dx}}{\sqrt {x}}={\frac {1}{2{\sqrt {x}}}}}$

${\displaystyle {\frac {d}{dx}}{\frac {1}{x}}=-{\frac {1}{x^{2}}}}$

${\displaystyle {{\frac {d}{dx}}(c_{n}x^{n}+c_{n-1}x^{n-1}+c_{n-2}x^{n-2}+\cdots +c_{2}x^{2}+c_{1}x+c_{0})=nc_{n}x^{n-1}+(n-1)c_{n-1}x^{n-2}+(n-2)c_{n-2}x^{n-3}+\cdots +2c_{2}x+c_{1}}}$

### Trigonometric FunctionsEdit

${\displaystyle {\frac {d}{dx}}\sin(x)=\cos(x)}$

${\displaystyle {\frac {d}{dx}}\cos(x)=-\sin(x)}$

${\displaystyle {\frac {d}{dx}}\tan(x)=\sec ^{2}(x)}$

${\displaystyle {\frac {d}{dx}}\cot(x)=-\csc ^{2}(x)}$

${\displaystyle {\frac {d}{dx}}\sec(x)=\sec(x)\tan(x)}$

${\displaystyle {\frac {d}{dx}}\csc(x)=-\csc(x)\cot(x)}$

### Exponential and Logarithmic FunctionsEdit

${\displaystyle {\frac {d}{dx}}e^{x}=e^{x}}$

${\displaystyle {\frac {d}{dx}}a^{x}=a^{x}\ln(a)\qquad {\mbox{if }}a>0}$

${\displaystyle {\frac {d}{dx}}\ln(x)={\frac {1}{x}}}$

${\displaystyle {\frac {d}{dx}}\log _{a}(x)={\frac {1}{\ln(a)x}}\qquad {\mbox{if }}a>0,a\neq 1}$

${\displaystyle {\frac {d}{dx}}(f^{g})={\frac {d}{dx}}\left(e^{g\ln(f)}\right)=f^{g}\left({\frac {df}{dx}}\cdot {\frac {g}{f}}+{\frac {dg}{dx}}\cdot \ln(f)\right),\qquad f>0}$

${\displaystyle {\frac {d}{dx}}(c^{f})={\frac {d}{dx}}\left(e^{f\ln(c)}\right)={\frac {df}{dx}}\cdot c^{f}\ln(c)}$

### Inverse Trigonometric FunctionsEdit

${\displaystyle {\frac {d}{dx}}\arcsin(x)={\frac {1}{\sqrt {1-x^{2}}}}}$

${\displaystyle {\frac {d}{dx}}\arccos(x)=-{\frac {1}{\sqrt {1-x^{2}}}}}$

${\displaystyle {\frac {d}{dx}}\arctan(x)={\frac {1}{1+x^{2}}}}$

${\displaystyle {\frac {d}{dx}}\operatorname {arcsec}(x)={\frac {1}{|x|{\sqrt {x^{2}-1}}}}}$

${\displaystyle {\frac {d}{dx}}\operatorname {arccot}(x)=-{\frac {1}{1+x^{2}}}}$

${\displaystyle {\frac {d}{dx}}\operatorname {arccsc}(x)=-{\frac {1}{|x|{\sqrt {x^{2}-1}}}}}$

### Hyperbolic and Inverse Hyperbolic FunctionsEdit

${\displaystyle {\frac {d}{dx}}\sinh(x)=\cosh(x)}$
${\displaystyle {\frac {d}{dx}}\cosh(x)=\sinh(x)}$
${\displaystyle {\frac {d}{dx}}\tanh(x)={\rm {sech}}^{2}(x)}$
${\displaystyle {\frac {d}{dx}}{\rm {sech}}(x)=-\tanh(x){\rm {sech}}(x)}$
${\displaystyle {\frac {d}{dx}}\coth(x)=-{\rm {csch}}^{2}(x)}$
${\displaystyle {\frac {d}{dx}}{\rm {csch}}(x)=-\coth(x){\rm {csch}}(x)}$
${\displaystyle {\frac {d}{dx}}{\rm {arcsinh}}(x)={\frac {1}{\sqrt {x^{2}+1}}}}$
${\displaystyle {\frac {d}{dx}}{\rm {arccosh}}(x)=-{\frac {1}{\sqrt {x^{2}-1}}}}$
${\displaystyle {\frac {d}{dx}}{\rm {arctanh}}(x)={\frac {1}{1-x^{2}}}}$
${\displaystyle {\frac {d}{dx}}{\rm {arcsech}}(x)={\frac {1}{x{\sqrt {1-x^{2}}}}}}$
${\displaystyle {\frac {d}{dx}}{\rm {arccoth}}(x)=-{\frac {1}{1-x^{2}}}}$
${\displaystyle {\frac {d}{dx}}{\rm {arccsch}}(x)=-{\frac {1}{|x|{\sqrt {1+x^{2}}}}}}$


text:
CryptoDB

Paper: On the Security of Iterated Hashing based on Forgery-resistant Compression Functions

Authors: Charles Bouillaguet Orr Dunkelman Pierre-Alain Fouque Antoine Joux URL: http://eprint.iacr.org/2009/077 Search ePrint Search Google In this paper we re-examine the security notions suggested for hash functions, with an emphasis on the delicate notion of second preimage resistance. We start by showing that, in the random oracle model, both Merkle-Damgaard and HAIFA achieve second preimage resistance beyond the birthday bound, and actually up to the level of known generic attacks, hence demonstrating the optimality of HAIFA in this respect. We then try to distill a more elementary requirement out of the compression function to get some insight on the properties it should have to guarantee the second preimage resistance of its iteration. We show that if the (keyed) compression function is a secure FIL-MAC then the Merkle-Damgaard mode of iteration (or HAIFA) still maintains the same level of second preimage resistance. We conclude by showing that this new'' assumption (or security notion) implies the recently introduced Preimage-Awareness while ensuring all other classical security notions for hash functions.
BibTeX
@misc{eprint-2009-18279,
title={On the Security of Iterated Hashing based on Forgery-resistant Compression Functions},
booktitle={IACR Eprint archive},
keywords={foundations /},
url={http://eprint.iacr.org/2009/077},
note={ charles.bouillaguet@ens.fr 14291 received 16 Feb 2009},
author={Charles Bouillaguet and Orr Dunkelman and Pierre-Alain Fouque and Antoine Joux},
year=2009
}


text:
# naginterfaces.library.stat.prob_normal_vector¶

naginterfaces.library.stat.prob_normal_vector(tail, x, xmu, xstd)[source]

prob_normal_vector returns a number of one or two tail probabilities for the Normal distribution.

For full information please refer to the NAG Library document for g01sa

https://www.nag.com/numeric/nl/nagdoc_28.4/flhtml/g01/g01saf.html

Parameters
tailstr, length 1, array-like, shape

Indicates which tail the returned probabilities should represent. Letting denote a variate from a standard Normal distribution, and , then for , for :

The lower tail probability is returned, i.e., .

The upper tail probability is returned, i.e., .

The two tail (confidence interval) probability is returned, i.e., .

The two tail (significance level) probability is returned, i.e., .

xfloat, array-like, shape

, the Normal variate values.

xmufloat, array-like, shape

, the means.

xstdfloat, array-like, shape

, the standard deviations.

Returns
pfloat, ndarray, shape

, the probabilities for the Normal distribution.

ivalidint, ndarray, shape

indicates any errors with the input arguments, with

No error.

On entry, invalid value supplied in when calculating .

On entry, .

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

(errno )

On entry, .

Constraint: .

Warns
NagAlgorithmicWarning
(errno )

On entry, at least one value of or was invalid.

Notes

The lower tail probability for the Normal distribution, is defined by:

where

The relationship

is used, where erfc is the complementary error function, and is computed using specfun.erfc_real.

When the two tail confidence probability is required the relationship

is used, where erf is the error function, and is computed using specfun.erf_real.

The input arrays to this function are designed to allow maximum flexibility in the supply of vector arguments by re-using elements of any arrays that are shorter than the total number of evaluations required. See the G01 Introduction for further information.

References

NIST Digital Library of Mathematical Functions

Hastings, N A J and Peacock, J B, 1975, Statistical Distributions, Butterworth


text:
# Sql-server – Database Design for a Graph (Network Topology)

database-designsql server

Is there a recommended pattern for modeling a graph in a relational database?

My presumption is that you'd have the following three tables:

Graphs
------
GraphID, PK
GraphName

Each record in the Graphs table represents a single graph you are modeling.

Nodes
-----
NodeID, PK
GraphID, FK
NodeName, string
...

Each record in the Nodes table represents a node in GraphID, specifying attributes specific to that node.

Edges
-----
EdgeID, PK
GraphID, FK
FromNodeID, FK
ToNodeID, FK
EdgeName, string
...

Each record in the Edges table represents an edge in GraphID, specifying the Nodes it connects and the attributes of an edge (name, distance, etc.).

What I'm having a hard time wrapping my head around is what if there are different types of nodes, where each type of a node has some attributes in common (say 5 or so), but has many unique attributes (say 10-30)?

For simplicity's sake, imagine there are two types of nodes to capture: A and B. How do I model this? I've seen one option being to have a "general" Nodes table:

Nodes
-----
NodeID, PK
GraphID, FK
NodeName, string
AnotherSharedAttribute, string
...

And then a detailed table for node type A and node type B:

NodesA
------
NodeID, PK
UniqueToA1, string
UniqueToA2, string
...

NodesB
------
NodeID, PK
UniqueToB1, string
UniqueToB2, string
...

Am I understanding this approach correctly? Because what flummoxes me is how do I query this efficiently? It seems to me that to determine the attributes for a particular node, I have to check all possible node type tables (NodesA and NodesB in this case) for a matching NodeID. This might not be a big deal with just two different types of nodes, but in my project there are ~30 different types of nodes and 5 different types of edges.

Thanks

There is no great way for modeling a graph in a relational database. They are two different data models. One says data "is really" sets of tuples. The other says it "is really" nodes connected by edges. These are different. Although any real-world scenario can be represented in either model the affordances of each are different. If the use-case is to perform an operation on multiple items that conform to a predicate (e.g. update .. where..) the relational model will, generally speaking, be more convenient. For use-cases involving following connections between items ("people who bought .. also bought ..", "you and Andi have 17 friends in common") the graph model is likely to work better. A relational DBMS makes implementing the former easy and the latter more difficult, and vice versa for a graph DBMS.

There are a few well-trodden relational implementations for the specific sub-set of graphs that are trees.

When implementing a solution in a RDBMS we only have tables to work with. So one has to decide which tables are needed to implement a generalized graph. Are the items of interest in the problem domain simply "things" which can be modeled as a single Node table and all the values of interest in a NodeAttribute table? This is analogous to an EAV, but in a graphy kind of way. Generally this is not useful unless we are concerned purely with the connectivity of nodes.

Usually we want to group things into classes and apply different constraints to each class. We could add a Class attribute to the Node table. This still leaves all the hard work of filtering rows of specific Class, and navigating between classes, to user code.

Relational databases are designed to have one table per class. If we have multiple classes of nodes then each should have its own table. If, as in your question, there are sub-classes of nodes then the problem can be restated as "how to model sub-classes in a relational way?" This is now a problem of table inheritance, about which quite a lot has been written. Some DBMS implement this natively; SQL Server does not.

how do I query this efficiently?

The same way you query any other relational database. Good indexes that support the queries. Understanding the implementation and referencing only those objects required to satisfy the query's needs. If you have 30 types of nodes and 5 types of edges it is unlikely that all will be required in every query.

The discussion above for node tables applies equally for edge tables.

There are hybrid DBMS which allow the representation of data in both graph and relational ways. Starting with 2017 SQL Server introduced graph extensions. Sadly the MATCH clause was little more than syntactic sugar on SQL-89 joins redux. No graph-like affordances were "supported in the first release", though the language was encouraging.

With SQL Server 2019 transitive closure is now supported. One can only hope polymorphism is not far behind.


text:
# Does this loop invariant guarantee that the variable never changes?

Suppose you have some loop and and integer k:

int k = 5;
for (int i = 0 ; i < N; i++)
{
//(*)
//do something
}

The loop invariant at (*) is: $\{ K=k\}$

Does that guarantee that $k$ doesn't change in between iterations? if not, is there any otherway to guarantee that?

• You can indicate that a varaible does not change value by using a constant modifier that many imperative languages come with. If you want to be explicit in your Hoare logic about it, then you can reference the new updated value or the old value and indicate that they are the same. For example, in the Z formalism, you would write k = k' which says updated value k' is identical to original value k. Another example would be k == \old(k) if you were using Frama-C. – Musa Al-hassy Apr 11 '16 at 18:19

The loop invariant doesn't "guarantee" anything. It is a summary of relevant information you know about the state of the program when it reaches that point. If your loop is e.g.:

k = 5;
...
for(int i = 0; i < N; i++) {
/* Invariant: k = 5 */
...
k = 207;
...
frob_very_hard(&k);
...
k *= 3;
...
k = 5;
}

at the marked point k == 5, but not all over the program.

• I see. Is there any invariant I can add to the body of the loop that would hold iff k is not changed in the body of the loop? – Shmoopy Apr 12 '13 at 16:33
• This are comments for the human reader, so you can write the invariants as you wish. But if you care that k does have a specific value at a particular point of the loop, state it that way where it matters. – vonbrand Apr 12 '13 at 16:35
• @Shmoopy Use constants; many languages provide these. – Raphael Apr 12 '13 at 23:05