text:
# Arduino nano sketch wont validate/wont upload.

#### gene-stevo

Joined Feb 22, 2019
13
Hi Folks, I'm trying to use a sketch (not my work) to control a high speed flash however when I try to validate it I get the error message: 'reading' was not declared in this scope. A certain amount of code is commented out as the sketch is a dual purpose solution for either controlling as laser trigger or a piezo vibration trigger. here is the complete sketch...There is also a screen shot of the error as shown. Thanks for reading, Cheers, Eugene.

C++:
/* This program is used as a laser trigger and/or sound trigger for high-speed photography
  ---> Made by Sander Vanhee <--

push button to activate program
Activate laser or sound trigger
delay
open camera shutter (manual for now)
drop an object
laser barrier or piezo sensor gets triggered
laser off
wait the delay set by potentiometer
trigger flash
delay
close camera shutter
delay
*/

int laserPin = 12;        // red wire from laser
int potPin = 0;           // potentiometer to read delay
int optoPin = 8;          // towards the optocoupler
int buttonApin = 2;       // pushbutton
int photocellPin = A1;    // the cell and 10K pulldown are connected to A1
int PiezoPin = A2;         // the Piezo is connected to a2

void setup(){
// We'll send debugging information via the Serial monitor
Serial.begin(9600);

//#define photocellPin 1
pinMode(laserPin, OUTPUT);
pinMode(buttonApin, INPUT);
pinMode(photocellPin, INPUT_PULLUP);
pinMode(PiezoPin, INPUT);
pinMode(optoPin, OUTPUT);
pinMode(potPin, INPUT_PULLUP);
}

void loop() {
// check if button is pressed, only continue when pressed.
Serial.println("Waiting for buttonpress...");

if (digitalRead(buttonApin) == HIGH) {  // start program if button is pressed
//start if(buttonpressed) loop
Serial.println("Button pressed");

reading = map(reading, 0, 1023, 1, 500);     // scale it to use it with the drops (delay between 1 and 500)

delay(50);

/* We'll put the laser parts in comments to isolate them from the Piezo code

// Activate laser
digitalWrite(laserPin, HIGH);
Serial.println("Laser Activated");

delay(1000); // delay before open shutter

Serial.println("Drop object");

// read the value of the photocellPin

//Check if laser is broken
Serial.println("Laser uninterrupted");

// as long as the laser is not broken, this "while" statement will loop.
// when the laser is broken, the program will continue.

// laser off
// turn laser off to not show up in the picture
// digitalWrite(laserPin, LOW);
*/

// what follows is the piezo code
Serial.println("no sound detected");
}

// Wait the amount indicated by the value of potentiometer
// give the waves time to rise back to the surface

//trigger flash - send signal from pin 8
digitalWrite(8, HIGH);
Serial.println("FLASH fired");
delay(1000);
digitalWrite(8, LOW);

//wait for flash light to die down
delay(200);

//close camera shutter

Serial.println("END");
// END OF (buttonpressed) while loop

digitalWrite(laserPin, LOW);
}}

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}

#### djsfantasi

Joined Apr 11, 2010
7,752
Hi Folks, I'm trying to use a sketch (not my work) to control a high speed flash however when I try to validate it I get the error message: 'reading' was not declared in this scope. A certain amount of code is commented out as the sketch is a dual purpose solution for either controlling as laser trigger or a piezo vibration trigger. here is the complete sketch...
C++:
/* This program is used as a laser trigger and/or sound trigger for high-speed photography
  ---> Made by Sander Vanhee <--

push button to activate program
Activate laser or sound trigger
delay
open camera shutter (manual for now)
drop an object
laser barrier or piezo sensor gets triggered
laser off
wait the delay set by potentiometer
trigger flash
delay
close camera shutter
delay
*/

int laserPin = 12;        // red wire from laser
int potPin = 0;           // potentiometer to read delay
int optoPin = 8;          // towards the optocoupler
int buttonApin = 2;       // pushbutton
int photocellPin = A1;    // the cell and 10K pulldown are connected to A1
int PiezoPin = A2;         // the Piezo is connected to a2

void setup(){
// We'll send debugging information via the Serial monitor
Serial.begin(9600);

//#define photocellPin 1
pinMode(laserPin, OUTPUT);
pinMode(buttonApin, INPUT);
pinMode(photocellPin, INPUT_PULLUP);
pinMode(PiezoPin, INPUT);
pinMode(optoPin, OUTPUT);
pinMode(potPin, INPUT_PULLUP);
}

void loop() {
// check if button is pressed, only continue when pressed.
Serial.println("Waiting for buttonpress...");

if (digitalRead(buttonApin) == HIGH) {  // start program if button is pressed
//start if(buttonpressed) loop
Serial.println("Button pressed");

reading = map(reading, 0, 1023, 1, 500);     // scale it to use it with the drops (delay between 1 and 500)

delay(50);

/* We'll put the laser parts in comments to isolate them from the Piezo code

// Activate laser
digitalWrite(laserPin, HIGH);
Serial.println("Laser Activated");

delay(1000); // delay before open shutter

Serial.println("Drop object");

// read the value of the photocellPin

//Check if laser is broken
Serial.println("Laser uninterrupted");

// as long as the laser is not broken, this "while" statement will loop.
// when the laser is broken, the program will continue.

// laser off
// turn laser off to not show up in the picture
// digitalWrite(laserPin, LOW);
*/

// what follows is the piezo code
Serial.println("no sound detected");
}

// Wait the amount indicated by the value of potentiometer
// give the waves time to rise back to the surface

//trigger flash - send signal from pin 8
digitalWrite(8, HIGH);
Serial.println("FLASH fired");
delay(1000);
digitalWrite(8, LOW);

//wait for flash light to die down
delay(200);

//close camera shutter

Serial.println("END");
// END OF (buttonpressed) while loop

digitalWrite(laserPin, LOW);
}}

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}
Whoever wrote the sketch is unfamiliar with how to code for an Arduino.

The main loop contains no code. The setup doesn’t define anything. For example, the potentiometer pin at least should be defined in setup(). Plus the laser or piezo should be defined as well.

Everything is defined in the global section, which is usually only used for global variable and library initialization.

The variable reading is initialized in one code block and then it is attempted to be used outside code block. That will give you the “‘reading’ is not declared inside this scope”.

It’s a wonder if this ever worked. You need to separate the code into global definitions, hardware/library setup and the main loop. And, you need to declare variable outside of the if, while, or for code blocks, if you need the value outside any of them.

#### gene-stevo

Joined Feb 22, 2019
13
Whoever wrote the sketch is unfamiliar with how to code for an Arduino.

The main loop contains no code. The setup doesn’t define anything. For example, the potentiometer pin at least should be defined in setup(). Plus the laser or piezo should be defined as well.

Everything is defined in the global section, which is usually only used for global variable and library initialization.

The variable reading is initialized in one code block and then it is attempted to be used outside code block. That will give you the “‘reading’ is not declared inside this scope”.

It’s a wonder if this ever worked. You need to separate the code into global definitions, hardware/library setup and the main loop. And, you need to declare variable outside of the if, while, or for code blocks, if you need the value outside any of them.
Thanks so much for your prompt response. Though I admit to not understanding much of it. The odd thing is the original version didn't mention the piezo stuff at all, just the laser stuff. I've build a rig using just the laser trigger stuff and it works perfectly. Once again thank you for your timely help. Cheers,
Eugene.

#### dl324

Joined Mar 30, 2015
12,917
'reading' was not declared in this scope
The error message is pretty clear. The variable 'reading' wasn't declared in a way that allows it to be used.

I didn't see it declared anywhere in the code you posted. Could it be in a header file?

#### djsfantasi

Joined Apr 11, 2010
7,752
The error message is pretty clear. The variable 'reading' wasn't declared in a way that allows it to be used.

I didn't see it declared anywhere in the code you posted. Could it be in a header file?
It’s declared inside an “if” code block.
Hence, it’s only available within that block.

#### djsfantasi

Joined Apr 11, 2010
7,752

• line 43 starts the “if” code block
• line 48 defines the variable ‘reading’ as an int
• line 91 is the end of the code block; and the end of the scope of the ‘reading’ variable
• line 95 is where ‘reading’ is referenced and not defined

#### s14rs4

Joined Sep 15, 2016
73
Hi Folks, I'm trying to use a sketch (not my work) to control a high speed flash however when I try to validate it I get the error message: 'reading' was not declared in this scope. A certain amount of code is commented out as the sketch is a dual purpose solution for either controlling as laser trigger or a piezo vibration trigger. here is the complete sketch...There is also a screen shot of the error as shown. Thanks for reading, Cheers, Eugene.
View attachment 201304
C++:
/* This program is used as a laser trigger and/or sound trigger for high-speed photography
  ---> Made by Sander Vanhee <--

push button to activate program
Activate laser or sound trigger
delay
open camera shutter (manual for now)
drop an object
laser barrier or piezo sensor gets triggered
laser off
wait the delay set by potentiometer
trigger flash
delay
close camera shutter
delay
*/

int laserPin = 12;        // red wire from laser
int potPin = 0;           // potentiometer to read delay
int optoPin = 8;          // towards the optocoupler
int buttonApin = 2;       // pushbutton
int photocellPin = A1;    // the cell and 10K pulldown are connected to A1
int PiezoPin = A2;         // the Piezo is connected to a2

void setup(){
// We'll send debugging information via the Serial monitor
Serial.begin(9600);

//#define photocellPin 1
pinMode(laserPin, OUTPUT);
pinMode(buttonApin, INPUT);
pinMode(photocellPin, INPUT_PULLUP);
pinMode(PiezoPin, INPUT);
pinMode(optoPin, OUTPUT);
pinMode(potPin, INPUT_PULLUP);
}

void loop() {
// check if button is pressed, only continue when pressed.
Serial.println("Waiting for buttonpress...");

if (digitalRead(buttonApin) == HIGH) {  // start program if button is pressed
//start if(buttonpressed) loop
Serial.println("Button pressed");

reading = map(reading, 0, 1023, 1, 500);     // scale it to use it with the drops (delay between 1 and 500)

delay(50);

/* We'll put the laser parts in comments to isolate them from the Piezo code

// Activate laser
digitalWrite(laserPin, HIGH);
Serial.println("Laser Activated");

delay(1000); // delay before open shutter

Serial.println("Drop object");

// read the value of the photocellPin

//Check if laser is broken
Serial.println("Laser uninterrupted");

// as long as the laser is not broken, this "while" statement will loop.
// when the laser is broken, the program will continue.

// laser off
// turn laser off to not show up in the picture
// digitalWrite(laserPin, LOW);
*/

// what follows is the piezo code
Serial.println("no sound detected");
}

// Wait the amount indicated by the value of potentiometer
// give the waves time to rise back to the surface

//trigger flash - send signal from pin 8
digitalWrite(8, HIGH);
Serial.println("FLASH fired");
delay(1000);
digitalWrite(8, LOW);

//wait for flash light to die down
delay(200);

//close camera shutter

Serial.println("END");
// END OF (buttonpressed) while loop

digitalWrite(laserPin, LOW);
}}

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}
Make the declaration global by inserting "int reading;" at line 25.

Remove the "int" before "reading" on line 48.

You also have an extra curly bracket on line 112 delete this.

There is also an extra "void setup()" and "void loop()" at the end of your code, delete every thing after line 113.

It should compile now, but I can't promise it will work.

I apologize if this reply doesn't display properly but I can't get a preview of my post. This is only my second posting.

Mod edit: move code out of quote - JohnInTX

Last edited by a moderator:

#### gene-stevo

Joined Feb 22, 2019
13
C++:
/* This program is used as a laser trigger and/or sound trigger for high-speed photography
  ---> Made by Sander Vanhee <--

push button to activate program
Activate laser or sound trigger
delay
open camera shutter (manual for now)
drop an object
laser barrier or piezo sensor gets triggered
laser off
wait the delay set by potentiometer
trigger flash
delay
close camera shutter
delay
*/

int laserPin = 12;        // red wire from laser
int potPin = 0;           // potentiometer to read delay
int optoPin = 8;          // towards the optocoupler
int buttonApin = 2;       // pushbutton
int photocellPin = A1;    // the cell and 10K pulldown are connected to A1
int PiezoPin = A2;         // the Piezo is connected to a2

