text:
• Create Account

# tab[10][10] in c

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

11 replies to this topic

### #1 fir   Members   -  Reputation: -464

Like
0Likes
Like

Posted 22 May 2014 - 02:31 PM

This is deadly confusing is such array

int tab[10][10];

a lite/solid block of 100 ints (equivalent of tab[a+b*10] where a is index of right [] and b index of left [] I mean [b][a]) or this is really (as someone say

but it is really hard to belive for me, an array of 10 pointers to 10-int chunks)?

(so really its size is 100 ints + 10 pointers and this pointers can lay far from int contents?)

could comeone finaly explain it to me (but please tell me a sure/solid answer youre sure of, TNX)

### #2ApochPiQ  Moderators   -  Reputation: 20434

Like
9Likes
Like

Posted 22 May 2014 - 02:43 PM

The declaration "T foo[n][m];" in C or C++ creates an array that is equivalent to "T foo[n * m];".

Wielder of the Sacred Wands

### #3rip-off  Moderators   -  Reputation: 10549

Like
9Likes
Like

Posted 22 May 2014 - 04:13 PM

It could be inferred from your question that you may believe that arrays are actually pointers. They are not. This can be confusing as arrays frequently decay into pointers, and function parameters that appear to be arrays are actually syntactic sugar for pointer declarations.

### #4Aardvajk  Crossbones+   -  Reputation: 11246

Like
1Likes
Like

Posted 23 May 2014 - 12:17 AM

What you seem to think it is is called a ragged array (ragged because the rows can be different lengths) and, in C and C++, you'd have to create this manually

int *tab[10];
for(int i = 0; i < 10; ++i)
{
tab[i] = new int[10];
}

There is no built-in support for ragged arrays in the way you are (I think) describing.

### #5frob  Moderators   -  Reputation: 39041

Like
11Likes
Like

Posted 23 May 2014 - 01:48 AM

This is deadly confusing is such array

int tab[10][10];

a lite/solid block of 100 ints (equivalent of tab[a+b*10] where a is index of right [] and b index of left [] I mean [b][a]) or this is really (as someone say
but it is really hard to belive for me, an array of 10 pointers to 10-int chunks)?
(so really its size is 100 ints + 10 pointers and this pointers can lay far from int contents?)

could comeone finaly explain it to me (but please tell me a sure/solid answer youre sure of, TNX)

Moving to For Beginners, and including a bit of a longer description.

Multidimensional arrays in C and in C++ can be a bit tricky if you are coming from another language.

They work differently from how they work in Java, C#, and several others.

The line you have above, int tab[10][10]; creates a block of 100 int values. The name of the block is "tab".

It does not create an array of pointers to other arrays, which is how several other languages work.

Effectively the object "tab" points to the first value, very similar to the way a pointer works, but it is not really a pointer. It is the name of the array. The language allows the name to work almost identically to a pointer, and it can automatically get interpreted as a pointer, but it is really the name of the array.

You can access the first item in the array as tab[0][0], or as tab[0], or as *tab. The compiler treats all of these the same.

Accessing other values gets more interesting.

Logically, when you are using the array, it looks like a square shape, with 10 rows of 10 columns.

0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, ... etc.

In memory, it looks like a flat line of integers, 100 spaces long.

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, ... etc.

The compiler keeps track of the "tab" variable for you as a square block as long as you use array notation. But when you start using pointer notation, it automatically switches to the second, linear format.

You can access elements of the array in several ways.

First, by using its name in array form. tab[0][0] is 0, tab[0][1] is 1, tab [0][2], is 2. These all follow the square block notation. Continuing down row index 0 gives us tab[0][8] is 8. tab[0][9] is 9. ... And then we have the trickery that comes at the end of a row.

The compiler knows (because we defined a [10][10] array) that each row is 10 lines long. They are treated as offset values, so 10 values are 0 to 9. We can access the next element as tab[1][0] for 10. That will cross to the next row. But that is not the only way to cross rows.

If you refer to the memory as pointers instead of arrays, it gives you lines like this: int tab[10][10]; int* ptr = tab; ++ptr; then the pointer ptr points at the second element. Using ++ptr will advance to the third element. Another ++ptr will continue for the next value, ++ptr advancing again, all the way through the 100 values in your array. Just be careful, since you are only guaranteed to have 100 blocks of memory. You can advance one space past the end, but trying to actually use that space is undefined. It might work fine, it might crash your program, it might format your hard drive. Be careful about the end of arrays.

Internally, the language does a bit of fancy work for you. When you use a multidimensional array notation, the compiler can treat several things as equivalent. When you define an array with sizes (we'll call them ROWS and COLUMNS), such the definition "int tab[ROWS][COLUMNS];", the compiler can treat an array notation tab[x][y] as though you used the pointer notation "*(tab+(COLUMNS*x)+y)". You don't need to write out the multiplication and addition yourself, just writing tab[x][y] allows the compiler to do that work for you.

The language doesn't care if the programmer uses array notation or pointer notation, it can easily switch between the two. The compiler is just trying to figure out the right spot in memory, and for C, it doesn't matter what route you use as long as you reach the proper destination.

When you use array notation, the language knows that a multidimensional array has a specific size. When you use tab[x][y] it knows that you are trying to reach row x column y of your block of memory, and internally will find the offset with multiplication and addition, using the"*(tab+(COLUMNS*x)+y)" formula internally to interpret the array.

When using array notation, if you use fewer specifiers it will still do the same work. It will assume an unspecified index is zero. tab[1] is the same as tab[1][0] and refers to value 10, tab[2] is the same as tab[2][0] and refers to value 20, tab[3] is the same as tab[3][0] and refers to value 30, and so on. The compiler knows the size and will still do the math to find the right offset it memory.

This also means that tab[1][0], tab[0][10], and tab[2][-10] all refer to the same location in memory. You could also use *(tab+10) or *(tab+(10*1)+0) or many other ways to reach the same slot of memory. All that matters is that when the computer adds and multiplies and does all the math, the number for the memory slot is correct.

An array in C is a contiguous block of memory, the size of all the array dimensions multiplied together. When you use array notation the compiler does the math for you to find the offset into that block of memory. When you use pointer notation you need to do the math to find the offset.

You can use this for any size of multidimensional array.

If we had three dimensions, and name the dimensions RANK, ROWS, and COLUMNS, then defined a variable like "int foo[RANK][ROWS][COLUMNS];" we will make single block of integers that is RANK * ROWS * COLUMNS long. The formula applies just as well to additional dimensions. If you used foo[a][b][c] it is identical to using "*(foo+(a*(ROWS*COLUMNS))+(b*COLUMNS)+c)". It will do all the math internally to find the correct offset inside the block of memory.

This is very different behavior from languages like Java and C#, where multidimensional arrays work differently, which seems to be the source of your confusion. The closest thing to the Java and C# behavior is what Aardvajk wrote above. In that case you need to specify an array of arrays rather than array of int values, and then create new internal arrays. These will not be located consecutively in memory, but may be scattered everywhere. You also cannot access them with a continuous pointer notation, you will need to dereference the first array, then dereference into the second array.

Check out my book, Game Development with Unity, aimed at beginners who want to build fun games fast.

Also check out my personal website at bryanwagstaff.com, where I occasionally write about assorted stuff.

### #6Pink Horror  Members   -  Reputation: 2447

Like
2Likes
Like

Posted 23 May 2014 - 05:41 PM

You can access the first item in the array as tab[0][0], or as tab[0], or as *tab. The compiler treats all of these the same.

I don't consider those are all the same. tab[0][0] is an int, and tab[0] and *tab are arrays. The things they refer to all have the same memory address, but the compiler does not treat them all the same. Well, the last two are the same because *x and x[0] are generally the same (I think operator overloading is about the only thing that can make them work differently).

int tab[10][10];

int* p1 = tab[0];
int* p2 = (int*)tab;
int* p3 = &tab[0][0];
int (*p4)[10] = tab;

assert(p1 == p2 && p1 == p3 && p1 == *p4);

### #7 fir   Members   -  Reputation: -464

Like
0Likes
Like

Posted 26 May 2014 - 04:03 AM

You can access the first item in the array as tab[0][0], or as tab[0], or as *tab. The compiler treats all of these the same.

I don't consider those are all the same. tab[0][0] is an int, and tab[0] and *tab are arrays. The things they refer to all have the same memory address, but the compiler does not treat them all the same. Well, the last two are the same because *x and x[0] are generally the same (I think operator overloading is about the only thing that can make them work differently).

int tab[10][10];

int* p1 = tab[0];
int* p2 = (int*)tab;
int* p3 = &tab[0][0];
int (*p4)[10] = tab;

assert(p1 == p2 && p1 == p3 && p1 == *p4);

Allright thanx for the answers all (Im not quite that newbie in c but still there are some subtle things that can confuse me)

Got yet two questons related to thing said above

1)

