text:
# A Neighborhood of Infinity

## Saturday, December 05, 2009

### Where do monads come from?

Introduction
Monads play an important part in implementing computational "effects" in Haskell, and yet monads come out of pure mathematics where they are used to describe operations in algebraic structures. What do these two applications have to do with each other? In this post I hope to answer that question and maybe give another view on monads.

> {-# LANGUAGE GADTs #-}

Algebra for Flowcharts
You might not have seen one of these in a long time. A flowchart describing a subroutine:

For now I'm considering flowcharts only with nodes to set or reset just one flag, test the flag, and return values. I'm not allowing any paths to reconverge. So these flowcharts are trees describing the possible paths of control flow.

We can describe such flowcharts with a more compact notation. Use xn to mean:

Think of xn being an variable of unknown value.
Use the + operator to mean tests of the flag. So x+y represents:

Note that this '+' isn't commutative because the left branch will always mean 'no' and the right branch will mean 'yes'.

And we'll use the symbols '0' and '1', applied on the left, to mean these two nodes respectively:

The flowchart above can now be written compactly as 1x3+0(x4+x5). (Note that I'm overloading the notation for addition and multiplication, this isn't intended to be ordinary addition and multiplication of numbers.)

It's clear that the 'return 5' never gets executed. So the above flowchart is equivalent to this one:

The rule describing this simplification can be expressed with our compact notation as the rule:

0(a+b) = 0a
1(a+b) = 1b

So we already have a strong clue that there is a connection between algebra and computation. Here are some more rules that you can check for yourself:

abc = bc (here a and b are each either 0 or 1)

a+(b+c) = a+c = (a+b)+c

a+a = a = 0a+1a

Substitution
Now suppose we wish to extend this subroutine so it does a bit more work. Instead of simply returning n we might want it to set a flag according to whether the previous result is even or odd, and subtract 1 if it is odd. It's a little awkward because I've insisted that these trees don't rejoin so we need to patch the tree in three places using the rule:

Note that the descriptions of the two cases and the n here aren't part of the flowchart, they're part of the language I'm using to talk about flowcharts.

We can do something similar for our algebraic expressions. We can define a mathematical function taking integers to algebraic expressions such that

f(n)
= 0xn if n is even
= 1xn-1 if n is odd

and now define an operation * by

f*u = u with xn replaced by f(n) throughout

Our updated flowchart can now be represented by f*(1x3+0(x4+x5)). Now you might see why I used the weird xn notation. The * operation is ordinary substitution of an expression for a variable that we learn in high school, so I used xn notation to make it clear that xn is a variable. You can think of f as a dictionary saying how the values of the variables are to be expanded.

Let TN be the set of expressions in our algebra where the subscripts of the x's come from the set N. Then we have the functions:

η:N→TN defined by η(n)=xn
and
μ:T(T(N))→T(N) defined by μ(a)=i*a, where i is the identity.

We have a monad. (Exercise: check the monad laws.) Note that this definition isn't specific to our particular algebra. This definition applies to a very broad class of algebraic expression. Monads in mathematics are used to describe substitution of subexpressions into expressions. But I hope you can now see why they have a role to play in computing: the act of substituting an expression for a variable is essentially the same thing as grafting more operations on to the end of our tree of computations.

But if you look at the definitions of typical monads in the Haskell libraries, they don't look much like trees, and the implementation of >>= doesn't look much like grafting trees. The rest of this post will be about working through a specific example to show that it really is about tree grafting after all.

A Type for Expression Trees
We'll need to define a type to represent our algebraic expressions in Haskell. The n is going to be used to label our variables, and s will be explained shortly:

> data Expr s n where

Now we need constructors to represent 0 and 1. We can simplify this by combining them into one constructor and using the type Bool to signify whether it is 0 or 1 that we want. But there's no need to restrict ourselves to Bool so I'll make the code more general and use s instead:

>    Put :: s -> Expr s n -> Expr s n

So 0 is False and 1 is True and Put is our multiplication operator. (Maybe you've already guessed why I called it that.)

The next constructor will be for addition. I'm going to give it the weird name Get. The obvious thing to write would be:
    Get :: Expr s n -> Expr s n -> Expr s n

We could uncurry that instead and use
    Get :: (Expr s n, Expr s n) -> Expr s n

But we know that a pair (a, a) is the same as a function Bool -> a. So I'm going to actually use:

>    Get :: (s -> Expr s n) -> Expr s n

So instead of giving us a binary node in a tree, Get gives us a possible infinite s-ary node. But we'll be working with s = Bool for now.

Now we need variables. We'll just use:

>    Var :: n -> Expr s n

This is a recursive type so we can write a fold for it. If we'd been using generic library we'd get the fold for free but I'm giving it explicitly:

> fold :: (s -> w -> w) -> ((s -> w) -> w) -> (n -> w) -> Expr s n -> w> fold put get var (Put s x) = put s (fold put get var x)> fold put get var (Get c) = get (\s -> fold put get var (c s))> fold put get var (Var n) = var n

We can implement the monad for substitution:

> instance Monad (Expr s) where>   return n = Var n>   x >>= f = fold Put Get f x where

Note how the fold recursively replaces Get with Get, Put with Put and Var n with f n.

By now the game's up. If you read my post from last week then you know that I'm building something like the State monad. But although this monad has a similar interface, internally it's nothing like State. For one thing, Expr is a tree type and internally it could end up with an arbitrarily large number of nodes. How can we extract the familar State monad from this?

Canonical Form
Expressions in various algebraic languages can often be reduced to a canonical form. For example, we have disjunctive normal form for (a fragment of) logic. Expressions in our language above can be reduced to a canonical form. In the language of flowcharts, every one of our flowcharts can be reduced to something of the form:

Algebraically the claim is that any expression reduces to something of the form au+bv. In the general case the items a and b are of type s and u and v can be represented by elements of n. So this is something of type ((s, n), (s, n)). Again we replace the pair by a function to get the type s -> (n, s). So we want a function to convert to canonical form:

> canonical :: Expr s n -> (s -> (n, s))> canonical = fold put get var where

We can get a return box into canonical form like this:

Algebraically this is xn→0xn+1xn and we can implement it as

>   var n = \s -> (n, s)

Now we need to simplify the application of 0 or 1 to something already in canonical form. 0(au+bv) = 0au = au and 1(au+bv) = 1bv = bv. Essentially it just picks the first or second term in the sum according to whether we're multiplying on the left by 0 or 1. But that's exactly what the function type in s -> (n, s) does. So we can just write:

>   put s c = \t -> c s

Now we need to consider sums of two terms in canonical form. We can derive this just by looking at the sum of two sums: (p+q)+(r+s). This is just p+s. We get this by picking the left branch twice or the right branch twice, so we're just applying our function twice to the same thing:

>   get c s = c s s

Comparing with my last post you should see that canonical is what I called an interpreter. So the act of interpreting these tree expressions is one and the same thing as reducing them to a canonical form. This shouldn't be so surprising - executing a functional program is itself a process of reduction to a normal form. Here's an example of using the above reduction to get our flowchart executed:

> test1 =>   Get $\c -> if c> then Put False$>       Get $\d -> if d> then Var 5> else Var 4> else> Put True$>           Var 3> go1 = canonical test1 False

canonical returns a different tree to the original tree. But we can easily map back to trees again:

> inject :: (s -> (n,s)) -> Expr s n> inject f = Get $(\(n, s) -> Put s (Var n)) . f So the composition inject . canonical takes a tree and reduces it to canonical form keeping it as a tree. We can view things like this: the State s n type is just the Expr s n type modulo an equivalence relation. The usual State type is a tree but this fact is obscured because we only work with a representative of each equivalence class, not entire trees. But the Monad instance is still simply tree grafting. We can prove this as follows: > data State s n = State { runState :: s -> (n, s) }> instance Monad (State s) where> return n = State$ canonical $Var n> State f >>= g = State$ canonical $inject f >>= (inject . runState . g) Note how the implementations consist solely of isomorphisms or wrapping/unwrapping. The type State is simply inheriting the Monad instance from the tree type. We can now put Put and Get into a form usable in the monad. Again, we're just wrapping and "canonicalising" near-trivial operations. > get = State$ canonical (Get (\s -> Var s))> put n = State $canonical$ Put n (Var ())> test2 = do>   c <- get>   if c>       then do>           put False>           d <- get>           if d>               then return 5>               else return 4>       else do>           put True>           return 3> go2 = runState test2 False

Summary
Like in the previous post We're starting with signatures for functions. We can form an expression tree type. With the substitution operation this naturally becomes a monad.

We also specified equations for our functions. This leads to the idea of a reduced form for our expression trees. The state monad (and, in fact, most of the standard monads) are examples of reduced forms. If we implement canonical for an algebra, the monad follows for free. More precisely: given a signature and equations, the tree type and monad can be derived automatically. It seems tricky to derive the rules for reducing expressions to canonical form, but once you've done that the monad for the reduced form can be derived automatically.

The act of evaluating a monadic expression is the same as reducing an expression tree to its canonical form.

Various Thoughts
Given two algebraic theories with their own signatures and equations they can be combined together. One obvious way is to simply "freely" throw all of the signatures and equations together. This gives the "sum" of the two theories. If we additionally impose some new equations, a certain type of compatibility condition between the theories, then we get the product. So starting with two theories we get the monads for the two theories and the monad for the sum or product. This might provide an alternative approach to monad transformers for combining effects. (Actually, I'm doubtful of this plan for automatically combining effects because surprising things can happen, but I still think there's something useful to be extracted from the theory.)

Could this form the basis for more monad tutorials? Programmers from imperative, functional and other backgrounds are familiar with the ideas of trees and substitutions.

By the way, it's sometimes useful to implement a monad by building a tree first and then interpreting it separately. That's what I did a few posts ago and I found it much easier than deriving a complete monad in one go.

These trees are related to the diagrams I drew here.

You can repeat much of what I said above with all kinds of algebraic structures. My ICFP talk was on what you can do with the monad that arises from vector spaces and a spent a slide or two on the rules for reduction to canonical form.

An earlier post of mine on substitution.

You can interpret the canonical form of the expressions above as saying that when you have a bunch of switches (in certain types of code) you can replace them with just one. This is reminiscent of the old folk theorem about loops. In fact, the algebra I describe above is a lot like Kleene Algebra with Tests which can be used to prove that result.

This was all motivated by this post on Lambda the Ultimate. Some comments by Derek Elkins (that he's probably long forgotten) and pieces of this by Conor McBride helped me write the code.

I originally planned to say more about forming sums and products of theories but the code is going to need more work...

Update: Following one of the links I gave above I just found Unimo which is closely related.

andre said...

Hello. Great post! Do you have any pointers to books or other literature that does more stuff like what you did here (bridging category theory with computer science applications)?

Thanks.

alpheccar said...

I had attempted to explain similar things on my blog a long long time ago. But, your explanation is much clearer. And, I think mine was a bit wrong. Simplifying too much is an easy way to say incorrect things.

Thanks for taking the time to explain complex things in an easy and correct way. It takes time to write that kind of posts.

Eelis said...

I hope you'll forgive me, but I was somewhat disappointed by this article (though I admittedly didn't get very far).

It started off great with an intriguing title and introduction. But then, totally out of the blue and without any hint of relevance or direction, it goes into a most tedious detailed description of some obscure and boring flowchart language with seemingly arbitrary restrictions and simplification rules and substitution and whatnot.. What a complete turn-off! I lost all interest and never made it to the part about monads.

sigfpe said...

Eelis,

I tried to warn you in the first line of the post! :-)

Will said...

η:N→TN defined by η(n)=xn

Shouldn't this be

η:N→T(N) defined by η(n)=xn

or

η:N→T N defined by η(n)=xn

Anyway, I find most of your stuff interesting. Keep up the good blogging.

sigfpe said...

Will,

It seems to be quite common in category theory to write the application of a functor F to an object X as FX rather than F(X), though I admit I haven't been consistent.

sigfpe said...

Here's the same question (on p.14), and much the same answer, but with more general notation: Monads and Theories.

< Fefo /> said...

Hi ! I'm new at Haskell, why is it necessary to use the GADTs extension for the code in this post??

sigfpe said...

Fefo,

GADTs are used because of the way I've written Put and Get. I could have written them in non-GADT style but I wanted to emphasize that though they are constructors I'm interpreting them as functions that perform actions.


text:
# $\mathbb Q(\sqrt 2,\sqrt 3,\sqrt 5)=\mathbb Q(\sqrt 2+\sqrt 3+\sqrt 5)$ - Generalisation?

Problem:

We know that $\mathbb Q(\sqrt 2,\sqrt 3,\sqrt 5)=\mathbb Q(\sqrt 2+\sqrt 3+\sqrt 5)$. Generalise this fact.

My idea is to use the (proof of the) primitive element theorem. Looking at the equations given, I think I would phrase a generalisation as follows:

Let $a_i,...,a_n\in\mathbb N$ be distinct integers such that gcd$(a_i,a_j)=1$ for all $i\ne j$. Then $$\mathbb Q(\sqrt{a_1},\ldots,\sqrt{a_n})=\mathbb Q(\sqrt{a_1}+\ldots+\sqrt{a_n})$$

Is this generalisation in fact correct, and if so, is it possible to generalise this notion of field extensions even more?

• Why don't you just write down your proof? – Martin Brandenburg Apr 9 '13 at 17:26
• Also this should answer your question: math.stackexchange.com/questions/15074 – Martin Brandenburg Apr 9 '13 at 17:31
• @Martin: the link you give doesn't look like it's related to this question at all. Did you mean some other link? – KCd Apr 20 '13 at 12:24

format: plain


text:
## Monday, February 17, 2014

### The Machine Learning Doghouse

This is a follow-up on the cosplay post. When I did that post I had to use a sub-optimal optimization strategy because Nikos was still refining the publication of a superior strategy. Now he has agreed to do a guest post detailing much better techniques.

## The Machine Learning Doghouse

About a year ago, Sham Kakade was visiting us here in Redmond. He came to give a talk about his cool work on using the method of moments, instead of maximum likelihood, for estimating models such as mixtures of Gaussians and Latent Dirichlet Allocation. Sham has a penchant for simple and robust algorithms. The method of moments is one such example: you don't need to worry about local minima, initialization, and such. Today I'm going to talk about some work that came out of my collaboration with Sham (and Alekh and Le and Greg).

When Sham visited, I was fresh out of grad school, and had mostly dealt with problems in which the examples are representated as high dimensional sparse vectors. At that time, I did not fully appreciate his insistence on what he called “dealing with correlations in the data”. You see, Sham had started exploring a very different set of problems. Data coming from images, audio and video, are dense, and not as high dimensional. Even if the data is nominally high dimensional, the eigenvalues of the data matrix are rapidly decaying, and we can reduce the dimension (say, with randomized SVD/PCA) without hurting the performance. This is simply not true for text problems.

What are the implications of this for learning algorithms? First, theory suggests that for these ill-conditioned problems (online) first order optimizers are going to converge slowly. In practice, things are even worse. These methods do not just require many passes, they simply never get to the test accuracy one can get with second order optimization methods. I did not believe it until I tried it. But second order optimization can be slow, so in this post I'll describe two algorithms that are fast, robust, and have no (optimization related) tuning parameters. I will also touch upon a way to scale up to high dimensional problems. Both algorithms take $O(d^2k)$ per update and their convergence does not depend on the condition number $\kappa$. This is considerably cheaper than the $O(d^3k^3)$ time per update needed for standard second order algorithms. First order algorithms on the other hand, take $O(dk)$ per update but their convergence depends on $\kappa$, so the methods below are preferable when the condition number is large.

We will be concerned with mutliclass (and multilabel) classification as these kinds of problems have special structure we will take advantage of. As a first recipe, suppose we want to fit a multinomial logistic model which posits $\mathbb{E}[y|x]=g(x^\top W^*),$
where $y$ is an indicator vector for one of the $k$ classes, $x \in \mathbb{R}^d$ is our input vector, $W^*$ is a $d\times k$ matrix of parameters to be estimated and $g:\mathbb{R}^k \to \Delta^k$ is the softmax link function mapping a vector of reals to the probability simplex: $g(v) = \left[\begin{array}{c} \frac{\exp(v_1)}{\sum_{j=1}^k\exp(v_j)}\\ \vdots\\ \frac{\exp(v_k)}{\sum_{j=1}^k\exp(v_j)}\\ \end{array} \right].$ The basic idea behind the first algorithm is to come up with a nice proxy for the Hessian of the multinomial logistic loss. This bad boy is $dk \times dk$ and depends the current parameters. Instead, we will use a matrix that does not depend on the parameters and is computationally easy to work with. The bottom line is for multinomial logistic regression we can get away with a block diagonal proxy with $k$ identical blocks on the diagonal each of size $d\times d$. Selecting the blocks to be $\frac{1}{2} X^\top X$ ensures that our updates will never diverge while at the same time avoiding line searches and messing with step sizes. With this matrix as a preconditioner we can go ahead and basically run preconditioned (batch) gradient descent. The script mls.m does this with two (principled) modifications that speed things up a lot. First, we compute the preconditioner on a large enough subsample. The script includes in comments the code for the full preconditioner. The second modification is that we use accelerated gradient descent instead of gradient descent.

Plugging this optimizer in the cosplay script from a few months ago gives a test accuracy of 0.9844 in 9.7 seconds on my machine, which is about 20 times faster and much more accurate than LBFGS.

The second algorithm is even faster and is applicable to multiclass as well as multilabel problems. There is also a downside in that you won't get very accurate probability estimates in the tails: this method is not optimizing cross entropy. The basic idea is we are going to learn the link function, sometimes known as calibration.

For binary classification, the PAV algorithm can learn a link function that minimizes squared error among all monotone functions. Interestingly, the Isotron paper showed that iterating between PAV and least squares learning of the parameters of a linear classifier, leads to the global minimum of this nonconvex problem.

The script cls.m extends these ideas to multiclass classification in the sense that we alternate between fitting the targets and calibration. The notion of calibration used in the implementation is somewhat weak and equivalent to assuming the inverse of the unknown link function can be expressed as a low degree polynomial of the raw predictions. For simplicity's sake, we cut two corners: First we do not force the link to be monotone (though monotonicity is well defined for high dimensions). Second we assume having access to the unlabeled test data at training time (aka the transductive setting). An implementation that does not assume this is more complicated without any additional insights.

Plugging this optimizer in the aforementioned cosplay script I get a test accuracy of 0.9844 in 9.4 seconds on my machine. Again, we are more than 20 times faster than LBFGS, and more accurate. Interestingly, extending this algorithm to work in the multilabel setting is very simple: instead of projecting onto the simplex, we project onto the unit hypercube.

What about high dimensional data? This is the main reason why second order methods are in the doghouse of the machine learning community. A simple and practical solution is to adapt ideas from boosting and coordinate descent methods. We take a batch of features and optimize over them as above with either recipe. Then we take another batch of features and fit the residual. Typically batch sizes can range between 300 and 2000 depending on the problem. Smaller sizes offer the most potential for speed and larger ones offer the most potential for accuracy. The batch size that offers the best running time/accuracy tradeoff is problem dependent. Script mlsinner.m deals with the inner loop of this procedure. It takes two additional parameters that will be provided by the outer loop. It only performs a few iterations trying to find how to extend our initial predictions using a new batch of features so that we approximate the labels better. We also pass in a vector of weights which tell us on which examples should the preconditioner focus on. The outer loop stagewisemls.m simply generates new batches of features, keeps track of the predictions, and updates the importance weights for the preconditioner.

Plugging this optimizer in the cosplay script gives a test accuracy of 0.986 in 67 seconds.

Finally, cosplaydriver.m runs all of the above algorithms on the mnist dataset. Here's how to replicate with octave. (The timings I report above are with MATLAB.)
git clone https://github.com/fest/secondorderdemos.git
cd secondorderdemos
octave -q cosplaydriver.m


text:
## rate constant k

Arrhenius Equation: $\ln k = - \frac{E_{a}}{RT} + \ln A$

Abigail Urbina 1K
Posts: 102
Joined: Thu Jul 27, 2017 3:01 am

### rate constant k

We know that the equilibrium constant K (capital K) is equal to k/k'. However is rate constant k (lowercase k) equal to k'/k? I was looking in the solution manual for question 15.61, and I wasn't entirely sure where ln(k'/k) came from or how exactly you get to that step. Can someone please clarify this question? And perhaps could someone explain how they derived the equation they got in the solutions manual?

