text:
# Dictionary (with silly hash)

Based on this question (but fixed so it can run).

I have kept the code as close to the original as possible.
I have Marked all the changes with Loki (should be easy to spot).

Code here is written in the style of the original author.

Dic.h

#ifndef DIC_H
#define DIC_H

#include <iostream>
#include <string>
using namespace std;

typedef string K;  //key type    //!!!
typedef double V;  //value type  //!!!

namespace HA
{
int hash(std::string key);  // There are plenty of things already called hash.
// This was confusing the compiler so I had
// to put it in its own namespace to make sure
// I was using the correct one.
}
/* Loki END*/

class Dic{
public:
Dic( );  //an empty Dic

//The BIG 3:  operator=, copyconstructor, destructor
~Dic();

Dic( const Dic & src );  //copy con

Dic & operator=( const Dic & rhs );  //assignment op

//return null or a pointer at the value in this Dic
V * find(K key);

//returns true if it ADDED (false if modified)

int size( );

private:
class DicNode{public: K key; V val; DicNode * nxt; };
int n;  int SZ;
DicNode**       table;   // DicNode* [ ]    an array of linked lists of DicNodes

int dichash(K);            //private hash function
void deallocate();      //private helper, used by the destructor.
};

#endif

dic.cpp

#include "Dic.h"
#include <string>

int Dic::dichash(K key){       //DEPENDS ON K. This one assumes K is string
/*Loki Change */
return std::abs(HA::hash(key)) % SZ;
/*Loki END*/
}

void Dic::deallocate(){     //separate member called by destruc and op=
for(int i=0; i<SZ; i++){
//get rid of chain i
DicNode * p = table[i];
while(p!=0){
DicNode * kill = p;
p = p->nxt;
delete kill;
}
}
delete []  table;
}

V * Dic::find(K key) {
/* Loki Wrote */
int hash = dichash(key);
DicNode* f = table[hash];
while(f != nullptr && f->key != key)
{   f = f->nxt;
}
return f == nullptr
? nullptr
: &f->val;
/* Loki END */
}

/* Loki Wrote */
V* current = find(key);
if (current != nullptr)
{
*current = val;
return false;   // false indicates value was not added just modified.
}

int hash = dichash(key);
table[hash] = new DicNode{key, val, table[hash]};
return true;        // true indicates new value was added to the table.
/* Loki END */
}

int Dic::size(){

return n;
}
//-----------------------------------------------------------------

//BIG 3

Dic::Dic()
Must initialize all the members.
Otherwise your object will have random values in it.
*/
: n(0)
, SZ(13)
, table(new DicNode*[SZ]())
/*Loki END*/
{}

Dic::Dic( const Dic & src )
Must initialize all the members.
Otherwise your object will have random values in it.
Having randome valus is not very useful when you call the assignment operator
which calls the dealloce() method.
*/
: n(0)
, SZ(0)
, table(nullptr)
/*Loki END*/
{
*this = src;   //Uses operator= defined for Dic
}

Dic & Dic::operator=( const Dic & rhs )
{  //assignment op
if(this == &rhs){ cout<<"goofy"<<endl; return *this; }

// clean up any memory allocated by this
this->deallocate();
// initialize this n,SZ,table to be like rhs
this->n=rhs.n; this->SZ = rhs.SZ; this->table=new DicNode*[SZ];
// duplicate the DicNode chains
for(int i=0;i<SZ;i++){
DicNode * q = rhs.table[i];
if(q==0){
this->table[i]=0;
}else{
this->table[i]=new DicNode;    //note: NOT DicNode()
DicNode * p = this->table[i];
while(true){  //loop inv: *p is blank node corresp to *q
p->key = q->key;  p->val = q->val;
if(q->nxt==0)break;
q=q->nxt; p->nxt=new DicNode; p=p->nxt;
}
p->nxt=0;
}
}
return *this;
}
namespace HA
{
int hash(string s) {
int ret=0;
/*Loki Remove
The SZ member variable is what you want to use.
This is because you want to take the hash and convert it into an index
into your table. The string length is the correct value to use as the
modulus.
int SZ = s.length();
* Loki END*/
for (int i=0; i<s.size(); i++) {
ret+=s[i]-'A';
}
/*Loki Change
return ret%SZ;
*Loki End*/

/* Note returning a hash of the string.
* It is not modulo anything. So
* we also need to modify all call points to
* use modulo if required.
*    I am not going to comment those changes.
*/
return ret;
}
}

Dic::~Dic(){this->deallocate();}

Test Code

int main()
{
Dic     dict;

std::cout << dict.find("Key") << "\n";
std::cout << *dict.find("Key") << "\n";
}

## Dict.h

Do not do this.

using namespace std;

Especially in a header file. You are polluting the namespace for everybody that uses your header file (and you will break peoples code). Some people say its OK to use this in a source file. I disagree with even that as it causes problems in anything more than a toy program. But to make sure you don't get into bad habits don't even use it in toy programs. Use the explicit prefix std::. It was named std rather than standard explicitly so it would not be a burden to be explicit. See: Why is “using namespace std;” considered bad practice?

When passing object around try and pass them by const reference.

int hash(std::string key);

// Prefer to do this:

int hash(std::string const& key);

This stop a copy of the object being made. Also the function can not modify the original because it was passed by reference.

This is a bit untidy:

Dic( );  //an empty Dic

//The BIG 3:  operator=, copyconstructor, destructor
~Dic();

Dic( const Dic & src );  //copy con

Dic & operator=( const Dic & rhs );  //assignment op

Group constructors together. Put Destructor at the end of the list. Assignment operator after that. The first thing people check when you are doing memory management is to make sure you have the rule of three correctly implemented so put it all together. An addition you should think about is adding move semantics to your class (Move constructor and ove assignment operator).

// Too much vertical space (and useless comments) I would have done:
Dic();
Dic(const Dic & src);
Dic(Dic&& src);
~Dic();
Dic& operator=(Dic const& rhs);
Dic& operator=(Dic&& rhs);

Not a great interface. But it is sufficient.
Remember to pass object parameters by const reference.

V * find(K key);                // Change to:  V*   find(K const& key);
bool addOrMod(K key, V val);    // Change to:  bool addOrMod(K const& key, V val);

When you have methods that don't change the state of your object you should mark them const. This will allow you to retrieve information from a const object. So passing it by const reference will still allow you to query from it:

int size();

// This should have a const on it:

int size() const;

// In addition to the normal find() you specify above.
// It is also worth having a const version that allows your users to read from the object.
V const* find(Key const& key) const;

// Notice that the method is const and the value I return is const.
// So you can read it but not modify the content.

If you are going to declare an all public class you may as well make it a struct (its the same thing).

class DicNode{public: K key; V val; DicNode * nxt; };

I changed the order of your member variable declarations.
In the constructor they are initialized in the same order that you declare them which is important.

int n;  int SZ;
DicNode**       table;   // Note: the * is part of the type.
//       So place it with the type.

Not particularly keen on an array of arrays. But you are building a container. But because you have no method to resize it I would have personally used std::array or potentially a std::vector.

To prevent confusion I renamed this function from hash. As it does not actually return a hash but an index into the table (using the hash to calculate the index).

int dichash(K);            //private hash function

## Dict.cpp

You have a strange order to your methods.
Personally I always put the Constructors/Destructors first. People need to know how the class is set up before other functions make any sense. So putting the constructors firsts will give people a context on how the other functions will work.

You did not implement this function:

int Dic::dichash(K key){       //DEPENDS ON K. This one assumes K is string
/*Loki Change */
return std::abs(HA::hash(key)) % SZ;
/*Loki END*/
}

Which is the main reason it did not work.

OK: This code looks like it should work.

void Dic::deallocate(){     //separate member called by destructor and op=
for(int i=0; i<SZ; i++){
//get rid of chain i
DicNode * p = table[i];
while(p!=0){
DicNode * kill = p;
p = p->nxt;
delete kill;
}
}
delete []  table;
}

But it looks very untidy. And could have been written much easier with a nested for loop. Other may suggest you use smart pointers here. But I am going to disagree with them. There are two basic types of memory management in C++.

• Smart pointers.
• Containers

There is no point in implementing containers in terms of smart pointers. The container is supposed to do the memory management. A Dictionary (hashed or otherwise) is a container so the memory management is well defined and contained.

Another three functions you did not implement:

V * Dic::find(K key) {
int Dic::size(){

So we get to the Big 3!!!!

Your main problem is that you did not initialize your members in the constructors. Do not assume they will be zero initialized. You must usually do this explicitly.

Dic::Dic()

The copy constructor you implement in terms of the assignment operator. Nice idea. But the wrong way around. You should implement the assignment operator in terms of the copy constructor (its called the Copy and Swap Idiom (easy to find on Google or SO)). Also because you did not correctly initialize the object before calling the assignment operator things were going horribly wrong.

Dic::Dic( const Dic & src )

When copying an object. You should do it three distinct phases. This allows you to provide the strong exception guarantee.

Dic & Dic::operator=( const Dic & rhs )

1. Copy the object into a temporary.
It is important to put it into a temporary. Because if things go wrong during the copy you still have the original state of the object to fall back on.
2. Swap the content of the temporary with the state of the current object.
Swap in C++ is a fundamental property that you should implement as a very simple transfer of safe objects (POD and pointers).
3. Now that you have swapped the state (and the object is all good) you can destroy the old state.
Which should now be in the temporary object.

If we look at your copy we can point out the danger spots.

    // clean up any memory allocated by this
this->deallocate();

At this point your object is not in a very dangerous state. All its data has been deleted but the pointers still point at that memory. If you throw an exception that is caught downstream this object would cause the program to potentially crash (or at least have a high likely hood of undefined behavior).

    this->n=rhs.n; this->SZ = rhs.SZ; this->table=new DicNode*[SZ];

Some extra white space around the gibberish would go a long way in making this easier to read.

    for(int i=0;i<SZ;i++){

Personally I would have created another method for copy a list of elements.

        DicNode * q = rhs.table[i];

## Hashing

This is a terrible hash function:

int hash(string s) {
int ret=0;
/*Loki Remove
The SZ member variable is what you want to use.
This is because you want to take the hash and convert it into an index
into your table. The string length is the correct value to use as the
modulus.
int SZ = s.length();
* Loki END*/
for (int i=0; i<s.size(); i++) {
ret+=s[i]-'A';
}
/*Loki Change
return ret%SZ;
*Loki End*/

/* Note returning a hash of the string.
* It is not modulo anything. So
* we also need to modify all call points to
* use modulo if required.
*    I am not going to comment those changes.
*/
return ret;
}

To be fair writing your own hash function is really hard; and thus a bad idea. Unless you happen to have a PhD in Maths this is not an easy task. It is better to go onto the internet and lockup existing hashing algorithms. There are some relatively simple ones that give a reasonable distribution for small pet projects like this.

Another thing to note about hash and hash tables. Prime numbers are key. So it is probably a good idea to make your table have a prime number of buckets (that is why I used 13 above). But check your hashing algorithm you eventually pick.


text:
Dear All,

Are concrete form release oil VOC limits included in the credit "Low-emitting Materials"?

Concrete Form Release Oil VOC limits are included under "Rule 1113; June 3, 2011" but are do not seem to be refereed to in the table "Table 1. Thresholds of compliance with emissions and content standards for 7 categories of materials" unless they are included in "coatings applied on site".

If there are included what is the limit for a European project? (Rule 1113; the current limit of 250 g/L and then 1/1/14 it drops to 100 g/L).

thank-you,

Ian

format: plain


text:
What's the deal with Deno? We talk with a major contributor to find out. Listen now.

# Tag Info

212

These types of cryptographic primitive can be distinguished by the security goals they fulfill (in the simple protocol of "appending to a message"): Integrity: Can the recipient be confident that the message has not been accidentally modified? Authentication: Can the recipient be confident that the message originates from the sender? Non-repudiation: If the ...

65

A Message Authentication Code (MAC) is a string of bits that is sent alongside a message. The MAC depends on the message itself and a secret key. No one should be able to compute a MAC without knowing the key. This allows two people who share a secret key to send messages to each without fear that someone else will tamper with the messages. (At least, if ...

45

I'll answer in order: Output size = input size That's correct, GCM uses CTR internally. It encrypts a counter value for each block, but it only uses as many bits as required from the last block. CTR turns the block cipher into a stream cipher. Note that this doesn't include any additional authenticated data (AAD) that needs to be send, the optional ...

42

Although there are already many answers here, I wanted to strongly advocate AGAINST MAC-then-encrypt. I fully agree with Thomas' first half of the answer, but completely disagree with the second half. The ciphertext is the ENTIRE ciphertext (including IV etc.), and this is what must be MACed. This is granted. However, if you MAC-then-encrypt in the ...

38

Everything was changed between SHA-2 and SHA-3. In the specific case of the "length extension attack": the issue is that SHA-2 process data by splitting it into elementary blocks (64 or 128 bytes, depending on the SHA-2 variant), and produces for each block an output which has exactly the same size as the function output. Moreover, the output for a complete ...

35

$\operatorname{Encrypt}(m\|H(m))$ is not an operating mode providing authentication; forgeries are possible in some very real scenarios. Depending on the encryption used, that can be assuming only known plaintext. Here is a simple example with $\operatorname{Encrypt}$ a stream cipher, including any block cipher in CTR or OFB mode. Mallory wants to forge an ...

28

You're missing the most important strength of HMAC: it comes with a proof of security (under some plausible assumptions). The outer key plays an important role in the proofs. The best place to learn more is to read the HMAC papers: Message authentication using hash functions: The HMAC construction, Mihir Bellare, Ran Canetti, Hugo Kawczyk, CryptoBytes ...

25

From the proposal of GCM (rewritten if statement): if $\operatorname{len}(IV) = 96$ then $Y_0 = IV || 0^{31}1$ else $Y_0 = \operatorname{GHASH}(H, \{\}, IV)$. So there are additional calculations for IV's other than 96 bits. This is why the original proposal has this recommendation: 96-bit IV values can be processed more efficiently, so that [ed: ...

23

HMAC was there first (the RFC 2104 is from 1997, while CMAC is from 2006), which is reason enough to explain its primacy. If you use HMAC, you will more easily find test vectors and implementations against which to test, and with which to interoperate, which again explains continued primacy. Being the de facto standard is a very strong position. On many ...

23

Given that you use the SHA-3 hash (which is resistant against length extension attacks), would you still need to go through that procedure in order to produce a secure MAC? No, you don't need to do that, but you can. Needless to say we'd still use a key, which we prepend or append to the message, but is that sufficient for a MAC? Yes, you can prepend ...

22

Poly1305 is a universal hash function. The output of that function cannot be used safely without being encrypted. In order to encrypt it, any cipher can be used. AES was used as an example in the paper, but the very same paper mentioned: Users can switch from Poly1305-AES to Poly1305-AnotherFunction, with an identical security guarantee. All the efforts ...

21

Moxie Marlinspike calls it in his article http://www.thoughtcrime.org/blog/the-cryptographic-doom-principle/ the doom principle: if you have to perform any cryptographic operation before verifying the MAC on a message you’ve received, it will somehow inevitably lead to doom. He also demonstrates two attacks which are possible because of trying to ...

21

Length extension attack The reason why $H(k \mathbin\| m)$ is insecure with most older hashes is that they use the Merkle–Damgård construction which suffers from length extensions. When length extensions are available it's possible to compute $H(k \mathbin\| m \mathbin\| m^\prime)$ knowing only $H(k \mathbin\| m)$ but not $k$. This violates the security ...

19

No. A MAC guarantees unforgeability but not pseudorandomness. It is true that all MACs that I can think of right now are essential pseudorandom functions, but this does not mean that the MAC definition implies this. Indeed, it clearly does not. So, conceptually, you need a pseudorandom function. You can assume that HMAC is a pseudorandom function. It is ...

18

TL;DR No, the approach is not secure. Use a standard like CMAC instead. Or even better, check your AES accelerator module to see if it supports any AEAD modes of encryption like GCM, CCM, EAX. Long Version In order for a message authentication code (MAC) to be secure, an adversary with oracle access to the MAC (basically this means the adversary can send ...

17

If this requires a single answer among 1/2/3/4 (rather than none), I would select 3, by the following reasoning: Digital Signature provides confidentiality while message authentication code can not We can summarily exclude this, since a Digital Signature simply does not provide confidentiality. Digital Signatures works faster than message ...

17

Would it not be easier simply to send $E(m||s,k)$ where s is a salt shared across the system? Yes, that would be simpler; however, that would not (in general) be secure. The assumption you are making is that if someone modifies the ciphertext in any way, then the last few bits of the resulting plaintext must also be modified. This is often not the case: ...

16

Alas, there is no simple satisfactory answer to this question. What I can offer is a very strong property that $m \mapsto H\bigl(k \mathbin\| H(k \mathbin\| m)\bigr)$ fails to achieve; a more pedestrian property which even HMAC may or may not achieve but is typically asked to achieve; a reason not to worry about it for any new systems; and some historical ...

15

While the one time pad seems obvious, I am not sure about Carter-Wegman-Style message auth. What they are talking about is a Carter-Wegman authentication method that uses a stream of random bits as a part of the process (just like a one time pad uses a stream of random bits to encrypt). Normally, when we implement CW, we use some almost universal (au) ...

14

The construction you are proposing is called the "envelope" or "sandwich" MAC, it predates HMAC, and it is in fact secure—provided the key and message are appropriately padded. That is, $$\text{SHA256}(k \parallel m \parallel 1 \parallel 0^{b - 1 - (|m| \bmod b)} \parallel k)$$ is secure, as long as $k$ is the underlying hash function's block length $b$ (...

13

Using $H(m\mathbin\Vert k)$ with hash function $H$, message $m$ and key $k$, is one possible way to build a MAC algorithm. It is not necessarily a good one; it depends on the used hash function. Even when it is a good one, that does not preclude the possibility of other, "better" algorithms (e.g. for performance). As an illustration of potential security ...

13

I think Encrypt-then-MAC does not deliver Plaintext integrity, but only ciphertext integrity. If the MAC over the ciphertext is OK but then we use the wrong key to decrypt (for whatever reason), then the recipient receives a plaintext that the sender did not send and did not vouch for. If this can happen, this is a violation of plaintext integrity. So, ...

13

I'll assume All ciphered blocks means the same as ciphertext for CBC-Encryption with implicit zero IV, while CBC-MAC is the last block of that. All ciphered blocks is unsafe as a message authenticator for messages longer than one block, for it succumbs to a trivial attack (here with two blocks): Eve intercepts message $M=M_0||M_1$ and its authenticator $A=... 13 Given some string s I want to [integrity protect], are following methods are equivalent to produce message with signature, assuming it does not matter whether s is visible in message or not? Absolutely not; with AES_CBC, if the attacker modifies one particular block of the ciphertext, then the decryption of the modified ciphertext will have two blocks ... 13 What are those existing constructions? Usually people consider three to four scenarios for authenticated encryption for embedded environments: Constrained for ROM + RAM In this case you probably would want to use as few primitives as possible and using something like the EAX or CCM mode to use your block cipher for both authentication and encryption. (... 12 Yes, this would be secure. CTR (Counter) mode based on keyed function$F_K$is secure as long as its output $$W_i = F_K(i)$$ is unpredictable given previous outputs $$F_K(1),F_K(2),\ldots,F_K(i-1).$$ This requirement is essentially the definition of a pseudo-random function (PRF). Most HMAC instantiations with widely used hash functions are believed to ... 12 One simple cryptographically secure rolling hash function is the following: $$F_{k1,k2}(x) = E_{k1}(R_{k2}(x))$$ where$R_{k2}(\cdot)$is a non-cryptographic rolling hash function (e.g., Rabin-Karp), and$E_{k1}$represents encryption with a block cipher (e.g., AES). By$R_{k2}(\cdot)$, I mean that the parameters of the rolling hash should be derived from ... 12 The MAC value should be calculated over all of the input, not just the first block. The chaining of CBC makes sure that the bits in the last block of ciphertext depends on all the previous blocks. 12 Can the$AES_k(n)$portion be simply replaced with$k \oplus n$? No, but you're close, it would be replaced with$k + n$, where$+$is addition modulo$2^{128}$; then it becomes informational theoretic. Here's why: Poly1305 is based on a polynomial universal hash. This is a hash where we select a finite field$GF(p^i)$, select a private value$x \in GF(p^...

Only top voted, non community-wiki answers of a minimum length are eligible


text:
## Question:

The two blocks A and B each have a mass ${ M }_{ 0 }$. The blocks are fixed to the horizontal rods, and their initial velocity is v’ in the direction shown. If a couple moment of M is applied about shaft CD of the frame, determine the speed of the blocks at time t. The mass of the frame is negligible, and it is free to rotate about CD. Neglect the size of the blocks. Given: ${ M }_{ 0 }$ = 0.4 kg , a = 0.3 m , v’ = 2 m/s , M = 0.6 N⋅m , t = 3 s


text:
Followers 0

# Implicit conversion of value is not exact

## 3 posts in this topic

Hi. some times i have problem with float

AS work strange with this.

example, that code not work because he not understand '0', he think is a "int".

float ret = true ? 0 : 0.1;

and ok, that code make warning!

next code, work wrong

float f = 0.1;
float ret = 0.2;
ret += false ? 0 : f * 15 ; // ( 15 * 0.1 == 1.5 ) then 1.5 + 0.2 == 1.7 ok ?
output( "ret: " + ret ); // BUT result == 1.2
Edited by FDsagizi
0

##### Share on other sites

That is odd. I'll look into this.

Which version of AS are you currently using?

0

##### Share on other sites

It was a bug that the compiler didn't implicitly convert the constant 0 to the type in the last expression.

I've fixed that bug in revision 1736. I also took the time to add a compiler warning about a truncated value when a float or double type is implicitly converted to an integer type.

Edited by Andreas Jonsson
0

##### Share on other sites

Ok! I'll look into this.

0

## Create an account

Register a new account


text:
5

# Evaluate J _ f where â‚¬ = [1,2] x [3,5] and f (x,y)2x...

## Question

###### Evaluate J _ f where â‚¬ = [1,2] x [3,5] and f (x,y)2x

Evaluate J _ f where â‚¬ = [1,2] x [3,5] and f (x,y) 2x

#### Similar Solved Questions

##### (b)Iim0/20 points Previous Answers SCalcCC4 2.3.049. Find the number a such that the limit exists 3x2 + ax ta+9 Ilm x2 + X - 2Find the value of the limit:Practice Another VersionSubmit AnswerSave ProgressType here to search
(b) Iim 0/20 points Previous Answers SCalcCC4 2.3.049. Find the number a such that the limit exists 3x2 + ax ta+9 Ilm x2 + X - 2 Find the value of the limit: Practice Another Version Submit Answer Save Progress Type here to search...
##### Let f(t) = [t] be the ceiling function of t (returns the smallest integer which is Z t, for example f(w) = 4). Find f(c + y) dx dy where Ris the rectangle 0 < â‚¬ < 2and0 < y < 1.Submit answer as a number rounded to the nearest hundredth:Question 191ptsA triangle has vertices at the points A, B,C in three-dimensional space: Which of the following represent the area of the triangle?Select all expressions which are equal to the area of the triangleIAB x ACl[AB x BC|BC BAICA x CB|[AB x
Let f(t) = [t] be the ceiling function of t (returns the smallest integer which is Z t, for example f(w) = 4). Find f(c + y) dx dy where Ris the rectangle 0 < â‚¬ < 2and0 < y < 1. Submit answer as a number rounded to the nearest hundredth: Question 19 1pts A triangle has vertices at ...
##### 7. Let X and Y be independent and Exp(1) distributed_ Consider the coor- dinate transformationy = U(thus u = â‚¬ +y and =c/( +9))Let U = X+Y and V = X/(X +Y)Determine the Jacobian of the above coordinate transformation:Determine the joint pdf of U and V. Show that U and V are independent.
7. Let X and Y be independent and Exp(1) distributed_ Consider the coor- dinate transformation y = U (thus u = â‚¬ +y and =c/( +9)) Let U = X+Y and V = X/(X +Y) Determine the Jacobian of the above coordinate transformation: Determine the joint pdf of U and V. Show that U and V are independent....
##### Find the work done by force F = (3i + 7 j) m in displacing an object from position (2i - IOj) m to another 12 (Si 10 j) m; Determine the angle between the force and the displacement vector Ar n-Tij
Find the work done by force F = (3i + 7 j) m in displacing an object from position (2i - IOj) m to another 12 (Si 10 j) m; Determine the angle between the force and the displacement vector Ar n-Tij...
##### Consider the hypothetical hydrides HT and HzVe and the diagram below:pH 2410121416HTHzVeHVeVezpH 2610121416What is the pKa of HT? What is the pKa of HVe ?Of all of the species on the two diagrams, which is the most acidic? Which is the most basic?Give the expected products (or indicate no reaction if none occurs) of the following reactions:HzVe + T -HVeTVez: + T -If Ve is the element Veigium, what are the names of HzVe and HVe ? What is the name of the Laz+ salt of Ve2 ?
Consider the hypothetical hydrides HT and HzVe and the diagram below: pH 2 4 10 12 14 16 HT HzVe HVe Vez pH 2 6 10 12 14 16 What is the pKa of HT? What is the pKa of HVe ? Of all of the species on the two diagrams, which is the most acidic? Which is the most basic? Give the expected products (or ind...
##### Explain briefly the meaning of A/ B of a considered whole Explain briefly the meaning of the words numerator and denominator What is the difference between a proper fraction and an improper fraction? Explain how to make sense out of an improper function Explain, with an example; how to write a fraction as a decimal number
Explain briefly the meaning of A/ B of a considered whole Explain briefly the meaning of the words numerator and denominator What is the difference between a proper fraction and an improper fraction? Explain how to make sense out of an improper function Explain, with an example; how to write a fract...
##### Oatarral30,30,20,13,Ji(@) Uqngue "SIATI"suhuc e( Lhc Amiatd terialson Ontt Joue anawct Ia @ue (5) uactmnal plucttWyMernndcd to Fuv Q)= Mlenima Ielce cemneanc thc t loc of thc uantIru davautlon &llig tna fornula rven che_Oire Knn enretzi In (ne (S) decimd paaEkaubFnhlallaemannan
Oatarral 30,30,20,13,Ji (@) Uqngue "SIATI" suhuc e( Lhc Amiatd terialson Ontt Joue anawct Ia @ue (5) uactmnal pluctt WyMe rnndcd to Fuv Q)= Mlenima Ielce cemneanc thc t loc of thc uantIru davautlon &llig tna fornula rven che_Oire Knn enretzi In (ne (S) decimd paa Ekaub Fnhlallaemannan...
##### A capacitor is connected in an electric circuit. Wher key is pressed, the current in the circuit is(A) Zero(B) Maximum(C) Any transient value(D) Depends on capacitor used
A capacitor is connected in an electric circuit. Wher key is pressed, the current in the circuit is (A) Zero (B) Maximum (C) Any transient value (D) Depends on capacitor used...
##### Consider the inner product space P(R) with inner product(p(z) , 9(2)) = EpkoJqkr) dx_(a) (4 points) Apply the Gram-Schmidt process to the basis1, 1. 1+2+22of the subspace P2(R). (leave answers in exact form) (b) (2 points) Find the polynomial in P2(R) which best approximates 2x2 14 with respect to the given inner product. (leave answer in exact form
Consider the inner product space P(R) with inner product (p(z) , 9(2)) = EpkoJqkr) dx_ (a) (4 points) Apply the Gram-Schmidt process to the basis 1, 1. 1+2+22 of the subspace P2(R). (leave answers in exact form) (b) (2 points) Find the polynomial in P2(R) which best approximates 2x2 14 with respect ...
##### (a) Draw a potential energy diagram for the mechanism proposed in Problem 13.31. Step 1 is endothermic, Step 2 is endothermic, and the overall reaction is exothermic. Label reactants, products, and activation energy.(b) Propose a different mechanism that agrees with the rate law for Problem 13.31. Identify all catalysts and intermediates in the mechanism.
(a) Draw a potential energy diagram for the mechanism proposed in Problem 13.31. Step 1 is endothermic, Step 2 is endothermic, and the overall reaction is exothermic. Label reactants, products, and activation energy. (b) Propose a different mechanism that agrees with the rate law for Problem 13.31. ...
##### 4 Pr/oxohp : M cell was O_(g), pH 2.2 Izzkzxa 0,(g) pH 2.2 M S H a saturated with Hg? 2 {3 mercury platinum anode V isolutien bubitleoithe? U and liquid
4 Pr/oxohp : M cell was O_(g), pH 2.2 Izzkzxa 0,(g) pH 2.2 M S H a saturated with Hg? 2 {3 mercury platinum anode V isolutien bubitleoithe? U and liquid...
##### Express each current or voltage in sinusoidal form. $$\mathbf{V}=150 \underline{/ 0^{\circ}}$$
Express each current or voltage in sinusoidal form. $$\mathbf{V}=150 \underline{/ 0^{\circ}}$$...
##### Whcn the !clocity 0fa moting objcct i doubkd und It muts abo doubkd Ihcn momcnmmTna sameIwicoquednolaElgnt Tmes
Whcn the !clocity 0fa moting objcct i doubkd und It muts abo doubkd Ihcn momcnmm Tna same Iwico quednola Elgnt Tmes...
##### When signals indicate that glycolysis should increase andgluconeogenesis should decrease, indicate what should happen to thefollowing pathway or regulatory enzyme activities andsignaling/regulatory intermediates. Write the word â€œINCREASESâ€ (ordraw an up arrow,â†‘) or â€œDECREASESâ€ (or draw a down arrow, â†“), toindicate the resulting change in the concentrations of molecules oractivities of enzymes in the cells. INCREASES, â†‘? or DECREASES,â†“?Phosphofructokinase-1 _______________________
When signals indicate that glycolysis should increase and gluconeogenesis should decrease, indicate what should happen to the following pathway or regulatory enzyme activities and signaling/regulatory intermediates. Write the word â€œINCREASESâ€ (or draw an up arrow,â†‘) or â€œDECR...


text:
# Maxwell's Equations: Mutual consistency

1. May 31, 2010

### Arijit Dutta

The no. of unknowns in the Maxwell's Equations is 6- the components of E and B. But there are 8 partial differential equations if we separate them out component- wise. So when we find the solution to them how do we ensure their mutual consistency?

2. May 31, 2010

### nicksauce

Last edited: May 31, 2010
3. May 31, 2010

### Arijit Dutta

4. May 31, 2010

### Meir Achuz

By working with the potentials and the wave equation, there are 4 source terms and 4 unknowns. These determine E and B.
There are constraints on possible E and B.

5. Jun 1, 2010

### Born2bwire

In addition, there are really three independent Maxwell's equations. I believe that you can derive Gauss' Law for Magnetism from the other three laws. I would imagine that if you are able to generate 8 partial differential equations that some of them may be degenerate. In addition to what Meir Achuz stated, there is of course the implicit requirement that boundary conditions are required for a unique solution.

6. Jun 1, 2010

### Phrak

Of Maxwell's equations, they are all independent until the magnetic vector potential and electric potential are introduced as fundamental fields. In this case, Gauss law for magnetism is a mathematical identity. Really though, all that is needed is to posit a 4-vector field (A, phi) and identify first derivatives with components of the electric and magnetic fields. Charge and charge continuity are second derivatives. We could call these identifications equalities if we wish, but other than that, the equal sign doesn't appear.

To answer Arijit Dutta's question, to some amount, any four continuous, twice differentiable, independent scalar valued fields Ax, Ay, Az and phi is a solution.

Last edited: Jun 1, 2010
7. Jun 2, 2010

### |squeezed>

You are right about the number of unknowns in Maxwell's eqs but you must also take into account the constitutive relations.

8. Jun 2, 2010

### Anamitra

We must not forget the charge density $$\rho$$ and the current density j,which has three components. We have ten variables indeed!. In general all these variables are functions of space and time.

Last edited: Jun 2, 2010
9. Jun 2, 2010

### Phrak

To anyone that follows differential p-forms:

We can cover space and time with a 4-vector field A. Amu=Amu(t,x,y,z). mu = {0...3}. Greek indices will range over spacetime. Latin ranges over space.

A is the so called four vector potential. It is unphysical up to a constant field, phi. A-->A'=A+d(phi). Here, A has upper indices.

Unscripted variables in the following are taken to be antisymmetric tensors with upper indices.

F = dA defines the Faraday tensor. It's elements are the electric and magnetic field components. All together, there are 6 independent components as should be expected.

$$F = F_{[\mu\nu]} = (1/2)(F_{\mu\nu}-F_{\nu\mu}) = \partial_{\mu}A_{\nu} - \partial_{\nu}A_{\mu}$$

By mathematical identity, ddA=0. (all exact forms are closed)

ddA=dF=0 says there are no magnetic charges. This equation also contains

$$-(\nabla \times E)_{k}+\partial_{t}B_{k}=0_{k}$$

*d*dF=-J is Faraday's law of magnetic induction and defines electric charge as the divergence of the electric field. (*) is the Hodge duality operator. It takes a tensor with lower indices, mulitiplies it by the completely antisymmetic unit tensor or rank k, with indices raised and lower so as to return a tensor of rank n-k, where n=4 for spacetime.

$$J = J_{\mu},\ and \ J^{\mu} = (J^{i}, \phi)$$

J combines charge density and current density.

10. Jun 2, 2010

### Dickfore

The equations are not independent. For example, from:

$$\mathbf{\textup{curl}} \, \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t}$$

by taking the divergence of both sides and using the vector identity:

$$\textup{div} \, \mathbf{\textup{curl}} \, \mathbf{a} = 0$$

we get:

$$\textup{div} \, \frac{\partial \mathbf{B}}{\partial t} = 0$$

$$\frac{\partial}{\partial t} \left(\textup{div} \, \mathbf{B} \right) = 0$$

$$\textup{div} \, \mathbf{B} = f(\mathbf{r})$$

where $f(\mathbf{r})$ is an arbitrary function of coordinates only. But, according to the Principle of Relativity, this has to hold in any inertial reference frame. Therefore, the only possibility is that this funcion is actually to zero. The second Maxwell equation simply serves as a verification of this, but is not an independent constraint.

Similarly, taking the divergence of the fourth Maxwell equation and using the first one, we get:

$$\frac{\partial \rho}{\partial t} + \textup{div} \, \mathbf{J} = 0$$

This is an additional condition that the external sources (charge and current densities) have to satisfy. It is the continuity equation and is the Law of conservation of charge in a differential form.

11. Jun 3, 2010

### Arijit Dutta

@ Meir Achuz
But what about the guage condition? Isn't it another constraint. So now there r 4 unknowns and 5 equations. Again a question of mutual consistency arises.

@ Phrak
I really don't get all that mathematics. Sorry, but I can't help. I guess I'm not upto ur level in mathematical proficiency.

@Dickfore
You just showed that the Maxwell's equations are mutually consistent as well as consistent with charge conservation and special relativity.

12. Jun 3, 2010

### zeebek

@Dickfore

There can be magnetic monopoles in principle. It does not contradict anything so far, just nobody found them. The equations are independent. I can refer to any famous course on EM. Math does not prove anything .All major physical equations were guessed, not derived.

@Arijit Dutta

ME were not derived, their historical devellopment was just a genious guess based on the experimental facts. There are 2 "dynamic" equations: ampere-maxwell's one and faraday's one, apart from them the conservation of charge should be included ( ampere-maxwell's + gauss's law) and the fact that there are no magnetic monoploes: div B = 0 (anlike electric charges). So they are consistent because they were made consisent. Suggest you to follow Walter Levin's cource on EM
http://www.learnerstv.com/lectures.php?course=ltv008&cat=Physics

Last edited: Jun 3, 2010
13. Jun 3, 2010

### Dickfore

This has nothing to do with the thread. If there is a source term in the second ME, then we must compensate with a convective magnetic current density in the third ME, leading to another continuity equation which is a necessary condition for ME to have a solution, just as the continuity equation for electric charges.

14. Jun 3, 2010

### Antiphon

For completeness let's also include a Lorentz force law on the monopole. F=qH-(vXepsE) where q is the monopole charge, eps is the permittivity of free space, E is the electric field, and v the velocity of the monopole.

15. Jun 4, 2010

### Phrak

This is true up to a constant for all points in spacetime. The constant, is of course, current density.

$$\mathbf{\textup{curl}} \, \mathbf{E} = - \frac{\partial \mathbf{B}}{\partial t} + \mathbf{J}$$

There are exactly four independent variables,

$$A^{\mu} = A(t,x,y,z)\ ,$$

at each spacetime event. These will define the electric field strength, the magnetic field strength and the charge and current density. This is simply because each is derivable from the magnetic potential Ai and electric potential phi. So, as you expected there is some interdependence between E, B, J and charge density.

This, very general result, does not include boundary conditions, so that admissible solutions can include every sort of radiation field.

16. Jun 4, 2010

### Phrak

For completeness we'd also have to include the Lorentz force on electric charges as well.

Allowing nonzero magnetic charge, and ignoring the Lorentz force for a moment, the total number of independent variables is eight.

One element of classical electromagnetism that is never explicitly stated, to my knowledge, is that charge is always associated with mass. This is another constraint. We are given Maxwell's equations plus the Lorentz force, but without exception, in my studies, we are expected to know that all charges have mass. Standing alone, Maxwell's equations are perfectly consistent without associating charge with nonzero mass.

But you elude to a good question, "How does the Lorentz force reduce the number of independent variables?"


text:
# looking for an online map pgm repository

I am currently writing a path planner. I wanted to test the planner for various scenarios.

I was wondering if there is a repository wherein I can find a number of pgm (+yaml) map files.

I came across this link but the two maps mentioned in the answer are very huge. Also, the corresponding yaml file seems to be missing as well.

Also, is there a way one can easily create 'small' maps so as to load them to the map_server ?


text:
Textmate+Rails: Easy partials for better code
22 Dec, 2006

As you may know, I use TextMate for editing Rails code.

I’ve just been browsing the Rails bundle today and I came across some very interesting things. Today I’ll tell you about partials.

Partials are ERb templates. They are mostly HTML (or RJS or XML or whatever output format you use) and include some embedded Ruby to show actual content. Partials are not linked to a method in a controller, but instead they can be easily rendered through-out your application.

TextMate allows you to refactor your application to use partials with almost no effort!

First something about partials for those who don’t know about it.

Partials are stored in files that start with an _ (underscore) and end in .rthml (or .rjs or .rxml) and you may include them in your ERb like this:

< %= render :partial => 'userinfo' %>

This will include the partial _userinfo.rhtml for you. This way you can avoid duplication by including the same ERb template (partial) over and over again.

Partials are also useful to keep your views (templates) clean and easy to understand. In large projects this will allow you later to easily change a view without having to spit through 500 lines of ERb.

Let’s say you have a profile page where you want to show a users’s profile and some options for when the user is viewing his own profile. Also, you want to show a simple message when the users has not yet created a profile, which is a possibility in my application. The show.rhtml template for the profile may look like this

Profile for < %=h @profile.user.login %>

< % if @profile.exists? -%>

< %= @profile.firstname %> has been a member for < %= distance_of_time_in_words_to_now @profile.user.created_at %>

General information
Name: < %= @profile.fullname %>
Country: < %= @profile.country %>
Birthday: < %= fmt_date @profile.birthday %>

About < %= @profile.firstname %>
< %= markdown @profile.about %>

< % else -%>

< %= @profile.user.login %> has been a member for < %= distance_of_time_in_words_to_now @profile.user.created_at %>

Oh my!
This user has not yet created a profile.

< % end -%>

< % if @profile.user.id == current_user.id -%>
Options
This is your profile, so you have some options:

< %= link_to "Change password", :controller => 'account', :action => "change_password" %>

< % end -%>

As you may see, this is chaos. It’s not easy to read and you can’t easily change something when you need to. Wouldn’t it be great to store all three seperate blocks (profile, no profile message and options) in partials?

This is where TextMate does it’s magic. Here’s a before snaphot:

Now, select the part between the if and else statements. This is where a normal profile is shown. Next, use TextMate: SHIFT-CTRL-H. You’ll get a pop-up asking you how you’d like to name the partial. In this case I choose ‘profile’.

After you click OK, the partial will be created containing the code you selected and an appropriate render method is placed instead. This is what the code looks like after:

After all this the same ERb template looks like this:

Profile for < %=h @profile.user.login %>

< % if @profile.exists? -%>
< %= render :partial => 'profile' %>
< % else -%>
< %= render :partial => 'noprofile' %>
< % end -%>

< % if @profile.user.id == current_user.id -%>
< %= render :partial => 'options' %>
< % end -%>

Now, isn’t that more readable? Even, if you want to change a profile, you can just edit _profile.rhtml and you’re done.


text:
# Elasticity of cell membranes

A cell membrane defines a boundary between the living cell and its environment. It consists of lipids, proteins,carbohydrates etc. Lipids and proteins are dominant components of membranes. One of the principal types of lipids in membranes is phospholipid. A phospholipid molecule has a polar hydrophilic head group and two hydrophobic hydrocarbon tails. When a quantity of lipid molecules disperse in water, they will assemble themselves into a bilayer in which the hydrophilic heads shield the hydrophobic tails from the water surroundings because of the hydrophobic forces.

The most widely accepted model for cell membranes is the fluid mosaic model proposed by Singer and Nicolson in 1972 [Science 175 (1972) 720] . In this model, the cell membrane is considered as a lipid bilayer where the lipid molecules can move freely in the membrane surface like fluid, while the proteins are embedded in the lipid bilayer. Some proteins are called integral membrane proteins because they traverse entirely in the lipid bilayer and play the role of information and matter communications between the interior of the cell and its outer environment. The others are called peripheral membrane proteins because they are partially embedded in the bilayer and accomplish the other biological functions. Beneath the lipid membrane, the membrane skeleton, a network of proteins, links with the proteins in the lipid membrane. A more recent model of the cell membrane as a self-organising, dynamic structure in which phospholipids flow in geometric patterns identical to those associated with 'Benard' convection' imbue the cell with its elastic properties is gaining wide acceptance(see 'The Dynamic Template' at )

Elasticity of lipid vesicles

The first step to study the elasticity of cell membranes is to study lipid bilayers. Usually, the thickness of the lipid bilayer is much smaller than the scale of the whole lipid bilayer. It is reasonable to describe the lipid bilayer by a mathematical surface. In 1973, Helfrich [Z. Naturforsch. C 28 (1973) 693] recognized that the lipid bilayer was just like a nematic liquid crystal at room temperature, and then proposed the curvature energy per unit area of the bilayer

(1)

where are bending rigidities. $c_0$ is called the spontaneous curvature of the membrane. $H$ and $K$ are the mean and Gaussian curvature of the membrane surface, respectively.

The free energy of a closed bilayer under the osmotic pressure $Delta p$ (the outer pressure minus the inner one) as:

$F_H=int \left(f_c+lambda\right) dA+Delta pint dV,$ (2)

where $dA$ and $dV$ are the area element of the membrane and the volume element enclosed by the closed bilayer, respectively. $lambda$ is the surface tension of the bilayer. By taking the first order variation of above free energy, Ou-Yang and Helfrich [Phys. Rev. Lett. 59 (1987) 2486] derived an equation to describe the equilibrium shape of the bilayer as:

$Delta p-2lambda H+k_c\left(2H+c_0\right)\left(2H^2-c_0H-2K\right)+k_c abla^2\left(2H\right)=0.$ (3)

They also obtained that the threshold pressure for the instability of a spherical bilayer was

$Delta p_\left\{c\right\}propto k_c/R^3,$ (4)

where $R$ being the radius of the spherical bilayer.

Using the shape equation (3) of closed vesilces, Ou-Yang predicted that there was a lipid torus with the ratio of two generated radii being exactly $sqrt\left\{2\right\}$ [Phys. Rev. A 41 (1990) 4517] . His prediction was soon confirmed by the experiment [Phys. Rev. A 43 (1991) 4525] . Additionally, researchers obtained an analytical solution [Phys. Rev. E 48 (1993) 2304] to (3) which explained the classical problem---the biconcave discoidal shape of normal red cells.

Elasticity of open lipid membranes

The opening-up process of lipid bilayers by talin was observed by Saitoh et al. [Proc. Natl. Acad. Sci. 95 (1998) 1026] arose the interest of studying the equilibrium shape equation and boundary conditions of lipid bilayers with free exposed edges. Capovilla et al. [Phys. Rev. E 66 (2002) 021607] , Tu and Ou-Yang [Phys. Rev. E 68 (2003) 061915] carefully studied this problem. The free energy of a lipid membrane with an edge $C$ is written as

$F_o=int \left(f_c+lambda\right) dA+gammaoint_C ds,$ (5)

where $ds$ and $gamma$ represent the arclength element and the line tension of the edge, respectively. The first order variation gives the shape equation and boundary conditions of the lipid membrane:

$k_\left\{c\right\}\left(2H+c_\left\{0\right\}\right)\left(2H^\left\{2\right\}-c_\left\{0\right\}H-2K\right)-2lambda H+k_\left\{c\right\} abla^\left\{2\right\}\left(2H\right)=0,$ (6) (7) (8) (9) where $k_n$, $k_g$, and $au_g$ are normal curvature, geodesic curvature, and geodesic torsion of the boundary curve, respectively. $mathbf\left\{e\right\}_2$ is the unit vector perpendicular to the tangent vector of the curve and the normal vector of the membrane.

Elasticity of cell membranes

A cell membrane is simplified as lipid bilayer plus membrane skeleton. The skeleton is a cross-linking protein network and joints to the bilayer at some points. Assume that each proteins in the membrane skeleton have similar length which is much smaller than the whole size of the cell membrane, and that the membrane is locally 2-dimensional uniform and homogenous. Thus the free energy density can be expressed as the invariant form of $2H$, $K$, $trvarepsilon$ and $detvarepsilon$:

$f_\left\{cm\right\}=f\left(2H,K,trvarepsilon,detvarepsilon\right),$ (10)

where $varepsilon$ is the in-plane strain of the membrane skeleton. Under the assumption of small deformations, and invariant between $trvarepsilon$ and $-trvarepsilon$, (10) can be expanded up to second order terms as:

(11)

where $k_d$ and $mu$ are two elastic constants. In fact, the first two terms in (11) are the bending energy of the cell membrane which contributes mainly from the lipid bilayer. The last two terms come from the entropic elasticity of the membrane skeleton.

Literature

Reviews on configurations of lipid vesicles

[1] R. Lipowsky, The Conformation of Membranes, Nature 349 (1991) 475-481.

[2] U. Seifert, Configurations of Fluid Membranes and Vesicles, Adv. Phys. 46 (1997) 13-137.

[3] Z. C. Ou-Yang, J. X. Liu and Y. Z. Xie, Geometric Methods in the Elastic Theory of Membranes in Liquid Crystal Phases (World Scientific, Singapore, 1999).

Research papers on closed vesicles

[1] W. Helfrich, Elastic Properties of Lipid Bilayers--Theory and Possible Experiments, Z. Naturforsch. C 28 (1973) 693-703.

[2] O.-Y. Zhong-Can and W. Helfrich, Instability and Deformation of a Spherical Vesicle by Pressure, Phys. Rev. Lett. 59 (1987) 2486-2488.

[3] O.-Y. Zhong-Can, Anchor Ring-Vesicle Membranes, Phys. Rev. A 41 (1990) 4517-4520.

[4] H. Naito, M. Okuda, and O.-Y. Zhong-Can, Counterexample to Some Shape Equations for Axisymmetric Vesicles, Phys. Rev. E 48 (1993) 2304-2307.

[5] U. Seifert, Vesicles of toroidal topology, Phys. Rev. Lett. 66 (1991) 2404-2407.

[6] U. Seifert, K. Berndl, and R. Lipowsky, Shape transformations of vesicles: Phase diagram for spontaneous- curvature and bilayer-coupling models, Phys. Rev. A 44 (1991) 1182-1202.

[7] L. Miao etal., Budding transitions of fluid-bilayer vesicles: The effect of area-difference elasticity, Phys. Rev. E 49 (1994) 5389-5407.

Research papers on open membranes

[1] A. Saitoh, K. Takiguchi, Y. Tanaka, and H. Hotani, Opening-up of liposomal membranes by talin, Proc. Natl. Acad. Sci. 95 (1998) 1026-1031.

[2] R. Capovilla, J. Guven, and J.A. Santiago, Lipid membranes with an edge, Phys. Rev. E 66 (2002) 021607.

[3] R. Capovilla and J. Guven, Stresses in lipid membranes, J. Phys. A 35 (2002) 6233-6247.

[4] Z. C. Tu and Z. C. Ou-Yang, Lipid membranes with free edges, Phys. Rev. E 68, (2003) 061915.

[5] T. Umeda, Y. Suezaki, K. Takiguchi, and H. Hotani, Theoretical analysis of opening-up vesicles with single and two holes, Phys. Rev. E 71 (2005) 011913.

Numerical solutions on lipid membranes

[1] J. Yan, Q. H. Liu, J. X. Liu and Z. C. Ou-Yang, Numerical observation of nonaxisymmetric vesicles in fluid membranes, Phys. Rev. E 58 (1998) 4730-4736.

[2] J. J. Zhou, Y. Zhang, X. Zhou, Z. C. Ou-Yang, Large Deformation of Spherical Vesicle Studied by Perturbation Theory and Surface Evolver, Int J Mod Phys B 15 (2001) 2977-2991.

[3] Y. Zhang, X. Zhou, J. J. Zhou and Z. C. Ou-Yang, Triconcave Solution to the Helfrich Variation Problem for the Shape of Lipid Bilayer Vesicles is Found by Surface Evolver, In. J. Mod. Phys. B 16 (2002) 511-517.

[4] Q. Du, C. Liu and X. Wang, Simulating the deformation of vesicle membranes under elastic bending energy in three dimensions, J. Comput. Phys. 212 (2006) 757.

[5] X. Wang and Q. Du, physics/0605095.

elected papers on cell membranes

[1] Y. C. Fung and P. Tong, Theory of the Sphering of Red Blood Cells, Biophys. J. 8 (1968) 175-198.

[2] S. K. Boey, D. H. Boal, and D. E. Discher, Simulations of the Erythrocyte Cytoskeleton at Large Deformation. I. Microscopic Models, Biophys. J. 75 (1998) 1573-1583.

[3] D. E. Discher, D. H. Boal, and S. K. Boey, Simulations of the Erythrocyte Cytoskeleton at Large Deformation. II. Micropipette Aspiration, Biophys. J. 75 (1998) 1584-1597.

[4] E. Sackmann, A.R. Bausch and L. Vonna, Physics of Composite Cell Membrane and Actin Based Cytoskeleton, in Physics of bio-molecules and cells, Edited by H. Flyvbjerg, F. Julicher, P. Ormos And F. David (Springer, Berlin, 2002).

[5] G. Lim, M. Wortis, and R. Mukhopadhyay, Stomatocyte–discocyte–echinocyte sequence of the human red blood cell: Evidence for the bilayer–couple hypothesis from membrane mechanics, Proc. Natl. Acad. Sci. 99 (2002) 16766-16769.

[6] Z. C. Tu and Z. C. Ou-Yang, A Geometric Theory on the Elasticity of Bio-membranes, J. Phys. A: Math. Gen. 37 (2004) 11407-11429.

[7] Z. C. Tu and Z. C. Ou-Yang, Elastic theory of low-dimensional continua and its applications in bio- and nano-structures, [http://arxiv.org/abs/0706.0001 arxiv:0706.0001] .

Wikimedia Foundation. 2010.

### Look at other dictionaries:

• Cell membrane — Illustration of a Eukaryotic cell membrane The cell membrane or plasma membrane is a biological mem …   Wikipedia

• cell — cell1 cell like, adj. /sel/, n. 1. a small room, as in a convent or prison. 2. any of various small compartments or bounded areas forming part of a whole. 3. a small group acting as a unit within a larger organization: a local cell of the… …   Universalium

• Lipid bilayer — [ phosphatidylcholine.] A lipid bilayer or bilayer lipid membrane (BLM) is a membrane composed of lipid molecules (usually phospholipids). The lipid bilayer is a critical component of all biological membranes, including cell membranes, and so is… …   Wikipedia

• aging — ag·ing (āʹjĭng) n. 1. The process of growing old or maturing. 2. An artificial process for imparting the characteristics and properties of age. * * * Gradual change in an organism that leads to increased risk of weakness, disease, and death. It… …   Universalium

• Atherosclerosis — For the journal, see Atherosclerosis (journal). Atherosclerosis Classification and external resources The progression of atherosclerosis (size exaggerated; see text) ICD 10 …   Wikipedia

• reproductive system, animal — Introduction       any of the organ systems by which animals reproduce.       The role of reproduction is to provide for the continued existence of a species; it is the process by which living organisms duplicate themselves. Animals compete with… …   Universalium

• Hans Alfred Nieper — Dr. Hans Alfred. Nieper (1928 1998) was a famous German physician, physicist and widely respected cancer specialist (oncologist) who was a pioneer in creating gene repairing and gene extinguishing substances for cancer. Dr. Hans Nieper was the… …   Wikipedia

• Niemann-Pick disease, type C — Classification and external resources ICD 10 E75.2 (ILDS E75.230) ICD 9 272.7 …   Wikipedia

• human body — Introduction       the physical substance of the human organism, composed of living cells and extracellular materials and organized into tissues, organs, and systems.       Human anatomy and physiology are treated in many different articles. For… …   Universalium

• fungus — fungic /fun jik/, adj. funguslike, adj. /fung geuhs/, n., pl. fungi /fun juy, fung guy/, funguses, adj. n. 1. any of a diverse group of eukaryotic single celled or multinucleate organisms that live by decomposing and absorbing the organic… …   Universalium


text:
# A* in Clojure - trickier than I expected

While working through some coding puzzles to brush up on Clojure, I encountered the need to use A* on some search problems. I tried to implement it from first principles/memory and that didn't go well, so I looked for existing implementations and found two (Joy of Clojure and cgrand's) but they were a little difficult to follow (for me) so I attempted to create my own. In the end it actually looks pretty close to cgrand's implementation.

I think this works as expected (using an example from here to verify), but just wanted to post to see if anybody can point out any glaring omissions / oversights. I've implemented this before in Python but it turned out to be quite different without using mutation.

The only issue I see is that I generate neighbors before testing whether I've already seen the node, so there is some inefficiency there. I couldn't figure out a good way to avoid this since my neighbor generation / filtering occurs in one step during the recursive call, whereas in languages allowing mutability you would process each child separately and you can test if it exists in the visited set each time.

(defn a-star-search
[start neighbor-func goal? remain-cost path-cost]
(loop [q (conj (sorted-set) [0 start])
cost-so-far {start 0}
came-from   {start nil}]
(if-let [[node-cost node :as node-state] (first q)]
(if (goal? node)
(reverse (take-while (complement nil?) (iterate came-from node)))
(let [neighbors (neighbor-func node)
prev-node (came-from node)
prev-cost (cost-so-far node)
cheaper (remove #(< (cost-so-far % Double/POSITIVE_INFINITY)
(+ prev-cost (path-cost node %)))
neighbors)
new-nodes (map #(vector (+ prev-cost
(path-cost node %)
(remain-cost %)) %)
cheaper)]
(recur (into (disj q node-state) new-nodes)
(->> cheaper
(map #(vector % (+ prev-cost (path-cost node %))))
(into cost-so-far))
(into came-from (map (juxt identity (fn [_] node)) cheaper)))))
"no more neigbors")))

(def graph {:s {:a 1 :b 4}
:a {:b 2 :c 5 :g 12}
:b {:c 2}
:c {:g 3}})

(def h-vals {:s 7 :a 6 :b 2 :c 1 :g 0})

(a-star-search :s
#(-> % graph keys)
#(= :g %)
h-vals
(fn [from to] (get-in graph [from to])))

I'm not going to be able to do a very thorough review. The code doesn't have anything outright wrong with it, and I'll admit, I've never been able to implement a decent A* implementation. It's just not something that's ever clicked for me very well (cue a new project to fix that).

That said, there's a few minor things that can be pointed out:

(fn [_] node) can be written as (constantly node). Your use of complement suggests you like to avoid explicit functions.

You can also replace:

(map (juxt identity (fn [_] node)) cheaper)

with:

(map vector cheaper (repeat node))

I personally find the latter to be much cleaner. (map vector xs ys) zips xs and ys together into pairs. Here, I'm just zipping cheaper with an infinite list of nodes.

#(-> % graph keys)

can be replaced with:

(comp keys graph)

If, again, you want to avoid explicit functions (although that's not necessarily better).

I don't think returning "no more neighbors" is a great idea. If you need an indicator value for something like this, I'd probably define at the top something like:

(def no-neighbors ::no-neighbors)

Then return no-neighbors. You could also just use ::no-neighbors inline wherever you need it, but then you need to change it multiple places if you ever decide to change the keyword used. IDE's can help with that, but I like to just avoid the problem.

You could avoid the efficiency problem regarding neighbors if you had neighbor-f return a lazy sequence of keys. I can't off hand think of a good way to do that though.

You never use prev-node. It's good to remove dead code like that to remove bulk.

I think that's all I can really comment on. Hopefully someone else can give you a better review regarding the algorithm itself.

Good luck!

• Thanks for the comments - I knew it just felt off writing (map (juxt identity (fn [_] node)) cheaper) - you're suggestion is much cleaner, also I agree constantly conveys intent more clearly than the explicit function I created. The return value on failure was left in by accident - you're right that definitely needs to go (was there for debugging earlier). I think returning the queue for inspection is traditional when you can't find the goal. Prev-node was also left in from an earlier iteration where I needed it (but factored out when came-from was added) - so thx for pointing that out! – Solaxun Jul 7 '18 at 0:43
• I am going to leave it open just in case somebody comments further on the algorithm, but I very much appreciate your recommendations! – Solaxun Jul 7 '18 at 0:43
• alright I don't think anybody is going to comment, accepting your answer. Thx for the pointers! – Solaxun Jul 10 '18 at 17:19
• @Solaxun Np. Unfortunately, I'm really the only frequent Clojure reviewer here. There's Alan and a few others, but they don't seem to check CR often. It's a pain when I want my code reviewed lol. I usually check the Clojure tag at least once a day though, so if you ever need more code reviewed, I'll be here. – Carcigenicate Jul 10 '18 at 17:42


text:
## lraines Group Title A package contains 6 candy canes, 4 of which are cracked. If 2 are selected, find the probability of getting exactly one cracked candy cane. one year ago one year ago

• This Question is Open
1. kropot72

This question relates to sampling without replacement. The hypergeometric distribution applies: $P(1)=\frac{\left(\begin{matrix}4 \\ 1\end{matrix}\right)\left(\begin{matrix}2 \\ 1\end{matrix}\right)}{\left(\begin{matrix}6 \\ 2\end{matrix}\right)}=\frac{4\times 2\times 2}{6\times 5}$

2. jishan

right ans p(1)=8/15

3. kropot72

$P(1)=\frac{4\times 2\times 2}{6\times 5}=\frac{16}{30}=\frac{8}{15}$


text:
# Calculators and complex numbers (Part 5)

In this series of posts, I explore properties of complex numbers that explain some surprising answers to exponential and logarithmic problems using a calculator (see video at the bottom of this post). These posts form the basis for a sequence of lectures given to my future secondary teachers.

To begin, we recall that the trigonometric form of a complex number $z = a+bi$ is

$z = r(\cos \theta + i \sin \theta)$

where $r = |z| = \sqrt{a^2 + b^2}$ and $\tan \theta = b/a$, with $\theta$ in the appropriate quadrant. As noted before, this is analogous to converting from rectangular coordinates to polar coordinates.

There’s a shorthand notation for the right-hand side ($r e^{i \theta}$) that I’ll justify later in this series.

The trigonometric form of a complex number permits a geometric interpretation of multiplication, given in the following theorem.

Theorem. $\left[ r_1 (\cos \theta_1 + i \sin \theta_1) \right] \cdot \left[ r_2 (\cos \theta_2 + i \sin \theta_2) \right] = r_1 r_2 (\cos [\theta_1+\theta_2] + i \sin [\theta_1+\theta_2])$.

While this theorem doesn’t seem all that helpful — just multiplying complex numbers seems easier — this theorem will be a great help for the following problem:

Compute $(\sqrt{3} + i)^{2014}$. (When teaching this in class, I usually choose the exponent to be the current year.)

Let’s discuss the options for evaluating this expression.

Method #1: Multiply it out. (Students reflexively wince in pain — or knowing laughter — when I make this suggestion.)

Method #2: Use the 2014th row of Pascal’s triangle. (More pain and/or laughter.)

Method #3: Use the above theorem. It’s straightforward to write $\sqrt{3} + i$ as $2 \displaystyle \left( \cos \frac{\pi}{6} + i \sin \frac{\pi}{6} \right)$… for reasons that will become apparent later, I tell my students that I’ll use radians and not degrees for this one. Most students can recognize — and this is important, before I formally prove De Moivre’s Theorem — that they need to multiply $2$ by itself 2014 times and add $\displaystyle \frac{\pi}{6}$ to itself 2014 times. Therefore,

$(\sqrt{3} + i)^{2014} = \displaystyle 2^{2014} \left( \cos \frac{2014\pi}{6} + i \sin \frac{2014\pi}{6} \right) = \displaystyle 2^{2014} \left( \cos \frac{1007\pi}{3} + i \sin \frac{1007\pi}{3} \right)$

I then try to coax my students to compute $\displaystyle \cos \frac{1007\pi}{3}$ without a calculator. With some prodding, they’ll recognize that $\displaystyle \frac{1007}{3} = \displaystyle {335}\frac{2}{3}$, and so they can subtract $334\pi$ (not $335\pi$) without changing the values of sine and cosine. Therefore,

$(\sqrt{3} + i)^{2014} = \displaystyle 2^{2014} \left( \cos \frac{5\pi}{3} + i \sin \frac{5\pi}{3} \right)$

$= 2^{2014} \left( \frac{1}{2} - i \frac{\sqrt{3}}{2} \right)$

$= 2^{2013} (1-i\sqrt{3})$

By this point, students absolutely believe that the trigonometric form of a complex number serves a useful purpose. Also, this numerical example has prepared students for the formal proof of DeMoivre’s Theorem, which will be the subject of the next two posts.

For completeness, here’s the movie that I use to engage my students when I begin this sequence of lectures.


text:
# Trigonometric Functions

Consider unit circle centered at origin and point P_0(1,0). If we begin to rotate point P_0 around origin on angle t then we will obtain point P_t.

x-coordinate of this point is called cosine of number t and denoted by cos(t), y-coordinate of this point is called sine of number t and denoted by sin(t).

Tangent of number t is ratio of sine and cosine: tan(t)=(sin(t))/(cos(t)).

Cotangent of number t is ratio of cosine and sine: cot(t)=(cos(t))/(sin(t)).

Secant of number t is sec(t)=1/(cos(t)).

Cosecant of number t is csc(t)=1/(sin(t)).

When we talk about trigonometric functions we can use both radian and degree measure of angle t, but in calculus we almost always use radian measure (unless other stated).

To convert radian measure to degree and vice versa following formulas are used:

1\ rad=(180^0)/pi~~57^0 and 1^0=pi/(180^0)\ rad~~0.017\ rad.

So, pi is 180^0, 2pi is 360^0, pi/2 is 90^0 etc.

Domain of cosine and sine is (-oo,oo), their range is [-1,1].

These functions are periodic with main period 2pi, i.e. sin(x+2pi)=sin(x) and cos(x+2pi)=cos(x) for all x.

Domain of tangent function is all x except those x where cos(x)=0.

Range of tangent function is (-oo,oo).

Tangent is periodic function with period pi: tan(x+pi)=tan(x) for all x.

Domain of cotangent function is all x except those x where sin(x)=0.

Range of cotangent function is (-oo,oo). Cotangent is periodic function with period pi: cot(x+pi)=cot(x) for all x.

Following formulas hold for trigonometric functions. They will be used in further notes:

1. cos^2(x)+sin^2(x)=1 for all x.
2. 1+tan^2(x)=sec^2(x) for all x.
3. 1+cot^2(x)=csc^2(x) for all x.
4. sin(x+-y)=sin(x)cos(y)+-cos(x)sin(y) for all x,y.
5. cos(x+y)=cos(x)cos(y)-sin(x)sin(y) for all x,y.
6. cos(x-y)=cos(x)cos(y)+sin(x)sin(y) for all x,y.
7. tan(x+y)=(tan(x)+tan(y))/(1-tan(x)tan(y)) for all x,y.
8. tan(x-y)=(tan(x)-tan(y))/(1+tan(x)tan(y)) for all x,y.

Trigonometric functions, because of periodicity, are widely used for modeling repetitive events: motion of pendulum, vibrating string, sound waves etc.


text:
Question about Gysin map (pushforward in cohomology)

The setting is the following: $X \subset \mathbb{CP}^r$ is an algebraic subvariety of dimension $n$, codimension $e=r-n$, and degree $d$. Call $j$ the inclusion. Then, Poincaré duality induces a map $$j_*:H^i(X,\mathbb{C}) \rightarrow H^{i+2e}(\mathbb{CP}^r,\mathbb{C}).$$ Denote by $\xi \in H^2(\mathbb{CP}^r,\mathbb{C})$ the hyperplane class and by $\psi$ its pullback to $X$. Then I am given two identities:

(1) $j_*j^*(x)=x \cup (d \xi^e)$;

(2) $j^*j_*(y)=y\cup(d \psi^e)$.

While I see that the first one comes from projection formula and the class of $X$ being $d \xi ^e \in H^*(\mathbb{CP}^r,\mathbb{C})$, I can not figure out the second one. I have been pushing symbols for a while, but without success. The only thing I got is that both sides of (2), if capped with $[X]$ and pushed forward, give the same thing. How can I show the second relation?


text:
My last post covered some considerations for using Spark SQL on a real-world JSON dataset. In particular, schema inference can suffer when you’re ingesting a dataset of heterogeneous objects. In this post, I’d like to sketch out some ways to connect schema inference to type inference, in order to point to automated solutions to some of the problems we’ve seen.

### Background

We’ll start out by reviewing some definitions from the world of type systems:

• a type is a range of values.
• a product type is a compound type that describes structures with multiple values of (possibly) different types (e.g., tuples or records). You can think of a product type as being like the Cartesian product of several other types: if we have types A and B, the type A × B (i.e., the type of pairs of one value in A and one value in B) can represent the Cartesian product of A and B.
• a sum type is a compound type that represents the disjoint union of several other types. Given types A and B, the type A + B represents the sum of A and B (i.e., any value in A or any value in B).

In Scala terms, a simple example of a product type is a tuple:

and a simple example of a sum type is a basic linked list:

Note that, in the case of the linked list (as with other standard recursive data structures), we’re actually looking at a sum type in which one of the summed types is a product type: an IntList can either be an EmptyList or a cons cell, consisting of a pair of an Int value (the head of the list) and an IntList (the tail of the list).

Also note that, in Scala, sum types are tagged. You can statically distinguish between cons cells and the empty list in a case match.1 C programmers are familiar with a related kind of sum type: the untagged union, which describes a structure that can hold one value that can be of several different types. If you have a C union, you’ll need to explicitly track what kind of value it’s holding since you won’t be able to tell what kind of value it contains statically.

### Schema inference

Given a collection of JSON objects,2 a schema inference algorithm produces a type that is the supertype of every object in the collection. (This is an interesting problem only if the collection contains objects of different types.) As an example, consider the following two objects:

The first models some characteristics of a bicycle and the second models some characteristics of a car. Both have gears, but bicycles have data about what kind of pedals and handlebars they include; cars have data about whether or not they include anti-lock brakes (abs) and specify what kind of fuel they expect. If we ask Spark SQL to infer a schema for a collection including these two objects, we’ll get something like this:

root
|-- abs: boolean (nullable = true)
|-- fuel: string (nullable = true)
|-- gears: integer (nullable = true)
|-- handlebars: string (nullable = true)
|-- pedals: string (nullable = true)

Given a collection of objects with types T₁, T₂, ⋯, Tₓ, what we’re trying to get is the sum type T₁ + T₂ + ⋯ + Tₓ . The way we get this type is as an untagged union: we get an object that has the union of all of the fields of T₁, all of the fields of T₂, and so on. (Put another way, we’re really treating a heterogeneous collection as a union of homogeneous collections and identifying its schema as the union of the schemas for each included homogeneous collection.) Just as if we were using a C union, we’d have to figure out whether or not each object was a bicycle or a car. Fortunately, since we’re be in a safe-language context, we’d know that an object with a value in the pedals field wouldn’t have a value in the abs field!

It should be clear that this is a totally reasonable approach, since it combines a straightforward implementation with a pleasant and unsurprising user experience: by adding a simple filter to my queries, I can select only objects of a given type from a heterogeneous collection. For example, if I want to find the mean number of gears for every bicycle with drop handlebars, I could write the following query (assuming I’d registered my SchemaRDD as a table called vehicles):

Since handlebars will be NULL for every car, this query will only consider bicycles. Other collections may not admit such straightforward differentiation between object kinds, of course.

### Problems and possible solutions

#### Tagging diverging types

As I mentioned last week, things begin to break down when we attempt to construct the sum of types that have the same field names but diverging types for those fields, as in the following example:

A few days ago, Spark would have failed to infer a schema for this collection of objects, but open-source development moves quickly and now it will handle the conflicting types by giving users a schema in which the branches field contains an array of strings (and in which every object in the collection has its branches field cast to an array of strings).

In general, it seems like whatever technique we might adopt schema inference should prefer imprecise results to a crash. But are there ways Spark could do a better job of inferring schemas for heterogeneous collections with diverging field types? I believe there might be, and part of the answer is going from untagged unions to tagged unions.

The fedmsg data set is a heterogeneous collection of objects; in some of these objects, the branches field models one concept as an array of strings, and in others, it models a different concept as an array of objects. I solved this problem by preprocessing the JSON to rename the different branches fields – in effect, dividing the branches fields into two tagged possibilities, like this. We could imagine that Spark could handle schema divergence by automatically identifying equivalence classes of field types, perhaps naming them with an integer subscript (e.g., branches_1 and branches_2) or with some abbreviated identifier for the value type, as follows:

Here’s an alternative way we could make the tagging explicit, by wrapping the diverging field’s values in an object:

The advantage to this tagged-union approach is that it makes it possible to write queries that handle heterogeneous collections. The disadvantage is that the path from the schema root to the tagged value will be different from the path to that value in the schemas of any of the objects in the original heterogeneous collection. The schema change may be surprising to the user, but – by definition – any approach to derive a fixed schema for a collection of objects with diverging schemas will not result in a schema that is totally compatible with the objects in the original collection.

#### Identifying maps

The other problem I observed related to encoding maps as JSON objects, as in the following example where we have a map from bicycle names to vehicle objects:

The inferred schema for a collection including an object like this will have a distinct field for every key in every map. In this case, we don’t have an immediately great solution from the broader world of type systems. However, it seems that some heuristic – for example, “if an object has more than n fields and each has a value of the same type, it is a map” – might be able to do a good job of identifying objects that model maps.

In any case, it is possible for the user to preprocess their objects in order to encode maps in a different way if that will make it easier to query the data after ingest.

### Final thoughts

Spark SQL’s support for schema inference is an extremely cool feature, although it obviously isn’t able to work magic by ascribing rigid structure to heterogeneous collections of ad hoc objects. Some minor improvements could make inferred schemas more useful for these kinds of collections, though.

1. Scala doesn’t support untagged union types directly – although there are clever ways to encode them in the type system – and Scala won’t actually be able to infer sum types from collections of untagged values: the inferred type of Array("foo", 1) is Array[Any], not Array[String + Int]

2. (Slightly) more precisely: objects are defined recursively as unordered collections of key-value pairs, where keys are strings and values can be numbers, booleans, strings, objects, or arrays of values.

type systemstype theoryjsonsparksqlscala • You may reply to this post on Twitter or