if i got

int tab[10][10];

what type has tab[1] ? is this an 10-int array of

{ tab[1][0], tab[1][1], ... tab[1][9] } ?

2) what is the way or recast one dimensional array into two dimensional, say i got

int tab1[100];

and want to 'recast' it  into

int tab2[10][10];

I would preferably got to pointers  tab1 for flat adressing and tab2 for [][] adressing of the same memory chunk)

(could then acces like tab[y][x]; could be slower or faster  than hand writting of tab[y*10+x] ?)

### #8Vortez  Crossbones+   -  Reputation: 2709

Like
0Likes
Like

Posted 26 May 2014 - 07:02 AM

Just think about the [] as a way for the compiler to calculate the offset from the first element of the array to the one you want.

1)

int tab[10][10];

what type has tab[1] ? is this an 10-int array of

This make no sense, it won't even compile. tab[1][0] is just a way of saying, hey, i want the int at location &tab[0][0] + (((1 * 10) + 0) * sizeof(int))

2) no need for indexing at all...

memcpy(&tab1[0], &tab2[0][0], 100 * sizeof(int));

To answer the question, i doubt it will be faster, since the compiler does the exact same thing i believe.

Edited by Vortez, 26 May 2014 - 07:15 AM.

### #9DvDmanDT  GDNet+   -  Reputation: 1515

Like
0Likes
Like

Posted 26 May 2014 - 07:08 AM

a. Let the compiler do as much as possible, it usually knows best.

b. You typically shouldn't care about performance for small things like these. Both are way faster than "enough" and trying to optimize will typically just give you headaches for other reasons.

c. There is rarely a universal answer to which is faster in these types of questions, it'll depend on lots of things and will therefore vary on a case by case basis.

### #10nobodynews  Crossbones+   -  Reputation: 2998

Like
0Likes
Like

Posted 26 May 2014 - 12:46 PM

1)

if i got

int tab[10][10];

what type has tab[1] ? is this an 10-int array of

{ tab[1][0], tab[1][1], ... tab[1][9] } ?

I believe Vortez meant specifically the notation you used at the bottom ( { tab[1][0], ... etc ) as 'not making sense'. I would say that tab[1] does have a type, which is an array of 10 ints. That is, if you did size(tab[1]) that would return the same result as 10*sizeof(int). This doesn't really help anything though because you can't do much with this information. You can't assign arrays to each other.

2) what is the way or recast one dimensional array into two dimensional, say i got

int tab1[100];

and want to 'recast' it into

int tab2[10][10];

I would preferably got to pointers tab1 for flat adressing and tab2 for [][] adressing of the same memory chunk)

(could then acces like tab[y][x]; could be slower or faster than hand writting of tab[y*10+x] ?)
You can't cast arrays of one type to another type like that in C.

Besides, you generally don't want to waste your time optimizing at that level. What you should be spending time on is understanding things at the algorithm level. Doesn't matter how quick it is to access tab[y][x] vs tab[y*10+x] if the algorithm you're using it in stinks. Even if you picked the best algorithms the best optimization is probably to use the appropriate compiler intrinsic. The best way to tell what to focus on and when is to understand how to profile your code. What works best in one situation won't work best in another situation.

C++: A Dialog | C++0x Features: Part1 (lambdas, auto, static_assert) , Part 2 (rvalue references) , Part 3 (decltype) | Write Games | Fix Your Timestep!

### #11Pink Horror  Members   -  Reputation: 2447

Like
1Likes
Like

Posted 26 May 2014 - 05:32 PM

1)

if i got

int tab[10][10];

what type has tab[1] ? is this an 10-int array of

{ tab[1][0], tab[1][1], ... tab[1][9] } ?

2) what is the way or recast one dimensional array into two dimensional, say i got

int tab1[100];

and want to 'recast' it  into

int tab2[10][10];

1. tab[1] is the same type as tab[0] - they are both arrays of 10 ints. As arrays of ints, they are also usable as pointers to ints without casting.

2.
int tab1[100];
int (*tab2)[10] = (int (*)[10])tab1;

Note that you have to know the 10 at compile time, which means you'll probably still find yourself using (10*y + x) whenever you need something with a dynamic size (I need dynamic sizing more often than not). I've used this cast when working on arrays full of vectors or triangles or other objects which were just some number of floats each, stored as some type I didn't want to deal with.

### #12 fir   Members   -  Reputation: -464

Like
-2Likes
Like

Posted 27 May 2014 - 03:05 AM

1)

if i got

int tab[10][10];

what type has tab[1] ? is this an 10-int array of

{ tab[1][0], tab[1][1], ... tab[1][9] } ?

2) what is the way or recast one dimensional array into two dimensional, say i got

int tab1[100];

and want to 'recast' it  into

int tab2[10][10];

1. tab[1] is the same type as tab[0] - they are both arrays of 10 ints. As arrays of ints, they are also usable as pointers to ints without casting.

2.
int tab1[100];
int (*tab2)[10] = (int (*)[10])tab1;

Note that you have to know the 10 at compile time, which means you'll probably still find yourself using (10*y + x) whenever you need something with a dynamic size (I need dynamic sizing more often than not). I've used this cast when working on arrays full of vectors or triangles or other objects which were just some number of floats each, stored as some type I didn't want to deal with.

allright tnx, best answer here (where vortez and nobodynews gave false answers)

could you say me maybe how is read this "(int (*)[10])"  type

pointer to array of 10 ints?

sad this is not dymaic working cast, youre right, I would need

it to recast adressing of my pixelbuffer which is dynamic size

so it still will be not working-

- bit sad I can Imagine physically posible in c to doing such

dynamic recasts to though maybe it would break some c common rules where typing is static (with possible recast everywhere but still to exact static type)

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS


text:
# Need a reference on period of LFSRs

I need a reference for the fact that each LFSR with XOR operation has a period of $2^m-1$ excluding zero state and every LFSR with XNOR operations has the same period excluding all ones state.

I want to cite it when I'm writing about the usage of LFSR in a paper, I've found some references but they avoid a proof and all of them include only the case of XOR operations.

Since LFSRs are mostly used in signal processing I ask it here.

Edit: I know that the feedback polynomial should be primitive.

• L in LFSR means Linear and so an LFSR with XNOR operation is, by definition, not an L FSR but merely an FSR/ Also, as Nir Regev's answer points out, your "fact" for which you need a reference is not true. – Dilip Sarwate Oct 18 '15 at 18:07
• @DilipSarwate I assume that the feedback polynomial is primitive, For XNOR operation I've found Xilinx, however I need a reference for it – SMA.D Oct 18 '15 at 18:14

Not all LFSRs have the property of maximum cycle length. In fact, those who do have this property are based on a primitive polynomial of order n. It is a basic property of the extension field $GF(2^n)$ which is "spanned" by this primitive polynomial. The LFSR merely iterates through all of the powers of the polynomial primitive root.
• XOR + negation = XNOR. negation over GF(2) is + 1. i.e. over GF(2) XOR(a,b) = a+b and XNOR(a,b) = a+b+1 (remember that everything is modulo 2), so basically the all ones state negated will turn into the all zeros state which is not a valid state for LFSR. In any case, it'll not change the cycle period which will stay $2^n-1$ – Nir Regev Oct 18 '15 at 19:58

format: plain


text:
Problem 724
The beam shown in Fig. P-724 is only partially restrained at the wall so that, after the uniformly distributed load is applied, the slope at the wall is $w_oL^3 / 48EI$ upward to the right. If the supports remain at the same level, determine $R$.

