text:
GMAT Question of the Day - Daily to your Mailbox; hard ones only

 It is currently 13 Oct 2019, 18:35

### GMAT Club Daily Prep

#### Thank you for using the timer - this advanced tool can estimate your performance and suggest more practice questions. We have subscribed you to Daily Prep Questions via email.

Customized
for You

we will pick new questions that match your level based on your Timer History

Track

every week, we’ll send you an estimated GMAT score based on your performance

Practice
Pays

we will pick new questions that match your level based on your Timer History

# Mrs. Williams has a certain number of coins in her bag in denomination

Author Message
TAGS:

### Hide Tags

Senior Manager
Joined: 25 Dec 2018
Posts: 484
Location: India
Concentration: General Management, Finance
GMAT Date: 02-18-2019
GPA: 3.4
WE: Engineering (Consulting)
Mrs. Williams has a certain number of coins in her bag in denomination  [#permalink]

### Show Tags

Updated on: 20 Jan 2019, 22:11
1
1
3
00:00

Difficulty:

85% (hard)

Question Stats:

62% (02:33) correct 38% (02:20) wrong based on 59 sessions

### HideShow timer Statistics

Mrs. Williams has a certain number of coins in her bag in denominations of 25 cents, 50 cents and $1. If she has a total of$5 in her bag, what is the number of 25 cents in her bag? Given that she has at least one coin of each denomination. ($1 = 100cents) (1) Number of$1 coins = number of 50 cent coins > number of 25 cent coins.

(2) The number of 25 cents coins is 2/3 of the number of 50 cent coins.

Kudos for each and every explanation

Originally posted by mangamma on 19 Jan 2019, 22:41.
Last edited by chetan2u on 20 Jan 2019, 22:11, edited 3 times in total.
edited the question and corrected the OA
Math Expert
Joined: 02 Aug 2009
Posts: 7941
Re: Mrs. Williams has a certain number of coins in her bag in denomination  [#permalink]

### Show Tags

19 Jan 2019, 23:13
2
mangamma wrote:
Mrs. Williams has a certain number of coins in her bag in denominations of 25 cents, 50 cents and $1. If she has a total of$5 in her bag, what is the number of 25 cents in her bag? Given that she has at least one coin of each denomination. ($1 = 100cents) (1) Number of$1 coins = number of 50 cent coins > number of 25 cent coins.

(2) The number of $1 coins is 23 of the number of 50 cent coins. Kudos for each and every explanation Let the number of 25-cents, 50-cents and 1$ be a,B, and c respectively.
So 25a+50b+100c=500....a+2b+4c=20
Statements..
I..c=b>a
So substitute b as c...a+2c+4c=20...a+6c=20..
Now c>a...so if a=1, c can be 3... possible
If a=2, no value of c satisfies c>a
So a=2, b=c=3
Sufficient

II.. some error in statement II
Now after editing the second statement as The number of 25 cents coins is 2/3 of the number of 50 cent coins.
a+2b+4c=20 and $$a=\frac{2b}{3}$$
thus $$\frac{2b}{3}+2b+4c=20......8b+12c=60......2b+3c=15$$
Possible values b=c=3, and a=2..
OR b=6, c=1, and a = 4..
so different possibilities
Insufficient

A
_________________
Director
Joined: 09 Mar 2018
Posts: 997
Location: India
Re: Mrs. Williams has a certain number of coins in her bag in denomination  [#permalink]

### Show Tags

19 Jan 2019, 23:21
2
mangamma wrote:
Mrs. Williams has a certain number of coins in her bag in denominations of 25 cents, 50 cents and $1. If she has a total of$5 in her bag, what is the number of 25 cents in her bag? Given that she has at least one coin of each denomination. ($1 = 100cents) (1) Number of$1 coins = number of 50 cent coins > number of 25 cent coins.

(2) The number of $1 coins is 23 of the number of 50 cent coins. So i went for A, Now when i read the 2nd statement, its not clear what it meant by 23 of the number of 50 cent coins. Statement 1, can be solved very easily x = number of 25 cents, y number of 50 cents and z number of 1 dollar 0.25 x + 0.50 y + 1 z = 5.00 25x + 50 y + 100z = 500 Number of$1 coins = number of 50 cent coins > number of 25 cent coins.
y=z > x, can only be true when you take values as y=z= 3 and x =2

50 + 150 + 300 = 500.

Sufficient.

_________________
If you notice any discrepancy in my reasoning, please let me know. Lets improve together.

Quote which i can relate to.
Many of life's failures happen with people who do not realize how close they were to success when they gave up.
Senior Manager
Joined: 25 Dec 2018
Posts: 484
Location: India
Concentration: General Management, Finance
GMAT Date: 02-18-2019
GPA: 3.4
WE: Engineering (Consulting)
Re: Mrs. Williams has a certain number of coins in her bag in denomination  [#permalink]

### Show Tags

20 Jan 2019, 21:48
1
chetan2u wrote:
mangamma wrote:
Mrs. Williams has a certain number of coins in her bag in denominations of 25 cents, 50 cents and $1. If she has a total of$5 in her bag, what is the number of 25 cents in her bag? Given that she has at least one coin of each denomination. ($1 = 100cents) (1) Number of$1 coins = number of 50 cent coins > number of 25 cent coins.

(2) The number of $1 coins is 23 of the number of 50 cent coins. Kudos for each and every explanation Let the number of 25-cents, 50-cents and 1$ be a,B, and c respectively.
So 25a+50b+100c=500....a+2b+4c=20
Statements..
I..c=b>a
So substitute b as c...a+2c+4c=20...a+6c=20..
Now c>a...so if a=1, c can be 3... possible
If a=2, no value of c satisfies c>a
So a=2, b=c=3
Sufficient
II.. some error in statement II

II edited
Math Expert
Joined: 02 Aug 2009
Posts: 7941
Re: Mrs. Williams has a certain number of coins in her bag in denomination  [#permalink]

### Show Tags

20 Jan 2019, 21:58
mangamma wrote:
chetan2u wrote:
mangamma wrote:
Mrs. Williams has a certain number of coins in her bag in denominations of 25 cents, 50 cents and $1. If she has a total of$5 in her bag, what is the number of 25 cents in her bag? Given that she has at least one coin of each denomination. ($1 = 100cents) (1) Number of$1 coins = number of 50 cent coins > number of 25 cent coins.

(2) The number of $1 coins is 23 of the number of 50 cent coins. Kudos for each and every explanation Let the number of 25-cents, 50-cents and 1$ be a,B, and c respectively.
So 25a+50b+100c=500....a+2b+4c=20
Statements..
I..c=b>a
So substitute b as c...a+2c+4c=20...a+6c=20..
Now c>a...so if a=1, c can be 3... possible
If a=2, no value of c satisfies c>a
So a=2, b=c=3
Sufficient
II.. some error in statement II

II edited

Hi,

still the question is required to be edited, it is not the number of 1$coins 2/3 of number of 50 cents coin because statement I gives you both as equal and you cannot have different information from the two statements. It should be the number of 25 cents coins is 2/3 of number of 50 cents coin. I am editing it accordingly _________________ Senior Manager Joined: 25 Dec 2018 Posts: 484 Location: India Concentration: General Management, Finance GMAT Date: 02-18-2019 GPA: 3.4 WE: Engineering (Consulting) Re: Mrs. Williams has a certain number of coins in her bag in denomination [#permalink] ### Show Tags 20 Jan 2019, 23:13 1 Thank you "chetan2u" II edited[/quote] Hi, still the question is required to be edited, it is not the number of 1$ coins 2/3 of number of 50 cents coin because statement I gives you both as equal and you cannot have different information from the two statements.
It should be the number of 25 cents coins is 2/3 of number of 50 cents coin.

I am editing it accordingly[/quote]
Re: Mrs. Williams has a certain number of coins in her bag in denomination   [#permalink] 20 Jan 2019, 23:13
Display posts from previous: Sort by

format: plain


text:
# American Institute of Mathematical Sciences

September 2018, 38(9): 4483-4507. doi: 10.3934/dcds.2018196

## Mixed dynamics of 2-dimensional reversible maps with a symmetric couple of quadratic homoclinic tangencies

 1 Departament de Matemàtiques and Lab of Geometry and Dynamical Systems, Universitat Politècnica de Catalunya, Av. Doctor Marañón, 44-50, Barcelona, 08028, Spain 2 Departament de Matemàtiques, Universitat de Barcelona. Gran Via de les Corts Catalanes, 585, Barcelona, 08007, Spain 3 Lobachevsky University of Nizhny Novgorod. Gagarina av. 23, Nizhny Novgorod, 603950, Russia 4 Departament de Matemàtiques, Universitat Politècnica de Catalunya, Av. Diagonal, 647, Barcelona, 08028, Spain

* Corresponding author: A. Delshams

Received  September 2017 Revised  April 2018 Published  June 2018

Fund Project: This work has been supported by the Russian Scientific Foundation grant: sections 1-4, 6 and 7 were carried out under the project 14-41-00044, and section 5 under the project 14-12-00811. AD, MG and JTL have been also partially supported by the MICIIN/FEDER grant MTM2015-65715-P and by the Catalan grant 2017SGR1049 (AD, JTL). MG has been partially supported by Juan de la Cierva-Formación Fellowship FJCI-2014-21229, the grant MTM2016-80117-P (MINECO/FEDER, UE) and the Knut and Alice Wallenberg Foundation grant 2013-0315. SG also thanks RFBR (grant 16-01-00364) and the Russian Ministry of Science and Education, project 1.3287.2017

We study dynamics and bifurcations of 2-dimensional reversible maps having a symmetric saddle fixed point with an asymmetric pair of nontransversal homoclinic orbits (a symmetric nontransversal homoclinic figure-8). We consider one-parameter families of reversible maps unfolding the initial homoclinic tangency and prove the existence of infinitely many sequences (cascades) of bifurcations related to the birth of asymptotically stable, unstable and elliptic periodic orbits.

Citation: Amadeu Delshams, Marina Gonchenko, Sergey V. Gonchenko, J. Tomás Lázaro. Mixed dynamics of 2-dimensional reversible maps with a symmetric couple of quadratic homoclinic tangencies. Discrete & Continuous Dynamical Systems - A, 2018, 38 (9) : 4483-4507. doi: 10.3934/dcds.2018196
##### References:
 [1] P. Berger, Generic family with robustly infinitely many sinks, Inv. Math., 205 (2016), 121-172. doi: 10.1007/s00222-015-0632-6. [2] A. Delshams, S. V. Gonchenko, V. S. Gonchenko, J. T. Lázaro and O. V. Sten'kin, Abundance of attracting, repelling and elliptic orbits in 2-dimensional reversible maps, Nonlinearity, 26 (2013), 1-33. doi: 10.1088/0951-7715/26/1/1. [3] A. Delshams, M. S. Gonchenko and S. V. Gonchenko, On dynamics and bifurcations of area-preserving maps with homoclinic tangencies, Nonlinearity, 28 (2015), 3027-3071. doi: 10.1088/0951-7715/28/9/3027. [4] P. Duarte, Abundance of elliptic isles at conservative bifurcations, Dyn. Stab. Syst., 14 (1999), 339-356. doi: 10.1080/026811199281930. [5] P. Duarte, Persistent homoclinic tangencies for conservative maps near the identity, Ergod. Th. Dyn. Sys., 20 (2000), 393-438. doi: 10.1017/S0143385700000195. [6] P. Duarte, Persistent homoclinic tangencies for conservative maps near the identity, Ergod. Th. & Dynam. Sys., 20 (2002), 393-438. doi: 10.1017/S0143385700000195. [7] N. K. Gavrilov and L. P. Shilnikov, On three-dimensional dynamical systems close to systems with a structurally unstable homoclinic curve (Part 1), Math. USSR Sb., 17 (1972), 467-485; (Part 2), Math. USSR Sb, 90 (1973), 139-156. [8] S. V. Gonchenko, On stable periodic motions in systems close to a system with a nontransversal homoclinic curve, Russian Math. Notes, 33 (1983), 745-755. [9] S. V. Gonchenko and L. P. Shilnikov, Invariants of Ω-conjugacy of diffeomorphisms with a structurally unstable homoclinic trajectory, Ukrainian Math. J., 42 (1990), 134-140. doi: 10.1007/BF01071004. [10] S. V. Gonchenko, L. P. Shilnikov and D. V. Turaev, On models with non-rough Poincare homoclinic curves, Physica D, 62 (1993), 1-14. doi: 10.1016/0167-2789(93)90268-6. [11] S. V. Gonchenko, D. V. Turaev and L. P. Shilnikov, On the existence of Newhouse regions near systems with non-rough Poincaré homoclinic curve (multidimensional case), Russian Acad. Sci. Dokl. Math., 47 (1993), 268-273. doi: 10.1016/0167-2789(93)90268-6. [12] S. V. Gonchenko, O. V. Stenkin and D. V. Turaev, Complexity of homoclinic bifurcations and Ω-moduli, Int. Journal of Bifurcation and Chaos, 6 (1996), 969-989. doi: 10.1142/S0218127496000539. [13] S. V. Gonchenko, D. V. Turaev and L. P. Shilnikov, On Newhouse domains of 2-dimensional diffeomorphisms with a structurally unstable heteroclinic cycle, Proc. Steklov Inst. Math., 216 (1997), 70-118. [14] S. V. Gonchenko, D. V. Turaev and L. P. Shilnikov, Homoclinic tangencies of an arbitrary order in Newhouse domains, Itogi Nauki Tekh., Ser. Sovrem. Mat. Prilozh., 67 (1999), 69-128 [English translation in J. Math. Sci. 105 (2001), 1738-1778]. [15] S. V. Gonchenko and L. P. Shilnikov, On 2-dimensional area-preserving mappings with homoclinic tangencies, Doklady Mathematics, 63 (2001), 395-399. [16] S. V. Gonchenko and V. S. Gonchenko, On bifurcations of birth of closed invariant curves in the case of 2-dimensional diffeomorphisms with homoclinic tangencies, Proc. Steklov Inst., 244 (2004), 80-105. [17] S. V. Gonchenko, V. S. Gonchenko and J. C. Tatjer, Bifurcations of three-dimensional diffeomorphisms with non-simple quadratic homoclinic tangencies and generalized Hénon maps, Regular and Chaotic Dynamics, 12 (2007), 233-266. doi: 10.1134/S156035470703001X. [18] S. V. Gonchenko, L. P. Shilnikov and D. Turaev, On dynamical properties of multidimensional diffeomorphisms from Newhouse regions, Nonlinearity, 21 (2008), 923-972. doi: 10.1088/0951-7715/21/5/003. [19] S. V. Gonchenko and M. S. Gonchenko, On cascades of elliptic periodic points in 2-dimensional symplectic maps with homoclinic tangencies, J. Regular and Chaotic Dynamics, 14 (2009), 116-136. doi: 10.1134/S1560354709010080. [20] S. V. Gonchenko, V. S. Gonchenko and L. P. Shilnikov, On homoclinic origin of Henon-like maps, Regular and Chaotic Dynamics, 15 (2010), 462-481. doi: 10.1134/S1560354710040052. [21] S. V. Gonchenko, J. S. W. Lamb, I. Rios and D. V. Turaev, Attractors and repellers near generic elliptic points of reversible maps, Doclady Mathematics, 89 (2014), 65-67. [22] S. V. Gonchenko and D. V. Turaev, On three types of dynamics, and the notion of attractor, Tr. Mat. Inst. Steklova, 297 (2017), 133-157. doi: 10.1134/S0371968517020078. [23] J. S. W. Lamb and O. V. Stenkin, Newhouse regions for reversible systems with infinitely many stable, unstable and elliptic periodic orbits, Nonlinearity, 17 (2004), 1217-1244. doi: 10.1088/0951-7715/17/4/005. [24] E. Lombardi, Oscillatory Integrals and Phenomena Beyond all Algebraic Orders, Lecture Notes in Mathematics, 1741, Springer-Verlag, Berlin, 2000. doi: 10.1007/BFb0104102. [25] D. Montgomery and L. Zippin, Topological Transformation Groups, Interscience, New York, 1955. [26] S. E. Newhouse, Non density of Axiom A(a) on $S^2$, Proc. Amer. Math. Soc. Symp. Pure Math., 14 (1970), 191-202. [27] S. E. Newhouse, Diffeomorphisms with infinitely many sinks, Topology, 13 (1974), 9-18. doi: 10.1016/0040-9383(74)90034-2. [28] S. E. Newhouse, The abundance of wild hyperbolic sets and non-smooth stable sets for diffeomorphisms, Publ. Math. Inst. Hautes Etudes Sci., 50 (1979), 101-151. [29] J. Palis and M. Viana, High dimension diffeomorphisms displaying infinitely many sinks, Ann. Math., 140 (1994), 207-250. doi: 10.2307/2118546. [30] N. Romero, Persistence of homoclinic tangencies in higher dimensions, Ergod. Th. Dyn.Sys., 15 (1995), 735-757. doi: 10.1017/S0143385700008634. [31] M. B. Sevryuk, Reversible Systems, Lecture Notes in Mathematics, 1211, Springer-Verlag, Berlin, 1986. doi: 10.1007/BFb0075877. [32] L. Tedeschini-Lalli and J. A. Yorke, How often do simple dynamical processes have infinitely many coexisting sinks?, Commun.Math.Phys., 106 (1986), 635-657. doi: 10.1007/BF01463400. [33] D. V. Turaev, On the genericity of the Newhouse phenomenon, in EQUADIFF 2003, World Sci. Publ., Hackensack, 2005.

show all references

##### References:
 [1] P. Berger, Generic family with robustly infinitely many sinks, Inv. Math., 205 (2016), 121-172. doi: 10.1007/s00222-015-0632-6. [2] A. Delshams, S. V. Gonchenko, V. S. Gonchenko, J. T. Lázaro and O. V. Sten'kin, Abundance of attracting, repelling and elliptic orbits in 2-dimensional reversible maps, Nonlinearity, 26 (2013), 1-33. doi: 10.1088/0951-7715/26/1/1. [3] A. Delshams, M. S. Gonchenko and S. V. Gonchenko, On dynamics and bifurcations of area-preserving maps with homoclinic tangencies, Nonlinearity, 28 (2015), 3027-3071. doi: 10.1088/0951-7715/28/9/3027. [4] P. Duarte, Abundance of elliptic isles at conservative bifurcations, Dyn. Stab. Syst., 14 (1999), 339-356. doi: 10.1080/026811199281930. [5] P. Duarte, Persistent homoclinic tangencies for conservative maps near the identity, Ergod. Th. Dyn. Sys., 20 (2000), 393-438. doi: 10.1017/S0143385700000195. [6] P. Duarte, Persistent homoclinic tangencies for conservative maps near the identity, Ergod. Th. & Dynam. Sys., 20 (2002), 393-438. doi: 10.1017/S0143385700000195. [7] N. K. Gavrilov and L. P. Shilnikov, On three-dimensional dynamical systems close to systems with a structurally unstable homoclinic curve (Part 1), Math. USSR Sb., 17 (1972), 467-485; (Part 2), Math. USSR Sb, 90 (1973), 139-156. [8] S. V. Gonchenko, On stable periodic motions in systems close to a system with a nontransversal homoclinic curve, Russian Math. Notes, 33 (1983), 745-755. [9] S. V. Gonchenko and L. P. Shilnikov, Invariants of Ω-conjugacy of diffeomorphisms with a structurally unstable homoclinic trajectory, Ukrainian Math. J., 42 (1990), 134-140. doi: 10.1007/BF01071004. [10] S. V. Gonchenko, L. P. Shilnikov and D. V. Turaev, On models with non-rough Poincare homoclinic curves, Physica D, 62 (1993), 1-14. doi: 10.1016/0167-2789(93)90268-6. [11] S. V. Gonchenko, D. V. Turaev and L. P. Shilnikov, On the existence of Newhouse regions near systems with non-rough Poincaré homoclinic curve (multidimensional case), Russian Acad. Sci. Dokl. Math., 47 (1993), 268-273. doi: 10.1016/0167-2789(93)90268-6. [12] S. V. Gonchenko, O. V. Stenkin and D. V. Turaev, Complexity of homoclinic bifurcations and Ω-moduli, Int. Journal of Bifurcation and Chaos, 6 (1996), 969-989. doi: 10.1142/S0218127496000539. [13] S. V. Gonchenko, D. V. Turaev and L. P. Shilnikov, On Newhouse domains of 2-dimensional diffeomorphisms with a structurally unstable heteroclinic cycle, Proc. Steklov Inst. Math., 216 (1997), 70-118. [14] S. V. Gonchenko, D. V. Turaev and L. P. Shilnikov, Homoclinic tangencies of an arbitrary order in Newhouse domains, Itogi Nauki Tekh., Ser. Sovrem. Mat. Prilozh., 67 (1999), 69-128 [English translation in J. Math. Sci. 105 (2001), 1738-1778]. [15] S. V. Gonchenko and L. P. Shilnikov, On 2-dimensional area-preserving mappings with homoclinic tangencies, Doklady Mathematics, 63 (2001), 395-399. [16] S. V. Gonchenko and V. S. Gonchenko, On bifurcations of birth of closed invariant curves in the case of 2-dimensional diffeomorphisms with homoclinic tangencies, Proc. Steklov Inst., 244 (2004), 80-105. [17] S. V. Gonchenko, V. S. Gonchenko and J. C. Tatjer, Bifurcations of three-dimensional diffeomorphisms with non-simple quadratic homoclinic tangencies and generalized Hénon maps, Regular and Chaotic Dynamics, 12 (2007), 233-266. doi: 10.1134/S156035470703001X. [18] S. V. Gonchenko, L. P. Shilnikov and D. Turaev, On dynamical properties of multidimensional diffeomorphisms from Newhouse regions, Nonlinearity, 21 (2008), 923-972. doi: 10.1088/0951-7715/21/5/003. [19] S. V. Gonchenko and M. S. Gonchenko, On cascades of elliptic periodic points in 2-dimensional symplectic maps with homoclinic tangencies, J. Regular and Chaotic Dynamics, 14 (2009), 116-136. doi: 10.1134/S1560354709010080. [20] S. V. Gonchenko, V. S. Gonchenko and L. P. Shilnikov, On homoclinic origin of Henon-like maps, Regular and Chaotic Dynamics, 15 (2010), 462-481. doi: 10.1134/S1560354710040052. [21] S. V. Gonchenko, J. S. W. Lamb, I. Rios and D. V. Turaev, Attractors and repellers near generic elliptic points of reversible maps, Doclady Mathematics, 89 (2014), 65-67. [22] S. V. Gonchenko and D. V. Turaev, On three types of dynamics, and the notion of attractor, Tr. Mat. Inst. Steklova, 297 (2017), 133-157. doi: 10.1134/S0371968517020078. [23] J. S. W. Lamb and O. V. Stenkin, Newhouse regions for reversible systems with infinitely many stable, unstable and elliptic periodic orbits, Nonlinearity, 17 (2004), 1217-1244. doi: 10.1088/0951-7715/17/4/005. [24] E. Lombardi, Oscillatory Integrals and Phenomena Beyond all Algebraic Orders, Lecture Notes in Mathematics, 1741, Springer-Verlag, Berlin, 2000. doi: 10.1007/BFb0104102. [25] D. Montgomery and L. Zippin, Topological Transformation Groups, Interscience, New York, 1955. [26] S. E. Newhouse, Non density of Axiom A(a) on $S^2$, Proc. Amer. Math. Soc. Symp. Pure Math., 14 (1970), 191-202. [27] S. E. Newhouse, Diffeomorphisms with infinitely many sinks, Topology, 13 (1974), 9-18. doi: 10.1016/0040-9383(74)90034-2. [28] S. E. Newhouse, The abundance of wild hyperbolic sets and non-smooth stable sets for diffeomorphisms, Publ. Math. Inst. Hautes Etudes Sci., 50 (1979), 101-151. [29] J. Palis and M. Viana, High dimension diffeomorphisms displaying infinitely many sinks, Ann. Math., 140 (1994), 207-250. doi: 10.2307/2118546. [30] N. Romero, Persistence of homoclinic tangencies in higher dimensions, Ergod. Th. Dyn.Sys., 15 (1995), 735-757. doi: 10.1017/S0143385700008634. [31] M. B. Sevryuk, Reversible Systems, Lecture Notes in Mathematics, 1211, Springer-Verlag, Berlin, 1986. doi: 10.1007/BFb0075877. [32] L. Tedeschini-Lalli and J. A. Yorke, How often do simple dynamical processes have infinitely many coexisting sinks?, Commun.Math.Phys., 106 (1986), 635-657. doi: 10.1007/BF01463400. [33] D. V. Turaev, On the genericity of the Newhouse phenomenon, in EQUADIFF 2003, World Sci. Publ., Hackensack, 2005.
Two different examples of planar reversible maps with symmetric nontransversal (quadratic tangency) heteroclinic cycles: (a) with a nontransversal symmetric heteroclinic orbit to a symmetric couple of saddle points, and (b) with a symmetric couple of nontransversal heteroclinic orbits to symmetric saddle points
Three examples of planar reversible maps with symmetric nontransversal homoclinic tangencies: (a) a symmetric quadratic homoclinic tangency; (b) a symmetric cubic homoclinic tangency; (c) a symmetric couple of nontransversal homoclinic (figure-8) orbits to the same symmetric saddle point
(a) An example of reversible map with a couple of symmetric homoclinic tangencies (homoclinic figure-8). (b) A neighbourhood of the contour $O\cup\Gamma_1\cup\Gamma_2$
(a) A reversible diffeomorphism with a symmetric transversal homoclinic orbit; (b) creation of a symmetric couple of nontransversal homoclinic orbits $\Gamma_1$ and $\Gamma_2$ (a "fish" configuration)
Domains of definitions and associated coordinates for the first return map ${T_{2m1k}} = T_2T_0^mT_1T_0^k$
A geometric structure of the homoclinic points $M_1^+$, $M_{1}^{-}$, $M_2^+$ and $M_2^-$ and their neighbourhoods in the figure-8 homoclinic configuration. Schematic actions of the first return maps: (a) $T_{1k} = T_1 T_0^k$, (b) $T_{2k} = T_2 T_0^k$ and (c) ${T_{2m1k}} = T_2 T_0^m T_1 T_0^k$
A geometric structure of the homoclinic points $M_1^+$, $M_{1}^{-}$, $M_2^+$ and $M_2^-$ and their neighbourhoods in the "fish" homoclinic configuration. Several schematic actions of the first return maps are represented: (a) $T_{1k} = T_1 T_0^k$, (b) $T_{2k} = T_2 T_0^k$ and (c) ${T_{2m1k}} = T_2 T_0^m T_1 T_0^k$
Domains of definition and range of the successor map from $\Pi_i^{+}$ into $\Pi_j^-$, $i, j = 1, 2$, under iterations of $T_{0}$ in the cases of (a) homoclinic figure-8; (b) homoclinic "fish"
Elements of the bifurcation diagram for the map $H$: painted regions correspond to the existence of symmetric elliptic and saddle fixed points of $H$
Two examples of creation of secondary homoclinic tangencies to the point $O$ together with their Smale horseshoes
 [1] Victoria Rayskin. Homoclinic tangencies in $R^n$. Discrete & Continuous Dynamical Systems - A, 2005, 12 (3) : 465-480. doi: 10.3934/dcds.2005.12.465 [2] Thorsten Riess. Numerical study of secondary heteroclinic bifurcations near non-reversible homoclinic snaking. Conference Publications, 2011, 2011 (Special) : 1244-1253. doi: 10.3934/proc.2011.2011.1244 [3] Nikolaz Gourmelon. Generation of homoclinic tangencies by $C^1$-perturbations. Discrete & Continuous Dynamical Systems - A, 2010, 26 (1) : 1-42. doi: 10.3934/dcds.2010.26.1 [4] Maria Carvalho. First homoclinic tangencies in the boundary of Anosov diffeomorphisms. Discrete & Continuous Dynamical Systems - A, 1998, 4 (4) : 765-782. doi: 10.3934/dcds.1998.4.765 [5] Sergey Gonchenko, Ivan Ovsyannikov. Homoclinic tangencies to resonant saddles and discrete Lorenz attractors. Discrete & Continuous Dynamical Systems - S, 2017, 10 (2) : 273-288. doi: 10.3934/dcdss.2017013 [6] Daniel Wilczak. Abundance of heteroclinic and homoclinic orbits for the hyperchaotic Rössler system. Discrete & Continuous Dynamical Systems - B, 2009, 11 (4) : 1039-1055. doi: 10.3934/dcdsb.2009.11.1039 [7] Steven M. Pederson. Non-turning Poincaré map and homoclinic tangencies in interval maps with non-constant topological entropy. Conference Publications, 2001, 2001 (Special) : 295-302. doi: 10.3934/proc.2001.2001.295 [8] Antonio Pumariño, Joan Carles Tatjer. Attractors for return maps near homoclinic tangencies of three-dimensional dissipative diffeomorphisms. Discrete & Continuous Dynamical Systems - B, 2007, 8 (4) : 971-1005. doi: 10.3934/dcdsb.2007.8.971 [9] Qingdao Huang, Hong Qian. The dynamics of zeroth-order ultrasensitivity: A critical phenomenon in cell biology. Discrete & Continuous Dynamical Systems - S, 2011, 4 (6) : 1457-1464. doi: 10.3934/dcdss.2011.4.1457 [10] E. Canalias, Josep J. Masdemont. Homoclinic and heteroclinic transfer trajectories between planar Lyapunov orbits in the sun-earth and earth-moon systems. Discrete & Continuous Dynamical Systems - A, 2006, 14 (2) : 261-279. doi: 10.3934/dcds.2006.14.261 [11] Yuncheng You. Asymptotic dynamics of reversible cubic autocatalytic reaction-diffusion systems. Communications on Pure & Applied Analysis, 2011, 10 (5) : 1415-1445. doi: 10.3934/cpaa.2011.10.1415 [12] Yuncheng You. Dynamics of three-component reversible Gray-Scott model. Discrete & Continuous Dynamical Systems - B, 2010, 14 (4) : 1671-1688. doi: 10.3934/dcdsb.2010.14.1671 [13] J. K. Krottje. On the dynamics of a mixed parabolic-gradient system. Communications on Pure & Applied Analysis, 2003, 2 (4) : 521-537. doi: 10.3934/cpaa.2003.2.521 [14] Dong-Lun Wu, Chun-Lei Tang, Xing-Ping Wu. Existence and nonuniqueness of homoclinic solutions for second-order Hamiltonian systems with mixed nonlinearities. Communications on Pure & Applied Analysis, 2016, 15 (1) : 57-72. doi: 10.3934/cpaa.2016.15.57 [15] Genghong Lin, Zhan Zhou. Homoclinic solutions of discrete $\phi$-Laplacian equations with mixed nonlinearities. Communications on Pure & Applied Analysis, 2018, 17 (5) : 1723-1747. doi: 10.3934/cpaa.2018082 [16] Oksana Koltsova, Lev Lerman. Hamiltonian dynamics near nontransverse homoclinic orbit to saddle-focus equilibrium. Discrete & Continuous Dynamical Systems - A, 2009, 25 (3) : 883-913. doi: 10.3934/dcds.2009.25.883 [17] Benoît Grébert, Tiphaine Jézéquel, Laurent Thomann. Dynamics of Klein-Gordon on a compact surface near a homoclinic orbit. Discrete & Continuous Dynamical Systems - A, 2014, 34 (9) : 3485-3510. doi: 10.3934/dcds.2014.34.3485 [18] Antonio Pumariño, José Ángel Rodríguez, Joan Carles Tatjer, Enrique Vigil. Expanding Baker Maps as models for the dynamics emerging from 3D-homoclinic bifurcations. Discrete & Continuous Dynamical Systems - B, 2014, 19 (2) : 523-541. doi: 10.3934/dcdsb.2014.19.523 [19] Shin Kiriki, Yusuke Nishizawa, Teruhiko Soma. Heterodimensional tangencies on cycles leading to strange attractors. Discrete & Continuous Dynamical Systems - A, 2010, 27 (1) : 285-300. doi: 10.3934/dcds.2010.27.285 [20] Alexis De Vos, Yvan Van Rentergem. Young subgroups for reversible computers. Advances in Mathematics of Communications, 2008, 2 (2) : 183-200. doi: 10.3934/amc.2008.2.183

2017 Impact Factor: 1.179

## Metrics

• PDF downloads (37)
• HTML views (61)
• Cited by (0)

## Other articlesby authors

• on AIMS
• on Google Scholar

[Back to Top]


text:
how to plot a 3x3 matrix in matlab
... % Plot matrix as image I have a cell in which I've put four matrices. Is this the correct way to calculate a rotation matrix for a given angle ... Matlab function, rotation matrix. (See help loglog.) In the example, the matrix A is not a full matrix, but matlabs inverse routine will still return a matrix. Learn more about 3d plots, matrices MATLAB Matrices. Christophe Geuzaine and Jean-Franois Remacle Gmsh is an automatic 3D finite element mesh generator with build-in pre- and post-processing facilities. Lecture 8 Matrices and Matrix Operations in Matlab Matrix operations Recall how to multiply a matrix Atimes a vector v: Av = 1 2 ... plot. In the example, the matrix A is not a full matrix, but matlabs inverse routine will still return a matrix. MATLAB Inverse of a Matrix - Learn MATLAB in simple and easy steps starting from Environment Setup, Basic Syntax, Commands, Data Getting started with MATLAB %%%%% % Introduction to Matlab % This course is adapted from MIT ... % Identity matrix (3x3) v = rand ... % Plot matrix as image The simplest way to create a matrix in MATLAB is to use the matrix constructor operator, []. Lecture 8 Matrices and Matrix Operations in Matlab Matrix operations Recall how to multiply a matrix Atimes a vector v: Av = 1 2 ... plot. I need to build up the matrix of matrices. Eigenvalues and Eigenvectors, More Direction ... An eigenvalue of an nxn matrix A means a ... We can get Matlab to plot tangent vectors to solutions. Creating and Concatenating Matrices. ways to create a matrix. MatrixPlot[m] generates a plot that gives a visual representation of the values of elements in a matrix. Say, for all $1\leq i,j\leq n$ I have to define a matrix $p_{ij}$ which will be a matrix $n\times n$. plot a 6x6 matrix in 3D . Google has many special features to help you find exactly what you're looking for. Hey guys, I'm having some trouble plotting a matrix. Linear Algebra Using MATLAB ... % Create a 3x3 Matrix and Find Its Inverse A=[1,2,0; ... MATLAB can easily solve such systems using the inverse method whereby There are many times where we want to do an operation to every entry in a vector or matrix. This MATLAB function creates a matrix of subaxes containing scatter plots of the columns of X against the columns of Y. MATLAB is an abbreviation for "matrix laboratory." Introduction Multicharts and Multitest can calculate a color correction matrix (CCM) from an image of a color test chart. a couple of days ago I am trying to figure out how to plot a 3x3 matrix into a unit cell along with a 3-length vector. ... MATLAB is designed to operate primarily on whole matrices and arrays. 1. type in matrix ... To eval and plot the function z=x^2+y^2 ... (from help pascal on MATLAB) 22. vander(N) Vandermonde matrix. The matrix rows define the lattice vectors. (See help loglog.) file exchange and newsgroup access for the MATLAB & Simulink user community How to plot 3 graphs using values arranged in columns in a ... V is the mode shapes matrix (3x3 ... plots in MATLAB, similar to plot matrix. Overview. Gmsh. International Journal of Engineering Research and Applications (IJERA) is an open access online peer reviewed international journal that publishes research .. Determinants in Matlab. Getting started with MATLAB %%%%% % Introduction to Matlab % This course is adapted from MIT ... % Creates a 3x3 matrix (!)


text:
## Introductory Algebra for College Students (7th Edition)

Subtract $\frac{7}{11}$ from both sides of the equation to isolate the variable. y+$\frac{7}{11}$=$\frac{7}{11}$ y=$\frac{7}{11}$-$\frac{7}{11}$ y=0 Check the answer. (0)+$\frac{7}{11}$=$\frac{7}{11}$ $\frac{7}{11}$=$\frac{7}{11}$


text:
# 4.5: Environmental Economics

It should be clear from reading this chapter that the well-being of people around the world is fundamentally linked to opportunities for biodiversity to survive and prosper. That means that when we destroy an ecosystem or let a species go extinct, we also put at risk our own ability to survive and prosper. To fully account for these risks, decisions that negatively affect biodiversity must account for all the costs and benefits (hidden or otherwise), including the impacts on ecosystem services, before the decision is implemented.

One of the most popular methods for accounting for potential harm to biodiversity, especially when weighing public policy and commercial decisions, is to attach market (or monetary) values to the ecosystem services. For some ecosystem services, it is rather straightforward to estimate a market value. For example, how much would it cost to replace a natural pollination service with hand pollination by farm workers? But for many services, estimating a monetary value is much more difficult. For example, how do we calculate the value of the Congo Basin’s carbon stocks? Where do we even start to estimate the value of breathing clean air, or knowing that dolphins exists?

Environmental economics strengthen arguments for biodiversity protection by examining the contribution of ecosystem services to global economies.

To examine these kinds of complex questions, conservation biologists look to a sub-discipline within economics called environmental economics. Environmental economics broadly examines the contribution of ecosystem services to global economies. An important component of this examination involves estimating the market value of all the different ecosystem services we benefit from, but it also includes studying the environmental costs of economic transactions, environmental policies, and other decisions that impact the environment.

## 4.5.1 Placing a price on the natural world

Approximating the market values of ecosystem services is no small feat, in part because nature’s contributions to people vary by location and perspective (Díaz et al., 2018). There also continue to be technical (e.g. Kling et al., 2012) and ethical (e.g. McCauley, 2006; Silvertown, 2015) disagreements about the need and methods used to translate nature’s services into monetary terms. Nevertheless, including such estimates has become a widely accepted norm in economics models and conservation activities (Guerry et al., 2015). To accomplish this task, economists rely on seven main methods to estimate the market values of ecosystem services (Farber et al., 2002):

• Market value: The price a person is willing to pay for a specific product or service. For example, how much is a person willing to pay for a bundle of firewood at a local market?
• Avoidance cost: The cost society avoids paying because a specific ecosystem service exists. For example, how much does society avoid paying for water filtration service otherwise provided by a region’s forests and wetlands?
• Replacement cost: The cost society would have incurred if a specific ecosystem service had to be replaced. For example, how much would society have to pay in extra healthcare costs and in clean-up costs for diseased carcasses to replace the sanitation services provided by vultures?
• Factor income: The additional income generated by the enhancement of an ecosystem service. For example, how much would a reduction in water pollution increase the income of fishermen through healthier fish populations?
• Travel cost: The additional travel cost a person is willing to pay to experience an ecosystem service otherwise not available to them. For example, how much extra is a person willing to pay for transport to participate in recreational activities at a cleaner lake?
• Hedonic pricing: The additional expense a person is willing to pay to experience an ecosystem service. For example, how much extra is someone willing to pay for a house with an ocean view, compared to an inland house?
• Contingent valuation: The additional expenses a person is willing to pay for an alternative hypothetical scenario. For example, how much is someone willing to pay for cleaner air, or the right to catch more fish?

The combined value of all of Earth’s ecosystem services may be double the current value of the global economy.

Using a combination of these methods, a range of ecosystem services have been valued in recent years. For example, the services offered by pollinating insects around the world have been valued at US $153 billion per year (Gallai et al., 2008). In just South Africa’s Western Cape Province, free pollination services provided by wild insects to the local fruit industry, valued at US$500 million, has been estimated at nearly US $360 million per year (Allsopp et al., 2008). The replacement cost of tropical forests is also increasingly appreciated in carbon sequestration markets, where heavy greenhouse gas emitters pay huge sums of money to conserve forests to become more carbon neutral (Section 10.4). For example, the United Nations Environmental Programme (UNEP) has estimated that their forests are worth 4.2 times more intact than the value that could be earned through logging; the value of just Kenya’s remaining Mau forest, if left intact, is estimated at US$1.3 billion per year (UNEP, 2012). One ambitious study estimated the value of all of Earth’s ecosystem services at US $145 trillion annually (Costanza et al., 2014), which is almost double the current US$78 trillion value of the global economy. By comparing the value of ecosystem services over time, Costanza et al. (2014) also estimated that we are losing US $4.3–20.2 trillion per year in ecosystem services through land degradation. ## 4.5.2 Environmental economics’ biggest contributions Since its development, environmental economics has contributed to conservation biology in several very important ways. Perhaps the most important contribution is that it has enabled conservation biologists to better communicate the value of ecosystem goods and services to audiences like government officials and business leaders, who often base decisions on economic considerations. By doing this, environmental economics has also focussed our attention on the wide range of goods and services that biodiversity provides and has elevated these topics into corridors where they were not previously discussed. These efforts have already paid dividends; in 2012, several Africa countries signed the Gaborone Declaration, a pledge to integrate the value of ecosystem services into their economies. Environmental economics enable us to better communicate the value of biodiversity to those who base decisions on economic considerations. Environmental economics also enabled conservation biologists to better account for environmental impacts of environmental damaging activities. In doing so, the field highlighted how activities that appear profitable are running at an economic loss when properly accounting for otherwise ignored environmental (and social) damages. While such calculations have traditionally focussed on imbalances in overharvesting of material contributions (see negative externalities, Section 4.5.3), recent developments have also started accounting for damages inflicted on regulating services and nonmaterial contributions, such as the loss of nature’s contribution to climate regulation (Auffhammer et al., 2017; Hsiang et al., 2017). ## 4.5.3 Environmental economics’ biggest challenges Despite all the direct and indirect contributions of environmental economics to biodiversity conservation, there are also several challenges facing the field. Some of these challenges relate to methodological complexities of valuing ecosystem services, but many challenges also have their roots in governance failures. Following is a discussion of the most important challenges facing environmental economics. ### Accounting for negative externalities Modern economics is built on the principle of voluntary transactions—that is, a transaction occurs only when it benefits all the stakeholders involved. However, environmental (and social) harm often arises when some hidden costs are passed on to people not directly involved in the transactions. The unregulated use of open-access resources—resources such as water, air, and fish populations that are freely used by many different groups of people—provide many opportunities for this kind of abuse. Consider a company that dumps chemical waste into a river instead of properly disposing of it. While the company may benefit from this cost-cutting measure, people further downstream bear the environmental and social costs of the company’s “free” waste disposal by having to contend with polluted drinking water, loss of swimming and other recreational opportunities, and loss of fish as a safe food source. Damage inflicted on rivers and other open-access resources also represent a classic example of the tragedy of the commons—while some people initially benefit from abusing the “free” ecosystem services, those values are gradually lost to all of society, including those who abused it (NRC, 2002). Because negative externalities allow a small number of people to benefit at the expense of the rest of society, they often lead to market failures. The hidden costs of economic transactions that are passed on to people not directly involved are generally known as negative externalities (Figure 4.10). Because negative externalities allow a small number of people to benefit at the expense of the rest of society, they often lead to market failures, characterized by transactions that do not lead to optimal outcomes for all stakeholders. Governments may correct for these kinds of market failures by imposing taxes on activities that are harmful to the environment. Carbon taxes imposed on greenhouse gas emitters (see climate change, Chapter 6) is a common example. But many times, governance structures fail, or even exacerbate, the impact of negative externalities, by artificially maintaining destructive activities with tax incentives, direct payments, and price regulations. For example, subsidies give foreign fishing fleets operating off Africa a competitive advantage over local fisherman and artificially inflate their profitability despite declining fish populations (Brashares et al., 2004; Sumaila and Pauly, 2006; Mallory, 2013). The financial incentives governments provide to maintain destructive activities are more often referred to as perverse subsidies (Myers and Kent, 2001). The size of perverse subsidies is often very large, regularly dwarfing conservation spending. For example, US$26 billion in subsidies were provided to the Africa’s fossil fuel industry just in 2015 (Whitley and van der Burg, 2015), compared to just US \$381 million spent annually to secure Africa’s protected areas with lions (Lindsey et al., 2018).

There are many reasons why governance structures continue to fail nature and allow market failures to occur. For example, due to the prevailing mindset of pursuing economic growth at all costs, politicians, developers, and industries often skew their cost-benefit analyses by prioritising the short-term benefits gained from destructive sectors over long-term societal well-being and sustainability. Another factor is intense lobbying by industries benefitting from perverse subsidies, which leads to corruption and other questionable decisions. Solving these challenges will rely on a society that prioritises economic development (Section 15.1) and establishes structures (i.e. passing and enforcing environmental laws, Chapter 12) that fully account for negative externalities.

### Determining ownership

Another problem that plagues environmental economists and other stakeholders is deciding who owns the commercial rights to biodiversity. Imagine a biochemist from a wealthy country traveling in a rural part of West Africa. The biochemist falls sick, but luckily local villagers help the chemist get better with the aid of a traditional healing plant. Once back home, the biochemist scientifically demonstrates that this plant can be used to synthesise a new effective medicine. Do the profits from this new medicine belong to the biochemist, the organization that sponsored his/her trip, or the local people in the area who helped the biochemist?

Scientists, economists, politicians, and others are currently debating who owns the commercial rights to the world’s biodiversity.

In the past, corporations and scientists (generally from wealthier countries) travelled extensively (often to poorer countries in the tropics) to collect species from which commercially valuable products might be obtained. These new products were then sold, but all profits were kept by the corporations while the people in the poorer source countries received little to no financial benefit. One such example is the production of palm oil, of which Malaysia and Indonesia currently contribute 85% of the global vegetable oil supply. This industry is entirely dependent on the oil palm (Elaeis guineensis, LC), and its specialist pollinator, the oil palm weevil (Elaeidobius kamerunicus), both imported from West Africa. Yet, West Africa have seen little benefit from the profits palm oil generated in Southeast Asia (Mbugua, 2017). (Note this exploitation goes multiple ways; for example, South America has also seen little benefit from profits generated from cacao production in West Africa.)

To combat this unfair exploitation, called biopiracy, many developing countries now require scientists and corporations to obtain permits before they can collect biological material for commercial or research purposes. Also, at the international level, nearly 100 countries have agreed to the fair sharing of benefits arising from the use of biological resources, through the Nagoya Protocol (see Section 12.2.1 for further discussion on international laws). Through these and similar laws and agreements, the hope is that a greater portion of the profits gained from biodiversity will be allocated to people who protect biodiversity and who live in the areas from where it is extracted.

### A more inclusive approach

The valuation of ecosystem services has traditionally relied on generalised principles of economics and natural sciences. While this focus enabled scientists to develop broadly applicable themes and metrics in ecosystem evaluation, it also neglected the role of context and culture in understanding nature’s role in people’s lives. Many people have also remained uneasy about commodifying nature (i.e. giving it a market value), because some of the most important contributions of biodiversity are not easily converted into monetary metrics. Consequently, many feared that the transactional approach to ecosystem services would lead to social inequity concerns and alienate people offended by the idea that nature’s metaphysical properties must compete against commercial interests.

To address these concerns, the valuation and classification of ecosystem services are currently undergoing several major transformations. Prominently, the UN’s most recent classification scheme (Díaz et al., 2018) has given a more prominent voice to a wider range of stakeholders, including the social sciences, and recognizes the importance of culture and context in nature’s contributions to people. This exciting area of research is actively developing, and readers are encouraged to track developments and reactions associated with 2019 IPBES Global Assessment at https://www.ipbes.net/news/ipbes-global-assessment-preview.

This page titled 4.5: Environmental Economics is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by John W. Wilson & Richard B. Primack (Open Book Publishers) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.


text:
# Permutation question involving seating

In a class of 20 students having 20 chairs in 5 rows of 4 each. If the class has 10 boys and 10 girls, in how many ways, can the student's be placed in the chair's such that no boy is sitting in front of, behind, or next to another boy and no girl is sitting in front of, behind or next to another girl.

Please explain in detail.

Since I had just started this I am having no ideas about permutation formulas so please explain this answer by logical thinking. Please NOTE:-I am just a highschool student seeking help from teachers. So please be calm and don't close my question

• Well, have you tried to find an arrangement that works? Suppose the upper left seat is taken by a girl. How much freedom does that leave you in the rest of the assignment? – lulu Aug 18 '18 at 18:44
• It just clicked in my head. I got this answer no need to solve it. So I am taking my question back to save other users time. – Rafael Nadal Aug 18 '18 at 18:46
• @Thanks sir for paying attention to my question – Rafael Nadal Aug 18 '18 at 18:46

Given a colouring, you have $10!$ ways to have the boys seated, and $10!$ ways to have the girls seated. (All right, this part is about permutations.)
So the number of solutions is $2\cdot 10!\cdot 10!$.


text:
# A Question on Hamilton's Principle

In some literatures, the Hamilton's principle for conservative systems is introduced by this equation: $$\delta \int_{t_1}^{t_2}(T-V) ~\mathrm{d}t~=~0$$

In some others, this principle is introduces as follow:

$$\int_{t_1}^{t_2}\delta(T-V) ~\mathrm{d}t~=~0$$

What is the difference between two equations? Are those expressions the same?

-
Note that the general expression of Hamilton's principle is: $\delta S=0$. –  jinawee Jun 18 '14 at 21:20
From the variational calculus point of view, we can get the first expression. I mean if we use the Principle of least action the first equation will appear. "The path taken by the system between times t1 and t2 is the one for which the action is stationary (no change) to first order." Why we could take the $\delta$ operator into the integral? What is the physical meaning of the second equation? –  Mas ooD Jun 18 '14 at 21:34
I just wanted to point out the general expression. I suggest you read Lanczos The Variational Principles of Mechanics, which is quite amusing (which gives the same answer as the given below). –  jinawee Jun 18 '14 at 21:41

They're the same, because integration is linear:

$$\int _{t_1}^{t_2} \left( f(t) - g(t) \right) \,dt = \int_{t_1}^{t_2}f(t)\,dt - \int_{t_1}^{t_2}g(t)\,dt$$

Consider two paths. Let the system trajectory in the first path be denoted $X_1(t)$ and the trajectory for the second path be denoted $X_2(t)$. Let the Lagrangian be denoted $L$. Then the action for the first trajectory is $$S_1 = \int_{t_1}^{t_2}L(X_1(t))\,dt$$ and the action for the second trajectory is $$S_2 = \int_{t_1}^{t_2}L(X_2(t))\,dt.$$
The difference in the action between the two paths is \begin{eqnarray} \Delta S \equiv S_1 - S_2 &=& \int_{t_1}^{t_2}L(X_1(t))\,dt - \int_{t_1}^{t_2}L(X_2(t))\,dt \\ &=& \int_{t_1}^{t_2} \left[ L(X_1(t))-L(X_2(t)) \right]\,dt \\ &=& \int_{t_1}^{t_2}\Delta L(t)\,dt \end{eqnarray} In the last equation we wrote $\Delta L$ to denote $L(X_1) - L(X_2)$. This is not quite what we're going for: we want to get $\delta L$ inside the integral, where $\delta L$ is the variation of the Lagrangian. The variation is the derivative of a function with respect to something. When you think about the definition of a derivative, you have something like $$\frac{df}{dx}(x_0)\equiv \lim_{h\rightarrow 0}\frac{f(x_0+h)-f(x_0)}{h}.$$ So really, taking the $\delta$ inside the integral requires the linearity property we already demonstrated and the ability to move the limit inside the integral. This is ok in almost every case you will ever encounter. To prove why you can move the limit inside the integral you have to do some analysis which I really don't want to recall and type here. You can find that sort of thing in analysis books.
@DanielSank Although the spirit of this is correct, it's not quite this simple. Recall that $\delta$ denotes a variation, not simply a change. In other words, it is a first order change in some parameter, say $\epsilon$, when one deforms a given path $q$ via a one-parameter family of paths $q + \epsilon\eta$. The validity of taking the $\delta$ inside then comes down to a question of when one can take derivatives inside of integrals, which one can under certain assumptions. –  joshphysics Jun 19 '14 at 9:20
@joshphysics: The cases in which you can't take the derivative inside integrals almost never show up in any physics problem, so I didn't want to bother about that. Also, while $\delta$ is indeed a variation, the reason it (And the derivative) can be put inside the integral follows from exactly the linearity property already discussed. That said, I didn't explicitly explain this, so I'll edit my answer. –  DanielSank Jun 19 '14 at 15:27


text:
# A Survey of the Elastic Flow of Curves and Networks

created by pluda on 28 Sep 2020
modified on 30 Apr 2021

[BibTeX]

Published Paper

Inserted: 28 sep 2020
Last Updated: 30 apr 2021

Journal: Milan J. Math.
Year: 2021
Doi: 10.1007/s00032-021-00327-w

ArXiv: 2009.12870 PDF

Abstract:

We collect and present in a unified way several results in recent years about the elastic flow of curves and networks, trying to draw the state of the art of the subject. In particular, we give a complete proof of global existence and smooth convergence to critical points of the solution of the elastic flow of closed curves in $\mathbb{R}^2$. In the last section of the paper we also discuss a list of open problems.


text:
MathOverflow will be down for maintenance for approximately 3 hours, starting Monday evening (06/24/2013) at approximately 9:00 PM Eastern time (UTC-4).

## boolean algebra proof [closed]

Hey guys,

I'm new at learning boolean algebra and understand the basic laws. But now I'm trying to proof:

x'z+ xyz + xy'z = z

Can someone help me with this please ?

Thanks in advance.

-
This question is not appropiate for MO, since it is not research level. The FAQ lists some websites that might be a better fit. Please try it at one of those. – Alberto García-Raboso Aug 13 2010 at 12:59
Am I right in thinking that this question should be closed? (Of course, this is not the fault of the questioner; it is easy to misunderstand the purpose of MathOverflow, especially if you are a newcomer.) You might be able to get an answer to this sort of question at the Wikipedia Mathematics Reference Desk. In fact, these questions are very much welcome there. Or, you could also see the Wikipedia article on Boolean algebras. – Amitesh Datta Aug 13 2010 at 14:14


text:
## Files in this item

FilesDescriptionFormat

application/pdf

9010889.pdf (6MB)
(no description provided)PDF

## Description

 Title: Electron beam interactive oxide films for nanometer scale lithography Author(s): Hollenbeck, James Lowell Doctoral Committee Chair(s): Buchanan, Relva C. Department / Program: Materials Science and Engineering Discipline: Materials Engineering Degree Granting Institution: University of Illinois at Urbana-Champaign Degree: Ph.D. Genre: Dissertation Subject(s): Engineering, Electronics and Electrical Physics, Condensed Matter Engineering, Materials Science Abstract: A number of oxide thin films produced by rf sputtering have been found to show high resolution lithographic characteristics when exposed under high dose rate conditions in a scanning transmission electron microscope. Holes and lines less than 10 nm in dimensions have been formed in amorphous films of Al$\sb2$O$\sb3$, Y$\sb2$O$\sb3$, Sc$\sb2$O$\sb3$, $\rm 3Al\sb2 {O\sb3}{\cdot}{2SiO\sb2}$ and $\rm {MgO}{\cdot}{Al\sb2}{O\sb3}$ through the direct removal of material during exposure. Complete exposure in these films was produced in less than 80 ms using a dose rate of $1 \times 10\sp5$ A/cm$\sp2$. In addition to the requirement of amorphous film structure the material characteristics found to be important in determining film response included high ionic character, high heat of formation and incorporation of inert gas into the structure. The high resolution characteristics in amorphous Al$\sb2$O$\sb3$ films allowed the production of 5.0 nm holes with a minimum center-to-center spacing of 8.9 nm.The effects of film thickness, inert gas incorporation and exposure parameters were studied using amorphous Al$\sb2$O$\sb3$ films. An optimum thickness was found to occur at approximately 90 nm where the dose required for exposure was $25 \times 10\sp2$ C/cm$\sp 2$ ($\sim$25 ms). Argon concentrations could be controlled over the range of approximately 1.0-2.5 At.% and films containing larger amounts of Ar showed improved sensitivity. Increasing the dose rate of exposure resulted in decreased time and increased total dose requirements for exposure. No threshold current densities for material removal were observed above $1 \times 10\sp3$ A/cm$\sp2$. A qualitative model of the exposure process has been developed which describes material removal as a sequence of events involving the desorption of surface species, generation of bulk defects, preferential diffusion of cations and rapid expulsion of oxygen and inert gas from the exposed volume. Such a model is consistent with observations made during and after exposure of oxide resist materials.Evaluation of amorphous Al$\sb2$O$\sb3$ and AlF$\sb3$ films exposed under the same conditions revealed similar dose requirements in the two materials, however, the exposure process appears to be slightly different. Less extensive damage to unexposed regions of Al$\sb2$O$\sb3$ films have shown them to have superior characteristics for exposure of line patterns. Issue Date: 1989 Type: Text Language: English URI: http://hdl.handle.net/2142/20924 Rights Information: Copyright 1989 Hollenbeck, James Lowell Date Available in IDEALS: 2011-05-07 Identifier in Online Catalog: AAI9010889 OCLC Identifier: (UMI)AAI9010889


text:
# Assign new data to a cluster (using Gower distance and PAM algorithm)

I have a dataset which has mixed data types and hence I used Gower dissimilarity matrix as input to cluster the data using Partitioning Around Medoids (PAM) algorithm.

I wanted to know if there is any way by which I can assign new data points using the existing PAM model. Since I have used Gower distance, I am not sure of how to go about it as I understand that calculating Gower dissimilarity for 1 new data point is not possible.

Is there any way in R like we have fit_transform in Python - for Gower distances? And is it even possible to save PAM/K-means models in R and use the same to "predict"/assign clusters to new data?

In theory if you know the medoids from the train clustering, you just need to calculate the distances to these medoids again in your test data, and assign it to the closest. So below I use the iris example:

library(cluster)
set.seed(111)
idx = sample(nrow(iris),100)
trn = iris[idx,]
test = iris[-idx,]

mdl = pam(daisy(iris[idx,],metric="gower"),3)

we get out the medoids like this:

trn[mdl\$id.med,]
Sepal.Length Sepal.Width Petal.Length Petal.Width    Species
40           5.1         3.4          1.5         0.2     setosa
100          5.7         2.8          4.1         1.3 versicolor
113          6.8         3.0          5.5         2.1  virginica

So below I write a function to take these 3 medoid rows out of the train data, calculate a distance matrix with the test data, and extract for each test data, the closest medoid:

predict_pam = function(model,traindata,newdata){

nclus = length(model$$id.med) DM = daisy(rbind(traindata[model$$id.med,],newdata),metric="gower")
max.col(-as.matrix(DM)[-c(1:nclus),1:nclus])

}

You can see it works pretty well:

predict_pam(mdl,trn,test)
[1] 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3
[39] 3 3 3 3 3 3 3 3 3 3 3 3

We can visualize this:

library(MASS)
library(ggplot2)

df = data.frame(cmdscale(daisy(rbind(trn,test),metric="gower")),
rep(c("train","test"),c(nrow(trn),nrow(test))))
colnames(df) = c("Dim1","Dim2","data")

df$$cluster = c(mdl$$clustering,predict_pam(mdl,trn,test))
df$$cluster = factor(df$$cluster)

ggplot(df,aes(x=Dim1,y=Dim2,col=cluster,shape=data)) +
geom_point() + facet_wrap(~data)

• thank you so much for the response - answers my question quite well!
– ANP
Jul 3 '20 at 10:58
• you're welcome ! i noticed there's a small error in the function, I have corrected it and it should work properly now (with calling the global variable) Jul 3 '20 at 11:29


text:
# Assembly vs. C++ vs. C# finding primes

## Recommended Posts

raccoonone    158
I was interested in seeing what the performance different between C++, C# and ASM with a C++ wrapper would be. So far the results have surprised me since C# is the fastest, this must be because my C++/ASM isn't good enough so maybe you guys can point out where I'm going wrong. The program I'm testing with is quite simple all it does is: a) get a number from the user b) calculate all the primes between 1 and the number c) output the number of primes found and the time taken to find them. All 3 programs use the same algorithm: if x is 1, 2, or 3 return true if x devided by 2 has a remainder of zero return false otherwise devide by all odd numbers starting with 3 until the square root of x is reached or the remainder is zero (indicating a composite number) I compiled all of the programs with full optimizations and ran them on my computer (AthlonXP 2800+ with 1GB of RAM). The C++ version and my ASM version both took 19.5-20secs to find all the primes between 1 and 10,000,000. The C# version took 20-20.5secs when I was using ints, but after I changed it to use doubles to reduce the ammount of type conversions, it does it in 16-17secs! When I looked at the disassembly for the C# version I found that it's using almost all floating point processer instructions, but then I calls some functions that I couldn't step into (well I'm sure I could if I spent some time figuring out how). Here's a short part of the disassembly. I haven't used floating point instructions much and I don't really understand what it's doing in the beginning there. It looks to me like it's just moving data through the ALU by pushing and then poping it somewhere else.
                if (TestNumber % x == 0)
0000008c  fld         qword ptr [ebp+8]
0000008f  sub         esp,8
00000092  fstp        qword ptr [esp]
00000095  fld         qword ptr [esp+10h]
00000099  sub         esp,8
0000009c  fstp        qword ptr [esp]
0000009f  call        79235954
000000a4  fldz
000000a6  fcomip      st,st(1)
000000a8  fstp        st(0)
000000aa  jp          000000B9
000000ac  jne         000000B9

Here's the source of my C# version
using System;
using System.Collections.Generic;
using System.Text;

namespace Csharp_Test_console_application
{
class Program
{
static void Main(string[] args)
{
double x;
int PrimesFound = 0;
DateTime start, end;
Console.WriteLine("Find primes up to 'x'. Please enter x:");
start = System.DateTime.Now;
for (double y = 1; y <= x; y++)
{
if (IsPrime(y))
{
PrimesFound++;
}
}
end = System.DateTime.Now;
Console.WriteLine("Found {0} primes in {1}", PrimesFound, end - start);
}

static bool IsPrime(double TestNumber)
{
double limit = System.Math.Sqrt(TestNumber) + 1;
if (TestNumber == 2)
return true;
if(TestNumber % 2 == 0) //Check if TestNumber is even
return false;
double x = 3;
//Devide until the square root is reached
for (; x < limit; x += 2)
{
if (TestNumber % x == 0)
return false;
}
return true;
}
}
}

Source of my C++ version
// Cpp primes.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
using std::cin;
using std::cout;
bool IsPrime(int TestNumber);

int _tmain(int argc, _TCHAR* argv[])
{
int x, PrimesFound = 0;
DWORD start, end;
cout << "Find primes up to 'x'. Please enter x:";
cin >> x;
start = GetTickCount();
for (int y = 1; y <= x; y++)
{
if (IsPrime(y))
{
PrimesFound++;
}
}
end = GetTickCount();
cout << "Found " << PrimesFound << " primes in " << end - start;
while(!_kbhit());
return 0;
}

_inline bool IsPrime(int TestNumber)
{
int limit = (int)sqrt((double)TestNumber) + 1;
if (TestNumber == 2)
return true;
if(TestNumber % 2 == 0) //Check if TestNumber is even
return false;
int x = 3;
//Devide until the square root is reached
for (; x < limit; x += 2)
{
if (TestNumber % x == 0)
return false;
}
return true;
}

Assembly with C++ for the input and output
// asm primes.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

using std::cout;
using std::cin;

int _tmain(int argc, _TCHAR* argv[])
{
int x, PrimesFound = 0;
DWORD start, end;
cout << "Find primes up to 'x'. Please enter x:";
cin >> x;
start = GetTickCount();
int limit, temp;
_asm
{
pusha					//Save registers
mov	esi, 1				//Start checking numbers from 1
mov	edi, x				//Loop until X is reached
Forloop: cmp	esi, edi
ja		Done			//Exit if X has been reached

//Check if this number is one, two, or three
cmp		esi, 3
ja		Next
inc		PrimesFound
jmp		CheckDone
//Check if divisible by two
Next:	test	esi, 1						//If ESI is odd it's not divisible by 2
jnz		Next2						// so continuing checking for primality
jmp		CheckDone

Next2:	mov		temp, esi
fild	temp						//Convert
fsqrt								// to square
fistp	limit						//  root

mov		ebx, 3						//Set EBX to 3

mov		ecx, limit					//Set up the loop counter
shr		ecx, 1						//  devide by 2 since we'll be incrementing by 2

Check:	mov		eax, esi					//Restore test number
xor		edx, edx					// and clear remainder

div		ebx							//Divide and
or		edx, edx					// test for
jz		CheckDone					//  zero

inc		ebx							//increment divisor
inc		ebx							// ""
loop	Check						//Continue until the square root is reached

//Number is prime
inc		PrimesFound
CheckDone: inc	esi							//Increment ESI so the next number will be checked
jmp	Forloop							// for primality

Done: popa									//Restore registers
}
end = GetTickCount();
cout << "Found " << PrimesFound << " primes in " << end - start;
while(!_kbhit());
return 0;
}

stdafx.h for C++ versions
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once

#define WIN32_LEAN_AND_MEAN		// Exclude rarely-used stuff from Windows headers
#include <stdio.h>
#include <tchar.h>
#include <math.h>
#include <windows.h>
#include <conio.h>
#include <iostream>

##### Share on other sites
Washu    7829
None of your methods are particularily optimized at all. From number theory, you can show that you do not need to test against every number below the sqrt(n), but just the primes below the sqrt(n) to see if n is prime. As such, I would recommend changing your algorithm to remember each prime it finds.
Quote:
 All 3 programs use the same algorithm:if x is 1, 2, or 3 return true

1 is not prime.
A simple sieve i wrote a bit back for a similar post.
#include <iostream>#include <deque>#include <cmath>void FindPrimes(std::deque<std::size_t>& primes, std::size_t upperBound) {	std::size_t current = 15;	while(current < upperBound) {		current += 2;		bool isPrime = true;		std::size_t mod6 = current % 6;		//Every prime number p > 3 has the form 6q + 1 or 6q + 5.		if(!(mod6 == 1 || mod6 == 5)) {			continue;		}		std::size_t maxVal = static_cast<std::size_t>(std::ceil(std::sqrt(static_cast<double>(current))));		for(int i = 0; primes[i] <= maxVal; ++i) {			if(current % primes[i] == 0) {				isPrime = false;				break;			}		}		if(isPrime) {			primes.push_back(current);		}	}}int main() {	std::size_t knownPrimes[6] = {2, 3, 5, 7, 11, 13}; //seed the list.	std::deque<std::size_t> primes(&knownPrimes[0], &knownPrimes[6]);	std::size_t upperBound;	std::cout<<"Please enter the upper bound: ";	std::cin>> upperBound;	FindPrimes(primes, upperBound);	std::copy(primes.begin(), primes.end(), std::ostream_iterator<std::size_t>(std::cout, "\n"));}

##### Share on other sites
raccoonone    158
Ya, I realize that only the primes below sqrt(n) need to be checked. But to make the assembly version simpler I decided not to keep track of the primes that have been found. I'm more interested in a comparison of the languages than making it as fast as possible. Since the C# version uses the same algorithm I don't understand how it can be faster.

Oh ya, I forgot 1 isn't prime.

##### Share on other sites
rip-off    10979
Quote:
 Original post by Procyon LotorYa, I realize that only the primes below sqrt(n) need to be checked. But to make the assembly version simpler I decided not to keep track of the primes that have been found. I'm more interested in a comparison of the languages than making it as fast as possible. Since the C# version uses the same algorithm I don't understand how it can be faster.Oh ya, I forgot 1 isn't prime.

The c# code will be compiled and optimised on the fly. The actual code that will be executed will likely not look like yours.

Langugage comparisons like this ( i.e. a very narrow comparision ) are meaningless, they don't accurately represent how the languages will compete in a complex system.

##### Share on other sites
Zahlman    1682
0) 1 is not normally counted as a prime. I will not count it below.

1) Speed improvements are more likely to be found by improving the algorithm. In your case you can get rid of all the FP operations by doing it the other way around: gradually increment a limit value. You could also try making it only use primes that have been found so far. I will implement that below, but no guarantees that it will actually help (while you test against fewer primes, you add the overhead of tracking which primes to test against).

I will just show a function to test for primes up to a limit; I/O and timing should be kept separate and naturally aren't intended to be part of what is benchmarked.

#include <vector>using std::vector;int primesUpTo(int max) {  if (max < 2) return 0;  // Find primes < max (not <=)  vector<int> primes;  int num_primes_in_use = 1;  primes.push_back(2);  int limit = 4;  for (int testvalue = 3; testvalue < max; testvalue += 2) {    if (testvalue > limit) {      // Ran out of numbers that can be tested with the current set; add another      int last_prime_in_use = primes[num_primes_in_use++];      limit = last_prime_in_use * last_prime_in_use;    }    bool isPrime = true;    for (int testprime = 0; testprime < num_primes_in_use; ++testprime) {      if (!(testvalue % primes[testprime])) { isPrime = false; break; }    }    if (isPrime) { primes.push_back(testvalue); }  }  return primes.length();}

##### Share on other sites
Washu    7829
Of course, if an exact answer isn't needed...
#include <iostream>#include <cmath>int main() {    std::size_t upper_bound;    std::cout<<"Enter the upper bound: ";    std::cin>>upperBound;    std::cout<<"There are approximately "<<upperBound / std::log(static_cast<double>(upperBound))<<" primes below "<<upperBound<<std::endl;}

##### Share on other sites
raccoonone    158
Sorry I should have been more clear. I wasn't looking for help on a better algorithm. I was wondering why the C# version is faster than the other two, and if there was some specific C++/ASM optimizations that I missed (maybe floating point instructions are faster than the integer instructions?)

##### Share on other sites
Spoonbender    1258
Quote:
 Original post by Procyon LotorYa, I realize that only the primes below sqrt(n) need to be checked. But to make the assembly version simpler I decided not to keep track of the primes that have been found. I'm more interested in a comparison of the languages than making it as fast as possible. Since the C# version uses the same algorithm I don't understand how it can be faster.

Please, don't waste your time. You can't compare the "speed" of languages.
They all compile to ASM, so it depends entirely on how much the compiler can optimize the code *in your specific case*.
For any other code, you might get different results. Or when a new version of the compiler is released. It just doesn't make sense to test.

But I can easily tell you why your ASM version is slow. Because you're not a compiler. This goes back to my first point. The compiler can optimize. It's pretty hard for a human to keep track of the complexities of a modern CPU. A compiler can do it easily. That is why it pays to use high level languages. Low level is not "fast". it just means it's easier to screw up and slow things down. And that is why it doesn't make sense to talk about the "speed" of a language.

So basically, use whatever language you're most comfortable with, and use the best algorithm you can find. And don't bother searching for the "fastest" language. Please. [wink]

Oh yeah, and if you really want to compare, you should at least use the same algorithm in all three, shouldn't you? So either all versions should use floats/doubles, or none of them should.

##### Share on other sites
mnansgar    421
Try printing out the primes to a file and see if the C# output is equivalent to the C++ and assembly output. It seems that in this case you may be safe, but using the modulus operator with doubles is a recipe for disaster, as is testing whether doubles are exact values (e.g. == 2).

##### Share on other sites
nmi    978
Quote:
 Original post by Procyon LotorI was interested in seeing what the performance different between C++, C# and ASM with a C++ wrapper would be. So far the results have surprised me since C# is the fastest, this must be because my C++/ASM isn't good enough so maybe you guys can point out where I'm going wrong....When I looked at the disassembly for the C# version I found that it's using almost all floating point processer instructions, but then I calls some functions that I couldn't step into (well I'm sure I could if I spent some time figuring out how).

Maybe C# generates SSE instruction for floating point computations ? Could explain why its faster than your asm version.

BTW if you are comparing the speed of compiled programs, you should also mention the flags you used for compilation and the compiler you used (i.e. gcc has an option -mfpmath=sse besides -O3).

##### Share on other sites
raccoonone    158
Quote:
 Original post by SpoonbenderBut I can easily tell you why your ASM version is slow. Because you're not a compiler. This goes back to my first point. The compiler can optimize. It's pretty hard for a human to keep track of the complexities of a modern CPU. A compiler can do it easily. That is why it pays to use high level languages. Low level is not "fast". it just means it's easier to screw up and slow things down. And that is why it doesn't make sense to talk about the "speed" of a language.

low level is fast if you know what you're doing, and while I'm not an expert I know the code I wrote should be quite good (except that it doesn't use any newer instruction sets). My ASM version keeps everything in registers and only goes to memory in one place, because you can't load to the FPU from a register only from memory.
Quote:
 Oh yeah, and if you really want to compare, you should at least use the same algorithm in all three, shouldn't you? So either all versions should use floats/doubles, or none of them should.

I would have, but you can't do modulus division in C++ using floats/doubles. and floating point division in ASM doesn't give you a remainder.

##### Share on other sites
raccoonone    158
Quote:
 Original post by nmiMaybe C# generates SSE instruction for floating point computations ? Could explain why its faster than your asm version.BTW if you are comparing the speed of compiled programs, you should also mention the flags you used for compilation and the compiler you used (i.e. gcc has an option -mfpmath=sse besides -O3).

That could be, I didn't use any SSE instructions, thanks I'll look at those.

I used Visual Studio 2005 to compile all of them. For C# it just has the Optimize Code box checked. For the C++ versions they're built with /O2 /Ot and /GL

Quote:
 Original post by mnansgarTry printing out the primes to a file and see if the C# output is equivalent to the C++ and assembly output. It seems that in this case you may be safe, but using the modulus operator with doubles is a recipe for disaster, as is testing whether doubles are exact values (e.g. == 2).

I checked the C# version against the C++ version up to 101, because that was the first thing I thought of is that it must be skipping some numbers. But it's not making any mistakes, and on longer checks (find all the primes up to 10,000,000 for example) it gives the same answer.

##### Share on other sites
Spoonbender    1258
Quote:
 Original post by Procyon Lotorlow level is fast if you know what you're doing, and while I'm not an expert I know the code I wrote should be quite good (except that it doesn't use any newer instruction sets). My ASM version keeps everything in registers and only goes to memory in one place, because you can't load to the FPU from a register only from memory.

So you're saying that, apart from the fact that your code should be good, but is *still* outperformed by C#, ASM is faster?
You have completely and totally missed my point. Congratulations. You have in fact managed to disprove your own claim, if you hadn't noticed. You make a benchmark showing C# to be faster, and then you argue that it's not? Good show.

Let me try again. Both C# and C++ compile to ASM. That's asm just like the stuff you've written. That means there is *no* magic overhead that makes it slower than a hand-written program. There *might* be, yes, or there might not. There isn't a "Run C# program" instruction that suddenly lowers the CPU speed by 15%. A well written C# compiled with a good compiler will generate *the exact* same ASM code as the best ASM programmer will.
Low level is not faster, it just gives you more fine-grained control. That means, yes, you can occasionally avoid doing things the compiler would do, which means you can save a few cycles. But it also means you have to do *all* your optimizations yourself. And there are a lot the compiler can do, but which are practically impossible to keep track of yourself.
So in the best case, you'll get the *exact* same performance from all three versions. But it's a lot easier to get *near* that performance in higher level languages.

Quote:
Quote:
 Oh yeah, and if you really want to compare, you should at least use the same algorithm in all three, shouldn't you? So either all versions should use floats/doubles, or none of them should.

I would have, but you can't do modulus division in C++ using floats/doubles. and floating point division in ASM doesn't give you a remainder.

So you think C# can do things that can't be done in ASM? Again, C# code compiles *to* ASM. If C# can do it, so can ASM, because otherwise, C# would not be able to do it.

##### Share on other sites
raccoonone    158
Quote:
Original post by Spoonbender
Quote:
 Original post by Procyon Lotorlow level is fast if you know what you're doing, and while I'm not an expert I know the code I wrote should be quite good (except that it doesn't use any newer instruction sets). My ASM version keeps everything in registers and only goes to memory in one place, because you can't load to the FPU from a register only from memory.

So you're saying that, apart from the fact that your code should be good, but is *still* outperformed by C#, ASM is faster?
You have completely and totally missed my point. Congratulations. You have in fact managed to disprove your own claim, if you hadn't noticed. You make a benchmark showing C# to be faster, and then you argue that it's not? Good show.

Did you read my post? I said "I'm not an expert", and "it doesn't use any newer instruction sets".
and in my original post "this must be because my C++/ASM isn't good enough so maybe you guys can point out where I'm going wrong."

I was looking for advice on why my C++/ASM code wasn't performing well, not an argument about which language is faster.

##### Share on other sites
Quote:
 A well written C# compiled with a good compiler will generate *the exact* same ASM code as the best ASM programmer will.

*tired laugh*
Ah, an invocation of the fabled "any (good|modern) compiler". I give you this quote: "In theory, there is no difference between theory and practice. But, in practice, there is.".

As to the asm code: there is considerable room for improvement. On the non-algorithmic level, probably the biggest issue is branches. You have some questionable constructs:

jnz Next2// so continuing checking for primality
jmp CheckDone
> use jz instead for smaller code size and better static prediction; your code is only necessary if Next2 is out of range of a short jump.

ja Next
inc PrimesFound
jmp CheckDone
> same issue. try to organize code in a straight line, but at least this branch is well-predicted.

Also:

OR edx, edx
> prefer TEST instead for less pipeline dependencies.

loop Check
> as a general rule, never use LOOP or other CISC-style instructions. dec/jnz is much faster.

##### Share on other sites
Spoonbender    1258
Quote:
 Original post by Procyon LotorDid you read my post? I said "I'm not an expert", and "it doesn't use any newer instruction sets".

I'm 99.9% sure the C# version doesn't use SSE instructions either. First, compilers just aren't smart enough to do that, and second, there's just nothing to be gained by it in your case.
Edit: Ok, they might use the scalar versions of SSE instructions, but that won't offer any big performance boost.
Edit2: Ok, just looked some of the latencies up. The SSE version of sqrt is actually a good deal faster than the x87 one. But the rest are pretty much the same. Try compiling your C++ program to use SSE, and see what happens.

Quote:
 I was looking for advice on why my C++/ASM code wasn't performing well, not an argument about which language is faster.

Well, you did start out by saying "I was interested in seeing what the performance different between C++, C# and ASM with a C++ wrapper would be".
Sounds like you were interested in which language was faster.
My point is simply that there's nothing too surprising in C# being fast.

But to answer your question, the main reason your ASM version isn't performing very well is because ASM is damn complex. You not only have to write the code, you also have to take latency and register pressure and other factors into account. You need to reorder your instructions to hide the latency. The CPU can read up to 3 instructions per cycle, and a lot of operations have several cycles latency. (Division and square root in particular are horrible). You have to reorder your instructions so that the instructions aren't dependant on the previous ones (especially if the previous ones had high latency). And branches are an entire research topic on their own. You want to avoid control hazards that stall the pipeline, and again, the order of instructions plays a huge role here as well.
So basically, don't bother with the ASM version. It's not faster, and doesn't even have the potential to be faster, but it takes *a lot* more work.

The C++ version is more interesting. Not sure why that is slower (Although the type conversions as you mentioned might play a role. That, or the compiler just isn't as good at optimizing this particular program.

[Edited by - Spoonbender on May 18, 2006 8:50:29 PM]

##### Share on other sites
Spoonbender    1258
Quote:
Original post by Jan Wassenberg
Quote:
 A well written C# compiled with a good compiler will generate *the exact* same ASM code as the best ASM programmer will.

*tired laugh*
Ah, an invocation of the fabled "any (good|modern) compiler". I give you this quote: "In theory, there is no difference between theory and practice. But, in practice, there is.".

True. But in practice, a C# compiler will generate much better code than *most* ASM programmers. I was just trying to say that there isn't some native, unavoidable overhead when programming in high level languages. It depends on the compilers ability to optimize. I'm well aware there are no compilers that are able to generate optimal code for everything (or anything, probably).
but that doesn't make claims that "ASM is just faster" any more true.

##### Share on other sites
raccoonone    158
Quote:
Original post by Jan Wassenberg
Quote:
 A well written C# compiled with a good compiler will generate *the exact* same ASM code as the best ASM programmer will.

*tired laugh*
Ah, an invocation of the fabled "any (good|modern) compiler". I give you this quote: "In theory, there is no difference between theory and practice. But, in practice, there is.".

As to the asm code: there is considerable room for improvement. On the non-algorithmic level, probably the biggest issue is branches. You have some questionable constructs:

jnz Next2// so continuing checking for primality
jmp CheckDone
> use jz instead for smaller code size and better static prediction; your code is only necessary if Next2 is out of range of a short jump.

ja Next
inc PrimesFound
jmp CheckDone
> same issue. try to organize code in a straight line, but at least this branch is well-predicted.

Also:

OR edx, edx
> prefer TEST instead for less pipeline dependencies.

loop Check
> as a general rule, never use LOOP or other CISC-style instructions. dec/jnz is much faster.

Thanks! Exactly the kind of help I was looking for. I had no idea dec&jnz was faster than loop, doesn't loop do exactly the same thing but in one instruction?

##### Share on other sites
sjelkjd    171
Quote:
 Original post by Procyon LotorThanks! Exactly the kind of help I was looking for. I had no idea dec&jnz was faster than loop, doesn't loop do exactly the same thing but in one instruction?

Welcome to the x86 ISA, where different instructions have different latencies and many will compile to multiple micro-code instructions.

##### Share on other sites
Dmytry    1151
BTW, if you actually print all primes, it will be IO limited.
edit: as about assembler, there is certain overhead in use of C++ or C# in cases when compiler can't optimize code well (which is common), but this is not going to happen with such algorithm(even though it is backwards), especially that most of time is probably spent doing division anyway.
As about C# using doubles, did you check you're getting same number of primes ?
(Also, doubles often works faster.)

##### Share on other sites
Rockoon1    104
First, thats one great quote given by Jan Wassenberg:

"In theory, there is no difference between theory and practice. But, in practice, there is."

The SSE sqrt instruction is faster only because its a poor approximation and as such a compiler will (should) not be emitting it without being told explicitely to do so. We are talking about a severe difference in accuracy. The instruction is meant for cases where approximations are reasonable (such as normalizing a vector to a length "near" 1.0)

Scaler SSE is typically slower mainly because the instructions are so damn big relative to FPU code. Its not uncommon for a scaler SSE version of a routine to be twice as large (in bytes) as an FPU version, even though scaler SSE code doesnt require any stack management while FPU code does. There is a lot of pressure on the instruction prefetch and decode logic of todays processors when they execute the fastest SSE instructions. One of the cases where scaler SSE code is usualy prefered is when the FPU is already in MMX mode and switching back and forth will be too expensive. The other (obviously) is when you arent using scalers, but instead are performing SIMD work.

ASM optimisations are still fairly simple because processors are still fairly simple. You just need to know about it. Lack of knowledge will obviously prevent you from writing efficient ASM. Knowledge is power. The amount of knowledge needed wont even fill a smaller than average sized book. Not even close. Most of it is common sense based on architecture understanding, rather than special case memorization. It is important to understand/memorize which instructions have been sacrificed for the sake of the efficiency of others (such as: loop, xlat, and so on) but quite honestly, the list of these special "memorization required" cases is quite small.

Floating point division doesnt give a remainder in ANY language discussed here.

No... a "well written C# compiled with a good compiler" will NOT produce the exact same code as the best asm programmer unless by "good compiler" you mean the magical ideal one that doesnt actualy exist.

Other notes:

That hand written ASM code is fairly bad but I guess we all agree on that now.

Compilers are very very good these days... especialy the latest .NET JIT... and it still has lots of room to mature... we should all be very excited about that.

If you program in ASM with an HLL mindset then you are not going to make any big strides verses the .NET JIT although you can certainly make small gains. Keep in mind that any strides you make might not apply to the "other" processor (Intel vs AMD)

The folks who are fluent in optimisation understand WHY you should drop down to ASM. Its for ALGORITHMIC changes that simply CANNOT be accomplished in an HLL. Thats right, HLL's do not offer operations with the same functionality as x86 assembler instructions and as such, some instruction streams are all but IMPOSSIBLE to generate via any HLL that doesnt have inline assembler. No matter how good the compiler is and no matter how craftily you arrange your code, you cannot coerce all sequences of well optimised assembler sequences out of any traditional HLL.

You don't have to take my word for it..

##### Share on other sites
Quote:
 So basically, don't bother with the ASM version. It's not faster, and doesn't even have the potential to be faster, but it takes *a lot* more work.

hm, I read this and think: argh! But then you say:
Quote:
 True. But in practice, a C# compiler will generate much better code than *most* ASM programmers. [..] I'm well aware there are no compilers that are able to generate optimal code for everything (or anything, probably).

which is more like it :)

Quote:
 Thanks! Exactly the kind of help I was looking for. I had no idea dec&jnz was faster than loop, doesn't loop do exactly the same thing but in one instruction?

Glad to. In order to really do well though, you need a good understanding of the microarchitecture, which cannot just be passed on as hints.
About LOOP vs. DEC/JNZ: the former is implemented via microcode (small register-transfer "programs" in the CPU itself, not actual hardware in the normal sense), which is much slower. This is slower to decode and even execute, so definitely avoid all such instructions.

##### Share on other sites
raccoonone    158
Wow, there's a big difference between LOOP and DEC/JNZ. Changing that one instruction gave a 5% increase in speed. I cleaned up some of the other ASM also, and it's not about 7% faster than the pure C++ version, it's still a good 10% behind C# but it's closer.

Thanks for the help.

// asm primes.cpp : Defines the entry point for the console application.//#include "stdafx.h"using std::cout;using std::cin;using std::endl;int _tmain(int argc, _TCHAR* argv[]){	int x, PrimesFound = 0;    DWORD start, end;	cout << "Assembly with C++ wrapper" << endl;    cout << "Find primes up to 'x'. Please enter x:";    cin >> x;    start = GetTickCount();	int limit, temp;	_asm 	{		pusha					//Save registers		mov	esi, 1				//Start checking numbers from 1		mov	edi, x				//Loop until X is reached//Check if this number is one, two, or threeForloop:cmp		esi, 3		jbe		Prime		//Check if divisible by two		test	esi, 1						//If ESI is odd it's not divisible by 2		jz		CheckDone					// so continuing checking for primality		mov		temp, esi		fild	temp						//Convert		fsqrt								// to square		fistp	limit						//  root		mov		ebx, 3						//Set EBX to 3		mov		ecx, limit					//Set up the loop counter		shr		ecx, 1						//  devide by 2 since we'll be incrementing by 2Check:	mov		eax, esi					//Restore test number		xor		edx, edx					// and clear remainder		div		ebx							//Divide and		test	edx, edx					// test for		jz		CheckDone					//  zero		inc		ebx							//increment divisor		inc		ebx							// ""		dec		ecx		jnz		Check						//Continue until the square root is reached		//Number is primePrime:	inc		PrimesFoundCheckDone: inc	esi							//Increment ESI so the next number will be checked		dec		edi		jnz		Forloop							// for primality		popa									//Restore registers	}    end = GetTickCount();    cout << "Found " << PrimesFound << " primes in " << end - start;    while(!_kbhit());	return 0;}

##### Share on other sites
Guest Anonymous Poster
I'm sorry that Spoonfeeder considers it necessary to be impolite rather than helpful, so if you are looking for more polite and also more competent support concerning performance improvements of your assembly program, you are invited over to the forum at http://www.asmcommunity.net/board/ where people will happily disprove Spoonfeeder's point about compilers being able to outperform humans ;-)
If you have a 3D graphics card, we can even provide a program that runs on your GPU :-)

Regarding the compiler vs. human debate, make sure to also check out: http://webster.cs.ucr.edu/Articles/GreatDebate/index.html

##### Share on other sites
PRS102076    122
Is the C++ version of your program even using floating point operations at all? If not, you are putting your ASM program at a disadvantage.
Also, instead of repeatedly dumping and loading an integer into the FPU, and relying on the FPU to convert to and from integer, why not load a 1.0 outside of the main loop, and add that value to your working value each time?
You may alo find that your pusha and popa instructions would be better replaced by a series of specific push and pop instructions.
You can also replace your two INC EBX instructions with an ADD EBX,2.
Although a compiler cant outperform well written ASM code, if the compiler has itself been written by a good ASM programmer, it will often produce better code than a beginner assembler programmer.