Brigitte Phung 1F
Posts: 50
Joined: Thu Jul 27, 2017 3:00 am
Been upvoted: 1 time

### Re: rate constant k

For 15.61, the ln(k'/k) simply comes from the equation, ln(k'/k) = Ea/R * (1/T1 - 1/T2). This equation is no longer on Lavelle's online equations sheet, however it was on one of his older equation sheets!
Here is the derivation:
lnk = -Ea/R (1/T1) + lnA
lnk' = -Ea/R (1/T2) + lnA
lnk' - lnk = [-Ea/R (1/T2) + lnA] - [ -Ea/R (1/T1) + lnA]
lnk' - lnk = -Ea/R (1/T2) + lnA + Ea/R (1/T1) - lnA
ln(k'/k) = -Ea/R (1/T2 - 1/T1) or Ea/R (1/T1 - 1/T2) (The negative sign in front of Ea/R determines which T is subtracted from which)

Hope this helps!


text:
mersenneforum.org Brimstone for cracking RSA. (jk)
 Register FAQ Search Today's Posts Mark Forums Read

2020-11-06, 21:42   #56
Uncwilly
6809 > 6502

"""""""""""""""""""
Aug 2003
101×103 Posts

2×11×431 Posts

Quote:
 Originally Posted by SarK0Y You lost very point == the task ain't been just solve (it has no sense) == the task is to solve (at least approximate as much as possible) for POLYNOMIAL TIME. can you do it? so, don't feed me numbers == the're a hella lot of them w/o such help
And you earned yourself a timeout. PM me or any supermod with the factorization of the first test to have posting privileges restored.

2020-12-15, 23:55   #57
SarK0Y

Jan 2010

2·43 Posts

@Gelly
Always good to see a decent criticism.. well then, let's be clear upon that AMAP
Quote:
 You claimed to "have a milestone" in integer factorization and continue claiming that you will "crack rsa,
First & foremost, we need to look into canonical definition of «MILESTONE»..
Quote:
 2. a significant event or point in development. https://www.thefreedictionary.com/milestone
it doesn't mean «final point» & definitely it doesn't mean something magic. It just means that project has had some positive/promising results to proceed further. 2nd moment, Polynomial time doesn't mean you can crack everything in no time. For example, O(N*lgN) & O(N²) are both polynomial time, but (w/ growing N) gap between those speeds becomes Abyss.
Quote:
 You then refuse to demonstrate (or even explain!) your method in a significant way
actually, there ain't been questions on-topic.. some guys struggled w/ their deep fears of malware & others just have wanted a magic out of the Blue
Quote:
 but I'm pretty sure you need the exact sum, and not just an approximation,
from the POV of Practice, we need approximation a way down to the point, where it's possible to use brute force for getting exact sum.

https://alg0z.blogspot.com/2020/12/major-update-fpc15rev3.html

Last fiddled with by Dr Sardonicus on 2020-12-16 at 00:13 Reason: As indicated

2020-12-16, 17:02   #58
mathwiz

Mar 2019

149 Posts

Quote:
 Originally Posted by SarK0Y actually, there ain't been questions on-topic..
Actually, there have been: "Can you factor this composite to demonstrate your algorithm isn't complete BS?"

Last fiddled with by mathwiz on 2020-12-16 at 17:02

2020-12-16, 21:12   #59
SarK0Y

Jan 2010

2·43 Posts

Quote:
 Originally Posted by mathwiz Actually, there have been: "Can you factor this composite to demonstrate your algorithm isn't complete BS?"
say me, please, what do you mean with phrase «complete BS». For now, the're no algorithms of integer factorization for practical use == they're too greedy for memory & cpu + they're bad for concurrency too. And actually I have shared everything about my researching. my goal hasn't been to crack occasional rsa numbers, just been researching possible ways to approximate Z. at the very least, it's curious from the POV of theoretical matter

 2020-12-16, 23:28 #60 Dylan14     "Dylan" Mar 2017 10001111012 Posts Initial investigation of the file: VirusTotal reports that the URL is clean. The file that that link takes me is clean, according to VirusTotal. Attempting to run the program sandboxed in Windows 10 doesn't work (needs the bash shell to work, plus Start.exe fails to start). Attempting to run it in a Linux VM, gets me this far when I run the first bit of code in the pdf you linked: Code: ./fpc -ver -poweredby -bye sh: en: command not found see seed: 682257166327978917907309860240882231625049719486075477905198 bits: 199 Please, enter a coef 4 Z: Which is not the expected result. So I thought, maybe I should recompile. Except that doesn't work, as the stuff in the makefile appears to be hardcoded, due to the software used to make the makefile. This of course makes it impossible for one to just download the source and compile, unless they go through the trouble of making the file themselves (which I am not going to do).
2020-12-16, 23:56   #61
SarK0Y

Jan 2010

2×43 Posts

Quote:
 Originally Posted by Dylan14 Initial investigation of the file: VirusTotal reports that the URL is clean. The file that that link takes me is clean, according to VirusTotal. Attempting to run the program sandboxed in Windows 10 doesn't work (needs the bash shell to work, plus Start.exe fails to start). Attempting to run it in a Linux VM, gets me this far when I run the first bit of code in the pdf you linked: Code: ./fpc -ver -poweredby -bye sh: en: command not found see seed: 682257166327978917907309860240882231625049719486075477905198 bits: 199 Please, enter a coef 4 Z: Which is not the expected result. So I thought, maybe I should recompile. Except that doesn't work, as the stuff in the makefile appears to be hardcoded, due to the software used to make the makefile. This of course makes it impossible for one to just download the source and compile, unless they go through the trouble of making the file themselves (which I am not going to do).
what is version you downloaded? actually, i use codelite to edit sources & build 'em.

P.S.
Quote:
my bad :) in the main.cpp