Solution

0 likes


text:
# PlaceholderValue¶

class propertyestimator.attributes.PlaceholderValue[source]

A class to act as a place holder for an attribute whose value is not known a priori, but will be set later by some specialised code. This may include the input to a protocol which will be set by a workflow as the output of an executed protocol.

__init__()

Initialize self. See help(type(self)) for accurate signature.

Methods

 __init__ Initialize self.


text:
# OpenFOAM can not find (Windows/Microsoft) MPI libraries

2 messages
 Administrator The external solvers OpenFOAM, SU2, and FEniCS all depend on MPI (https://en.wikipedia.org/wiki/Message_Passing_Interface) libraries to enable solving problems in parallel. The interfaces are typically set-up automatically when installing the external solvers. If they are not you must install MPI libraries, which depends on your operating system (OS).   https://www.featool.com/doc/openfoam.html#install_of_mpiWith OpenFOAM it is recommended to use the ESI distribution https://www.openfoam.com/download/openfoam-mingw-cross-compilation, which should include MPI libraries. Otherwise, as suggested in the error message Microsoft provides Windows compatible MPI libraries via https://www.microsoft.com/en-us/download/details.aspx?id=100593You can test if the MPI libraries can be found by running the following commands in Matlab  if( ispc() ) [st1,res1] = system('mpiexec /?') [st2,res2] = system('mpirun /?"') else [st1,res1] = system('bash -c "mpiexec -V"') [st2,res2] = system('bash -c "mpirun -V"') end if either of "st1" or "st2" return zero (0 = no system call error) MPI libraries could be found.


text:
American Institute of Mathematical Sciences

ISSN:
1930-5311

eISSN:
1930-532X

All Issues

Journal of Modern Dynamics

January 2007 , Volume 1 , Issue 1

Select all articles

Export/Reference:

2007, 1(1): 1-35 doi: 10.3934/jmd.2007.1.1 +[Abstract](1098) +[PDF](308.5KB)
Abstract:
The paper discusses a number of open questions,which were collected during the AIM workshop “Emerging applications of measure rigidity”. The main emphasis is made on the rigidity problems in the theory of dynamical systems and their connections with Diophantine approximation, arithmetic geometry, and quantum chaos.
2007, 1(1): 37-60 doi: 10.3934/jmd.2007.1.37 +[Abstract](936) +[PDF](231.8KB)
Abstract:
Let $X$ be a vector field on a compact connected manifold $M$. An important question in dynamical systems is to know when a function $g: M\to \mathbb{R}$ is a coboundary for the flow generated by $X$, i.e., when there exists a function $f: M\to \mathbb{R}$ such that $Xf=g$. In this article we investigate this question for nilflows on nilmanifolds. We show that there exists countably many independent Schwartz distributions $D_n$ such that any sufficiently smooth function $g$ is a coboundary iff it belongs to the kernel of all the distributions $D_n$.
2007, 1(1): 61-92 doi: 10.3934/jmd.2007.1.61 +[Abstract](1060) +[PDF](288.0KB)
Abstract:
We make use of representation theory to study the first smooth almost-cohomology of some higher-rank abelian actions by parabolic operators. First, let $N$ be the upper-triangular group of $SL(2,\mathbb{C})$, $\Gamma$ any lattice and $\pi = L^2(SL(2,\mathbb{C})$/$\Gamma)$ the usual left-regular representation. We show that the first smooth almost-cohomology group $H_a^1(N, \pi)$ $H_a^1(SL(2,\mathbb{C}) , \pi)$. In addition, we show that the first smooth almost-cohomology of actions of certain higher-rank abelian groups $A$ acting by left translation on $(SL(2,\mathbb{R}) \times G)$/$\Gamma$ trivialize, where $G = SL(2,\mathbb{R})$ or $SL(2,\mathbb{C})$ and $\Gamma$ is any irreducible lattice. The abelian groups $A$ are generated by various mixtures of the diagonal and/or unipotent generators on each factor. As a consequence, for these examples we prove that the only smooth time changes for these actions are the trivial ones (up to an automorphism).
2007, 1(1): 93-105 doi: 10.3934/jmd.2007.1.93 +[Abstract](1070) +[PDF](139.5KB)
Abstract:
Our main purpose is to present a surprising new characterization of the Shannon entropy of stationary ergodic processes. We will use two basic concepts: isomorphism of stationary processes and a notion of finite observability, and we will see how one is led, inevitably, to Shannon's entropy. A function $J$ with values in some metric space, defined on all finite-valued, stationary, ergodic processes is said to be finitely observable (FO) if there is a sequence of functions $S_{n}(x_{1},x_{2},...,x_{n})$ that for all processes $\mathcal{X}$ converges to $J(\mathcal{X})$ for almost every realization $x_{1}^{\infty}$ of $\mathcal{X}$. It is called an invariant if it returns the same value for isomorphic processes. We show that any finitely observable invariant is necessarily a continuous function of the entropy. Several extensions of this result will also be given.
2007, 1(1): 107-122 doi: 10.3934/jmd.2007.1.107 +[Abstract](1079) +[PDF](144.2KB)
Abstract:
We provide sufficient conditions on a positive function so that the associated special flow over any irrational rotation is either weak mixing or $L^2$-conjugate to a suspension flow. This gives the first such complete classification within the class of Liouville dynamics. This rigidity coexists with a plethora of pathological behaviors.
2007, 1(1): 123-146 doi: 10.3934/jmd.2007.1.123 +[Abstract](1160) +[PDF](229.1KB)
Abstract:
We prove that every smooth action $\a$ of $\mathbb{Z}^k,k\ge 2$, on the $(k+1)$-dimensional torus whose elements are homotopic to corresponding elements of an action $\a_0$ by hyperbolic linear maps preserves an absolutely continuous measure. This is the first known result concerning abelian groups of diffeomorphisms where existence of an invariant geometric structure is obtained from homotopy data.
We also show that both ergodic and geometric properties of such a measure are very close to the corresponding properties of the Lebesgue measure with respect to the linear action $\a_0$.
2007, 1(1): 147-153 doi: 10.3934/jmd.2007.1.147 +[Abstract](1196) +[PDF](87.4KB)
Abstract:
Let $T$ be a measure-preserving transformation of a metric space $X$. Assume $T$ is conservative and $X$ can be covered by a countable family of open sets, each of finite measure. Then any eigenfunction is invariant with respect to the stable foliation of $T$.

2018  Impact Factor: 0.295


text:
# XNA Distortion Shader problem

So I came up with a distortion pixel shader in hlsl, but it has some issues. First of all, here is how it works:

The shader uses another texture generated by the program as a distortion "map" (if that's the correct term) I called this map a "mask".

The shader uses the red values in the mask for horizontal distortion and the blue values as vertical distortion. The green values are not used.

It subtracts 0.5 from the red and green values so that they have a range from -0.5 to 0.5 instead of 0 to 1. This lets the distortion go in any direction using only two color values.

I let the shader "push" pixels up to 128 pixels.

sampler s0;
texture textu;
sampler tex_sampler = sampler_state{Texture = textu;};
float2 screenSize;

float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0
{
float4 tex_color = tex2D(tex_sampler, coords);

if (tex_color.a)
{
float distX = (tex_color.r - 0.5f) * (256.0f / screenSize.x) * tex_color.a;
float distY = (tex_color.b - 0.5f) * (256.0f / screenSize.y) * tex_color.a;

return tex2D(s0, float2(coords.x + distX, coords.y + distY));
}
return tex2D(s0, coords);
}

technique Technique1
{
pass Pass1
{
}
}

"textu" being the mask, "tex_color" is the color value from the mask. It also multiplies the distortion by the alpha value in the mask.

This seemed to work perfectly at first, but I started noticing some issues. I was using a completely white texture (as the mask) that was blurred around the edges. I set the color of this texture based on its rotation. Here is the method I used for that:

private Color GetDirectionColor(float rad)
{
Vector2 v = new Vector2(
);

float r = (v.X * 0.5f) + 0.5f;
float b = (v.Y * 0.5f) + 0.5f;

return new Color(new Vector3(r, 0, b));
}

This allows the texture to "push" pixels in whatever direction it is facing. This method seems to work fine.

The problem is, when the texture is rotated more than 135 degrees and less than 315 degrees (as in, the texture is pointing into the upper left half of a circle if you cut it in half at a 45 degree angle) it does something strange. Where the texture is blurred (the alpha values become less than 1) it starts to "push" the pixels in the opposite direction that it should be.

I suspect this has to do with my shader and not something else in the program. Possibly the -0.5f part???

I'm terribly sorry if this is confusing... I could not find a better way to word it.

Thanks a lot for your help!

Ok I was able to fix the issue on my own!

I figured out that all color values become less as the mask blurs. So where the mask was fading out, not only were the A values fading, but the R G and B values were fading too! I'm not sure why that is, but here is the change that fixed it:

sampler s0;
texture textu;
sampler tex_sampler = sampler_state{Texture = textu;};
float2 screenSize;

float4 PixelShaderFunction(float2 coords: TEXCOORD0) : COLOR0
{
float4 tex_color = tex2D(tex_sampler, coords);

if (tex_color.a)
{
float resolver = (1.0f - tex_color.a) * 0.5f;

float distX = ((tex_color.r + resolver) - 0.5f) * (256.0f / screenSize.x) * tex_color.a;
float distY = ((tex_color.b + resolver) - 0.5f) * (256.0f / screenSize.y) * tex_color.a;

return tex2D(s0, float2(coords.x + distX, coords.y + distY));
}
return tex2D(s0, coords);
}

technique Technique1
{
pass Pass1
{


text:
# Bose-Einstein and Fermi-Dirac distributions in nonextensive quantum statistics: Exact and interpolation approaches - Condensed Matter > Statistical Mechanics

Bose-Einstein and Fermi-Dirac distributions in nonextensive quantum statistics: Exact and interpolation approaches - Condensed Matter > Statistical Mechanics - Descarga este documento en PDF. Documentación en PDF para descargar gratis. Disponible también para leer online.

Abstract: Generalized Bose-Einstein BE and Fermi-Dirac FD distributions innonextensive quantum statistics have been discussed by the maximum-entropymethod MEM with the optimum Lagrange multiplier based on the exact integralrepresentation Rajagopal, Mendes, and Lenzi, Phys. Rev. Lett. {\bf 80}, 39071998. It has been shown that the $q-1$ expansion in the exact approachagrees with the result obtained by the asymptotic approach valid for $Oq-1$.Model calculations have been made with a uniform density of states forelectrons and with the Debye model for phonons. Based on the result of theexact approach, we have proposed the {\it interpolation approximation} to thegeneralized distributions, which yields results in agreement with the exactapproach within $Oq-1$ and in high- and low-temperature limits. By using thefour methods of the exact, interpolation, factorization and superstatisticalapproaches, we have calculated coefficients in the generalized Sommerfeldexpansion, and electronic and phonon specific heats at low temperatures. Acomparison among the four methods has shown that the interpolationapproximation is potentially useful in the nonextensive quantum statistics.Supplementary discussions have been made on the $q-1$ expansion of thegeneralized distributions based on the exact approach with the use of theun-normalized MEM, whose results also agree with those of the asymptoticapproach.

Autor: Hideo Hasegawa Tokyo Gakugei Univ.

Fuente: https://arxiv.org/


text:
# CH2F2 Polar or Nonpolar

Come on friends today we will talk about CH2F2 Polar or Nonpolar. Is CH2F2 polar or nonpolar? A general question can be answered easily because CH2F2 is a polar molecule because the structure of this molecule has partial positive and negative charges depending on the pull of electrons.

## CH2F2 – Difluoromethane

It is a polar organic compound belonging to the halogen-alkane class, chemically known as difluoromethane, also known as R-32 or HFC-32. Difluoromethane is a colorless and odorless gas that is present in the atmosphere. In addition, this gas is non-toxic and non-flammable.

### structure:

Structurally, this molecule is an improved form of methane, except that methane’s two hydrogens (CH4) are replaced by two fluorine atoms, giving a halogen atom with the chemical formula CH2F2, a hydrocarbon. The molecular formula is 52.023 g/mol.

## physical and chemical properties:

Melting Point: -52°C

Boiling point: -136°C

Density: at 25 °C; 0.961 and at 0 °C (in the liquid state); 1.502

Solubility: Insoluble in water while soluble in ethanol

Vapor pressure: 1.26 E 4 mm Hg at 25 °C

### Use:

• One of the major uses of difluoromethane is as a ‘refrigerant’ because it has excellent heat transfer performance during evaporation and condensation.
• It is also used in air conditioners in some countries.

### Polarity of CH2F2:

The term polarity can be briefly explained as the separation of electric charges in a molecule, producing a dipole moment with two oppositely charged ions, i.e. positive and negative. This is done by the electron pulling by the atoms.

Not all of them exhibit such activity, only the atoms with higher electronegativity attract the bonding electron pair. This action causes unequal distribution of electrons between the bonded atoms and leads to the formation of partial negative and positive charges on the molecule making it polar in nature.

The polarity of a molecule can be easily identified according to the Pauling scale:

Non-polar molecules, when the difference between the electronegativity is less than 0.4.

Polar molecules, when the difference between electronegativity is between 0.4 and 2.0.

ionic molecules, when the difference between the electronegativity is greater than 2.0.

The question of whether CH2F2 is polar or non-polar can be quite confusing. To clear your mind, the concept leading to the answer to the question is described below:

## Polar molecule:

• Atoms with polar bonds between them form a polar molecule. This type of bond forms when the difference between the electronegativity of the participating atoms is greater than 0.4 and less than or equal to 2.0, creating a partial positive and a partial negative charge on the molecule.
• Not only this, polar molecules can also be formed when chemical bonds are arranged in such a way that the arrangement leads to a more positive charge from one side to the other.
• These molecules are asymmetric in shape because of either the presence of electronegativity differences between the atoms or the presence of a lone pair of electrons on the central atom.

The following are some examples of a polar molecule with a polar bond due to a greater electronegativity difference:

### Non-polar Molecules:

• Similarly atoms with non-polar bonds between them form a non-polar molecule. This type of molecule does not have any distinct electrical charge which means there is no positive or negative charge like polar molecules. The charges are evenly distributed throughout the molecule.
• A non-polar bond is formed when the difference between the electronegativity of the participating atoms is less than 0.4.
• These molecules are symmetric in shape, as they do not have a shared pair of electrons.

The following are some examples of non-polar molecules with little or no electronegativity difference:

### Electronegativity:

It is one of the major atomic properties based on the share of electrons. Electronegativity can be defined as;

“The tendency of an atom to attract bonding pairs of electrons to itself.”

Electronegativity can be measured using a system called the Pauling scale. This value is never constant, it varies depending on its ability to attract electrons. Fluorine is considered the most electronegative element while cesium and francium are the least electronegative elements on the scale.

The following are the electronegativities of some commonly used elements:

### Partial Charges:

When charges are measured in elementary charge units, a non-integer charge is called a partial charge.

This type of charge appears due to the unequal distribution of electrons in a bond. It can also be called ‘net atomic charge’. Partial charge is denoted by the Greek letter. The positivity and negativity of charges depend on the force of attraction of the two bonded atoms. The greater the electronegativity, the greater the force of attraction and the greater the partial negative charge. Whereas less negativity, less will be the force of attraction and there will be partial positive charge.

Example: HCl molecule contains hydrogen and chlorine atoms with electronegativity values: H = 2.20 .

 𝛿+ H ---- Cl 𝛿-

### CH2F2 Polar or nonpolar:

To determine whether CH2F2 is polar or nonpolar, first you need to know about the structure of the molecule.

It has a tetrahedral structure with a carbon atom in the middle of the structure surrounding four other atoms, two of which are hydrogen and the other two fluorine atoms. There is no lone pair of electrons on the molecule. Whereas the electronegativity of atoms are:

c = 2.55

F = 3.98

h = 2.20

The difference between the electronegativity of carbon (central atom) and fluorine is found to be:

 3.98 – 2.55 = 1.43

The answer is greater than 0.4 which indicates that the molecule is definitely polar. This difference also suggests that electrons are more attracted to fluorine than to carbon, resulting in partial positive and negative charges. Also the presence of two fluorine atoms suggests that the molecule has a slightly stronger dipole moment.

Summary: It is therefore quite clear that the CH2F2 molecule is a polar molecule with a polar bond with an electronegativity difference of 1.43, which gives a partial positive charge to the carbon atom and a partial negative charge to the fluorine atom.

## Polarity of other molecules:

Apart from CH2F2 being a polar molecule, there are some other molecules as well which are illustrated below:

### CO2 Polar or Non-Polar:

To learn about CH2F2 polar or nonpolar, now learn about O2 polar or nonpolar. Carbon dioxide is a colorless gas that is present in small amounts in the atmosphere. Structurally it is a linear molecule and is composed of one carbon atom and two oxygen atoms. The bonding between the two atoms is covalent bond which means that either the molecule has a polar bond or a non-polar bond.

The electronegativity of the bonded atoms are:

c = 2.55

o = 3.44

The difference between them is found in:

 3.44 – 2.55 = 0.89

This suggests that the molecule must have positive and negative charges and dipole moments. But this is not the case in this molecule, since the molecule is linearly arranged, the structure can be shown as:

 O === C === O

The effect of the partial negative charges on either side of the carbon cancel each other out giving zero dipole moment. Hence, making the molecule non-polar despite the electronegativity difference.

### NH3 Polar or Nonpolar:

NH3 is commonly known as ammonia gas. It is a colorless gas with a strong pungent odor. Most of the ammonia produced is used in agriculture and as a refrigerant gas. It is quite clear from its formula that a central nitrogen atom is surrounded by three hydrogen atoms.

Considering the first factor i.e. the structure of the molecule, the odd number of the bonding atom indicates that the structure is triangular and not proving the polar nature of the molecule. As far as other factors are concerned, the electronegativity of the participating atoms is:

n = 3.04

h = 2.20

And the difference between these values is:

 3.04 – 2.20 = 0.84

The value is above or above 0.4 which also proves that the NH3 molecule is a polar molecule.

### H2O Polar or NonPolar:

The world revolves around water, it is a basic necessity of life. There are two hydrogen atoms and one oxygen atom in a water molecule.

According to the number of atoms it seems that matter would be similar to carbon dioxide but the difference arises in the arrangement of atoms. The structure of water is arranged non-linearly. The structure of the carbon dioxide molecule is linear due to which the two opposite end atoms cancel each other’s effect.

Waiting for the other factor of electronegativity difference, the values of EN of the bonding atoms are:

h = 2.20

o = 3.44

And the difference would be;

 3.44 – 2.20 = 1.24`

Hence, proving the polar nature of the molecule as well.

Summary: CH2F2 is polar due to electronegativity difference, CO2 on the other hand is non-polar due to its structure, although it has electronegativity difference. This shows that the polarity of the molecule depends not only on the electronegativity but also on the arrangement of the atoms.

#### Is ch2f2 tetrahedral?

Yes, the structure of CH2F2 i.e. difluoromethane is tetrahedral which helps or supports the dipole effect of the molecule. Two fluorine and two hydrogen atoms are arranged tetrahedral around the central carbon atom.

#### Does ch2f2 dissolve in water?

CH2F2 is highly insoluble in water. However, it is said that polar molecules are more soluble in polar solvents. CH2F2 is a polar molecule that can be soluble in a polar solvent H2O. But, difluoromethane lacks hydrogen bonding which leads to insoluble in water.

#### Is CCl4 polar or nonpolar?

CCl4 is known chemically as carbon tetrachloride. Although the molecule contains four chlorine atoms that are highly electronegative in nature, the molecule is still non-polar. This is due to the orientation of the atoms, with the four chlorines arranged tetrahedral around the central carbon atom. This arrangement causes the electronegative effect and the cancellation of the dipole moment, making the molecule non-polar.

#### Is O2 polar or nonpolar?

Diatomic molecules are always and always nonpolar. This is due to the fact that they are linearly arranged and cancel each other’s electronegative effect (having the same EN value). O2 (oxygen gas) is also an example of a diatomic molecule.

#### Is ethanol polar or non-polar?

Ethanol is a hydrocarbon with the chemical formula C2H5OH. Hydrocarbons are mostly non-polar due to the presence of carbon and hydrogen atoms and their low electronegativity difference. But in this case the presence of oxygen atom which is an electronegative element, the molecule gets converted to polar due to greater difference of EN

This suggests that polarity can be judged based on the following factors:

1. Difference Between Electronegativity Values

2. Structure of Molecules or Orientation of Atoms

These two factors can also identify the type of bond and molecule.

#### What is the electronegativity of ch4?

CH4 2,5−2,1=0,4
Since, we know that the electronegativity of carbon C in CH4 is higher than that of hydrogen, the bonding moment will be oriented towards carbon. Thus, the electronegativity will be more significant and the dipole moment will be less.

#### CO2 polar non polar

Carbon dioxide, whose chemical formula is CO2, is nonpolar. It consists of two polar links arranged symmetrically. Carbon forms a double bond with each oxygen atom. Since carbon and oxygen have different electronegativity, electrons are not shared equally between the two atoms.

#### Is ch2f2 polar?

Yes, difluoromethane (CH2F2) is polar despite its symmetric shape, ie its tetrahedral geometry . The polarity results from the large difference in the electronegativity of the C-F bond. The CF bond is polar in nature and hence strong dipole is formed. Therefore, the molecule will have a net dipole moment with a negative pole on the fluorine atom. This leads to the polar nature of the CH2F2 molecule.

### Is methane polar or non-polar?

methane is non polar

#### potassium bromide polar or non-polar

Potassium bromide is polar in nature.

## Ch2f2 Lewis Structure

Chemical bond is the force of attraction between two atoms and atoms form a chemical bond to achieve stability as most of the elements are unstable in their atomic form. Kossel and Lewis were the first to explain the formation of chemical bonds in terms of electrons, specifically valence electrons.

According to Lewis, with the exception of hydrogen and helium, each atom moves towards a stable octet when it forms chemical bonds. Only valence electrons present in the outermost layer of an atom take part in bond formation.

In CH2F2, carbon, hydrogen and fluorine belong to groups 14, 1 and 17, respectively. Therefore, the number of valence electrons in carbon, hydrogen and fluorine are 4, 1 and 7 respectively. The group valencies of carbon, hydrogen and fluorine are 4, 1 and 1 respectively. Group valency indicates the number of chemical bonds that an atom can form with other atoms.

Therefore, carbon can form four chemical bonds whereas hydrogen and fluorine can form only one chemical bond. Therefore, carbon will be the central atom of difluoromethane.

The total number of valence electrons in difluoromethane is 4 + 1(2) + 7(2) = 20 electrons. The valence electrons in the Lewis structure of a molecule are represented by dots.

The important conditions for Lewis structures are that each combined atom must contribute at least one electron to be shared with other atoms and that a chemical bond is formed due to the sharing of electron pairs between atoms.

The combined atom will reach the nearest noble gas configuration by sharing electrons. Now we need to arrange 20 valence electrons in the Lewis structure of CH2F2 with carbon as the central atom.

Carbon has four valence electrons and hence will share two of its valence electrons with two hydrogen atoms and the remaining two electrons with two fluorine atoms resulting in the formation of a byte around it.

Therefore, the Lewis structure of CH2F2 can be represented as:

In the Lewis structure of CH2F2, the hydrogen and fluorine atoms share only one electron with the carbon atom. Therefore, a single bond is formed between carbon and hydrogen as well as between carbon and fluorine. In short, a carbon atom, a central atom, will form four single bonds without any dissociated pairs.

But we can’t limit ourselves to just the Lewis structure to understand the chemical reactions of CH2F2, which involve breaking and forming bonds. Therefore, it is essential to understand the molecular geometry of CH2F2.

#### Is methane a polar molecule?

Methane, which does not have polar bonds, is clearly non-polar. It has four carbon-fluorine polar bonds but they oppose each other, so the molecule itself is non-polar.

#### Is O2 polar?

The oxygen (O2) molecule is diatomic and nonpolar because both atoms have the same electronegativity. As a result, two atoms share the same charge and neither atom has a partial charge. Therefore, we know that O2 is a non-polar molecule having zero dipole moment.

#### Polar or non-polar?

Nitrogen is on the right side of Oxygen in the periodic table. Nitrogen has less electronegativity than oxygen. All NO bonds are polar bonds that have a high electron density on the oxygen atom.

#### Ch2f2 Molecular Geometry

The molecular structure of CH2F2 can be inferred from the theory given by Sedgwick and Powell, VSEPR. This principle is based on the repulsion between the valence electrons of an atom. These valence electron shell electrons can be bonded (bonded electron pair) or unbonded (lone pair of electrons). These electron pairs occupy a position around the central atom to minimize repulsion and maximize molecular stability. For example, if there are two chemical bonds around the central atom, these bonds are arranged at a bond angle of 180°, thus forming a linear shape.

In difluoromethane, the carbon atom is the central atom with its bond pair of four electrons. These four chemical bonds are arranged in a tetrahedral shape with a bond angle of 109.5° to minimize the repulsion between any two bond pairs. The size of difluoromethane can also be estimated in the following table based on the VSEPR principle.

However, in CH2F2, the FCF bond angle is slightly less than 109.5° and the H-CH bond angle is slightly larger than 109.5°.

Furthermore, the C-H bond length of CH2F2 is less than the C-H bond length of methane (CH4). These two discrepancies can be explained by hybrid Bent’s law. If we know the hybridization of the carbon atoms in difluoromethane, we can understand Bent’s law of hybridisation.

#### carbon dioxide polar or non-polar

Carbon dioxide is nonpolar with the chemical formula CO2. It consists of two symmetrically arranged polar bonds. Carbon forms a double bond with each oxygen atom. Due to the different electronegativity of carbon and oxygen, electrons are not shared equally between the two atoms.

#### Why is methane non polar?

All outer atoms are equal—the same dipole and dipole moment point in the same direction—the whole molecule becomes nonpolar toward the carbon atom. Therefore, methane has non-polar bonds and is overall non-polar.

#### Is ammonia polar or non polar?

The answer is that ammonia is a polar molecule whose polarity is affected by its asymmetric shape and the presence of nitrogen and hydrogen atoms contained in it.

#### Ch2f2 dipole moment

The dipole moment depends on the difference in electronegativity. It must be greater than 0.4 for a chemical bond to be polar. The electronegativity of carbon, hydrogen and fluorine atoms is 2.55, 2.20 and 3.98, respectively. This large difference in electronegativity produces dipoles.

#### boiling point of ch2f2.

The boiling point of ch2f2 is -51.7 °C.

#### Is sugar polar or non polar?

Sugar (sucrose) is a polar non-electrolyte. Sucrose is very soluble because its molecule contains an OH group accessible to water that can form strong hydrogen bonds with water. Therefore, sugar is no exception to the rule of thumb that it “dissolve the same way.”

#### Why is cf2h2 polar?

CH2F2 is a polar molecule because electrons are drawn towards the fluorine dipole (i.e. partially negatively charged), resulting in a partially positive charge at the hydrogen end of the tetrahedron.

#### Is CH2Cl2 polar or non-polar?

CH2Cl2 polar molecule This molecule is tetrahedral because of the four electron repulsion around the central C atom. The C–Cl bonds are polar due to the difference in electronegativity between C and Cl, and the C-H bonds are almost non-polar or differ in polarity from C–Cl.

#### Does CH2F2 have a dipole moment?

The shape of CH2F2 is tetrahedral and symmetric, so the distribution of atoms around the carbon atoms is symmetric. The dipole moment depends on the difference in electronegativity. It must be greater than 0.4 for a chemical bond to be polar. Therefore, difluoromethane is a polar molecule.

#### Is CCl4 polar or non-polar?

Carbon tetrachloride, CCl4, is nonpolar because all four bonds are symmetric and extend in all directions.

#### Is acetone polar or non-polar?

Acetone is a polar molecule because it has a polar bond, and does not have dipole cancellation due to its molecular structure.

Question: Is bromomethane polar or non-polar?
Ch3Br(bromomethane) is a polar compound with a tetrahedral molecular shape, with bromine (2.96) having a higher electronegativity than carbon (2.55) and a higher electron density toward the bromine atom. As a result, a dipole moment occurs on the bromine side, making CH3Br polar molecules.

#### What are polar and non-polar?

Polar molecules are formed when there is a difference in electronegativity between the bonded atoms. Nonpolar molecules occur when electrons are shared equally between the atoms of a diatomic molecule, or when the polar bonds of a larger molecule cancel each other out.

#### conclusion

The question is, is the molecule polar or non-polar like CH2F2 polar or nonpolar? can be easily understood. CH2F2, having a tetrahedral structure and electronegativity difference of 1.43, is a polar molecule.


text:
Question:

# What is the characteristics of a chemical reaction?

## A chemical reaction is a process that leads to the transformation of one set of chemical substances to another. Chemical reactions can be either spontaneous, requiring no input of energy, or non-spontaneous.

In chemistry, a chemical substance is a form of matter that has constant chemical composition and characteristic properties. It cannot be separated into components by physical separation methods, i.e. without breaking chemical bonds. It can be solid, liquid, gas, or plasma.

Chemical substances are often called 'pure' to set them apart from mixtures. A common example of a chemical substance is pure water; it has the same properties and the same ratio of hydrogen to oxygen whether it is isolated from a river or made in a laboratory. Other chemical substances commonly encountered in pure form are diamond (carbon), gold, table salt (sodium chloride) and refined sugar (sucrose). However, simple or seemingly pure substances found in nature can in fact be mixtures of chemical substances. For example, tap water may contain small amounts of dissolved sodium chloride and compounds containing iron, calcium and many other chemical substances.

energy

A chemical reaction is a process that leads to the transformation of one set of chemical substances to another. Classically, chemical reactions encompass changes that only involve the positions of electrons in the forming and breaking of chemical bonds between atoms, with no change to the nuclei (no change to the elements present), and can often be described by a chemical equation. Nuclear chemistry is a sub-discipline of chemistry that involves the chemical reactions of unstable and radioactive elements where both electronic and nuclear changes may both occur.

The substance (or substances) initially involved in a chemical reaction are called reactants or reagents. Chemical reactions are usually characterized by a chemical change, and they yield one or more products, which usually have properties different from the reactants. Reactions often consist of a sequence of individual sub-steps, the so-called elementary reactions, and the information on the precise course of action is part of the reaction mechanism. Chemical reactions are described with chemical equations, which graphically present the starting materials, end products, and sometimes intermediate products and reaction conditions.

A chemical reaction is a process that leads to the transformation of one set of chemical substances to another. Classically, chemical reactions encompass changes that only involve the positions of electrons in the forming and breaking of chemical bonds between atoms, with no change to the nuclei (no change to the elements present), and can often be described by a chemical equation. Nuclear chemistry is a sub-discipline of chemistry that involves the chemical reactions of unstable and radioactive elements where both electronic and nuclear changes may both occur.

The substance (or substances) initially involved in a chemical reaction are called reactants or reagents. Chemical reactions are usually characterized by a chemical change, and they yield one or more products, which usually have properties different from the reactants. Reactions often consist of a sequence of individual sub-steps, the so-called elementary reactions, and the information on the precise course of action is part of the reaction mechanism. Chemical reactions are described with chemical equations, which graphically present the starting materials, end products, and sometimes intermediate products and reaction conditions.

Thermodynamics

A chemical reaction is a process that leads to the transformation of one set of chemical substances to another. Classically, chemical reactions encompass changes that only involve the positions of electrons in the forming and breaking of chemical bonds between atoms, with no change to the nuclei (no change to the elements present), and can often be described by a chemical equation. Nuclear chemistry is a sub-discipline of chemistry that involves the chemical reactions of unstable and radioactive elements where both electronic and nuclear changes may both occur.

The substance (or substances) initially involved in a chemical reaction are called reactants or reagents. Chemical reactions are usually characterized by a chemical change, and they yield one or more products, which usually have properties different from the reactants. Reactions often consist of a sequence of individual sub-steps, the so-called elementary reactions, and the information on the precise course of action is part of the reaction mechanism. Chemical reactions are described with chemical equations, which graphically present the starting materials, end products, and sometimes intermediate products and reaction conditions.

In chemistry, a chemical substance is a form of matter that has constant chemical composition and characteristic properties. It cannot be separated into components by physical separation methods, i.e. without breaking chemical bonds. It can be solid, liquid, gas, or plasma.

Chemical substances are often called 'pure' to set them apart from mixtures. A common example of a chemical substance is pure water; it has the same properties and the same ratio of hydrogen to oxygen whether it is isolated from a river or made in a laboratory. Other chemical substances commonly encountered in pure form are diamond (carbon), gold, table salt (sodium chloride) and refined sugar (sucrose). However, simple or seemingly pure substances found in nature can in fact be mixtures of chemical substances. For example, tap water may contain small amounts of dissolved sodium chloride and compounds containing iron, calcium and many other chemical substances.

Energy

In chemistry, Chemical energy is the potential of a chemical substance to undergo a transformation through a chemical reaction or, to transform other chemical substances. Examples include batteries and light bulbs and cells etc. Breaking or making of chemical bonds involves energy, which may be either absorbed or evolved from a chemical system.

Energy that can be released (or absorbed) because of a reaction between a set of chemical substances is equal to the difference between the energy content of the products and the reactants. This change in energy is change in internal energy of a chemical reaction. Where $\Delta {U_f^\circ}_{\mathrm {reactants}}$ is the internal energy of formation of the reactant molecules that can be calculated from the bond energies of the various chemical bonds of the molecules under consideration and $\Delta {U_f^\circ}_{\mathrm {products}}$ is the internal energy of formation of the product molecules. The internal energy change of a process is equal to the heat change if it is measured under conditions of constant volume, as in a closed rigid container such as a bomb calorimeter. However, under conditions of constant pressure, as in reactions in vessels open to the atmosphere, the measured heat change is not always equal to the internal energy change, because pressure-volume work also releases or absorbs energy. (The heat change at constant pressure is called the enthalpy change; in this case the enthalpy of formation).

Chemical thermodynamics is the study of the interrelation of heat and work with chemical reactions or with physical changes of state within the confines of the laws of thermodynamics. Chemical thermodynamics involves not only laboratory measurements of various thermodynamic properties, but also the application of mathematical methods to the study of chemical questions and the spontaneity of processes.

The structure of chemical thermodynamics is based on the first two laws of thermodynamics. Starting from the first and second laws of thermodynamics, four equations called the "fundamental equations of Gibbs" can be derived. From these four, a multitude of equations, relating the thermodynamic properties of the thermodynamic system can be derived using relatively simple mathematics. This outlines the mathematical framework of chemical thermodynamics.

Chemistry Science

Physical chemistry is the study of macroscopic, atomic, subatomic, and particulate phenomena in chemical systems in terms of laws and concepts of physics. It applies the principles, practices and concepts of physics such as motion, energy, force, time, thermodynamics, quantum chemistry, statistical mechanics and dynamics, equilibrium.

Physical chemistry, in contrast to chemical physics, is predominantly (but not always) a macroscopic or supra-molecular science, as the majority of the principles on which physical chemistry was founded, are concepts related to the bulk rather than on molecular/atomic structure alone. For example, chemical equilibrium, and colloids.

Education Health Medical Pharma Environment Health Medical Pharma

11


text:
# Callen's problem 4.6-7, thermodynamics

Gold Member

## Homework Statement

Hi guys. I'm basically clueless on what's going on, I get 2 different results while I should get the same.
The problem reads "Each of two bodies has a heat capacity at constant volume given by ##C_v=nc_v=A+2BT## where A and B are known constants (both positive).
If the 2 bodies are initially at temperatures ##T_1=200K## and ##T_2=400K## and if a reversible work source is available, what are the maximum and minimum final common temperatures to which the 2 bodies can be brought? What is the maximum amount of work that can be transferred to the reversible work source? It is to be assumed throughout that each body is maintained at constant volume.

## Homework Equations

1st law of Thermodynamics: ##dU=\delta Q + \delta W## where U is the internal energy of the system I'm considering, Q is the heat going toward the system and W is the work done on the system.
Others.

## The Attempt at a Solution

First I want to calculate the minimum final common temperature. It occurs when the work done BY the system is maximum and it corresponds to a zero change in entropy in the whole system. I.e. ##\Delta S_{\text{Total}}=\Delta S_1+\Delta S_2 + \underbrace {\Delta S _{\text{heat engine}}}_{\text{=0 because the engine works with cycles}}=\Delta S_1+ \Delta S_2##.
Now I use the equation ##dS=\frac{dQ}{T}## and that ##dQ=nc_vdT## for both bodies. I get that ##\Delta S= \int _{T_1}^{T_f} nc_v \frac{dT}{T}+\int _{T_2}^{T_f} nc_v \frac{dT}{T}=nA\ln \left ( \frac{T_f^2}{T_1T_2} \right ) +2nB[2T_f-(T_1+T_2)]## where I skipped some arithmetical steps. Now the minimum ##T_f## can be found by setting ##\Delta S=0## and isolating ##T_f## (which I don't think is possible, so a numerical method should be used). So far so good I've virtually determined the ##T_f## that they ask me and it cannot be written in terms of elemental functions.

Now if I use a different way to solve the problem I get a different answer.
If I consider the whole system 2 bodies+heat engine as my system, I get that ##\Delta U=W## where W is the work done on the system. And delta U is the change in internal energy of the 2 bodies + heat engine but the change in internal energy of the heat engine is 0 because it works with cycles.
So my goal is to get the work done by the system, in other words, ##-W##.
The change in internal energy of the first body is worth ##dU_1=dQ_1+\underbrace {dW_1}_{=0 \text{ because V=constant}}=nc_vdT_1 \Rightarrow \Delta U_1=n[A(T_f-T_1)+B(T_f^2-T_1^2)]##. In the same fashion I get ##\Delta U_2##. So ##\Delta U=\Delta U_1+\Delta U_2 =n[2AT_f-A(T_1+T_2)+2BT_f ^2 - B(T_1^2+T_2^2)]## which is worth the work done on the system (because of the 1st Law of Thermodynamics and using the fact that the whole system is isolated and therefore Q=0).
Therefore the work done by the system is ##-W=W'=n[B(T_1^2+T_2^2)-2BT_f^2+A(T_1+T_2)-2AT_f]##.( The maximum amount of work is done when ##T_f## is minimum so if I could isolate ##T_f## above and plug it here I'd answer the question of the problem.)
Here I can think of W' as a function of ##T_f## only. In such case I want to see what value of ##T_f## extremizes W'. Derivating W' with respect to ##T_f## and setting that expression equal to 0, I found ##T_f=\frac{A}{2B}## and the second derivatives gives me ##-4B<0## thus W' is maximum and therefore ##T_f## corresponds to a minimum. But it is not equal to the previous one I had found! I really don't understand what's going on. I would like someone to comment on this.

To continue the problem, if I set ##W'=0## (where the prime denotes the work done BY the system, not the derivative!) I should get ##T_f## maximum because no work is being done by the heat engine and so the heat flows from body 1 to body 2 until both temperatures are equal. In that case I get ##T_{fmax}=-\frac{A}{B}+\sqrt{\left ( \frac{A}{B} \right ) ^2 +2 [T_1^2+T_2^2 + \frac{A(T_1+T_2)}{B}] }##. I wonder if this result is good.

Last edited:

## Answers and Replies

Homework Helper
1st law of Thermodynamics: ##dU=\delta Q + \delta W## where U is the internal energy of the system I'm considering, Q is the heat going toward the system and W is the work done on the system.

## The Attempt at a Solution

First I want to calculate the minimum final common temperature. It occurs when the work done BY the system is maximum and it corresponds to a zero change in entropy in the whole system. I.e. ##\Delta S_{\text{Total}}=\Delta S_1+\Delta S_2 + \underbrace {\Delta S _{\text{heat engine}}}_{\text{=0 because the engine works with cycles}}=\Delta S_1+ \Delta S_2##.
Now I use the equation ##dS=\frac{dQ}{T}## and that ##dQ=nc_vdT## for both bodies. I get that ##\Delta S= \int _{T_1}^{T_f} nc_v \frac{dT}{T}+\int _{T_2}^{T_f} nc_v \frac{dT}{T}=nA\ln \left ( \frac{T_f^2}{T_1T_2} \right ) +2nB[2T_f-(T_1+T_2)]## where I skipped some arithmetical steps.[

Now the minimum ##T_f## can be found by setting ##\Delta S=0## and isolating ##T_f## (which I don't think is possible, so a numerical method should be used). So far so good I've virtually determined the ##T_f## that they ask me and it cannot be written in terms of elemental functions.

Now if I use a different way to solve the problem I get a different answer.
If I consider the whole system 2 bodies+heat engine as my system, I get that ##\Delta U=W## where W is the work done on the system. And delta U is the change in internal energy of the 2 bodies + heat engine but the change in internal energy of the heat engine
Your approach is correct for determining minimum Tf. But the n factor should not be there ie. should be:

$$\Delta S = A\ln \left ( \frac{T_f^2}{T_1T_2} \right ) +2B[2T_f-(T_1+T_2)]$$

which simplifies to:

$$\Delta S = 2A\ln(T_f) - A(\ln 400 + \ln 200) + 4BT_f - 2B(600)$$

If ΔS = 0,:

$$2A\ln(T_f) + 4BT_f = A(\ln 400 + \ln 200) + 1200B$$

I agree that you would need to use numerical methods to solve for Tf. That gives you the minimum Tf.

The maximum Tf though is much easier. The question says that a reversible engine is available - it doesn't say you have to use it. What is Tf if you just let the heat flow irreversibly from one body to the other?

How is the work done in the first situation (minimum Tf) related to the difference in the internal energies of the bodies at maximum Tf and at minimum Tf?

AM

Gold Member
Your approach is correct for determining minimum Tf. But the n factor should not be there ie. should be:

$$\Delta S = A\ln \left ( \frac{T_f^2}{T_1T_2} \right ) +2B[2T_f-(T_1+T_2)]$$

which simplifies to:

$$\Delta S = 2A\ln(T_f) - A(\ln 400 + \ln 200) + 4BT_f - 2B(600)$$

If ΔS = 0,:

$$2A\ln(T_f) + 4BT_f = A(\ln 400 + \ln 200) + 1200B$$

I agree that you would need to use numerical methods to solve for Tf. That gives you the minimum Tf.
I see, thank you very much. On my draft I had not put the n but when copying here I thought I had to put it for some reason that I will check out when I've time.
Andrew Mason said:
The maximum Tf though is much easier. The question says that a reversible engine is available - it doesn't say you have to use it. What is Tf if you just let the heat flow irreversibly from one body to the other?
Yeah I know, this is basically what I've done. I've found an expression for the work done by the machine: ##-W=W'=n[B(T_1^2+T_2^2)-2BT_f^2+A(T_1+T_2)-2AT_f]## (I have to check out whether the n should be here). When I set W'=0 I found out the maximum T_f: ##T_{fmax}=-\frac{A}{B}+\sqrt{\left ( \frac{A}{B} \right ) ^2 +2 [T_1^2+T_2^2 + \frac{A(T_1+T_2)}{B}] }##, which is as we both said no work is done by the engine and what happens is only the flow of heat from body 1 to body 2 until both temperatures are equal.
But what I found strange is when I think of W' as a function of T_f, then I derivated W' and equated it to 0 and found out that the minimum T_f does not correspond to the value we had found earlier.
How is the work done in the first situation (minimum Tf) related to the difference in the internal energies of the bodies at maximum Tf and at minimum Tf?

AM
Ok I'll check this out as soon as I can.
Thanks a lot for all.

Homework Helper
Yeah I know, this is basically what I've done. I've found an expression for the work done by the machine: ##-W=W'=n[B(T_1^2+T_2^2)-2BT_f^2+A(T_1+T_2)-2AT_f]## (I have to check out whether the n should be here). When I set W'=0 I found out the maximum T_f: ##T_{fmax}=-\frac{A}{B}+\sqrt{\left ( \frac{A}{B} \right ) ^2 +2 [T_1^2+T_2^2 + \frac{A(T_1+T_2)}{B}] }##, which is as we both said no work is done by the engine and what happens is only the flow of heat from body 1 to body 2 until both temperatures are equal.
But what I found strange is when I think of W' as a function of T_f, then I derivated W' and equated it to 0 and found out that the minimum T_f does not correspond to the value we had found earlier.
For irreversible heat flow resulting in maximum Tf:

$$\Delta U_1 = \int C_vdT = \int (A + 2BT)dT = A(T_f-200) + B(T_f^2-200^2) = -\Delta U_2 = -A(T_f-400) - B(T_f^2-400^2)$$

So Tf max. is the solution to this quadratic equation:

$$AT_f + BT_f^2 - (300A + 20000B) = 0$$

The work obtained in the first case should be equal to the heat flow required to raise both bodies from the minimum Tf to the maximum Tf. Your approach (calculating the difference in changes of internal energy in body 1 going from T1 to Tfmin and in body 2 going from T2 to Tfmin) should give the same result. Either way it is a rather ugly looking calculation!

AM

Gold Member
Yeah I also had to solve a quadratic in T_f. I kept the positive temperature, the other T_f being negative.
I asked a TA at my university what's wrong between my 2 results for the minimal T_f. He told me that I cannot conclude that if T_f maximizes W' (in my expression ##W'=[B(T_1^2+T_2^2)-2BT_f^2+A(T_1+T_2)-2AT_f] ## ) then T_f is the minimal one. Because this would be ignoring the fact that T_f has a minimum value set by the 2nd Law of Thermodynamics, which I already found using ##\Delta S=0##.
In other words maximizing my W' would ignore that ##\Delta S \geq 0##. So basically my question is answered and the problem is solved.
And yeah, I put an extra n in my first post as you pointed out!
Thanks a lot for all.

Homework Helper
Yeah I also had to solve a quadratic in T_f. I kept the positive temperature, the other T_f being negative.
I asked a TA at my university what's wrong between my 2 results for the minimal T_f. He told me that I cannot conclude that if T_f maximizes W' (in my expression ##W'=[B(T_1^2+T_2^2)-2BT_f^2+A(T_1+T_2)-2AT_f] ## ) then T_f is the minimal one. Because this would be ignoring the fact that T_f has a minimum value set by the 2nd Law of Thermodynamics, which I already found using ##\Delta S=0##.
In other words maximizing my W' would ignore that ##\Delta S \geq 0##. So basically my question is answered and the problem is solved.
And yeah, I put an extra n in my first post as you pointed out!
Thanks a lot for all.
I see what you were trying to do. I thought you were using the minimum Tf in the expression for ΔU (ie. W = -(ΔU1 + ΔU2) = - Cv(Tf-T1) - Cv(Tf-T2)). You were simply trying to find the value of Tf that maximizes the value of W in that expression. As your instructor pointed out, Wmax (min. Tf) is not the maximum value of W in that expression. The maximum value of W in W = -(ΔU1 + ΔU2) is where ΔU2 = 0 (ie. body 1 ends up at T2 and all the heat flow from 1 is converted to work).

AM

Gold Member
I see what you were trying to do. I thought you were using the minimum Tf in the expression for ΔU (ie. W = -(ΔU1 + ΔU2) = - Cv(Tf-T1) - Cv(Tf-T2)). You were simply trying to find the value of Tf that maximizes the value of W in that expression. As your instructor pointed out, Wmax (min. Tf) is not the maximum value of W in that expression. The maximum value of W in W = -(ΔU1 + ΔU2) is where ΔU2 = 0 (ie. body 1 ends up at T2 and all the heat flow from 1 is converted to work).

AM
Ah I see! So this would correspond to an efficiency of 1, right? Which is of course greater than Carnot's engine, thus impossible.