void setup(){
// We'll send debugging information via the Serial monitor
Serial.begin(9600);

//#define photocellPin 1
pinMode(laserPin, OUTPUT);
pinMode(buttonApin, INPUT);
pinMode(photocellPin, INPUT_PULLUP);
pinMode(PiezoPin, INPUT);
pinMode(optoPin, OUTPUT);
pinMode(potPin, INPUT_PULLUP);
}

void loop() {
// check if button is pressed, only continue when pressed.
Serial.println("Waiting for buttonpress...");

if (digitalRead(buttonApin) == HIGH) {  // start program if button is pressed
//start if(buttonpressed) loop
Serial.println("Button pressed");

reading = map(reading, 0, 1023, 1, 500);     // scale it to use it with the drops (delay between 1 and 500)

delay(50);

/* We'll put the laser parts in comments to isolate them from the Piezo code

// Activate laser
digitalWrite(laserPin, HIGH);
Serial.println("Laser Activated");

delay(1000); // delay before open shutter

Serial.println("Drop object");

// read the value of the photocellPin

//Check if laser is broken
Serial.println("Laser uninterrupted");

// as long as the laser is not broken, this "while" statement will loop.
// when the laser is broken, the program will continue.

// laser off
// turn laser off to not show up in the picture
// digitalWrite(laserPin, LOW);
*/

// what follows is the piezo code
Serial.println("no sound detected");
}

// Wait the amount indicated by the value of potentiometer
// give the waves time to rise back to the surface

//trigger flash - send signal from pin 8
digitalWrite(8, HIGH);
Serial.println("FLASH fired");
delay(1000);
digitalWrite(8, LOW);

//wait for flash light to die down
delay(200);

//close camera shutter

Serial.println("END");
// END OF (buttonpressed) while loop

digitalWrite(laserPin, LOW);
}}

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}
Make the declaration global by inserting "int reading;" at line 25.

Remove the "int" before "reading" on line 48.

You also have an extra curly bracket on line 112 delete this.

There is also an extra "void setup()" and "void loop()" at the end of your code, delete every thing after line 113.

It should compile now, but I can't promise it will work.

I apologize if this reply doesn't display properly but I can't get a preview of my post. This is only my second posting.

Mod edit: move code out of quote - JohnInTX
Thank you so much for that. The sketch now compiles fine. The problem I now have (apart from a profound lack of understanding) is the nano wont acept the upload. I've tried uploading a default sketch, like Blink without sucess. I've tried different computers, different USB cables. Nothing works, apart from the power light and the blinking "L" light.
I've checked I'm using the correct port on each computer and selected nano from the board list.
Curiously when I check for board info this is the info I get:
BN: Unknown board
VID: 1A86
PID: 7523
SN: Upload any sketch to obtain it
After trying to upload I then get this error message:
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x18
I bought a three pack of unsoldered nano boards (e-bay) and none of them will accept an upload. Is it likely I've bought a duff batch?

#### s14rs4

Joined Sep 15, 2016
73
Thank you so much for that. The sketch now compiles fine. The problem I now have (apart from a profound lack of understanding) is the nano wont acept the upload. I've tried uploading a default sketch, like Blink without sucess. I've tried different computers, different USB cables. Nothing works, apart from the power light and the blinking "L" light.
I've checked I'm using the correct port on each computer and selected nano from the board list.
Curiously when I check for board info this is the info I get:
BN: Unknown board
VID: 1A86
PID: 7523
SN: Upload any sketch to obtain it
After trying to upload I then get this error message:
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x18
I bought a three pack of unsoldered nano boards (e-bay) and none of them will accept an upload. Is it likely I've bought a duff batch?
If they are from e-bay I assume they are Chinese clones. In the Tools menu when you select processor be sure to select ATmega328P(Old Bootloader). The newer genuine Arduino nano's use a different baud rate.

#### gene-stevo