Quote:
 system("TZ='Europe/Moscow' en date");
delete it or change to..
Quote:
 system("date");

Last fiddled with by SarK0Y on 2020-12-17 at 00:03

2020-12-17, 00:07   #62
Dylan14

"Dylan"
Mar 2017

10001111012 Posts

Quote:
 Originally Posted by SarK0Y what is version you downloaded? actually, i use codelite to edit sources & build 'em.
Rev 3, the latest one in this thread (ie the one where the hyperlink is disabled due to potential malware risk).

2020-12-17, 00:16   #63
SarK0Y

Jan 2010

2·43 Posts

Quote:
 Originally Posted by Dylan14 Rev 3, the latest one in this thread (ie the one where the hyperlink is disabled due to potential malware risk).
what is funny sourceforge has shown no downloads and all archives are healthy (except directory for encrypted ones).

 2020-12-17, 03:54 #64 SarK0Y     Jan 2010 10101102 Posts https: //sourceforge.net/projects/fastprimecruncher/files/Build/FPC15/build.sh/download this script builds stuff... [QUOTEmkdir ./Debug export compiler=$1$compiler -c "./main.cpp" -g -g3 -O0 -pedantic -Wall -std=gnu++20 -o ./Debug/main.cpp.o -I$2/include -I.$compiler -c "./gears.cpp" -g -g3 -O0 -pedantic -Wall -std=gnu++20 -o ./Debug/gears.cpp.o -I$2/include -I.$compiler -c "./vars.cpp" -g -g3 -O0 -pedantic -Wall -std=gnu++20 -o ./Debug/vars.cpp.o -I$2/include -I.$compiler -c "./S0T.cpp" -g -g3 -O0 -pedantic -Wall -std=gnu++20 -o ./Debug/S0T.cpp.o -I$2/include -I.$compiler -c "./alt_funcs.cpp" -g -g3 -O0 -pedantic -Wall -std=gnu++20 -o ./Debug/alt_funcs.cpp.o -I$2/include -I.$compiler -c "./taltws.cpp" -g -g3 -O0 -pedantic -Wall -std=gnu++20 -o ./Debug/taltws.cpp.o -I$2/include -I.$compiler -c "./S0T_v0.cpp" -g -g3 -O0 -pedantic -Wall -std=gnu++20 -o ./Debug/S0T_v0.cpp.o -I$2/include -I.$compiler -c "./gears2.cpp" -g -g3 -O0 -pedantic -Wall -std=gnu++20 -o ./Debug/gears2.cpp.o -I$2/include -I.$compiler -o ./Debug/FastPrimeCruncher @"FastPrimeCruncher.txt" -L. -L\$2/lib64 -g -lgmp -lpthread chmod u+x ./Debug/FastPrimeCruncher echo "path to program is ./Debug/FastPrimeCruncher"[/QUOTE]just put it into project's directory, then chmod u+x ./build.sh & run ./build.sh /path/to/g++ /dir/of/gcc Ex. ./build.sh /gcc10/bin/g++ /gcc10 Last fiddled with by SarK0Y on 2020-12-17 at 04:02
2020-12-17, 21:36   #66
SarK0Y

Jan 2010

2·43 Posts

Quote:
 Originally Posted by Dylan14 Initial investigation of the file: VirusTotal reports that the URL is clean. The file that that link takes me is clean, according to VirusTotal. Attempting to run the program sandboxed in Windows 10 doesn't work (needs the bash shell to work, plus Start.exe fails to start). Attempting to run it in a Linux VM, gets me this far when I run the first bit of code in the pdf you linked: Code: ./fpc -ver -poweredby -bye sh: en: command not found see seed: 682257166327978917907309860240882231625049719486075477905198 bits: 199 Please, enter a coef 4 Z: Which is not the expected result. So I thought, maybe I should recompile. Except that doesn't work, as the stuff in the makefile appears to be hardcoded, due to the software used to make the makefile. This of course makes it impossible for one to just download the source and compile, unless they go through the trouble of making the file themselves (which I am not going to do).
Quote:
 ./fpc date Fri Dec 18 00:28:56 MSK 2020 see seed: -17298806269879287989854479267472249225451484322313065116803 bits: 194 Please, enter a coef 4 Z: 1 n = 155089812478348440509606754370011861770654545830995430655466945774312632703463465954363335027577729025391453996787414027003501631772186840890795964683 origP = 348009867102283695483970451047593424831012817350385456889559637548278410717 origQ = 445647744903640741533241125787086176005442536297766153493419724532460296199 zero = 0No luck, cycles 247, bits in numero 496 max delta 496, min delta 482 pvt 452481620476707434240172611436088862775136030162941194679675157584264838795 bits in pvt 249 fctr0 452481620476707434223143780492380366100056287714190241526593877347970056190 fctr1 342777029041274693209436393106254960601139864285139500599868342747434696109 delta of pvt & fctr0 17028830943708496675079742448750953153081280236294782605 Enter '1' to run test Enter '2' to try factorization Take a look in windows deeply '3'