Joined Feb 22, 2019
13
If they are from e-bay I assume they are Chinese clones. In the Tools menu when you select processor be sure to select ATmega328P(Old Bootloader). The newer genuine Arduino nano's use a different baud rate.
Thanks so much for your quick responce, that did it. Upload worked first time (so I don't need a refund}. Bloody code doesn't work though. Back to the drawing board. All I'm trying to do if fire a flash (via optocoupler) in responce to a noise/vibration detected by piezo. I'll dig around in the default sketch library.
Thanks to all who responded and for your patience with an obvious newb. Very much appreciated.

#### djsfantasi

Joined Apr 11, 2010
7,752
Thanks so much for your quick responce, that did it. Upload worked first time (so I don't need a refund}. Bloody code doesn't work though. Back to the drawing board. All I'm trying to do if fire a flash (via optocoupler) in responce to a noise/vibration detected by piezo. I'll dig around in the default sketch library.
Thanks to all who responded and for your patience with an obvious newb. Very much appreciated.
If that is all you need right now, I've modified the sketch. I removed everything related to the laser, etc... Ive corrected several errors and this slim, trim sketch is all you need given the requirements you stated above...

Arduino Nano Sketch to Listen to a Piezo device and Trigger an Optocoupler:
// This program is used as a sound trigger for high-speed photography

int potPin = D4;            // potentiometer pin to read delay
// pin 0 won't work because youre using Serial.println()
int optoPin = D8;          // towards the optocoupler
int PiezoPin = A2;         // the Piezo is connected to a2
int PiezoReading = 0;         // the analog reading from the sensor divider
int PiezoDiff = 0;

void setup() {
// We'll send debugging information via the Serial monitor
Serial.begin(9600);

pinMode(potPin, INPUT_PULLUP);
pinMode(optoPin, OUTPUT);
pinMode(PiezoPin, INPUT);
}

void loop() {

PotReading = map(PotReading, 0, 1023, 1, 500);     // scale it to use it with the drops (delay between 1 and 500)
delay(50);

// what follows is the piezo code
Serial.println("no sound detected");
//wait for Piezo to change significantly

// Wait the amount indicated by the value of potentiometer
// give the waves time to rise back to the surface

//trigger flash - send signal from pin 8
digitalWrite(8, HIGH);
Serial.println("FLASH fired");
delay(1000);  // delay 1 second
digitalWrite(8, LOW);

//wait for flash light to die down
delay(200);

}

#### gene-stevo

Joined Feb 22, 2019
13
If that is all you need right now, I've modified the sketch. I removed everything related to the laser, etc... Ive corrected several errors and this slim, trim sketch is all you need given the requirements you stated above...

Arduino Nano Sketch to Listen to a Piezo device and Trigger an Optocoupler:
// This program is used as a sound trigger for high-speed photography

int potPin = D4;            // potentiometer pin to read delay
// pin 0 won't work because youre using Serial.println()
int optoPin = D8;          // towards the optocoupler
int PiezoPin = A2;         // the Piezo is connected to a2
int PiezoReading = 0;         // the analog reading from the sensor divider
int PiezoDiff = 0;

void setup() {
// We'll send debugging information via the Serial monitor
Serial.begin(9600);

pinMode(potPin, INPUT_PULLUP);
pinMode(optoPin, OUTPUT);
pinMode(PiezoPin, INPUT);
}

void loop() {

PotReading = map(PotReading, 0, 1023, 1, 500);     // scale it to use it with the drops (delay between 1 and 500)
delay(50);

// what follows is the piezo code
Serial.println("no sound detected");
//wait for Piezo to change significantly

// Wait the amount indicated by the value of potentiometer
// give the waves time to rise back to the surface

//trigger flash - send signal from pin 8
digitalWrite(8, HIGH);
Serial.println("FLASH fired");
delay(1000);  // delay 1 second
digitalWrite(8, LOW);

//wait for flash light to die down
delay(200);

}
Huge thanks for that. I'll have another play tomorrow. Can't thank you enough for your trouble.
Cheers,
Eugene


text:
# How to get the following approximation for the following function?

I have a function $$f(x)=\frac{1}{x^2+1}$$ defined for $x\geq 0$. In one of the paper it is represented by its concave representation which is given below $$f'(x)\simeq -x^2+2\left(1-\frac{1}{(x_0^2+1)^2}\right)xx_0+\frac{1}{x_0^2+1}+\frac{2x_0^2}{(x_0^2+1)^2}-x_0^2$$ where the approximation is evaluated at $x=x_0$. I tried to get it through second order Taylor approximation but my expression does not match with it. Any help in this regard will be much appreciated.Thanks in advance.

• You mention $a$ and $b$ are positive constants, but I don't see them anywhere in your question. Mar 8 '18 at 8:57
• @TobyMak thank you for your correction comment. I have removed them from my question. Mar 8 '18 at 9:01
• According to Wolfram Alpha, the Taylor series at $x=a$ is $\frac{1}{a^2+1} - \frac{2a(x-a)}{(a^2+1)^2}$. Subtracting this from the approximation gives $-(a-x)^2$, which approaches $0$ as $x$ approaches $a$. Mar 8 '18 at 9:10
• @TobyMak yes at $x=a$ they give same answer but at other points their answer are different. For example I tried to check for $x_0=2$ case. For this case the Taylor expansion provides a convex looking function while the above equation(in my post) provides a concave function over all values of $x$ Mar 8 '18 at 9:16

$$f(x)=\frac{1}{x^2+1}\quad\implies\quad f'(x)= -\frac{2x}{(x^2+1)^2}$$ The approximation evaluated at $x=x_0$ is proposed as : $$f'(x)\simeq -x^2+2\left(1-\frac{1}{(x_0^2+1)^2}\right)xx_0+\frac{1}{x_0^2+1}+\frac{2x_0^2}{(x_0^2+1)^2}-x_0^2$$ So, at $x=x_0$ the above formula gives : $$f'(x_0)\simeq -x_0^2+2\left(1-\frac{1}{(x_0^2+1)^2}\right)x_0x_0+\frac{1}{x_0^2+1}+\frac{2x_0^2}{(x_0^2+1)^2}-x_0^2$$ After simplification : $$f'(x_0)\simeq \frac{1}{x_0^2+1}$$

If the proposed approximation was true, we should have $\quad f'(x_0)=-\frac{2x_0}{(x_0^2+1)^2}$

So, the proposed approximation is obviously false.

It seems that this is an approximation for $f(x)=\frac{1}{x^2+1}$, not for $f'(x)$. Probably a typo.

NOTE :

Even supposing that the proposed formula is an approximation for $f(x)$, it doesn't correspond exactly with the first terms of the Taylor series.

The first terms of the Taylor series are : $$f(x)=\frac{1}{x^2+1}\simeq \frac{1}{x_0^2+1} -\frac{2x_0}{(x_0^2+1)^2}(x-x_0)-\frac{1-3x_0^2}{(x_0^2+1)^3}(x-x_0)^2+...$$ or, rearranged as : $$f(x)\simeq -\frac{1-3x_0^2}{(x_0^2+1)^3}x^2-\frac{8x_0^3}{(x_0^2+1)^3}x+\frac{1+3x_0^2+6x_0^4}{(x_0^2+1)^3}$$ This draw us to think that the textbook approximation doesn't comes from a Taylor series expansion, but from another method of fitting, for example least mean squares. Since the range of $x$ where such regression calculus was carried out isn't specified, it is impossible to reproduce it. Of course, the validity of the approximate formula is limited to a range of $x_0$ depending on the unknown range of the regression calculus. For example, if the approximation is bad in case of $x_0=2$, this means that $x_0=2$ is outside the range that was taken into account for the calculus of the formula.

All those approximate functions are valid only on a small range of $x$ around $x_0$ as one can see on the next figures :

• you are right I just used $'$ to mean approximation I forgot that it is also used as to represent the first derivative Mar 9 '18 at 8:17
• @Frank Moses : See the comment in addition to my first answer. Mar 9 '18 at 9:19

format: plain


text:
The Transpose of a Linear Operator

# The Transpose of a Linear Operator

Let $(E, F)$ and $(G, H)$ be dual pairs and let $t : E \to G$ be a linear operator. Observe that for each $h \in H$, the map $\langle t(\cdot), h \rangle : E \to \mathbf{F}$ defined by $\langle t(e), h \rangle$ is a linear operator on $E$.

So for each $h \in H$, let $t'(h) \in E^*$ be the linear operator defined for all $e \in E$ by:

(1)
\begin{align} \quad t'(h)(e) := \langle t(e), h \rangle \end{align}
 Definition: Let $(E, F)$ and $(G, H)$ be dual pairs and let $t : E \to G$ be a linear operator. The Transpose of $t$ is the linear mapping $t' : H \to E^*$ defined above.

Note that the transpose $t'$ of $t$ has the following identify which holds for all $e \in E$ and for all $h \in H$:

(2)
\begin{align} \quad \langle e, t'(h) \rangle = \langle t(e), h \rangle \end{align}


text:
# How use the term "bias"

• I
Gold Member
I don't know if it's the best place to ask this, but oh well... how to use the term "bias"?
What is the meaning of bias? I always thought that biasing a measurement meant something like "enforcing" some of its results, as for example predetermining what you want to get and so biasing it...
However I read a phrase like this:
"The largest deviation is found in the transition region between the electromagnetic (EM) barrel and endcap. This is due to clusters reconstructed in poorly instrumented regions of the calorimeters which tend to have underestimated energies, and may lead to a bias in the τh pseudorapidity value."
--Determination of the tau energy scale and the associated systematic uncertainty in proton-proton collisions at √ s = 8 TeV with the ATLAS detector at the LHC in 2012
Does the bold phrase make sense?


text:
blog

# Announcing Norfair 2.0: an open-source real-time multi-object tracking library

Tue, Sep 20, 2022

We are excited to announce the release of Norfair 2.0, available in GitHub and PyPI as of now. This is the biggest upgrade to Tryolabs’ open-source multi-object tracking library since its first release two years ago.

For those unfamiliar with the term, multi-object tracking (abbreviated as MOT) is essentially the process of associating unique identifiers over time to every object in the video. It is generally performed by first running the video frames through a detector that identifies the objects in the scene (like YOLO, Faster R-CNN, or another deep learning model), and then linking those objects over time.

Norfair was born out of the need to solve the tracking problem in a straightforward way, with a simple setup and no extraneous dependencies, so that tracking capabilities could be added to any pre-existing codebase. Initially, it was adapted from a simple mechanism that does tracking by estimating the trajectories and velocities of objects called SORT. But it has matured!

Object detection.
Object detection and tracking.

Over the last two years, Norfair has steadily evolved in terms of features, and the community of users and contributors has continued to grow. Its simplicity of use has made it the go-to choice for many to add tracking to several different detectors, and it has been the angular stone behind many of Tryolabs’ projects related to video analytics.

For its second birthday 🎂, we have decided to release version 2.0. Even though 1.0 was released not long ago, there are a lot of new and exciting features that merit the release of a new major version. On top of many bugs fixed and improved documentation, we added support for estimating camera motion to allow tracking under a moving frame of reference, n-dimensional tracking (yes, Norfair can now track 3D objects!), and re-identification with appearance embeddings for the most challenging of scenarios with occlusion.

Buckle up, as we will go over all these features and how they work!

## Support for 3D and n-dimensional tracking

In the past few years, 3D has become more ubiquitous thanks to LIDAR and detection models that output cuboids instead of 2D bounding boxes. This trend will only accelerate in the future, so we had to do something about it.

There was no fundamental blocker to adding 3D object — and more generally, n-dimensional object — tracking support to Norfair. The Kalman filter can estimate objects’ trajectories no matter the number of dimensions, so we generalized the rest of Norfair to support it.

The new 3D support in Norfair opens the door to new applications in augmented reality and non-video realms.

We made a demo that uses Google’s MediaPipe Objectron, a mobile real-time 3D object detection solution for everyday objects.

3D tracking with Norfair and MediaPipe's Objectron.

## Camera motion estimation

What do video analytics applications on self-driving cars and soccer matches have in common? The camera is not static. This makes object tracking more challenging because the objects move but also does your frame of reference. But don’t worry, we got you covered!

We added a new optional component that can be used to estimate the movement of the camera. Internally, this component will map camera movements and estimate coordinate transformations to construct a fixed reference frame, over which the tracking of the objects will occur. You then pass these coordinate transformations to the Tracker, and it will use them internally.

This will significantly improve tracking results under some scenarios by compensating the camera motion. Let’s look at an example:

Improvements by estimating camera motion using optical flow.

On the left, we ran the usual tracking without camera motion estimation. By the end of the video, the person gets assigned id 5, meaning that the tracker lost it 4 times. The reason the tracker performs this bad is simple: the camera movement makes the apparent movement of the object too erratic for the tracker to accurately estimate the future position of the object.

On the right, we estimate the motion of the camera and stabilize the detections. Now the detections can be processed in a fixed reference making them much easier to track.

In code, this looks really simple:

The second benefit to this is that now the position of objects in this fixed reference frame is available to the user.

For instance, if you want to know if a person entered a certain area or the path they walked through, now you can do it on a fixed set of coordinates, independent of how the camera moved. In the following example, we draw the paths of the players in a fixed frame of reference. Note how it’s consistent no matter the panning movement of the camera:

Tracking soccer players under a moving camera.

### Motion estimation: behind the scenes

If you are wondering how this works, the solution involves some classical computer vision. On each frame, we sample corner points and calculate the optical flow associated with each one. Optical flow is just a way of calculating the movement vector of a point from one frame to another.

Armed with these vectors, we simply estimate a transformation that undoes the movement for each frame. Furthermore, by concatenating these transformations we can take points in each frame and calculate their coordinates in an absolute frame of reference corresponding to the first frame of the video.

Estimating optical flow for more accurate tracking under a moving camera.
Sampled points with arrows help visualize the optical flow.

The sampled points are key for this method to work. This is why we provide a number of parameters for the user to customize how many points are sampled, how crammed together they can be, and even to avoid certain regions of the frame. This last point is important since it allows users to mask out the tracked objects and the detections, forcing the points to be sampled from the background of the scene.

See this feature in action in the new Hugging Face Space. If you want to apply it to your own project, check out our demo on GitHub.

## Re-identification (ReID)

Re-Identification of objects in complex scenarios such as those with heavy occlusions brings the need to consider not only positional information but also appearance. We had implemented some forms of ReID in the past with previous versions of Norfair, attaching embeddings to each detection and considering them in the distance function. This is still possible, but we found that was not enough.

In this new iteration, instead of relying on a combination of position information and embeddings to track the objects all the time, we added a new matching stage to deal with ReID. This new stage focuses on matching recently lost objects with those new objects that are about to be initialized. This has its own set of rules that can be tuned by the user and is independent of the regular tracking stage we’ve worked with until now.

This new stage of ReID matching has the benefit of delaying the decision until you have gathered the most evidence about the new object. This is important since partially-occluded objects tend to have poor quality embeddings and you don’t want those to interfere with your matching.

### Understanding the object lifecycle

1. Every time a tracked object is successfully matched with a detection, the counter is increased by one. Matches occur when the customizable distance function goes below a threshold.
2. On the contrary, for every frame with no match, we subtract one from the counter.
3. When the hit_counter reaches initialization_delay the object is considered active. It will continue accumulating hits (+1) with each new match until it reaches hit_counter_max, where the counter is capped.
4. If hit_counter drops to 0, the tracked object is considered inactive and ReID kicks in: the object will wait for reid_hit_counter_max frames to be matched with one of the initializing objects. After this, the object is deleted. In case of a match, the older object is activated again and the younger one is deleted after being merged into the older one.

### Putting it all together: a demo of ReID

In Norfair, the user is free to define how to compare objects for ReID. Any type of embedding can be used. Depending on the application, you might want to use the embeddings from your detector or the ones coming from another model specific for ReID.

To provide a straightforward example of this feature that shows the power of embeddings in a simple case, we took inspiration from the synthetic example on motpy and adapted it. It’s basically a simulation video where boxes are moving around. When boxes get occluded by other boxes we just grab the detection from the top box, so any other box occluded is not getting a detection. For this demo we went with the simplest embedding we could think of: the color histogram inside the bounding box. On the left, we are only using positional information, while on the right the ReID stage is being used:

Demo of ReID with appearance embeddings and Norfair.

This demo can be found on GitHub. Take a look at it to get a better idea of how to use the new ReID stage.

In a more complex case, we suggest looking at models that generate embeddings specific to the type of ReID that you wish to perform (person, vehicle, or other).

## Other news

Other things relevant to Norfair 2.0:

• New site with official documentation which we plan to keep improving.
• Norfair now ships with the most common distance functions, so you don’t need to write your own copy if you are dealing with standard cases.
• Norfair now uses our optimized Kalman filter implementation, which is significantly faster than filterpy.
• Regarding the demos:
• All have been implemented in Docker to make them more easily reproducible. Moreover, we added a demo in our Hugging Face Space.
• We added several new ones on YOLOv7, MMDetection, moving camera, 3D tracking, and ReID. More to come!
• Many other bug fixes and improvements.

## Closing

We want to thank all the people and organizations who are actively using and contributing to Norfair. Seeing you choose Norfair in your projects, pushing its limits, opening GitHub issues, and contributing back has made the tool much better, and working on it much more gratifying. Community feedback has also been paramount for prioritizing our roadmap.

Hope the new features excite you as much as they do us. More will come! 🥂

Services
Resources
Company


text:
How much is a Human hamster ball?

Human hamster balls are also known as zorbing balls or soccer bubbles and inflatable bumper balls. Human hamster ball can be classified into two kinds, the first one of which is suitable for road surfaces, while the other one will be suitable for water.

Zorbing prices range from $5 for a player to the$100 mark. The cost varies based on where you’re playing and the length of time you wish to play. There are many Zorbing balls available on the market. Are you a bit confused?

After the thrill of rock climbing and bungee jumping, hamster balls are an additional popular and exciting idea. It is a solution for people who love to be active and offers high security. It can be used in a variety of tourist destinations such as water parks, as well as kids’ parks.

Celebrities and Hamster Balls

Inflatable spheres have been gaining popularity over the last few years. There have been numerous appearances by Zorbs in different television programs worldwide.

In early 2016, Lindsey tried to cross over the Irish Sea in an inflatable globe. Not to be left out, Jimmy Fallon, Collin Farell, and Chris Prat engaged in a hilarious bubble soccer play on The Tonight Show in real-time.

Read Also: San judas tattoos meaning

Hamster Ball Structure

The ball comprises two parts with one ball in another, with an air layer in between. They are joined through a complex network composed of nylon cables. There are often more than 300 threads that connect them. This design protects the rider from harm as it functions as a shock absorber to cushion bumps during the ride.

Size

The typical size of the human hamster ball is about 3 meters (10 feet) across. In one instance, Nissan placed one of their cars into the zorb of their design and then rolled the ball down an incline to create a promotion in the name of security.

In any case, for the most common balls in the market, the diameter of the inner sphere is typically 2 meters (6 7 inches or ft). The 50cm (20in) between two spheres constitutes an air cushion. The inner and outer spheres are connected through nylon strings. Zorbs are equipped with one or two tunnel entryways.

What is the reason hamster balls are in existence?

While hamster balls are intended to guard the hamsters, there are risks like stairs and other areas that are high enough for hamsters to fall from. They could fall, resulting in the death or injury of a hamster.

Do hamster balls have to be discarded?

Hamster balls create confusion and stress. As hamsters are prey animals living in rugged environments, their natural response when they are allowed into the open spaces of a large area is to flee and hide.

What is the reason my hamsters’ balls are that big?

They are symmetrical, do not itch, and don’t change in size. They’re normal and not something to be concerned about. Additionally, the testicles of male hamsters expand in spring; therefore, two significant bumps on the bottom of your hamster’s body are usually not something to be concerned about.


text:
RedHat’s Matthias Clasen came up with the idea of caching the MIME information provided by the Shared MIME database (the list of MIME type aliases, subclass information, the glob patterns, the magic patterns and the XML namespaces) in a mmapable file today. With his attempt, there’ll be one cache file (mime.cache) per mime directory, e.g. on most Linux systems, this will be

• /usr/local/share/mime/mime.cache
• /usr/share/mime/mime.cache
• ~/.local/share/mime/mime.cache

while on for example FreeBSD, this will be

• /usr/X11R6/share/mime/mime.cache
• /usr/local/share/mime/mime.cache
• ~/.local/share/mime/mime.cache

(both with default \$XDG_DATA_DIRS settings). He also provides patches for both xdgmime (the MIME implementation used by gtk+ and gnome-vfs) and update-mime-database.

The general idea is good, and the implementation looks good too. We should consider using the cache for Thunar as well. My major concern about this currently is the bad data locality with many mime.cache files (which should only happen if the admin is on crack) and the probably reduced performance due to the big endian to little endian conversions (we need a benchmark here to decide if it’s really worth to spend another thought on this conversion). If we’d adopt this idea for Thunar, we could further reduce startup time, as the process would not need to parse the MIME database first, and it would reduce the memory overhead, tho this is less critical in case of Thunar, since all windows (and the desktop background) run in the same process space and thereby share the MIME database.

Anyways, it’s nice to see some useful activity on the xdg mailinglist again, after all this discuss it to death-threads about D-VFS and gconf.

Edit: Additional notes can be found in this mail.


text:
## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

Chapter 17

# Problems

These practical problems, developed over many years from actual experience, provide the opportunity to apply the material in the book by practicing the basic techniques. Problems involving application choices are generally so subjective that I have avoided them whenever possible. Each problem has a message to be unlocked with a reasonable minimum of labor—that is, with a good RH factor, where R denotes relative minimum labor and H denotes high educational value.

## Chapter 2

1. 2.1 A wye-connected generator has a nameplate rating of 200 MVA, 20 kV, and its subtransient reactance (${{X}^{″}}_{\text{d}}$ ) is 1.2 pu. Determine its reactance in ohms.
2. 2.2 The generator of Problem 2.1 is connected in a power system where the base is specified as 100 ...

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required


text:
×
Back to all chapters

# Linear Equations

Your music collection grows by 20 songs every week. If you currently have 1,000 songs, how many weeks will it take to amass 3,500 songs?

# Linear Equations - Intersection of Lines

 In the graph above, $$l_1$$ is a horizontal line with $$y$$-intersept $$3$$, and $$l_2$$ has a slope of $$2$$ with $$y$$-intercept $$-1$$. Find the coordinates of the intersection point of the two lines.

What is the interval of all possible values of $$a$$ such that the two lines $$x+y=\lvert a \rvert$$ and $$ax-y=196$$ intersect in the first quadrant?

Consider the line passing through two points $$(5, 0)$$ and $$(0, -5)$$. Consider another line passing through two points $$(-4, 0)$$ and $$(0, -2)$$. If these two lines and a third line $$y=ax-85$$ intersect at one point, what is the value of the constant $$a$$?

A line passing through the intersection point of the two lines $x+2y+3=0\;\;\text{and}\;\; 2x-y+\frac{a}{2}=0$ also passes through two other points $$(9,\ -8)\$$ and $$\ (-17,\ 9)$$. What is the value of $$a$$?

Suppose the intersection point of the two lines $x-2y-9=0, 2x+3y-53=0$

is $$P=(a,b)$$. What is the value of $$a+b$$?

×


text:
## Counting Subtrees

Arrangements, sorting, packing, partitions, critical path analysis, networks, graphs, ...
szymczak
Posts: 15
Joined: Wed Nov 23, 2011 8:43 am

### Counting Subtrees

Consider the following rooted binary tree.
For each node v, consider the subtree rooted at v. For the tree above we get the following subtrees (ignoring duplicates).
Note how the second and third subtree above are considered distinct.
We notice that there are 5 distinct subtrees.
Let T(k) be the number of rooted binary trees with exactly k distinct subtrees.
For example, T(1) = 1, T(2) = 3, T(6) = 14487.

Find T(16) mod 109.

jaap
Posts: 550
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

### Re: Counting Subtrees

Unfortunately that sequence (including the 16th term) is a bit too easy to find in the OEIS, which in turn links to the extensive stackexchange discussion that generated the sequence.

szymczak
Posts: 15
Joined: Wed Nov 23, 2011 8:43 am

### Re: Counting Subtrees

Yea I wrote the long SE post. I was hoping someone here could come up with a more elegant solution, a way to find say T(100). Should have added a twist so it's not on OEIS.

mpiotte
Posts: 1914
Joined: Tue May 08, 2012 4:40 pm

### Re: Counting Subtrees

Interesting question. We could have made a PE problem out of this.
Dynamic programming is once again effective for this kind of problem.
I get the following result with O(n6) time and O(n5) memory complexity, keeping things under 1 minute:

Code: Select all

T(  1) =                                                                                1
T(  2) =                                                                                3
T(  3) =                                                                                15
T(  4) =                                                                                111
T(  5) =                                                                                1119
T(  6) =                                                                                14487
T(  7) =                                                                                230943
T(  8) =                                                                                4395855
T(  9) =                                                                                97608831
T( 10) =                                                                               2482988079
T( 11) =                                                                              71321533887
T( 12) =                                                                            2286179073663
T( 13) =                                                                           80984105660415
T( 14) =                                                                         3144251526824991
T( 15) =                                                                       132867034410319359
T( 16) =                                                                      6073991827274809407
T( 17) =                                                                    298815244349875677183
T( 18) =                                                                  15746949613850439270975
T( 19) =                                                                 885279424331353488224511
T( 20) =                                                               52902213099156326247243519
T( 21) =                                                             3349349968648038146756090367
T( 22) =                                                           224008474237110735818328494463
T( 23) =                                                         15784481675552990217004355155455
T( 24) =                                                       1168980983609271828189092132883711
T( 25) =                                                      90789628326447871556044333389045759
T( 26) =                                                    7379671591913867687413635289032264447
T( 27) =                                                  626614739073537117360355723435583202303
T( 28) =                                                55485577115128371124823191707413779511295
T( 29) =                                              5115454359795311832797712178681313437868031
T( 30) =                                            490310519553284322702752182845108549592875519
T( 31) =                                          48791468725761851199449519655205582018214453247
T( 32) =                                        5034369951561638858570924846904585834050350695423
T( 33) =                                      537964973713998388999889514657023448872676106387455
T( 34) =                                    59467875273261002743066517406088534107058019534881791
T( 35) =                                  6793164751908330197524197123822029953827509352828620799
T( 36) =                                801109989079284363555583411034360284129353799268061933567
T( 37) =                              97439774800234157527936865903950535420883900577338857119743
T( 38) =                           12212966842762677445920937938343431481488602466294029830690815
T( 39) =                         1576102568966667715777124386738220705637159432149738884321779711
T( 40) =                       209258483862486797315415155447759265226105288742426622806920744959
T( 41) =                     28562201839019312638597793617092469246748808899696158195441127292927
T( 42) =                   4004990457079402844735981023665557864353516616675783648506722317185023
T( 43) =                 576526026299295223790052290449858497256713186201245773065940447813943295
T( 44) =               85146064699321983042897937056238854596395499358114811035260281811412877311
T( 45) =            12893542166293539662215995925168478556182067594359044316243370721375672729599
T( 46) =          2000727533814254009821605140674456289993982732539619481011084097733785705259007
T( 47) =        317957574456214497639799228877982309585978351841711260500637449128815475171262463
T( 48) =      51723046966659730222763456537636334604630427786738469658935909161758736064153665535
T( 49) =    8608171476830272116837045761769711695845434641798904200741065837473162376652967903231
T( 50) = 1464998441941572191008123746853973707755444234070174247285019683005025893928381236264959
Total time =    56.47 s.

Alternatively, I can also do O(n7) time with only O(n4) memory.
Anyone else willing to confirm?

szymczak
Posts: 15
Joined: Wed Nov 23, 2011 8:43 am

### Re: Counting Subtrees

Confirmed up to T(20). Those are all the values I had though. I was thinking about submitting it as a potential Euler problem but I didn't have a good solution for it. Need to figure out your DP.

mpiotte
Posts: 1914
Joined: Tue May 08, 2012 4:40 pm

### Re: Counting Subtrees

Results for 51 to 100 in 2h20:

Code: Select all

T(51)=254835085445543722215634944512650148042285342540187050263916802228774246942593912081809407
T(52)=45287850941429082230865074942447214927480513849149509424582203044956495749331824540996009983
T(53)=8218963331111956374791801588528351546948056492993708307325513881997526207328619264182647914495
T(54)=1522596907111625798328686575910961990495813331669959225982902238125888016145066514677839522004991
T(55)=287814090727233343624724823200646668827772592350698110858734950111852996110935883732866646513418239
T(56)=55492147073182888752732748303425634686236489102328973223305697845440886854038884262659866188537724927
T(57)=10908943524318124866584558646577574495553717331120678665106248223683710369781228810542474617915602632703
T(58)=2185801382287953120354455770936078446546062996422979632701095128528097200693145017748413064359853671776255
T(59)=446237646438675493197277447367311468775663138709802489429277567738843688655751379079922408800073713837146111
T(60)=92790843834597575121485103242705040622688846873730368075858749213891410572441916279604111799486761449540812799
T(61)=19646641171352959128943032240587277469876366612142648815606393436583923192190783828436826394378226808238100185087
T(62)=4234297317141392818776911727668104602518488571957721872591943900782418973864516124091250043305321553783485588701183
T(63)=928654755551200768501604583930786589349974337764115289022292847199094382526705850766775504030165111160736477280731135
T(64)=207196035108109817419415207529410552319657099478997256005811238055683316176562878461295520559720967110173930205393190911
T(65)=47015512965942941486348873225844767761817421240038369180684005370273252393794291683498718907840707989451350827899436400639
T(66)=10847152207421585934354391653976470993032677409411645474042644823439928801374144082861597910459472615120528085963582445191167
T(67)=2543847202437147943123431892103657235324535685483601527456696700482985141653880991051275786510918494677879660473516395487821823
T(68)=606256586544372096615517709260195923184537323966906378521746448397643397418750686429305600939763256111873776724831013276956491775
T(69)=146792836641992755140949619041659265194932531118677411078798580252172017123178764277827372524214237407641120120899832528614543327231
T(70)=36102077128783856959458374601567918829170934800282306711028605033992963158443958589798870173789422328512656453175904351672706046361599
T(71)=9016489971634686129975111308337566526313370570256573117977358040749860454759660046995889040008808845073103840385576376269929730558394367
T(72)=2286245119110048953986679359440690960661397501936954984932288490549292397629633943067234258744834776961083676101294254298720870046387666943
T(73)=588427341086117363145869973606117129388791944015177812079253508311440080714882269523329960315250997919393787263379619837499401477929289383935
T(74)=153693373181961024156183699261159229332498828612139388088088745189580538270567166315550720910963090823791657644408653610031518128020391216545791
T(75)=40730500267690831653594440708975666112777665312814993294015508096272887377484130284652377559589198909310096450695441584575421619756130760424161279
T(76)=10949623299336364303604974431085058392596398853862021280565818257282910272468689554353647415429386940744044923521631732561680283705330058130660261887
T(77)=2985439981349112881966444020503233551718324073512607849410831795577100961120063015748039172099907850914318560285188112314434512081124401389970615435263
T(78)=825399915024681556607625427652174413646246831616488253415790565473334494396064627837712297536563191673019723789717703780677649014794676109032959399428095
T(79)=231359196682252971620348967126049803799281177361644710778152431156321965453021650877647845776379878550157036867866741068936823820595923110946597997182451711
T(80)=65735028246138729486111958146802926444641136913057796673618618301813606529291936341059827649359277626195785453717614323378616900798604520795521409802085335039
T(81)=18928585688860145587610148324230761367391260801847422051653321664351830341359231985244452433198930143540282532691478895599229419250437593801642958544640722075647
T(82)=5523013871241715479945855035168627612834284381097964153704930535910572020227555358884568744174883417447026810140729028754874120900524941556411545165911664984326143
T(83)=1632668684755395169078949317322595412246175362026555791784319666400016733947245545905211998058819628605027648176353368659376734697688275978755080183362128727062347775
T(84)=488892143468568249491626529094674672405558366621449853452020286719845023387976786398253014293042170537641627495881457860280747792395466015782797952863675532002524659711
T(85)=148269547620695602327411393167658345704244757721363029851313252963024137475342178368067201246719896412952991907871610438316386838424952207095851398724505631337231134228479
T(86)=45535204619014192923397238751714292535848318131816373557799673250766054116479046447118139105405058046738530346176804327067789322714123896012402837154344368845573041608982527
T(87)=14159019469403608334295290534756351645535814250289612571014265391221839785647232197098984709773899437836762934443180419011521085400487770844585438747551810923772712883043958783
T(88)=4457027461420224550250224177702627598591419828202762445302276523564238570838863418412685981558313220009218939930992608827885311170032638336495432873243051685056072772191535497215
T(89)=1420106373451041197128706760959469423251147066674187382035973037270663937609069489102489346907294161752941819692424327112735873734795689846893046727961083091947353931366386821496831
T(90)=457929393554747857904738028107197246892301742012245327563897290337381949602749294549169912891326457606789580170867916210270702659044552334424647076098693610541935002307733299543408639
T(91)=149423287370483314511628840599093582643271044102235204655747515666474963152324645262910252800644723735598763396498163386314417300879446237150635318720554288176213041717249143768380080127
T(92)=49331187797795147340599872468700165856169475256580009818021273647256623229797357374780555374648544220704635823268646924491220546089555451971400516369455557916642651001718178457215674875903
T(93)=16475973528303040263834696975864047068631891522197163561555432124848322365283985033522566336809649894684667307384426494090663648109002485355048606922876782179092654796792580176661489622450175
T(94)=5566097368536569872461666010363123942115725963564114547045811936105465550753961104488123945346276199649713699812608302950604946037279419282243078297770075960457029858541662151137527449247547391
T(95)=1901804680891364522653195739383310106941797935709273838428473871954079573372741841127578543145019408602982471511376419070301745554594184574503992306504891408045378417435901893569808837260104171519
T(96)=657117158009218553023967905328870809671140757015463607947560260156787681924584431099344818995651643370308471034988220459436791777620450369228415634985667664992297136076947064192295256376246269902847
T(97)=229577337946512462203729298756201222174834619525408637608026400807460449720958705002750282656270250271861262373008163295259337771557693281807273580955420060018984634441004592388056028408828789600026623
T(98)=81091097716583798198367504419675193302839237890226926251564079120408267913597110561334222993977241436483266420378997047202752749995965263392456792524940331094197041643412734736794702961010010484570587135
T(99)=28955096488971376189813894570849386252788973564824795476013139629315218166255385930937462771759852727500957723974812026319151930550590150964866098472781333195419544617904119392156067643028895288111778496511
T(100)=10450457132583269349450617394714442608751206265530678410381635192788309450706495588686041179258450375873075914837789821383155323561722331425003064223479600883976025606894381013869321432750565338950806462791679
Total time =  8371.34 s.

Dynamic Programming approach part I:
Expand

mpiotte
Posts: 1914
Joined: Tue May 08, 2012 4:40 pm

### Re: Counting Subtrees

Dynamic Programming approach part II:
Expand
I'm sure there are ways to simplify this approach, but I did not investigate further. I'll post some code once I have cleaned it up a little.

szymczak
Posts: 15
Joined: Wed Nov 23, 2011 8:43 am

### Re: Counting Subtrees

Brilliant solution! I think I might be able to simplify B but I need to think on it more. Unfortunately it'll have to wait until tomorrow.. I've barely had enough time to read your posts these last two days

szymczak
Posts: 15
Joined: Wed Nov 23, 2011 8:43 am

### Re: Counting Subtrees

I wrote my own (slow) code and confirmed your values up to T(50). It uses your algorithm so how well it "confirms" is debatable. For the sister sequence T' where we don't distinguish between
the only thing that needs to change is the number of new subtrees k(i+j)+k(k+1)/2 in the calculation of A. The code is in Python2.7 and it uses numpy. Calculating T(50) takes about 10 minutes.

Code: Select all

T'(1)=1
T'(2)=2
T'(3)=6
T'(4)=25
T'(5)=137
T'(6)=945
T'(7)=7927
T'(8)=78731
T'(9)=906705
T'(10)=11908357
T'(11)=175978520
T'(12)=2893866042
T'(13)=52467157456
T'(14)=1040596612520
T'(15)=22425725219277
T'(16)=522102436965475
T'(17)=13064892459014192
T'(18)=349829488635512316
T'(19)=9983594851603361440
T'(20)=302595243049622291132
T'(21)=9709654327333904247720
T'(22)=328903501349364758535742
T'(23)=11730834245562877653553046
T'(24)=439499477724515631342816210
T'(25)=17259105843445284845953724977
T'(26)=709001872452143272423199623310
T'(27)=30412531388984531527650718225872
T'(28)=1359882311145651991023001603605331
T'(29)=63287078411450376102052573665416495
T'(30)=3061000444512448121107521821538907542
T'(31)=153659477474364121511372973556664569000
T'(32)=7995672159062043048918465357429752114537
T'(33)=430762266692393567329188251346127405562256
T'(34)=24000860250584249352744670773943113490702210
T'(35)=1381564098165671982201523273255799997524948462
T'(36)=82081551157095967346141807570437481606862885930
T'(37)=5028632681971636699786149067669638356244385933912
T'(38)=317399328521955656168741128730106175577741456307716
T'(39)=20623209084695165932602694167147745052335058810134905
T'(40)=1378357817942999597505867314474520294477794992100237467
T'(41)=94689537403423524528866753957217500202434426019729924875
T'(42)=6681458463034996867636810855811215755925054063022843457462
T'(43)=483926889203663723347220556626654810090447112583817037678646
T'(44)=35954338094829256894524920526678058655784779349619905842274125
T'(45)=2738562812650855914400529909833599741271576709207369964088421487
T'(46)=213718857122989323339364170908419911918841623238860998005357418665
T'(47)=17079369249041898531359197994299681178883933073815373088069470515392
T'(48)=1396948203185223071392625392717685335255334095391664072757423526911131
T'(49)=116882303493124092348455672322477033799790643961967597785062203772221860
T'(50)=9999238552244796357461982943895456551979492719134019786696565696441397152
T'(51)=874245083489161484924827693815494801763032648833194756817087540598837277555
T'(52)=78082571579635930573669814620079895085447362885948654627295419729906106936582
T'(53)=7121047151134377177271918046725429059209297757174655919396212949551250522643656
T'(54)=662863162428457144080702189230716513945533188450535494739460713421524917906238225
T'(55)=62953867306295553469403153262600744872892877082183242322537987285573803277838780172
T'(56)=6097813253866341850267643517792216477211951028774395471171801920580989201460832793335
T'(57)=602170879766887225098497786760958485739987872241127276273402244011625891600226741146657
T'(58)=60604630083061404980235881407169169630862930869653235565773812719485573416414875308629191
T'(59)=6214185799485070374623688284668871769488914746648225437661589893135077776042641048339896045
T'(60)=648951368449440444086127770295302998655584699961021393031326152093639801258957097962989693552
T'(61)=69000394787029810249613325306581568357736077965705583853528531527540370037411244297689599570030
T'(62)=7467395844421242060029940871627887215912045441528843683702244511310868417341296936501534359152382
T'(63)=822310891297469761405329050745738161611261495782082830687788811997496827873119118469126508534507696
T'(64)=92114391217755012834305284336117081650072713636231943752916793614218708970949544927017381695434424865
T'(65)=10493559214257242256526457352556131378333286574545327589425798910700798275838126647311299643028471635697
T'(66)=1215360640648237760639718339151422176513325564738518244436562071102838557397903931301249284466119513861045
T'(67)=143074194363064208644657327225914416800855433373973027852043072470374249429872869715070169583738163954344137
T'(68)=17115180726876180450731922408823710770636530849589657482602321235329081665528720187379096876726373367017386781
T'(69)=2079980551609732309595154934543650430068950077275253213511414410894279837525855761335787978914460331864889113575
T'(70)=256738736796213362308527599608757065176561083782237398354650655974608096220515215875658163796782791914144917865737
T'(71)=32179377277830043835868719196550917494190748987905081552396926458215872684015547511739274087781392766356937542473135
T'(72)=4094686441906531182091415133948943821993414121670322212671922946341533297714845796664465236171508742284040962606519652
T'(73)=528841943194356796809513822339846662472514992024371643639311767919782445952963783453853430358680924615671760419065882781
T'(74)=69310889092971535131136521334524312335340050079207074130818235116138588601709144037724993477120401490590970020109919919765
T'(75)=9216330550066055115593707202968113470938861144433599860381353450786857511821018631580608603714687022852864894832438572716007
T'(76)=1243107587282513240015523325992473472219888428789811444909910259254120332111907597962522383754574765924431842603199251605229965
T'(77)=170046989689877952007767633162728817556301178528193742909205121127242154105496583912331107219510839524692751033549089473418645127
T'(78)=23586116798766560891370993889548421899731997481568867835181572042262811623537310162340970452243924975550807349164743727933966245891
T'(79)=3316584624490571969875069497921439883891376783130125456415144307074796058025586538441924137680152938388360999226943603003205727617985
T'(80)=472710033613557597987526205304465938761095903914050658546993862065860713113526131183830707315189953367887597235923760016100997254848037

Here is the code subtree.py

Code: Select all

from subtree_helper import *

def A(i,j,k,t):
newt = (i+j+k)**2 - (i+j)**2 if plane else k*(i+j)+k*(k+1)/2
return  ( binom(newt, t) - sum( binom(j,p) * binom(k,q) * A(i,p,q,t)
for p in xrange(min(j,t)+1)
for q in xrange(min(k,2*t)+1)
if (p,q) != (j,k) ) )

def B(i,j,k,u,t):
return sum( binom(j,p) * binom(k,q) * A(i,p,q,t)
for p in xrange(min(j,t)+1)
for q in [j+k-p-u] )

def C(h,c,u,t):
if (h,c,u,t) == (1,1,0,1): return 1
if h <= 1: return 0
return sum( C(h-1,i,j,k) * B(i,j,k,u,t)
for i in xrange(1,c+1)
for j in xrange(c+u-i)
for k in [c+u-i-j] )

def T(n):
return sum( C(h,n,0,1) for h in xrange(1,n+1) )

if __name__ == "__main__":

n = 20
plane = True                                         # CHILDREN ORDERED?
toc = time()

binom = Memo_Array([4*n*n+1,n+1]) (binom)            # DECORATE FUNCTIONS
B = Memo_Array ([min(n,50)+1]*5, partial=n>50) (B)
A = Memo_Array ([n+1]*4) (A)
C = Memo_Array ([n+1]*4) (C)
T = Memo_Array ([n+1]*1) (T)

for i in xrange(1,n+1):
print 'T({}) = {}'.format(i,T(i))

h,m,s = hms(time()-toc)
print 'Time elapsed {}.{}.{}'.format(h,m,s)

Here is the helper code subtree_helper.py

Code: Select all

import operator as op
import numpy as np
from functools import wraps
from math import factorial as fact
from time import time

def prod(L): return reduce(op.mul,L,1)
def perm(n,k): return prod(xrange(n,n-k,-1))
def binom(n,k): return 0 if k<0 or k>n else perm(n,k)/fact(k)

def hms(t):
h = int(t/24/60)
m = int((t-(h*24*60))/60)
s = round(t-(h*24*60+m*60),3)
return h,m,s

def Memo_Array(dims, fndims=[], partial=False, nptype='object', negv=lambda x:0):
"""Memoize into a numpy array
- partial for when the cache isn't large enough to store all the values
- nptype is the datatype for the numpy array
- negv provide a base case for negative arguments
"""
def factory(func):
cache = func.cache = np.zeros(dims+fndims,dtype=type)
hit = func.hit = np.zeros(dims,dtype='bool_')
@wraps(func)
def wrapper(*args):
if min(args) < 0: return negv(args)
if partial and reduce(lambda x,i: x or args[i]>=dims[i], xrange(len(args)), False):
return func(*args)
if not hit[args]:
cache[args] = func(*args)
hit[args] = True
return cache[args]
return wrapper
return factory

mpiotte
Posts: 1914
Joined: Tue May 08, 2012 4:40 pm

### Re: Counting Subtrees

Here's my own code in Java.
Things to be careful with:
- There is an offset of 1 in the height because the empty sub-tree with zero node is considered the smallest tree.
- The order of the indexes in the tables A, B and C is different from the equations above.

Code: Select all

import java.math.*;

public class CountingSubtrees
{
public static void main(String[] args)
{
try
{
new CountingSubtrees().run(args);
}
catch (Exception e)
{
e.printStackTrace();
}
}

private CountingSubtrees run(String[] args) throws Exception
{
long    start = System.currentTimeMillis();
int     size  = 51; // Size has extra 1 because empty tree is counted in the size.
if (args.length > 0) size = Integer.parseInt(args[0]) + 1;
long[]  mods;
if (size <= 51)
{
mods = new long[]{1000000007, 1000000009, 1000000021, 1000000033, 1000000087, 1000000093, 1000000097, 1000000103,
1000000123, 1000000181};
}
else if (size <= 101)
{
mods = new long[]{1000000007, 1000000009, 1000000021, 1000000033, 1000000087, 1000000093, 1000000097, 1000000103,
1000000123, 1000000181, 1000000207, 1000000223, 1000000241, 1000000271, 1000000289, 1000000297,
1000000321, 1000000349, 1000000363, 1000000403, 1000000409, 1000000411, 1000000427, 1000000433};
}
else
{
throw new RuntimeException("Build large enough mods table to recover full value using chineese remainder theorem.");
}
int[][] result = new int[size][mods.length];
for (int iMod = 0; iMod < mods.length; ++iMod)
{
long mod = mods[iMod];
System.out.format("Processing #%02d/%02d mod = %10d time = %8.2f s.\n", iMod + 1, mods.length, mod, 0.001*(System.currentTimeMillis() - start));

// Compute binomial coefficients
int[][] bin = new int[size*size][];
for (int i = 0; i < bin.length; ++i)
{
bin[i]    = new int[i + 1];
bin[i][0] = 1;
bin[i][i] = 1;
for (int j = 1; j < i; ++j)
{
bin[i][j] = bin[i - 1][j] + bin[i - 1][j - 1];
if (bin[i][j] >= mod) bin[i][j] -= mod;
}
}

// Compute A. Order of indexes is A[i][t][k][j].
int[][][][] A = new int[size - 1][][][]; // c, s, u, t, r
for (int i = 0; i <= size - 2; ++i) // At least one in t and one in s.
{
A[i] = new int[size - i][][];
for (int t = 1; i + t <= size - 1; ++t) // At least one in t
{
A[i][t] = new int[size + 1 - i - t][];
for (int k = 1; i + t + k <= size; ++k)
{
A[i][t][k] = new int[size + 1 - i - t - k];
for (int j = 0; i + t + k + j <= size; ++j) // At least one in t
{
int np = (i + j + k)*(i + j + k) - (i + j)*(i + j);
if (t > np) continue;
long z = 0;
for (int q = 1; q <= k; ++q) for (int p = 0; p <= j; ++p) z = (z + (long)bin[k][q]*bin[j][p]%mod*A[i][t][q][p])%mod;
z = bin[np][t] - z;
if (z < 0) z += mod;
A[i][t][k][j] = (int)z;
}
}
}
}

// Compute B. Order of indexes is B[i][j][k][t][u].
int[][][][][] B = new int[size - 1][][][][];
for (int i = 0; i < size - 1; ++i)
{
B[i] = new int[size - i - 1][][][];
for (int j = 0; i + j < size - 1; ++j)
{
B[i][j] = new int[size - i - j][][];
for (int k = 1; i + j + k < size; k++)
{
B[i][j][k] = new int[size + 1 - i - j - k][];
for (int t = 1; i + j + k + t <= size; ++t)
{
B[i][j][k][t] = new int[j + k];
for (int q = 1; q <= k; ++q) for (int p = 0, u = j + k - q; p <= j; ++p, --u)
{
B[i][j][k][t][u] = (int)((B[i][j][k][t][u] + bin[k][q]%mod*bin[j][p]%mod*A[i][t][q][p])%mod);
}
}
}
}
}

// Dynamic programming:
// Iteration: height (h)
// State: number of connected subtrees (c), number of unconnected subtrees (u), top level subtrees (t)
// Value: number of configurations
int[][][] C = new int[size][size][size];
C[0][0][1]  = 1; // Empty tree
for (int h = 1; h <= size; ++h)
{
int[][][] old = C;
C             = new int[size][size][size];
for (int i = 0; i < size - 1; ++i) for (int j = 0; i + j < size - 1; ++j) for (int k = 1; i + j + k < size; k++)
{
long y = old[i][j][k];
for (int t = 1; i + j + k + t <= size; ++t) for (int u = 0, c = i + j + k; u < j + k; ++u, --c)
{
C[c][u][t] = (int)((C[c][u][t] + y*B[i][j][k][t][u])%mod);
}
}
for (int i = 1; i < size; ++i) result[i][iMod] = (int)((result[i][iMod] + C[i][0][1])%mod);
}
}

// Generate final results using chinese remainder theorem.
for (int i = 1; i < result.length; ++i) System.out.format("T(%3d) = %s\n", i, crt(mods, result[i]).toString());
System.out.format("Total time = %8.2f s.\n", 0.001*(System.currentTimeMillis() - start));
return this;
}

private BigInteger crt(long[] mod, int[] a)
{
BigInteger x = BigInteger.ZERO;
BigInteger n = BigInteger.ONE;
for (int i = 0; i < mod.length; ++i) n = BigInteger.valueOf(mod[i]).multiply(n);
for (int i = 0; i < mod.length; ++i)
{
BigInteger p = BigInteger.valueOf(mod[i]);
BigInteger q = n.divide(p);


text:
# Relation between heat capacities and van der Waals equation

patrickmoloney

## Homework Statement

Find the expression for $c_p - c_v$ for a van-der-waals gas, with the equation of state

$$\Bigg{(}p+\dfrac{a}{V^2}\Bigg{)}(V-b)=RT$$

## The Attempt at a Solution

Basically I've proved

$$c_p - c_v = \Bigg{[} p + \Bigg{(}\dfrac{\partial E}{\partial V}\Bigg{)}_T \Bigg{]}\Bigg{(}\dfrac{\partial V}{\partial T}\Bigg{)}_p$$

($E$ and $V$ are the energy and volume of one mole).

The question states that

$$p + \Bigg{(}\dfrac{\partial E}{\partial V}\Bigg{)}_T = T \Bigg{(}\dfrac{\partial p}{\partial T}\Bigg{)}$$

I don't need to prove this I just need to use it.

So far the only thing that I can come up with is rearranging the van der waals equation in terms of $p$ which gives

$$p = \dfrac{RT}{(V-b)}-\dfrac{a}{V^2}$$

Then

$$\Bigg{(}\dfrac{\partial p}{\partial T}\Bigg{)}_V = \dfrac{R}{(V-b)}$$

Which can be substituted into the equation $c_p - c_v$ but rearranging the van der waals formula for $V$ is very tedious. Which leads to believe there is a an easier step. It's an exam question so there much be a neat way to solve this. I want to ask here rather than look up someone else's long winded solution. I'm not looking for the solution I genuinely want to be able to tackle this problem or another problem like it should it come up in the exam

Mentor
Why can't you just differentiate the left side of the equation by the product rule?

TSny and patrickmoloney
patrickmoloney
Why can't you just differentiate the left side of the equation by the product rule?
The van der waals equation?

Mentor
The van der waals equation?
Sure.

patrickmoloney
patrickmoloney
Sure.
Differentiating the LHS with respect to $T$ and keeping the volume constant I get

$$\Bigg{(}\dfrac{\partial p}{\partial T}\Bigg{)}_V= \dfrac{R}{V-b}$$

Substituting that into my desired equation I get

$$c_p - c_v = \Bigg{[}T\Bigg{(}\dfrac{R}{V-b}\Bigg{)}\Bigg{]}\Bigg{(}\dfrac{\partial V}{\partial T}\Bigg{)}_p$$

Homework Helper
Gold Member
You might be able to avoid solving for V by using the "reciprocal rule" for partial derivatives $$\left( \frac{\partial x}{\partial y} \right)_z = \frac{1}{\left( \frac{\partial y}{\partial x} \right)_z}$$

patrickmoloney
patrickmoloney
You might be able to avoid solving for V by using the "reciprocal rule" for partial derivatives $$\left( \frac{\partial x}{\partial y} \right)_z = \frac{1}{\left( \frac{\partial y}{\partial x} \right)_z}$$
Would that mean I could do $$\Bigg{(}\dfrac{\partial T}{\partial V}\Bigg{)}_p$$ to solve the VDW equation?

Homework Helper
Gold Member
Would that mean I could do $$\Bigg{(}\dfrac{\partial T}{\partial V}\Bigg{)}_p$$ to solve the VDW equation?
Yes, but I'm not sure what you mean when you say "solve the VDW equation".

patrickmoloney
Yes, but I'm not sure what you mean when you say "solve the VDW equation".

Van der waals equation of state. Like I did with $$\Bigg{(}\dfrac{\partial p}{\partial T}\Bigg{)}_V$$

Homework Helper
Gold Member
Van der waals equation of state. Like I did with $$\Bigg{(}\dfrac{\partial p}{\partial T}\Bigg{)}_V$$
Yes, you use the VdW equation of state to find an expression for the partial derivative.

patrickmoloney
patrickmoloney
I got $$\Bigg{(}\dfrac{\partial T}{\partial V}\Bigg{)}_p = -\Bigg{(}\dfrac{2ab}{V^3} +\dfrac{a}{V^2}- P\Bigg{)} \cdot \dfrac{1}{R}$$

Then inverting this equation yields

$$\Bigg{(}\dfrac{\partial V}{\partial T}\Bigg{)}_p = -\Bigg{(}\dfrac{V^3}{2ab} +\dfrac{V^2}{a}-\dfrac{1}{P}\Bigg{)} \cdot R$$

Homework Helper
Gold Member
I got $$\Bigg{(}\dfrac{\partial T}{\partial V}\Bigg{)}_p = -\Bigg{(}\dfrac{2ab}{V^3} +\dfrac{a}{V^2}- P\Bigg{)} \cdot \dfrac{1}{R}$$

Then inverting this equation yields

$$\Bigg{(}\dfrac{\partial V}{\partial T}\Bigg{)}_p = -\Bigg{(}\dfrac{V^3}{2ab} +\dfrac{V^2}{a}-\dfrac{1}{P}\Bigg{)} \cdot R$$
The first equation looks correct. It involves the three variables P, V, and T. You could use the VdW equation of state to express one of these variables in terms of the other two so that you reduce the number of variables in the expression. For example, you can express P in terms of V and T if you want the final answer to be in terms of V and T.

[EDIT: Sorry. Your first equation does not involve T. But if you use the first equation as you wrote it, your final answer for the difference in specific heats will involve the three variables P, V, and T. You can use the VdW equation to eliminate one of these variables.]

You did not invert the equation correctly. The inverse of the expression ##\frac{2}{3} + \frac{4}{5}## is not ##\frac{3}{2} + \frac{5}{4}##. Rather, it would be ##\frac{1}{\frac{2}{3} + \frac{4}{5}}##.

patrickmoloney
patrickmoloney
The first equation looks correct. It involves the three variables P, V, and T. You could use the VdW equation of state to express one of these variables in terms of the other two so that you reduce the number of variables in the expression. For example, you can express P in terms of V and T if you want the final answer to be in terms of V and T.

[EDIT: Sorry. Your first equation does not involve T. But if you use the first equation as you wrote it, your final answer for the difference in specific heats will involve the three variables P, V, and T. You can use the VdW equation to eliminate one of these variables.]

You did not invert the equation correctly. The inverse of the expression ##\frac{2}{3} + \frac{4}{5}## is not ##\frac{3}{2} + \frac{5}{4}##. Rather, it would be ##\frac{1}{\frac{2}{3} + \frac{4}{5}}##.
$$\Bigg{(}\dfrac{\partial T}{\partial V}\Bigg{)}_p = -\Bigg{(}\dfrac{2ab}{V^3} +\dfrac{a}{V^2}- P\Bigg{)} \cdot \dfrac{1}{R}$$

Letting

$$p = \dfrac{RT}{(v-b)}-\dfrac{a}{V^2}$$

and substituting into my equation for $\Bigg{(}\dfrac{\partial T}{\partial V}\Bigg{)}_p$ gives

$$\Bigg{(}\dfrac{\partial T}{\partial V}\Bigg{)}_p= -\Bigg{(}\dfrac{2ab}{V^3} +\dfrac{2a}{V^2}- \dfrac{RT}{(V-b)}\Bigg{)} \cdot \dfrac{1}{R}$$

But this still looks hideous even though I have everything in terms of $V, a, b, R$ and $T$

Homework Helper
Gold Member
$$\Bigg{(}\dfrac{\partial T}{\partial V}\Bigg{)}_p= -\Bigg{(}\dfrac{2ab}{V^3} +\dfrac{2a}{V^2}- \dfrac{RT}{(V-b)}\Bigg{)} \cdot \dfrac{1}{R}$$

But this still looks hideous even though I have everything in terms of $V, a, b, R$ and $T$
It looks like maybe the sign of the first term is wrong. (I should have caught that earlier.)

It won't be that bad when you put it all together.

patrickmoloney
Homework Helper
Gold Member
Somehow I overlooked @Chestermiller 's post #2. His suggestion is a nice way to get ##\left(\frac{\partial V}{\partial T} \right)_p## without needing to use the reciprocal rule. It's a method that is well worth keeping in mind since it can be used in many different circumstances.

At this point, you are almost done with the problem. After finishing it off, if you would like some guidance in this alternate method, let us know.

patrickmoloney
patrickmoloney
It looks like maybe the sign of the first term is wrong. (I should have caught that earlier.)

It won't be that bad when you put it all together.
I was thinking cause ]
Somehow I overlooked @Chestermiller 's post #2. His suggestion is a nice way to get ##\left(\frac{\partial V}{\partial T} \right)_p## without needing to use the reciprocal rule. It's a method that is well worth keeping in mind since it can be used in many different circumstances.

At this point, you are almost done with the problem. After finishing it off, if you would like some guidance in this alternate method, let us know.
Yeah I would love that in the end I got

$$\dfrac{T^2(2a-1)}{V^3(V-b)}$$ which looks respectable. It's not a homework problem anyway but it was from an exam paper which means it could be something that could come up in the exam. Would you be able to teach the method chester was talking about?

Thanks very much for all the help. You've been more than helpful.

Homework Helper
Gold Member
in the end I got

$$\dfrac{T^2(2a-1)}{V^3(V-b)}$$ which looks respectable.
I don't think this is correct.

You have
$$c_p - c_v = \Bigg{[}T\Bigg{(}\dfrac{R}{V-b}\Bigg{)}\Bigg{]}\Bigg{(}\dfrac{\partial V}{\partial T}\Bigg{)}_p$$
This can be written
$$c_p - c_v = \frac{T\Bigg{(}\dfrac{R}{V-b}\Bigg{)}}{\Bigg{(}\dfrac{\partial T}{\partial V}\Bigg{)}_p}$$
After substituting for the denominator, I don't see how you would get your result.

Would you be able to teach the method chester was talking about?
Yes, certainly.

patrickmoloney
I don't think this is correct.

You have
$$c_p - c_v = \Bigg{[}T\Bigg{(}\dfrac{R}{V-b}\Bigg{)}\Bigg{]}\Bigg{(}\dfrac{\partial V}{\partial T}\Bigg{)}_p$$
This can be written
$$c_p - c_v = \frac{T\Bigg{(}\dfrac{R}{V-b}\Bigg{)}}{\Bigg{(}\dfrac{\partial T}{\partial V}\Bigg{)}_p}$$
After substituting for the denominator, I don't see how you would get your result.

Yes, certainly.
Ok I've tried it using your fraction and got

$$\dfrac{RV(V-b)}{4a(\frac{b}{V}-1)}$$
I've just realized how bad I am at algebra.

Mentor
I got $$\frac{R}{1-\frac{2a}{V^3}\frac{(V-b)^2}{RT}}$$

Homework Helper
Gold Member
I got $$\frac{R}{1-\frac{2a}{V^3}\frac{(V-b)^2}{RT}}$$
I get the same result.

Chestermiller
patrickmoloney
I got $$\dfrac{RT}{1-\frac{2a}{V^3}\frac{(V-b)^2}{RT}}$$. But I'm happy enough that I know how to solve the problem should it come up. Thanks guys.

Mentor
I got $$\dfrac{RT}{1-\frac{2a}{V^3}\frac{(V-b)^2}{RT}}$$. But I'm happy enough that I know how to solve the problem should it come up. Thanks guys.
There should not be a T in the numerator.

patrickmoloney
There should not be a T in the numerator.
I got it from $$T \Bigg{(}\dfrac{\partial p}{\partial T}\Bigg{)}_V$$

I couldn't get an $R$ on its own

Mentor
I got it from $$T \Bigg{(}\dfrac{\partial p}{\partial T}\Bigg{)}_V$$

I couldn't get an $R$ on its own
Too bad. Check the units on your expression for the difference between the heat capacities. It doesn't have the correct units.


text:
Copied to
clipboard

## G = D4×C2×C10order 160 = 25·5

### Direct product of C2×C10 and D4

direct product, metabelian, nilpotent (class 2), monomial, 2-elementary

Series: Derived Chief Lower central Upper central

 Derived series C1 — C2 — D4×C2×C10
 Chief series C1 — C2 — C10 — C2×C10 — C5×D4 — D4×C10 — D4×C2×C10
 Lower central C1 — C2 — D4×C2×C10
 Upper central C1 — C22×C10 — D4×C2×C10

Generators and relations for D4×C2×C10
G = < a,b,c,d | a2=b10=c4=d2=1, ab=ba, ac=ca, ad=da, bc=cb, bd=db, dcd=c-1 >

Subgroups: 316 in 236 conjugacy classes, 156 normal (10 characteristic)
C1, C2, C2, C2, C4, C22, C22, C5, C2×C4, D4, C23, C23, C23, C10, C10, C10, C22×C4, C2×D4, C24, C20, C2×C10, C2×C10, C22×D4, C2×C20, C5×D4, C22×C10, C22×C10, C22×C10, C22×C20, D4×C10, C23×C10, D4×C2×C10
Quotients: C1, C2, C22, C5, D4, C23, C10, C2×D4, C24, C2×C10, C22×D4, C5×D4, C22×C10, D4×C10, C23×C10, D4×C2×C10

Smallest permutation representation of D4×C2×C10
On 80 points
Generators in S80
(1 42)(2 43)(3 44)(4 45)(5 46)(6 47)(7 48)(8 49)(9 50)(10 41)(11 52)(12 53)(13 54)(14 55)(15 56)(16 57)(17 58)(18 59)(19 60)(20 51)(21 33)(22 34)(23 35)(24 36)(25 37)(26 38)(27 39)(28 40)(29 31)(30 32)(61 73)(62 74)(63 75)(64 76)(65 77)(66 78)(67 79)(68 80)(69 71)(70 72)
(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)(31 32 33 34 35 36 37 38 39 40)(41 42 43 44 45 46 47 48 49 50)(51 52 53 54 55 56 57 58 59 60)(61 62 63 64 65 66 67 68 69 70)(71 72 73 74 75 76 77 78 79 80)
(1 18 27 74)(2 19 28 75)(3 20 29 76)(4 11 30 77)(5 12 21 78)(6 13 22 79)(7 14 23 80)(8 15 24 71)(9 16 25 72)(10 17 26 73)(31 64 44 51)(32 65 45 52)(33 66 46 53)(34 67 47 54)(35 68 48 55)(36 69 49 56)(37 70 50 57)(38 61 41 58)(39 62 42 59)(40 63 43 60)
(1 74)(2 75)(3 76)(4 77)(5 78)(6 79)(7 80)(8 71)(9 72)(10 73)(11 30)(12 21)(13 22)(14 23)(15 24)(16 25)(17 26)(18 27)(19 28)(20 29)(31 51)(32 52)(33 53)(34 54)(35 55)(36 56)(37 57)(38 58)(39 59)(40 60)(41 61)(42 62)(43 63)(44 64)(45 65)(46 66)(47 67)(48 68)(49 69)(50 70)

G:=sub<Sym(80)| (1,42)(2,43)(3,44)(4,45)(5,46)(6,47)(7,48)(8,49)(9,50)(10,41)(11,52)(12,53)(13,54)(14,55)(15,56)(16,57)(17,58)(18,59)(19,60)(20,51)(21,33)(22,34)(23,35)(24,36)(25,37)(26,38)(27,39)(28,40)(29,31)(30,32)(61,73)(62,74)(63,75)(64,76)(65,77)(66,78)(67,79)(68,80)(69,71)(70,72), (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)(31,32,33,34,35,36,37,38,39,40)(41,42,43,44,45,46,47,48,49,50)(51,52,53,54,55,56,57,58,59,60)(61,62,63,64,65,66,67,68,69,70)(71,72,73,74,75,76,77,78,79,80), (1,18,27,74)(2,19,28,75)(3,20,29,76)(4,11,30,77)(5,12,21,78)(6,13,22,79)(7,14,23,80)(8,15,24,71)(9,16,25,72)(10,17,26,73)(31,64,44,51)(32,65,45,52)(33,66,46,53)(34,67,47,54)(35,68,48,55)(36,69,49,56)(37,70,50,57)(38,61,41,58)(39,62,42,59)(40,63,43,60), (1,74)(2,75)(3,76)(4,77)(5,78)(6,79)(7,80)(8,71)(9,72)(10,73)(11,30)(12,21)(13,22)(14,23)(15,24)(16,25)(17,26)(18,27)(19,28)(20,29)(31,51)(32,52)(33,53)(34,54)(35,55)(36,56)(37,57)(38,58)(39,59)(40,60)(41,61)(42,62)(43,63)(44,64)(45,65)(46,66)(47,67)(48,68)(49,69)(50,70)>;

G:=Group( (1,42)(2,43)(3,44)(4,45)(5,46)(6,47)(7,48)(8,49)(9,50)(10,41)(11,52)(12,53)(13,54)(14,55)(15,56)(16,57)(17,58)(18,59)(19,60)(20,51)(21,33)(22,34)(23,35)(24,36)(25,37)(26,38)(27,39)(28,40)(29,31)(30,32)(61,73)(62,74)(63,75)(64,76)(65,77)(66,78)(67,79)(68,80)(69,71)(70,72), (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)(31,32,33,34,35,36,37,38,39,40)(41,42,43,44,45,46,47,48,49,50)(51,52,53,54,55,56,57,58,59,60)(61,62,63,64,65,66,67,68,69,70)(71,72,73,74,75,76,77,78,79,80), (1,18,27,74)(2,19,28,75)(3,20,29,76)(4,11,30,77)(5,12,21,78)(6,13,22,79)(7,14,23,80)(8,15,24,71)(9,16,25,72)(10,17,26,73)(31,64,44,51)(32,65,45,52)(33,66,46,53)(34,67,47,54)(35,68,48,55)(36,69,49,56)(37,70,50,57)(38,61,41,58)(39,62,42,59)(40,63,43,60), (1,74)(2,75)(3,76)(4,77)(5,78)(6,79)(7,80)(8,71)(9,72)(10,73)(11,30)(12,21)(13,22)(14,23)(15,24)(16,25)(17,26)(18,27)(19,28)(20,29)(31,51)(32,52)(33,53)(34,54)(35,55)(36,56)(37,57)(38,58)(39,59)(40,60)(41,61)(42,62)(43,63)(44,64)(45,65)(46,66)(47,67)(48,68)(49,69)(50,70) );

G=PermutationGroup([[(1,42),(2,43),(3,44),(4,45),(5,46),(6,47),(7,48),(8,49),(9,50),(10,41),(11,52),(12,53),(13,54),(14,55),(15,56),(16,57),(17,58),(18,59),(19,60),(20,51),(21,33),(22,34),(23,35),(24,36),(25,37),(26,38),(27,39),(28,40),(29,31),(30,32),(61,73),(62,74),(63,75),(64,76),(65,77),(66,78),(67,79),(68,80),(69,71),(70,72)], [(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),(31,32,33,34,35,36,37,38,39,40),(41,42,43,44,45,46,47,48,49,50),(51,52,53,54,55,56,57,58,59,60),(61,62,63,64,65,66,67,68,69,70),(71,72,73,74,75,76,77,78,79,80)], [(1,18,27,74),(2,19,28,75),(3,20,29,76),(4,11,30,77),(5,12,21,78),(6,13,22,79),(7,14,23,80),(8,15,24,71),(9,16,25,72),(10,17,26,73),(31,64,44,51),(32,65,45,52),(33,66,46,53),(34,67,47,54),(35,68,48,55),(36,69,49,56),(37,70,50,57),(38,61,41,58),(39,62,42,59),(40,63,43,60)], [(1,74),(2,75),(3,76),(4,77),(5,78),(6,79),(7,80),(8,71),(9,72),(10,73),(11,30),(12,21),(13,22),(14,23),(15,24),(16,25),(17,26),(18,27),(19,28),(20,29),(31,51),(32,52),(33,53),(34,54),(35,55),(36,56),(37,57),(38,58),(39,59),(40,60),(41,61),(42,62),(43,63),(44,64),(45,65),(46,66),(47,67),(48,68),(49,69),(50,70)]])

D4×C2×C10 is a maximal subgroup of
(D4×C10)⋊18C4  (C2×C10)⋊8D8  (C5×D4).31D4  C24.18D10  C24.19D10  C24.20D10  C24.21D10  C24.38D10  C248D10  C24.41D10  C24.42D10

100 conjugacy classes

 class 1 2A ··· 2G 2H ··· 2O 4A 4B 4C 4D 5A 5B 5C 5D 10A ··· 10AB 10AC ··· 10BH 20A ··· 20P order 1 2 ··· 2 2 ··· 2 4 4 4 4 5 5 5 5 10 ··· 10 10 ··· 10 20 ··· 20 size 1 1 ··· 1 2 ··· 2 2 2 2 2 1 1 1 1 1 ··· 1 2 ··· 2 2 ··· 2

100 irreducible representations

 dim 1 1 1 1 1 1 1 1 2 2 type + + + + + image C1 C2 C2 C2 C5 C10 C10 C10 D4 C5×D4 kernel D4×C2×C10 C22×C20 D4×C10 C23×C10 C22×D4 C22×C4 C2×D4 C24 C2×C10 C22 # reps 1 1 12 2 4 4 48 8 4 16

Matrix representation of D4×C2×C10 in GL4(𝔽41) generated by

 1 0 0 0 0 40 0 0 0 0 40 0 0 0 0 40
,
 40 0 0 0 0 1 0 0 0 0 25 0 0 0 0 25
,
 40 0 0 0 0 40 0 0 0 0 0 40 0 0 1 0
,
 1 0 0 0 0 1 0 0 0 0 0 40 0 0 40 0
G:=sub<GL(4,GF(41))| [1,0,0,0,0,40,0,0,0,0,40,0,0,0,0,40],[40,0,0,0,0,1,0,0,0,0,25,0,0,0,0,25],[40,0,0,0,0,40,0,0,0,0,0,1,0,0,40,0],[1,0,0,0,0,1,0,0,0,0,0,40,0,0,40,0] >;

D4×C2×C10 in GAP, Magma, Sage, TeX

D_4\times C_2\times C_{10}
% in TeX

G:=Group("D4xC2xC10");
// GroupNames label

G:=SmallGroup(160,229);
// by ID

G=gap.SmallGroup(160,229);
# by ID

G:=PCGroup([6,-2,-2,-2,-2,-5,-2,985]);
// Polycyclic

G:=Group<a,b,c,d|a^2=b^10=c^4=d^2=1,a*b=b*a,a*c=c*a,a*d=d*a,b*c=c*b,b*d=d*b,d*c*d=c^-1>;
// generators/relations

׿
×
𝔽


text:
## When is P(x)-Q(y) irreducible?

Let $k$ be an algebraically closed field (in my application, it is characteristic zero, but this probably doesn't matter so much), and let $P: k \to k$, $Q: k \to k$ be polynomials of one variable. Then $P(x)-Q(y)$ is a polynomial of two variables $x,y$. Generically, one expects this polynomial to be irreducible, but there are some exceptional cases where it becomes reducible. For instance, if $P=Q$ and $P,Q$ have degree greater than $1$, then $P(x)-Q(y)$ contains $x-y$ as a nontrivial factor. More generally, if $P = R \circ \tilde P$ and $Q = R \circ \tilde Q$ for some polynomials $\tilde P, \tilde Q, R$ with $R$ having degree greater than $1$, then $P(x)-Q(y)$ contains $\tilde P(x)-\tilde Q(y)$ as a nontrivial factor.

My (somewhat vague) question is whether there is a way to classify all the pairs of polynomials $P, Q$ in which $P(x)-Q(y)$ becomes reducible. Of course, this has a tautological answer - it is those $P, Q$ for which one can factorise $P(x)-Q(y) = R(x,y) S(x,y)$ for some polynomials $R,S$ - but I am looking for a criterion which is somehow simpler to verify than the general problem of determining whether an arbitrary polynomial of two variables is irreducible. Ideally it should have the flavour of "the only obstructions to irreducibility are the obvious ones". One could naively conjecture that the above examples are in fact the only reducible examples; indeed I could not produce any other examples, but this is likely a failure of my own imagination.

I have this vague picture of viewing the curve $\{ (x,y): P(x)=Q(y)\}$ as a relative product of the curves $\{ (x,z): z = P(x) \}$ and $\{ (y,z): z = Q(y) \}$ over the $z$-axis, so that the irreducibility of the former should somehow relate to the structure of the latter two factors (and in particular, in the location and nature of the singular points of the projection maps to the $z$-axis), but I don't know how to make this precise. (Maybe I should have paid more attention to Riemann surfaces as a student...)

Actually, I'm ultimately interested in the multidimensional version of this question, namely to give a criterion for when the algebraic set $\{ (x,y) \in k^d \times k^d: P(x)=Q(y) \}$ is an irreducible variety, where $P, Q: k^d \to k^m$ are polynomial maps, but given that even the $d=m=1$ case seems to be non-trivial, I thought I should focus on that first.

-
The expert on this is Mike Zieve, here at U Michigan. I don't know that there is a complete answer, but e-mail him and he'll have a lot to say. – David Speyer Aug 28 at 18:35
Wasn't there a similar question asked a few days ago? Gerhard "Currently Not Trusting His Memory" Paseman, 2012.08.28 – Gerhard Paseman Aug 28 at 18:49
Have a look at ams.org/mathscinet-getitem?mr=137703 – Boris Bukh Aug 28 at 18:49
I remember reading an answer elsewhere on mathoverflow that said "A polynomial $P(x)$ is indecomposable if there do not exist nonlinear polynomials $Q, R$ such that $P(x) = Q(R(x)).$ If $P,Q$ are nonconstant and indecomposable polynomials such that $P(x) - Q(y)$ is not irreducible, then either $Q(x) = P(ax+b)$ for some complex numbers $a,b$, or deg $P$ = deg $Q$ = 7,11,13,15,21, or 31." Unfortunately, I don't remember where I read it. – David Aug 28 at 18:52
Nevermind, I found the answer: mathoverflow.net/questions/14076/…, Graham's answer. – David Aug 28 at 18:53
show 1 more comment

THis is answered in great detail by @quid in this question.

-
That might be what I was not quite remembering. Gerhard "Back To Bounding Jacobsthal's Function" Paseman, 2012.08.28 – Gerhard Paseman Aug 28 at 19:21
Thank you for mentioning my answer! Meanwhile, Michael Zieve gave an additional answer to that question. – quid Aug 29 at 15:17

An interesting example perhaps is \eqalign{4 x^4 &- 4 x^2 + y^4 + 4 y^3 + 4 y^2\cr &= \left( 2{x}^{2}+2x+2xy+2y+{y}^{2} \right) \left( 2{x}^{2}-2x-2xy+2y+{y}^{2} \right)}

-
If you multiply this by 2, and note that $8x^4-8x^2+1=2(2x^2-1)^2-1$ is the Chebyshev polynomial $T_4(x)$, and $2y^4+8y^3+8y^2-1=2((y+1)^2-1)^2-1$ is $T_4(\frac{y+1}{\sqrt{2}})$, this example falls into the pattern mentioned in the answer of quid linked in the other answer here, due to Yuri Bilu (Acta Arith. 90 (1999), matwbn.icm.edu.pl/ksiazki/aa/aa90/aa9043.pdf). – Vladimir Dotsenko Aug 29 at 5:18


text:
Where is the fallacy?

Note by Trishit Chandra
4 years, 4 months ago

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold
- bulleted- list
• bulleted
• list
1. numbered2. list
1. numbered
2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in $ ... $ or $ ... $ to ensure proper formatting.
2 \times 3 $2 \times 3$
2^{34} $2^{34}$
a_{i-1} $a_{i-1}$
\frac{2}{3} $\frac{2}{3}$
\sqrt{2} $\sqrt{2}$
\sum_{i=1}^3 $\sum_{i=1}^3$
\sin \theta $\sin \theta$
\boxed{123} $\boxed{123}$

Sort by:

There's another definition for the gamma function. Check it out here: Gamma Function

- 4 years, 4 months ago

I saw that there is another definition of gamma function but there is not another definition of factorial which implies the above derivation. And as the formulas I have written in the first portion are correct then the derivation should be correct but there is a contradiction between the definition of factorial and the formulas.

- 4 years, 4 months ago

Definitions can be extended to include more cases than what you initially dealt with.

A typical example that you should be familiar with, is that in (say) 2nd grade you were told that "multiplication is just repeated addition. To find $4 \times 5$, you draw out 4 groups of 5 items, and count them to get 20". However, that "logic" quickly fails when you try and extend it to frations / irrational numbers. Pray tell, how do you draw out $\sqrt{2}$ groups of $\pi$ items and count them?

The next example would be exponentiation, which is (similarly) often introduced as "exponentiation is just repeated multiplication" To find $4 ^ 5$, we do $4 \times 4 \times 4 \times 4 \times 4$. Pray tell, how would you write $\sqrt{2} ^ \pi$?

Staff - 4 years, 4 months ago

So, is the process of this derivation wrong ?

- 4 years, 4 months ago

So you are saying that the factorial of fraction should be possible but this can not be possible according to the definition of it. And hence the derivation is correct.

- 4 years, 4 months ago

We can take the factorial of fractions, and or irrational numbers. The definition of it is not $x ! = x \times (x-1) \times (x-2) \times \ldots$ where the last term is between 0 and 1.

We can also extend this to negative numbers, but not to the negative integers.

The above derivation is correct, but it does not explain how it calculated $\Gamma ( \frac{1}{2} )$. With that as the working assumption (ie not proven), the rest of the steps look correct.

Staff - 4 years, 4 months ago

Okay. Thank you Calvin Lin for helping me. Now I've understood. Can you refer me some link or book where I can find this conception of factorial because Wikipedia is saying that factorial means the product of the positive integers less the or equal to the number. And you said in the last line bracket that something is not proven, what is that?

- 4 years, 4 months ago

See Trishit, a special form of the gamma function (the one you have mentioned in your problem) is actually an improper integral of the following form: $\Gamma (t)=\int _{ 0 }^{ \infty }{ { x }^{ t-1 }{ e }^{ -x }dt }$ the domain of this function being the set of all complex numbers t, with Re(t)>=0. The gamma function reduces to the simple factorial function defined by $n!=\prod _{ i=1 }^{ n }{ i } ,when\quad n\ge 1$ and $n!=1,when\quad n=0$ which has its domain the set of non-negative integers. Factorial function turns out to be a very special form of the gamma function in the set of non-negative integers. Clearly, the domain of the factorial function does not contain fractions like 2.5 and thus (2.5)! is not defined. Your fallacy is that you are considering the factorial and gamma functions to be the same. Well, you cannot call two functions the same if their domains are different.

- 3 years, 11 months ago

Got it. And thank you very much.

- 3 years, 11 months ago

Welcome. You can learn more about functions like gamma and beta in the topic of improper integrals There you will learn why $\Gamma \left( \frac { 1 }{ 2 } \right) =\sqrt { \pi }$. This result can be proved from the Euler's reflection formula. I give a short sketch of the proof here. The reflection formula states that(this can also be proved):$\Gamma (t)\Gamma (1-t)=\frac { \pi }{ sin\quad \pi t } \\ \Longrightarrow \Gamma \left( \frac { 1 }{ 2 } \right) \Gamma \left( 1-\frac { 1 }{ 2 } \right) =\Gamma \left( \frac { 1 }{ 2 } \right) \Gamma \left( \frac { 1 }{ 2 } \right) ={ \left\{ \Gamma \left( \frac { 1 }{ 2 } \right) \right\} }^{ 2 }=\frac { \pi }{ sin\quad \frac { \pi }{ 2 } } =\pi$$\Longrightarrow \Gamma \left( \frac { 1 }{ 2 } \right) =\sqrt { \pi }$

- 3 years, 11 months ago

Thanks for providing the insight!

Could you look over this Gamma Function wiki page and provide us with feedback about areas that it can be improved?

Staff - 3 years, 11 months ago