it's old stuff. not sure of version.. perhaps, even 5th/6th one, if not older. the newest one is ./Debug/FastPrimeCruncher -ver -poweredby

 Similar Threads Thread Thread Starter Forum Replies Last Post Owl Miscellaneous Math 11 2021-01-01 01:26 jasong Soap Box 9 2013-03-17 03:28

All times are UTC. The time now is 10:37.

Thu Apr 15 10:37:36 UTC 2021 up 7 days, 5:18, 0 users, load averages: 1.23, 1.36, 1.41


text:
# Antimatter antiproperties?

1. Oct 1, 2015

### jonatron5

Well my question is two fold. Everyone knows that Antimatter anihlates matter on contact. Why? What causes this?

Also as elements get heavier and heavier they are less and less stable.

Would Antimatter become increasingly stable as you added more antiparticles?

2. Oct 1, 2015

### DaveC426913

https://en.wikipedia.org/wiki/Annihilation

No. Antimatter behaves pretty much exactly like matter, just opposite charges. It behaves the same as matter when interacting with gravity, EMR, etc.

3. Oct 2, 2015

### Staff: Mentor

Antimatter in isolation is just as stable (or unstable) as matter in isolation. A positron sitting all by itself will last forever, just like an electron sitting all by itself. An anti-muon sitting all by itself will eventually decay, with a half-life of 2.2 microseconds, same as a muon sitting all by itself.

4. Oct 2, 2015

### ChrisVer

Well that is approximately true - there is CP violation... and once upon a period of our universe, it had to be even larger.

5. Oct 2, 2015

### Staff: Mentor

It is true for every known particle where an assignment as "matter" or "antimatter" is meaningful, this is guaranteed by CPT symmetry. CP violation allows that some mesons decay faster than their antiparticles, but which one is matter and which one is antimatter?

6. Oct 4, 2015

### ChrisVer

And in fact when I wrote it I was thinking 1 of Sakharov's condition for the matter-antimatter asymmetry.

7. Oct 4, 2015

### Staff: Mentor

Neutrinos have no known decay mode.

8. Oct 4, 2015

### vanhees71

That's a question of convention. You start with the elementary particles in the standard model. You have quarks and leptons and their antiparticles (concerning the neutrinos it's not yet clear whether they are their own antiparticles or not; in the usual standard model they are not, being represented by Dirac fields).

Now mesons in the parton model are bound states of quarks and antiquarks. So it's not a priori clear how to label them as particle or antiparticle. Here's a nice table, where you can look it up:

https://de.wikipedia.org/wiki/Liste_der_Mesonen#Anmerkungen_zu_den_neutralen_Kaonen

An explanation for the systematics of this convention, see the article on mesons:

https://de.wikipedia.org/wiki/Meson

9. Oct 4, 2015

### ChrisVer

@mfb they don't, but they can cause a particle to decay...
An example is the $\mu \rightarrow e \gamma$.
If the CP-V phase in the PMNS matrix is non-zero, then there would be a difference in such a decay mode between $\mu^+, \mu^-$...or so I guess.

10. Oct 4, 2015

### Staff: Mentor

That's why I excluded particles where this assignment is not meaningful. Are $B_0$ and $\bar B_0$ matter/antimatter pairs? Their CP eigenstates? Their mass eigenstates? If yes, which one is matter and which one is antimatter? How do we even define the lifetime for particles that are not eigenstates of their decay interaction? That just doesn't make sense.
The muon and antimuon lifetime should be exactly the same, and I don't see how neutrino mixing would be relevant here.

11. Oct 4, 2015

### ChrisVer

Because
$\mu^+ \rightarrow W \nu_\mu \rightarrow W \nu_e \rightarrow \gamma e^+$
vs
$\mu^- \rightarrow W \bar{\nu}_\mu \rightarrow W \bar{\nu}_e \rightarrow \gamma e^-$
Shouldn't be the same if there is CPV for the neutrinos (i.e. $\bar{\nu}$ behave differently than $\nu$) ?

12. Oct 4, 2015

### Staff: Mentor

I still think CPT covers that. Even if not, it would be at most a 10-50 effect.

13. Oct 4, 2015

### vanhees71

The $B_0$ and $\overline{B_0}$ are charge eigenstates and thus one is the charge-conjugated eigenstate of the other. They are not weak-isospin eigenstates and thus mix (CP violation), i.e. For the neutral kaons you even name the flavor eigenstates $K_s$ and $K_l$ (K short and K long) due to their very different life times. Originally they were thought as two different particles called $\theta$ and $\tau$ (not to be mixed up with the modern $\tau$, which is a charged lepton rather than a meson).


text:
Last Updated: August 21, 2021

# Inground Pool Slides: Costs, Types, Safety

Written By: Pool Care Guide

There is little better than relaxing in the cool, clear waters of a pool on a hot summer day. But sometimes, we want a bit more. Restless legs and energetic children seek a thrill: a hop off a diving board, a game of Marco Polo, or maybe a trip down a slide.

If you're considering a slide, there are a few additional items that you'll also need to consider:

• Type: All slides perform the same basic function; climb to the top and slide into the water. Each type just tweaks the formula a little bit, and learning their names and descriptions will help you narrow your search to the slide type that fits your needs. Do you want a steep drop, corkscrew turns, decorative rocks, tunnels, or enclosures for the slide or ladder? These wants will determine the type of slide you should purchase
• Cost: Some will only cost you a couple of thousand dollars. The most expensive will cost you the same as an inexpensive house. There's obviously quite a range there, and we'll try to help you narrow down what cost you can expect for the features you want.
• Safety: Slides are a blast, but we need to put the safety of children first. We're not being hyperbolic. An alarming number of children drown each year, and slides increase that risk. Will children use your future slide? If so, you need to know those statistics and the guidelines set forth by the Consumer Protection Safety Commission.

## Types of Pool Slides

There are three common types of pool slides: straight leg, molded slide leg, and elephant leg. These slides differ by the height of the slides and the shape of their chutes.

We will also very briefly discuss custom slides. In most cases, custom slides are expensive enough to be out of reach for most people. However, if you can afford a custom slide, that slide can easily become a highlight of your home.

Slide Types At a Glance

The shape and intensity assessments of these slides are rated on a relative scale. In a non-relative sense, these slides will not be considered extreme to individuals with an ordinary level of apprehension towards heights.

### Straight Leg Pool Slide

Typically, straight leg pool slides have a mid-range height of 8 to 12 feet. Small children might have difficulty climbing up what will likely be a steep staircase or ladder. However, once up there, the chute should be less intimidating.

If you compare products, you will find straight-leg slides with enclosed or open entries. We recommend enclosed entries for extra protection against potential falls from inevitable rough play around the pool.

Straight leg chutes are straight at the entry with a slight curve just before a short drop. The speed of the descents are smooth but will vary a bit with the height of the slide.

### Molded Leg Slide

In a general sense, molded leg slides are eight feet tall, making them the shortest of the slides. While these drops won't be as thrilling, the curves are more pronounced. There are expectations for this description. You can find molded leg slides that are taller or shorter if you choose to look for them.

For the eight-footers, the minimum water requirements will often be 3 ½', so they can be placed at the shallow end of most pools. You should always follow manufacturer recommendations over our generalized description, so be safe and check the owner's manual.

### Elephant Leg Slide

Elephant leg slides are the most extreme slides within our selection of prefabricated slides. The slides are typically taller, the drops are bigger, and their curvy configurations will disorient you before gently depositing you into the water. They're a lot of fun and very popular for both kids and adults.

There are two distinct variants of elephant leg slides, G-force and X-stream. They are dissimilar enough from each other to warrant separate descriptions.

#### X-Stream

If you want a tall slide with a big drop, the X-stream is probably the right choice for you. At 14 feet tall, it's the most intimidating and dangerous of the slides. It will also require additional deck space for stability. As from the G-force slides, the X-stream's curves will be more prominent than the rest of our selection of slides.

#### G-Force

G-force slides are nine feet tall, which makes them shorter than the X-streams. They have a corkscrew design which can be a blast. You won't gain a lot of speed, but you'll notice the centrifugal force as you careen towards the water.

#### Prefabricated vs Custom

Prefabricated slides will almost always be more affordable than a custom-built pool slide. When prefabricated, the costs of designing and manufacturing the "new" slides are split amongst the buyers.

When custom-designed, the single buyer is paying for those costs and using an untested product. Additionally, most do not pay for a custom design without planning something extravagant. Long and tall slides that wrap around the landscape and tunnel through walls will quickly bring these prices up to and even over $100,000. ## How Much Does a Pool Slide Cost? Prefabricated pool slide prices can cost anywhere from$1,000 to just under $100,000. On average, most homeowners can find suitable pool slides between the price points of$1,000 to $4,500. When the installation costs are factored into the pool slide’s budget, the total average cost will be somewhere just over$4,000.

Prefabricated slides can be quite expensive, but the extravagant custom slides can cost up to and over \$100,000.

### Can You Get a Pool Slide Later?

Yes, you can install a pool slide after a pool has already been constructed. That said, the planning and construction phase is the easiest and cheapest time to prep for a slide. For that reason, we highly recommend that you plumb for it even if you don't know if you'll need it.

Pool slides require a continuous source of water supplied from the pool pump's return line. Tapping into that return line is much easier when there isn't a block of cement and a pool deck sitting between you and the return line.

It is not a complicated procedure and can be completed by your average layman. You just need to couple a single line of pipe to that return line. Without that water source, you'll be trading fun on the slide for friction burns.

This inexpensive addition keeps the possibility for a cheaper pool slide installation down the road. Even if you don't plan on using a slide, it could be a good addition If you ever decide to sell your current home. A pool slide is an eye-catching addition for any home buyers with kids.

If you want to add a water line and install a slide to an existing pool, you'll need to hire a plumber. That plumber can cut into the pool deck and couple a pipe to the return line. It will cost more, but it isn't likely to be prohibitively expensive.

## Safety

If children will use your slide, please pay close attention. We need you to understand the risks that pools pose for kids, and how slides increase those risks. Slides have staircases and ladders. Slides introduce elevation and an uncontrolled speedy descent to a location with concrete and water that naturally inspires roughhousing.

### Swimming Pool Drowning Statistics

We don't know the statistics of pool slide injuries, but we do know drowning statistics. Drowning is the most common cause of death of children under the age of 4. If you increase that range out to 1 to 14, drowning drops to the second leading cause of childhood deaths.

We can't quote the numbers regarding pool slide injuries, but they are reported to be common and sometimes quite serious. Many of us have seen close calls and black eyes when one swimmer lands on top of another.

Sometimes, these mishaps result in permanent damage from traumatic brain injuries and spinal cord damage.

### Consumer Protection Safety Commission (CPSC)

Wet and slippery surfaces are dangerous enough. When you add height and speed to the equation, you are just asking for trouble. For this reason, when purchasing your slide, it would be wise to print out the guidelines set forth by the CPSC. Use the guidelines as a checklist to ensure that you pick from the safest slides. While you won't get into any immediate legal trouble by not abiding by the guidelines, it would put you, your loved ones, and visitors at unnecessary risk.

Have you ever skinned your back on the floor of the pool because the water depth was too shallow for the slide? Have you ever slipped on a slide's steps because the steps were not slotted or textured? The safety requirements change with the slide's height, and these guidelines will help you navigate those requirements. It is your legal responsibility as the pool owner to ensure the safety of those that use the pool. Don't risk lives and don't risk a lawsuit.

### How Deep Does the Pool Need to Be for a Pool Slide?

The minimum water depth is primarily determined by the height of the occupants and the drop distance. We can give some generalized guidelines of the depth requirements that you can expect. However, you should always defer to the manufacturer's recommendations.

• Small Slides: Is the slide meant for children? Is the distance from the pool's surface to the bottom of the slide less than three inches? If you answered yes to both, the water only needs to be two feet deep.
• Large Slides: If the slide was built to support people with a height of 4 feet or taller, most manufacturers will recommend a water depth of 3 feet or deeper.
• Slides with Drops: At a minimum, any slides with drops require a minimum depth of 9 feet.
• Slides with Turns: Do not have much of an impact on the depth. As long as the slide levels off, the depth requirements should be roughly 3 feet.

### Are Pool Slides Safe?

No, pool slides are not safe. That said, there are precautions that you can take to make them safer. As long as everyone follows some basic guidelines, the inherent risks that a slide presents should be mitigated to the point that fun becomes the primary concern.

• When the slide is first installed, double-check that all the galvanized nuts and bolts are tightly secured.

We’re calling these rules, but it’s clearly up to you.

Rule 1: Don't use the slide without someone else nearby
Rule 2: Don't roughhouse near the slide
Rule 3: Butt on the slide and feet first

Don't try any risky tricks. Don't stand, and don't slide headfirst. Many people get injuries from pools, and this is an excellent way to get your own.

Rule 4: Don't start sliding until the exit is clear.

Rule 5: Don't drink alcohol and slide

This rule is obvious, and it is commonly broken. There are a lot of ways this can go wrong. Is your coordination too impaired to drive a vehicle? If so, you probably shouldn't propel your body down a ramp.

If your balance is compromised, you could also fall onto the concrete. If your blood alcohol level is through the rough, you could end up drowning.

Rule 6: One at a time

Rule 7: If you aren't allowed onto a roller coaster, you aren't allowed onto the slide. It seems tame, but the same health risks apply to each situation. Do not climb the slide if you:

• Have a heart condition
• Are pregnant
• Elderly
• User(s) are over the slide’s maximum weight capacity

Rule 8: Don't exceed the maximum weight capacity

Many residential pool slides are not built to support weight exceeding 175 lbs.