Saturday, August 31, 2019
Human Services Practice Framework
SWK141A MODULE THREE LEARNING ACTIVITY DUE 12/04/13 think about the following three broad practice contexts 1. Remote areas health policy at the national level 1. The practice context is at the macro practice level 2. The practice method in this context would be Social policy 3. The Target population includes people living in remote locations. 4. The practice approach chosen is the radical, structural and critical approach due to the focus of social action being on the system, and the outcomes on broad social change at a structural level.Chenoweth & McAuliffe ( 2008) state that the radical and structural approaches align with the social model of disability barriers create disability through social and environmental issues. therefore, change is made possible through policy and legislation affecting the whole of the remote regions. 5. Five ways further knowledge could be generated include : 1) Procedural knowledge: finding relevant legislation and policy, and promoting and engaging in actions aligned with current requirements. ) Empirical data: Collection of data from hospitals and other healthcare clinics throughout the regions. 3) Theoretical knowledge. relating to the policy outcomes 4) Practice wisdom: applied from knowledge acquired from previous experience. 5) Professional knowledge : Knowledge stemming from theoretical practice guidelines. 2. Individual counselling for gambling addiction. 1. The practice context is at the micro practice level 2. The practice method in this context would be Direct practice with individuals 3.The target population is individuals with gambling addictions. 4. A practice approach using Cognitive Behavioural Therapy may be beneficial because the target of therapy is on thinking and behavior change. It is believed that thoughts create emotions which drive behaviour, so with the focus on changing the thought process, emotional and behavioural changes can result (Gerald and Gerald, 2009). 5. Five different ways of generating knowle dge in this practice context are: 1) Practice wisdom including the use of previous systemic reflection. ) Personal reflection on how each session is progressing. 3) Empirical research from research in gambling and addictions, data and other resource information, . 4) Observation: from other practitioners. 5) Theoretical knowledge. 3. Community development to strengthen social networks in Katherine, NT. 1. The practice context is at the mezzo practice level 2. The practice method in this context would be community work 3. The target population is the people living within the Katherine, NT region. 4.A practice approach is systems and ecological perspectives because this approach is from the perspective of people interacting with different parts of their environment making it applicable for developing community development solutions. As well focus can be on improving systems within the community because this approach looks at the various systems and how they relate to each other (Cheno weth & McAuliffe. 2008). 5. Knowledge can be generated via: 1) Theoretical knowledge: theories previously shown to have positive outcomes for community development. ) Empirical knowledge: derived from statistical data on what areas are in greater need for development as well as numerous other areas of information required. 3) Procedural Knowledge: policy and legislation information is crucial to the projects outcomes in a broader context. 4) Professional knowledge: 5) Practice wisdom. REFERENCES Chenoweth, L. & McAuliffe, D. (2008). The Road to Social Work & Human Service Practice. South Melbourne, VIC: Cengage Learning. Gerald, D. & Gerald, K. (2009). Basic Personal Counselling. French Forrest, NSW: Pearson Education Australia.
Friday, August 30, 2019
Blacks in the Military
Behind the American dream lies a series of rebels and insurrections on the part of black Americans in order to mark their presence equal to that of the white citizens of the country. Just like the rise of a black man in the society did not happen over night, his status and entrance into the military services also took decades to create a non-segregated military of the contemporary America.The participation of blacks in the U. S. military is a path with its commencement right after the exemption of prohibitive years when the U. S. army permitted the black men to serve the military as cooks and stewards. In the wake of centuries, these African Americans achieved their current status as equal members of the unified U. S. army. This paper succinctly recounts the history of blacksââ¬â¢ entrance into the military and their gradual rise of status over the period of time. The paper also elucidates the importance of the blacks for the U. S. during the times of different wars and the impact of such military activities on the black men in the armed forces of America today. Introduction:ââ¬Å"We must tell stories of black successes to every child in our country because we need heroes. We need them as much as we need our dreams, and black Americans have always provided both_ George H. W. Bush (Rosenthal: 1991). â⬠In the contemporary world, the word ââ¬Ëblackââ¬â¢ refers to a multifaceted concept. Generally the term signifies the people with dark skin involving the human population from Africa, Oceania and Southeast Asia etc. In a more peculiar sense, the word refers to a black-white segregation with its origins profoundly rooted in the American history.More formally, the term Afro-Americans is also employed for the people who had been brought to the U. S. as slaves and had been allocated to different colonies within the country. Although initially allocated as the servants of whites, the blacks gained power with the passage of time resulting in an insurrecti on against the whites due to the inhuman attitude towards them. Once prohibited to cross the premises of educational institutes or dine in the whitesââ¬â¢ restaurants, blacks of the contemporary U. S.society not only enjoy equal rights but have proved to be a significant contribution to the country in every walk of life and form one of the chief minorities of America. According to the statistics of 2006 by U. S. Census Beareu about 13. 1 percent of total U. S. population comprises of this minority with a numeric figure around 39,151,870. Today, to more than any area of national strength, these black men and women provide a tenacious contribution to the military of the United States. History of Blacksââ¬â¢ Entrance in the Military: ââ¬Å"Although African Americans have participated in every major U.S. war, the battle for integration and for recognition of the accomplishments of black soldiers has been a slow process (Haney: 2007). â⬠Since the arrival of blacks, no war ha ving U. S. as a participant went without the presence of blacks in the countryââ¬â¢s military. During the time of French and Indian wars in the 18th century, the American army heavily depended on black people working as labourers, scouts and drivers etc. Even during the time of World War I, about 404,348 black men and women worked in the Services of Supply-in quartermaster, stevedore, and pioneer infantry units (Lee: 1966, p.5). As a result of their active contribution, the United Press reported that the ââ¬ËAmerican Negro troops proved their value as fightersââ¬â¢ (Lee: 1966, p. 6). though appreciated in printed media, the reality possessed extreme racism running between the blacks and whites. After the commencement of the Second World War, the number of blacks enlisted to the military services increased from 3,640 men on 31 August 1939 to 97,725 on 30 November 1941. the following years marked a further increase of black enlistees (Lee: 1966, p. 88). Revolutionary War:Acco rding to the statistics provided by Albrecht and Davis based on U. S. Census Bureau, U. S. Army and U. S. Department of Defence, the eighteenth century holds the history of the Revolutionary War that marked a presence of 5000 black soldiers in the continental army and far more with the British forces as a result of Lord Dunmoreââ¬â¢s proclamation in November 1775 promising the freedom of negroes if they support the British. As a result more and more African Americans joined forces against the Patriots since freedom was something they cherished most.So, this war was unique in a sense that blacks served both the continental army and the British colonizers as a part of their military to be used against Americans however the majority of black men and women served the British in road building and other such meagre tasks since they were promised emancipation from years of slavery (PBS). Civil War: Since the year 1861, Civil war has never lost its debate for one reason that its undercur rents still flow in the roots of modern American society. Owing to the great impact of war between whites and blacks, Higham believes thatââ¬Å"No other subject in U. S. history, perhaps no other subject in the history of the world, has elicited the tremendous outpouring of writing that has been lavished on the American Civil War (1996). â⬠Although the blacks served in the Revolutionary War, it was till 1792 that the federal law of the United States prohibited the entrance of blacks as arms bearing soldiers. As a consequence of this law, the aspiring blacks raised the issue in Boston requesting the government to bring alternation in the rule. Resulting from the proclamation of emancipation made by Gen.John C. Fremont in Missouri and Gen. David Hunter in South Carolina, an increasing number of slaves were emancipated on one hand when on the other hand the whitesââ¬â¢ spirit of voluntary services in military declined. In such a scenario, the need of military personnel in Uni on army was overwhelming thereby making the Government reconsider the ban on blacks. This led to the exemption of ban resulting in gradual recruitment of black volunteers to serve in the army. Formally, it was in the form of Union Army that emerged as a result of acts passed by the Congress in 1862.According to the Second Confiscation and Militia Act, all the slaves with their masters serving in the Confederate Army were freed. In about 2 days, slavery was abolished in all the states of the country. Seeing the aggrandizing number of black men willing to join military the government established a separate Bureau of Colored Troops by 1863. The active participation of blacks in U. S. not only marked a significant chapter of history but also left an impact on literature as the influence can be witnessed in the works of Rudyard Kipling and Kate Chopin.Similarly, movies like ââ¬ËGloryââ¬â¢ are constant reminders of blacksââ¬â¢ military role in war times. The U. S. Coast guard bei ng one of the smallest yet effective of the seven uniformed services and military branches of t he U. S with a purpose of patrolling the maritime region also marked an informal entrance of blacks in about 1831 when Captain W. W. Polk, USRCS, commanding the Revenue cutter Florida requested to the Treasury Secretary Samuel D. Ingham to employ his black slave of 21 years on board.After a month of permission, the free blacks were employed as stewards and cooks. The year 1887 marked a heyday for the African Americans military status in the coast guard when Captain Michael A. Healy was commissioned as the commander of the cutter Bear till 1895 (U. S. Coast Guard). Korean War By 1930s the prejudices of whites against blacks started to debilitate. It was in 1937 that the General Assembly of the Presbyterian Church, U. S. A passed a resolution which said, ââ¬Å"We accept completely the ideal of the brotherhood of all races, as all are the children of God.We therefore call upon Christians ev erywhere to practice mutual good-will and cooperation among all racial groups, to eliminate every form of discrimination, and to work actively for the recognition of civil and religious rights of all minority groups(Sternsher: 1969. p. 105). â⬠Although a part of military comprising of nearly one million soldiers, the blacks were still considered unfit for military services by the white military men till 1941 when black leaders proposed a constitution of all-black combat units on experimental basis.The outstanding performance of these black units led to their participation on permanent basis thereby disentangling the military from the shackles of prejudices against the minority. In the words of Retired U. S. Army Colonel Bill De Shields, ââ¬Å"The symbol of black participation at that time was ââ¬Ëthe Double V'. in other words, ââ¬ËDouble V' meant two victories: victory against the enemy abroad, and victory against the enemy at home. The enemy at home of course being rac ism (VOA: 2005). â⬠By the late 1950s that marked the end of Korean War, the black units were kept separate.Although some blacks worked in white units too, their presence was only in the capacity of lower staff members. Vietnam War: The era of Vietnam War was the time when U. S. Army had fully integrated with whites and blacks serving in the same combat units and absence of racism. The blacks by this time had appraisal in their ranks and served even as generals (VOA: 2005). Of all the races participating in the Vietnam War, blacks are often considered to have suffered the most in terms of the casualty rate. Comprising of 11 percent of the total participating population, blacks served the U.S. in Vietnam in disproportionate number comprising of about 20 percent of early combat deaths. Later the proportion of casualties declined to about 12. 5 percent (Albrecht and Davis). The figure points out the increasing role of blacks in the military. There lie several reasons behind the gr eater black demise in comparison with other races. Firstly, as the fight between South and North escalated, the U. S. needed more soldiers because of the heavy rate of casualty at the front thereby resulting conscription of people for military services.According to the studies of Defence department of Sam Houston University, a considerable number of blacks entered the U. S. military in this way that formed 16 percent of its total population. Secondly, it is often reckoned that the high casualty rate was not just because of increasing number but partly due to the higher morale and willingness of blacks to offer their voluntary services causing their casualty rate supersede other races in terms of their participating population. It was the consequence of extraordinary morale of African American military men that about 20 medals of bravery were awarded to these black soldiers.Persian Gulf War: Continued for a time span of almost a year from 1990 to 1991, the statistics of Persian Gulf War as reported by the U. S. Defence Department suggest the presence of black men and women to have made up to 25percent of the American troops when their total share in the U. S. population was about 12percent. This according to Pentagon officials was a result of their willingness rather than their conscription into the military services. The era of Persian Gulf War marked an augmentation of blacks in the military when their joining superseded the whites by three times.This according to many analysts was a way for blacks to improved quality of life. According to Martin Binkin a military analyst, the percentage of black young men and women serving in military forces by 1991 was 30-33percent in comparison with that of 16 to 17percent for the white youngsters (Wilkerson: 1991). It was such participation and morale of black Americans in the Persian Gulf War that President H. W. Bush exalted their chivalry with the following words, ââ¬Å"For two centuries, black soldiers have establish ed a record of pride in the face of incredible obstacles (Rosenthal: 1991). â⬠Iraq War:In the words of Gregory Black, founder of web portal of black military, ââ¬Å"The first reason for the drop is the black communityââ¬â¢s overall objection to the war (Foley: 2007). â⬠The growing unpopularity of Bush Administration after the invasion in Iraq and continual spending on the war to cause a deficit in the year 2008 is not only confined to the international community but has greatly affected the numeric strength of the U. S. military. Although, the U. S. army has suffered an enormous decline in terms of the number of people applying for the military services, the fall of military participation is highest for the black community.According to the analysis of Williams and Baron in The Boston Globe, the blacksââ¬â¢ percentage in the U. S. military has declined by 58percent since 11 September 2000 but Iraq War seemed to have greatly catalyzed the process as suggested by oth er military analysts, Pentagon surveys, and interviews with young African-Americans. The analysis of James Foley made in the fall of the last year suggests that the whites who formed 61 percent of the recruits in the year 2000 now make up around 67 percent of the U. S. military force (2007).Michael O'Hanlon, a military analyst for the liberal-leaning Brookings Institution, witnesses this trend to be a loss for the American army since he believes that the ââ¬ËAfrican-Americans have been such a key part of the modern military (whose decline) portends the possibility of a longer-term loss of interest. It can be tough to get it backââ¬â¢ (Williams and Baron: 2007). For the blacks, the threat of Iraq War is double edged. It does not only mean a loss of a few lives but poses a threat of the loss of a whole generation since the blacks are in minority as approved by the fact that 3,540 U. S.troops have died in Iraqââ¬â¢s bloodshed till the last year (Baldor: 2007). Also, the discou raging attitude from the military has dissuaded many blacks. Lieutenant Colonel Irving Smith, a sociologist at the US Military Academy at West Point, the basic goal behind excessive blacksââ¬â¢ participation was to reach equal status of citizenship and leadership roles in the mainstream but ââ¬ËThe fewer African-Americans that enlist, the fewer African-Americans there are that can tell their stories in the future. The fewer that get commissioned as officers, the smaller the leadership pool will be in the futureââ¬â¢ (Williams and Baron: 2007).At the top of everything James Foley in his article ââ¬ËBlack interest in military service decreasingââ¬â¢ also believes that the decline is also because the key influencers in the black community are against the war. As a result of their ascendance on their followers, more and more blacks are being dissuaded from their participation in the U. S. military (2007). It was the foresight of blacks regarding their decline as a result of Iraq invasion that in the year 2003, different polls investigating the attitude of people towards Iraq invasion suggested that the blacks opposed Iraq War much more than the whites.Pew Research Centreââ¬â¢s poll suggested the support of 44 percent of African-Americans in comparison with 73percent whites, According to the Atlanta Journal-Constitution/Zogby America poll, only 23percent blacks supported the war whereas according to the findings of the Joint Centre for Political and Economic Studies, the percentage of these black votaries declined to 19 percent (Jackson: 2003). The reason behind such opposition is that the blacks make up far more percentage in the U. S. military as compared to their share in the countryââ¬â¢s population.Conclusion: Due to a record of excessive invasions and interventions of the U. S. in the past few decades, what stays most wounded is the military wing of the country. Since the operations of the U. S. military in Afghanistan and Iraq, the count ryââ¬â¢s army has lost its charm for many U. S. citizens to a considerable deal. Of these Americans, the reaction is most severe from the black community as proved by the fact that the participation level of blacks in the U. S army has enormously declined over the last few years.With a history of intrepid contribution as warriors and soldiers of the Spanish American War in 1898, the Korean war in early 1950s, the Vietnam war of 1960s and 1970s and the Persian Gulf war of early 1990s, the blacks of the contemporary U. S. seem less inclined to the military services thereby causing a serious threat to the over all strength of the U. S. With their contribution in all the capacities of armed forces, the black military men of today play a key role for the unified army at one hand whereas their very presence poses a risk of losing entire generations of African Americans on the other hand.Keeping in mind the nature of risks for black Americans, it is likely that the recent trend of decli ning participation would continue for the years to come thereby debilitating the military strength of the worldââ¬â¢s super power. References African Americans in the United States Coast Guard. U. S. Coast Guard. Jan. 1999. Retrieved on 24 Feb. 2008 < http://www. uscg. mil/hq/g-cp/history/h_Africanamericans. html> African-American Soldiers in World War II Helped Pave Way for Integration of US Military. Voice of America. 10 May 2005.Retrieved on 24 Feb. 2008 Baldor, Lolita C. Number of Blacks Joining Military Down. Washington Post. 25 Jun. 2007. Retrieved on 25 Feb. 2008 Black Americans in Defense of Our Nation, Sam Houston State University, Department of Defence, 1985, retrieved on 24 Feb. 2008 Foley, James. Black interest in military service decreasing.Medill Reports Washington. 29 Nov. 2007. Retrieved on 25 Feb. 2008 Haney, Elissa. Info Please. Blacks in the Military: The fight for recognition of African-American soldiers. 2007. Retrieved on 24 Feb. 2008 < http://www. infop lease. com/spot/bhmmilitary1. html> Higham, Robin and Woodworth, Steven E. The American Civil War: A Handbook of Literature and Research. Westport, CT: Greenwood Press, 1996. Jackson, Derrick Z. Blacks Have Good Cause to Oppose War in Iraq.Common Dreams News Centre. 26 Feb. 2003. Retrieved on 25 Feb. 2008 Lee, Ulysses. The Employment of Negro Troops. Washington D. C. : U. S . Government Printing Office. 1966. Rosenthal, Andrew. War in the Gulf: The Black G. I. ; Blacks Are Hailed by Bush for their role in Military. The New York Times. 26 Feb. 1991. Retrieved on 25 Feb. 2008 Sternsher, Bernard.The Negro in Depression and War: Prelude to Revolution, 1930- 1945. Chicago: Quadrangle Books, 1969. The Revolutionary War. PBS. Retrieved on 24 Feb. 2008 Wilkerson, Isabel. War in the Gulf: The Troops; Blacks Wary of Their Big Role as Troops. The New York Times. 25 Jan. 1991. Retrieved on 25 Feb. 2008 Williams, Joseph and Baron, Kevin. Military sees big decline in black enlistees. The
Sage 50 Accounting Software Tutorial
Sage Tutorial Release 5. 3 The Sage Development Team September 10, 2012 CONTENTS 1 Introduction 1. 1 Installation 1. 2 Ways to Use Sage . . 1. 3 Longterm Goals for Sage . . 3 4 4 4 7 7 9 10 13 18 21 24 26 29 33 38 39 41 51 51 53 54 54 55 56 57 58 60 61 62 65 65 66 67 68 2 A Guided Tour 2. 1 Assignment, Equality, and Arithmetic 2. Getting Help . 2. 3 Functions, Indentation, and Counting 2. 4 Basic Algebra and Calculus . . 2. 5 Plotting . 2. 6 Some Common Issues with Functions 2. 7 Basic Rings . . 2. 8 Linear Algebra 2. 9 Polynomials . 2. 10 Parents, Conversion and Coercion . . 2. 11 Finite Groups, Abelian Groups . 2. 12 Number Theory . . 2. 13 Some More Advanced Mathematics 3 The Interactive Shell 3. 1 Your Sage Session . . 3. 2 Logging Input and Output . 3. 3 Paste Ignores Prompts 3. 4 Timing Commands . . 3. 5 Other IPython tricks . 3. 6 Errors and Exceptions 3. 7 Reverse Search and Tab Completion . . 3. 8 Integrated Help System . 3. 9 Saving and Loading Individual Objects 3. 10 Savi ng and Loading Complete Sessions 3. 11 The Notebook Interface . . 4 Interfaces 4. 1 GP/PARI 4. 2 GAP . . 4. 3 Singular . 4. 4 Maxima i 5 Sage, LaTeX and Friends 5. 1 Overview . . 5. 2 Basic Use . . 5. 3 Customizing LaTeX Generation . . 5. 4 Customizing LaTeX Processing . . 5. 5 An Example: Combinatorial Graphs with tkz-graph . 5. 6 A Fully Capable TeX Installation . 5. 7 External Programs . 71 71 72 73 75 76 77 77 79 79 80 81 81 82 84 85 86 86 88 91 93 93 94 95 97 97 99 101 103 105 6 Programming 6. 1 Loading and Attaching Sage ? les 6. 2 Creating Compiled Code . 6. 3 Standalone Python/Sage Scripts . 6. 4 Data Types 6. 5 Lists, Tuples, and Sequences 6. 6 Dictionaries 6. 7 Sets . 6. 8 Iterators . . 6. 9 Loops, Functions, Control Statements, and Comparisons 6. 10 Pro? ling . 7 Using SageTeX 8 . . Afterword 8. 1 Why Python? . . 8. I would like to contribute somehow. How can I? . 8. 3 How do I reference Sage? . 9 Appendix 9. 1 Arithmetical binary operator precedence . . 10 Bibliography 1 1 Indices and tables Bibliography Index ii Sage Tutorial, Release 5. 3 Sage is free, open-source math software that supports research and teaching in algebra, geometry, number theory, cryptography, numerical computation, and related areas. Both the Sage development model and the technology in Sage itself are distinguished by an extremely strong emphasis on openness, community, cooperation, and collaboration: we are building the car, not reinventing the wheel. The overall goal of Sage is to create a viable, free, open-source alternative to Maple, Mathematica, Magma, and MATLAB. This tutorial is the best way to become familiar with Sage in only a few hours. You can read it in HTML or PDF versions, or from the Sage notebook (click Help, then click Tutorial to interactively work through the tutorial from within Sage). This work is licensed under a Creative Commons Attribution-Share Alike 3. 0 License. CONTENTS 1 Sage Tutorial, Release 5. 3 2 CONTENTS CHAPTER ONE INTRODUCTION This tutorial should take at most 3-4 hours to fully work through. You can read it in HTML or PDF versions, or from the Sage notebook click Help, then click Tutorial to interactively work through the tutorial from within Sage. Though much of Sage is implemented using Python, no Python background is needed to read this tutorial. You will want to learn Python (a very fun language! ) at some point, and there are many excellent free resources for doing so including [PyT] and [Dive]. If you just want to quickly try out Sage, this tutorial is the place to start. For example: sage: 2 + 2 4 sage: factor(-2007) -1 * 3^2 * 223 sage: A = matrix(4,4, range(16)); A [ 0 1 2 3] [ 4 5 6 7] [ 8 9 10 11] [12 13 14 15] sage: factor(A. charpoly()) x^2 * (x^2 ââ¬â 30*x ââ¬â 80) sage: m = matrix(ZZ,2, range(4)) sage: m[0,0] = m[0,0] ââ¬â 3 sage: m [-3 1] [ 2 3] sage: E = EllipticCurve([1,2,3,4,5]); sage: E Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Rational Field sage: E. anlist(10) [0, 1, 1, 0, -1, -3, 0, -1, -3, -3, -3] sage: E. ank() 1 sage: k = 1/(sqrt(3)*I + 3/4 + sqrt(73)*5/9); k 1/(I*sqrt(3) + 5/9*sqrt(73) + 3/4) sage: N(k) 0. 165495678130644 ââ¬â 0. 0521492082074256*I sage: N(k,30) # 30 ââ¬Å"bitsâ⬠0. 16549568 ââ¬â 0. 052149208*I sage: latex(k) frac{1}{i , sqrt{3} + frac{5}{9} , sqrt{73} + frac{3}{4}} 3 Sage Tutorial, Release 5. 3 1. 1 Installation If you do not have Sage installed on a computer and just want to try s ome commands, use online at http://www. sagenb. org. See the Sage Installation Guide in the documentation section of the main Sage webpage [SA] for instructions on installing Sage on your computer. Here we merely make a few comments. 1. The Sage download ? le comes with ââ¬Å"batteries includedâ⬠. In other words, although Sage uses Python, IPython, PARI, GAP, Singular, Maxima, NTL, GMP, and so on, you do not need to install them separately as they are included with the Sage distribution. However, to use certain Sage features, e. g. , Macaulay or KASH, you must install the relevant optional package or at least have the relevant programs installed on your computer already. Macaulay and KASH are Sage packages (for a list of available optional packages, type sage -optional, or browse the ââ¬Å"Downloadâ⬠page on the Sage website). . The pre-compiled binary version of Sage (found on the Sage web site) may be easier and quicker to install than the source code version. Just unpack the ? le and run sage. 3. If youââ¬â¢d like to use the SageTeX package (which allows you to embed the results of Sage computations into a LaTeX ? le), you will need to make SageTeX known to yo ur TeX distribution. To do this, see the section ââ¬Å"Make SageTeX known to TeXâ⬠in the Sage installation guide (this link should take you to a local copy of the installation guide). Itââ¬â¢s quite easy; you just need to set an environment variable or copy a single ? e to a directory that TeX will search. The documentation for using SageTeX is located in $SAGE_ROOT/local/share/texmf/tex/generic/sagetex/, where ââ¬Å"$SAGE_ROOTâ⬠refers to the directory where you installed Sage ââ¬â for example, /opt/sage-4. 2. 1. 1. 2 Ways to Use Sage You can use Sage in several ways. â⬠¢ Notebook graphical interface: see the section on the Notebook in the reference manual and The Notebook Interface below, â⬠¢ Interactive command line: see The Interactive Shell, â⬠¢ Programs: By writing interpreted and compiled programs in Sage (see Loading and Attaching Sage ? es and Creating Compiled Code), and â⬠¢ Scripts: by writing stand-alone Python scripts that use the Sag e library (see Standalone Python/Sage Scripts). 1. 3 Longterm Goals for Sage â⬠¢ Useful: Sageââ¬â¢s intended audience is mathematics students (from high school to graduate school), teachers, and research mathematicians. The aim is to provide software that can be used to explore and experiment with mathematical constructions in algebra, geometry, number theory, calculus, numerical computation, etc. Sage helps make it easier to interactively experiment with mathematical objects. Ef? cient: Be fast. Sage uses highly-optimized mature software like GMP, PARI, GAP, and NTL, and so is very fast at certain operations. â⬠¢ Free and open source: The source code must be freely available and readable, so users can understand what the system is really doing and more easily extend it. Just as mathematicians gain a deeper understanding of a theorem by carefully reading or at least skimming the proof, people who do computations should be able to understand how the calculations work by re ading documented source code. If you use Sage to do computations 4 Chapter 1. Introduction Sage Tutorial, Release 5. 3 in a paper you publish, you can rest assured that your readers will always have free access to Sage and all its source code, and you are even allowed to archive and re-distribute the version of Sage you used. â⬠¢ Easy to compile: Sage should be easy to compile from source for Linux, OS X and Windows users. This provides more ? exibility for users to modify the system. â⬠¢ Cooperation: Provide robust interfaces to most other computer algebra systems, including PARI, GAP, Singular, Maxima, KASH, Magma, Maple, and Mathematica. Sage is meant to unify and extend existing math software. â⬠¢ Well documented: Tutorial, programming guide, reference manual, and how-to, with numerous examples and discussion of background mathematics. â⬠¢ Extensible: Be able to de? ne new data types or derive from built-in types, and use code written in a range of languages. â⬠¢ User friendly: It should be easy to understand what functionality is provided for a given object and to view documentation and source code. Also attain a high level of user support. 1. 3. Longterm Goals for Sage 5 Sage Tutorial, Release 5. 3 6 Chapter 1. Introduction CHAPTER TWO A GUIDED TOUR This section is a guided tour of some of what is available in Sage. For many more examples, see ââ¬Å"Sage Constructionsâ⬠, which is intended to answer the general question ââ¬Å"How do I construct ? â⬠. See also the ââ¬Å"Sage Reference Manualâ⬠, which has thousands more examples. Also note that you can interactively work through this tour in the Sage notebook by clicking the Help link. (If you are viewing the tutorial in the Sage notebook, press shift-enter to evaluate any input cell. You can even edit the input before pressing shift-enter. On some Macs you might have to press shift-return rather than shift-enter. ) 2. 1 Assignment, Equality, and Arithmetic With some minor exceptions, Sage uses the Python programming language, so most introductory books on Python will help you to learn Sage. Sage uses = for assignment. It uses ==, =, < and > for comparison: sage: sage: 5 sage: True sage: False sage: True sage: True a = 5 a 2 == 2 2 == 3 2 < 3 a == 5 Sage provides all of the basic mathematical operations: age: 8 sage: 8 sage: 1 sage: 5/2 sage: 2 sage: True 2**3 2^3 10 % 3 10/4 10//4 # for integer arguments, // returns the integer quotient # # # ** means exponent ^ is a synonym for ** (unlike in Python) for integer arguments, % means mod, i. e. , remainder 4 * (10 // 4) + 10 % 4 == 10 7 Sage Tutorial, Release 5. 3 sage: 3^2*4 + 2%5 38 The computation of an expression like 3^2*4 + 2%5 depends on the order in which the operations are applied; this is speci? ed in the ââ¬Å"operator precedence tableâ⬠in Arithmetical binary operator precedence. Sage also provides many familiar mathematical functions; here are just a few examples: sage: sqrt(3. ) 1. 84390889145858 sage: sin(5. 135) -0. 912021158525540 sage: sin(pi/3) 1/2*sqrt(3) As the last example shows, some mathematical expressions return ââ¬Ëexactââ¬â¢ values, rather than numerical approximations. To get a numerical approximation, use either the function n or the method n (and both of these have a longer name, numerical_approx, and the function N is the same as n)). These take optional arguments prec, which is the requested number of bits of precision, and digits, which is the requested number of decimal digits of precision; the default is 53 bits of precision. sage: exp(2) e^2 sage: n(exp(2)) 7. 8905609893065 sage: sqrt(pi). numerical_approx() 1. 77245385090552 sage: sin(10). n(digits=5) -0. 54402 sage: N(sin(10),digits=10) -0. 5440211109 sage: numerical_approx(pi, prec=200) 3. 14 15926535897932384626433832795028841971693993751058209749 Python is dynamically typed, so the value referred to by each variable has a type associated with it, but a given variable may hold values of any Python type within a given scope: sage: sage: The C programming language, which is statically typed, is much different; a variable declared to hold an int can only hold an int in its scope. A potential source of confusion in Python is that an integer literal that begins with a zero is treated as an octal number, i. e. , a number in base 8. sage: 9 sage: 9 sage: sage: ââ¬â¢11ââ¬â¢ 011 8 + 1 n = 011 n. str(8) # string representation of n in base 8 8 Chapter 2. A Guided Tour Sage Tutorial, Release 5. 3 This is consistent with the C programming language. 2. 2 Getting Help Sage has extensive built-in documentation, accessible by typing the name of a function or a constant (for example), followed by a question mark: sage: tan? Type: Definition: Docstring: tan( [noargspec] ) The tangent function EXAMPLES: sage: tan(pi) 0 sage: tan(3. 1415) -0. 0000926535900581913 sage: tan(3. 1415/4) 0. 999953674278156 sage: tan(pi/4) 1 sage: tan(1/2) tan(1/2) sage: RR(tan(1/2)) 0. 546302489843790 sage: log2? Type: Definition: log2( [noargspec] ) Docstring: The natural logarithm of the real number 2. EXAMPLES: sage: log2 log2 sage: float(log2) 0. 69314718055994529 sage: RR(log2) 0. 693147180559945 sage: R = RealField(200); R Real Field with 200 bits of precision sage: R(log2) 0. 9314718055994530941723212145817656807550013436025525412068 sage: l = (1-log2)/(1+log2); l (1 ââ¬â log(2))/(log(2) + 1) sage: R(l) 0. 18123221829928249948761381864650311423330609774776013488056 sage: maxima(log2) log(2) sage: maxima(log2). float() . 6931471805599453 sage: gp(log2) 0. 6931471805599453094172321215 # 32-bit 0. 69314718055994530941723212145817656807 # 64-bit sage: sudoku? 2. 2. Getting Help 9 Sage Tutorial, Release 5. 3 File: Type: D efinition: Docstring: sage/local/lib/python2. 5/site-packages/sage/games/sudoku. py sudoku(A) Solve the 9Ãâ"9 Sudoku puzzle defined by the matrix A. EXAMPLE: sage: A = matrix(ZZ,9,[5,0,0, 0,8,0, 0,4,9, 0,0,0, 5,0,0, 0,3,0, 0,6,7, 3,0,0, 0,0,1, 1,5,0, 0,0,0, 0,0,0, 0,0,0, 2,0,8, 0,0,0, 0,0,0, 0,0,0, 0,1,8, 7,0,0, 0,0,4, 1,5,0, 0,3,0, 0,0,2, 0,0,0, 4,9,0, 0,5,0, 0,0,3]) sage: A [5 0 0 0 8 0 0 4 9] [0 0 0 5 0 0 0 3 0] [0 6 7 3 0 0 0 0 1] [1 5 0 0 0 0 0 0 0] [0 0 0 2 0 8 0 0 0] [0 0 0 0 0 0 0 1 8] [7 0 0 0 0 4 1 5 0] [0 3 0 0 0 2 0 0 0] [4 9 0 0 5 0 0 0 3] sage: sudoku(A) [5 1 3 6 8 7 2 4 9] [8 4 9 5 2 1 6 3 7] [2 6 7 3 4 9 5 8 1] [1 5 8 4 6 3 9 7 2] [9 7 4 2 1 8 3 6 5] [3 2 6 7 9 5 4 1 8] [7 8 2 9 3 4 1 5 6] [6 3 5 1 7 2 8 9 4] [4 9 1 8 5 6 7 2 3] Sage also provides ââ¬ËTab completionââ¬â¢: type the ? rst few letters of a function and then hit the tab key. For example, if you type ta followed by TAB, Sage will print tachyon, tan, tanh, taylor. This provides a good way to ? nd the names of functions and other structures in Sage. 2. 3 Functions, Indentation, and Counting To de? ne a new function in Sage, use the def command and a colon after the list of variable names. For example: sage: def is_even(n): return n%2 == 0 sage: is_even(2) True sage: is_even(3) False Note: Depending on which version of the tutorial you are viewing, you may see three dots n the second line of this example. Do not type them; they are just to emphasize that the code is indented. Whenever this is the case, press [Return/Enter] once at the end of the block to insert a blank line and conclude the function de? nition. You do not specify the types of any of the input arguments. You can specify multiple inputs, each of which may have an optional defaul t value. For example, the function below defaults to divisor=2 if divisor is not speci? ed. 10 Chapter 2. A Guided Tour Sage Tutorial, Release 5. 3 sage: sage: True sage: True sage: False ef is_divisible_by(number, divisor=2): return number%divisor == 0 is_divisible_by(6,2) is_divisible_by(6) is_divisible_by(6, 5) You can also explicitly specify one or either of the inputs when calling the function; if you specify the inputs explicitly, you can give them in any order: sage: is_divisible_by(6, divisor=5) False sage: is_divisible_by(divisor=2, number=6) True In Python, blocks of code are not indicated by curly braces or begin and end blocks as in many other languages. Instead, blocks of code are indicated by indentation, which must match up exactly. For example, the following is a syntax error because the return statement is not indented the same amount as the other lines above it. sage: def even(n): v = [] for i in range(3,n): if i % 2 == 0: v. append(i) return v Syntax Error: return v If you ? x the indentation, the function works: sage: def even(n): v = [] for i in range(3,n): if i % 2 == 0: v. append(i) return v sage: even(10) [4, 6, 8] Semicolons are not needed at the ends of lines; a line is in most cases ended by a newline. However, you can put multiple statements on one line, separated by semicolons: sage: a = 5; b = a + 3; c = b^2; c 64 If you would like a single line of code to span multiple lines, use a terminating backslash: sage: 2 + 3 5 In Sage, you count by iterating over a range of integers. For example, the ? rst line below is exactly like for(i=0; i x^2 sage: g(3) 9 sage: Dg = g. derivative(); Dg x |ââ¬â> 2*x sage: Dg(3) 6 sage: type(g) sage: plot(g, 0, 2) Note that while g is a callable symbolic expression, g(x) is a related, but different sort of object, which can also be plotted, differentated, etc. , albeit with some issues: see item 5 below for an illustration. sage: x^2 sage: g(x). derivative() plot(g(x), 0, 2) 3. Use a pre-de? ed Sage ââ¬Ëcalculus functionââ¬â¢. These can be plotted, and with a little help, differentiated, and integrated. sage: type(sin) sage: plot(sin, 0, 2) sage: type(sin(x)) sage: plot(sin(x), 0, 2) By itself, sin cannot be differentiated, at least not to produce cos. sage: f = sin sage: f. derivative() Traceback (most recent call last): AttributeError: Using f = sin(x) instead of sin works, but it is probably even better to use f(x) = sin(x) to de? ne a callable symbolic expression. sage: S(x) = sin(x) sage: S. derivative() x |ââ¬â> cos(x) Here are some common problems, with explanations: 4. Accidental evaluation. sage: def h(x): f x 1 to 0. sage: G = DirichletGroup(12) sage: G. list() [Dirichlet character modulo 12 of conductor 1 mapping 7 |ââ¬â> 1, 5 |ââ¬â> 1, Dirichlet character modulo 12 of conductor 4 mapping 7 |ââ¬â> -1, 5 |ââ¬â> 1, Dirichlet character modulo 12 of conductor 3 mapping 7 |ââ¬â> 1, 5 |ââ¬â> -1, Dirichlet character modulo 12 of conductor 12 mapping 7 |ââ¬â> -1, 5 |ââ¬â> -1] sage: G. gens() (Dirichlet character modulo 12 of conductor 4 mapping 7 |ââ¬â> -1, 5 |ââ¬â> 1, Dirichlet character modulo 12 of conductor 3 mapping 7 |ââ¬â> 1, 5 |ââ¬â> -1) sage: len(G) 4 Having created the group, we next create an element and compute with it. age: G = DirichletGroup(21) sage: chi = G. 1; c hi Dirichlet character modulo 21 of conductor 7 mapping 8 |ââ¬â> 1, 10 |ââ¬â> zeta6 sage: chi. values() [0, 1, zeta6 ââ¬â 1, 0, -zeta6, -zeta6 + 1, 0, 0, 1, 0, zeta6, -zeta6, 0, -1, 0, 0, zeta6 ââ¬â 1, zeta6, 0, -zeta6 + 1, -1] sage: chi. conductor() 7 sage: chi. modulus() 21 sage: chi. order() 6 sage: chi(19) -zeta6 + 1 sage: chi(40) -zeta6 + 1 It is also possible to compute the action of the Galois group Gal(Q(? N )/Q) on these characters, as well as the direct product decomposition corresponding to the factorization of the modulus. sage: chi. alois_orbit() [Dirichlet character modulo 21 of conductor 7 mapping 8 |ââ¬â> 1, 10 |ââ¬â> zeta6, 2. 13. Some More Advanced Mathematics 45 Sage Tutorial, Release 5. 3 Dirichlet character modulo 21 of conductor 7 mapping 8 |ââ¬â> 1, 10 |ââ¬â> -zeta6 + 1] sage: go = G. galois_orbits() sage: [len(orbit) for orbit in go] [1, 2, 2, 1, 1, 2, 2, 1] sage: [ Group 6 and Group 6 and ] G. decomposition() of Dirichlet char acters of modulus 3 over Cyclotomic Field of order degree 2, of Dirichlet characters of modulus 7 over Cyclotomic Field of order degree 2 Next, we construct the group of Dirichlet characters mod 20, but with values n Q(i): sage: sage: sage: Group K. = NumberField(x^2+1) G = DirichletGroup(20,K) G of Dirichlet characters of modulus 20 over Number Field in i with defining polynomial x^2 + 1 We next compute several invariants of G: sage: G. gens() (Dirichlet character modulo 20 of conductor 4 mapping 11 |ââ¬â> -1, 17 |ââ¬â> 1, Dirichlet character modulo 20 of conductor 5 mapping 11 |ââ¬â> 1, 17 |ââ¬â> i) sage: G. unit_gens() [11, 17] sage: G. zeta() i sage: G. zeta_order() 4 In this example we create a Dirichlet character with values in a number ? eld. We explicitly specify the choice of root of unity by the third argument to DirichletGroup below. age: x = polygen(QQ, ââ¬â¢xââ¬â¢) sage: K = NumberField(x^4 + 1, ââ¬â¢aââ¬â¢); a = K. 0 sage: b = K. gen(); a == b True sage: K Number Field in a with defining polynomial x^4 + 1 sage: G = DirichletGroup(5, K, a); G Group of Dirichlet characters of modulus 5 over Number Field in a with defining polynomial x^4 + 1 sage: chi = G. 0; chi Dirichlet character modulo 5 of conductor 5 mapping 2 |ââ¬â> a^2 sage: [(chi^i)(2) for i in range(4)] [1, a^2, -1, -a^2] Here NumberField(x^4 + 1, ââ¬â¢aââ¬â¢) tells Sage to use the symbol ââ¬Å"aâ⬠in printing what K is (a Number Field in a with de? ning polynomial x4 + 1). The name ââ¬Å"aâ⬠is undeclared at this point. Once a = K. 0 (or equivalently a = K. gen()) is evaluated, the symbol ââ¬Å"aâ⬠represents a root of the generating polynomial x4 + 1. 46 Chapter 2. A Guided Tour Sage Tutorial, Release 5. 3 2. 13. 4 Modular Forms Sage can do some computations related to modular forms, including dimensions, computing spaces of modular symbols, Hecke operators, and decompositions. There are several functions available for computing dimensions of spaces of modular forms. For example, sage: dimension_cusp_forms(Gamma0(11),2) 1 sage: dimension_cusp_forms(Gamma0(1),12) 1 sage: dimension_cusp_forms(Gamma1(389),2) 6112 Next we illustrate computation of Hecke operators on a space of modular symbols of level 1 and weight 12. sage: M = ModularSymbols(1,12) sage: M. basis() ([X^8*Y^2,(0,0)], [X^9*Y,(0,0)], [X^10,(0,0)]) sage: t2 = M. T(2) sage: t2 Hecke operator T_2 on Modular Symbols space of dimension 3 for Gamma_0(1) of weight 12 with sign 0 over Rational Field sage: t2. matrix() [ -24 0 0] [ 0 -24 0] [4860 0 2049] sage: f = t2. charpoly(ââ¬â¢xââ¬â¢); f x^3 ââ¬â 2001*x^2 ââ¬â 97776*x ââ¬â 1180224 sage: factor(f) (x ââ¬â 2049) * (x + 24)^2 sage: M. T(11). charpoly(ââ¬â¢xââ¬â¢). factor() (x ââ¬â 285311670612) * (x ââ¬â 534612)^2 We can also create spaces for ? 0 (N ) and ? 1 (N ). sage: ModularSymbols(11,2) Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field sage: ModularSymbols(Gamma1(11),2) Modular Symbols space of dimension 11 for Gamma_1(11) of weight 2 with sign 0 and over Rational Field Letââ¬â¢s compute some characteristic polynomials and q-expansions. sage: M = ModularSymbols(Gamma1(11),2) sage: M. T(2). charpoly(ââ¬â¢xââ¬â¢) x^11 ââ¬â 8*x^10 + 20*x^9 + 10*x^8 ââ¬â 145*x^7 + 229*x^6 + 58*x^5 ââ¬â 360*x^4 + 70*x^3 ââ¬â 515*x^2 + 1804*x ââ¬â 1452 sage: M. T(2). charpoly(ââ¬â¢xââ¬â¢). actor() (x ââ¬â 3) * (x + 2)^2 * (x^4 ââ¬â 7*x^3 + 19*x^2 ââ¬â 23*x + 11) * (x^4 ââ¬â 2*x^3 + 4*x^2 + 2*x + 11) sage: S = M. cuspidal_submodule() sage: S. T(2). matrix() [-2 0] [ 0 -2] sage: S. q_expansion_basis(10) [ q ââ¬â 2*q^2 ââ¬â q^3 + 2*q^4 + q^5 + 2*q^6 ââ¬â 2*q^7 ââ¬â 2*q^9 + O(q^10) ] 2. 13. Some More A dvanced Mathematics 47 Sage Tutorial, Release 5. 3 We can even compute spaces of modular symbols with character. sage: G = DirichletGroup(13) sage: e = G. 0^2 sage: M = ModularSymbols(e,2); M Modular Symbols space of dimension 4 and level 13, weight 2, character [zeta6], sign 0, over Cyclotomic Field of order 6 and degree 2 sage: M. T(2). charpoly(ââ¬â¢xââ¬â¢). factor() (x ââ¬â 2*zeta6 ââ¬â 1) * (x ââ¬â zeta6 ââ¬â 2) * (x + zeta6 + 1)^2 sage: S = M. cuspidal_submodule(); S Modular Symbols subspace of dimension 2 of Modular Symbols space of dimension 4 and level 13, weight 2, character [zeta6], sign 0, over Cyclotomic Field of order 6 and degree 2 sage: S. T(2). charpoly(ââ¬â¢xââ¬â¢). factor() (x + zeta6 + 1)^2 sage: S. q_expansion_basis(10) [ q + (-zeta6 ââ¬â 1)*q^2 + (2*zeta6 ââ¬â 2)*q^3 + zeta6*q^4 + (-2*zeta6 + 1)*q^5 + (-2*zeta6 + 4)*q^6 + (2*zeta6 ââ¬â 1)*q^8 ââ¬â zeta6*q^9 + O(q^10) ] Here is another example of how Sage can compute the action of Hecke operators on a space of modular forms. sage: T = ModularForms(Gamma0(11),2) sage: T Modular Forms space of dimension 2 for Congruence Subgroup Gamma0(11) of weight 2 over Rational Field sage: T. degree() 2 sage: T. level() 11 sage: T. group() Congruence Subgroup Gamma0(11) sage: T. dimension() 2 sage: T. cuspidal_subspace() Cuspidal subspace of dimension 1 of Modular Forms space of dimension 2 for Congruence Subgroup Gamma0(11) of weight 2 over Rational Field sage: T. isenstein_subspace() Eisenstein subspace of dimension 1 of Modular Forms space of dimension 2 for Congruence Subgroup Gamma0(11) of weight 2 over Rational Field sage: M = ModularSymbols(11); M Modular Symbols space of dimension 3 for Gamma_0(11) of weight 2 with sign 0 over Rational Field sage: M. weight() 2 sage: M. basis() ((1,0), (1,8), (1,9)) sage: M. sign() 0 Let Tp denote the usual Hecke operators (p prime). How do the Hecke operators T2 , T3 , T5 act on the space of modular symbols? sage: M. T(2). matrix() [ 3 0 -1] [ 0 -2 0] [ 0 0 -2] sage: M. T(3). matrix() [ 4 0 -1] 8 Chapter 2. A Guided Tour Sage Tutorial, Release 5. 3 [ 0 -1 0] [ 0 0 -1] sage: M. T(5). matrix() [ 6 0 -1] [ 0 1 0] [ 0 0 1] 2. 13. Some More Advanced Mathematics 49 Sage Tutorial, Release 5. 3 50 Chapter 2. A Guided Tour CHAPTER THREE THE INTERACTIVE SHELL In most of this tutorial, we assume you start the Sage interpreter using the sage command. This starts a customized version of the IPython shell, and imports many functions and classes, so they are ready to use from the command prompt. Further customization is possible by editing the $SAGE_ROOT/ipythonrc ? le. Upon starting Sage, you get output similar to the following: ââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬â| SAGE Version 3. 1. 1, Release Date: 2008-05-24 | | Type notebook() for the GUI, and license() for information. | ââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬â- sage: To quit Sage either press Ctrl-D or type quit or exit. sage: quit Exiting SAGE (CPU time 0m0. 00s, Wall time 0m0. 89s) The wall time is the time that elapsed on the clock hanging from your wall. This is relevant, since CPU time does not track time used by subprocesses like GAP or Singular. Avoid killing a Sage process with kill -9 from a terminal, since Sage might not kill child processes, e. g. , Maple processes, or cleanup temporary ? les f rom $HOME/. sage/tmp. ) 3. 1 Your Sage Session The session is the sequence of input and output from when you start Sage until you quit. Sage logs all Sage input, via IPython. In fact, if youââ¬â¢re using the interactive shell (not the notebook interface), then at any point you may type %history (or %hist) to get a listing of all input lines typed so far. You can type ? at the Sage prompt to ? nd out more about IPython, e. g. ââ¬Å"IPython offers numbered prompts with input and output caching. All input is saved and can be retrieved as variables (besides the usual arrow key recall). The following GLOBAL variables always exist (so donââ¬â¢t overwrite them! )â⬠: _: previous input (interactive shell and notebook) __: next previous input (interactive shell only) _oh : list of all inputs (interactive shell only) Here is an example: sage: factor(100) _1 = 2^2 * 5^2 sage: kronecker_symbol(3,5) 51 Sage Tutorial, Release 5. 3 _2 = -1 sage: %hist #This only works from the interacti ve shell, not the notebook. : factor(100) 2: kronecker_symbol(3,5) 3: %hist sage: _oh _4 = {1: 2^2 * 5^2, 2: -1} sage: _i1 _5 = ââ¬â¢factor(ZZ(100)) ââ¬â¢ sage: eval(_i1) _6 = 2^2 * 5^2 sage: %hist 1: factor(100) 2: kronecker_symbol(3,5) 3: %hist 4: _oh 5: _i1 6: eval(_i1) 7: %hist We omit the output numbering in the rest of this tutorial and the other Sage documentation. You can also store a list of input from session in a macro for that session. sage: E = EllipticCurve([1,2,3,4,5]) sage: M = ModularSymbols(37) sage: %hist 1: E = EllipticCurve([1,2,3,4,5]) 2: M = ModularSymbols(37) 3: %hist sage: %macro em 1-2 Macro ââ¬Ëemââ¬Ë created. To execute, type its name (without quotes). sage: E Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Rational Field sage: E = 5 sage: M = None sage: em Executing Macro sage: E Elliptic Curve defined by y^2 + x*y + 3*y = x^3 + 2*x^2 + 4*x + 5 over Rational Field When using the interactive shell, any UNIX shell command can be executed from Sage by prefacing it by an exclamation point !. For example, sage: ! ls auto example. sage glossary. tex t tmp tut. log tut. tex returns the listing of the current directory. The PATH has the Sage bin directory at the front, so if you run gp, gap, singular, maxima, etc. you get the versions included with Sage. sage: ! gp Reading GPRC: /etc/gprc Done. GP/PARI CALCULATOR Version 2. 2. 11 (alpha) i686 running linux (ix86/GMP-4. 1. 4 kernel) 32-bit version 52 Chapter 3. The Interactive Shell Sage Tutorial, Release 5. 3 sage: ! singular SINGULAR A Computer Algebra System for Polynomial Computations 0< by: G. -M. Greuel, G. Pfister, H . Schoenemann FB Mathematik der Universitaet, D-67653 Kaiserslautern October 2005 / / Development version 3-0-1 3. 2 Logging Input and Output Logging your Sage session is not the same as saving it (see Saving and Loading Complete Sessions for that). To log input (and optionally output) use the logstart command. Type logstart? for more details. You can use this command to log all input you type, all output, and even play back that input in a future session (by simply reloading the log ? le). [emailà protected]:~$ sage ââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬â| SAGE Version 3. 0. 2, Release Date: 2008-05-24 | | Type notebook() for the GUI, and license() for information. | ââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âsage: logstart setup Activating auto-logging. Current session state plus future input saved. Filename : setup Mode : backup Output logging : False Timestamping : False State : active sage: E = EllipticCurve([1,2,3,4,5]). minimal_model() sage: F = QQ^3 sage: x,y = QQ[ââ¬â¢x,yââ¬â¢]. gens() sage: G = E. gens() sage: Exiting SAGE (CPU time 0m0. 61s, Wall time 0m50. 39s). [emailà protected]:~$ sage ââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬â| SAGE Version 3. 0. 2, Release Date: 2008-05-24 | | Type notebook() for the GUI, and license() for information. | ââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âsage: load ââ¬Å"setupâ⬠Loading log file one line at a time Finished replaying log file sage: E Elliptic Curve defined by y^2 + x*y = x^3 ââ¬â x^2 + 4*x + 3 over Rational Field sage: x*y x*y sage: G [(2 : 3 : 1)] If you use Sage in the Linux KDE terminal konsole then you can save your session as follows: after starting Sage in konsole, select ââ¬Å"settingsâ⬠, then ââ¬Å"history â⬠, then ââ¬Å"set unlimitedâ⬠. When you are ready to save your session, select ââ¬Å"editâ⬠then ââ¬Å"save history as â⬠and type in a name to save the text of your session to your computer. After saving this ? le, you could then load it into an editor, such as xemacs, and print it. 3. 2. Logging Input and Output 53 Sage Tutorial, Release 5. 3 3. Paste Ignores Prompts Suppose you are reading a session of Sage or Python computations and want to copy them into Sage. But there are annoying >>> or sage: prompts to worry about. In fact, you can copy and paste an example, including the prompts if you want, into Sage. In other words, by de fault the Sage parser strips any leading >>> or sage: prompt before passing it to Python. For example, sage: 2^10 1024 sage: sage: sage: 2^10 1024 sage: >>> 2^10 1024 3. 4 Timing Commands If you place the %time command at the beginning of an input line, the time the command takes to run will be displayed after the output. For example, we can compare the running time for a certain exponentiation operation in several ways. The timings below will probably be much different on your computer, or even between different versions of Sage. First, native Python: sage: %time a = int(1938)^int(99484) CPU times: user 0. 66 s, sys: 0. 00 s, total: 0. 66 s Wall time: 0. 66 This means that 0. 66 seconds total were taken, and the ââ¬Å"Wall timeâ⬠, i. e. , the amount of time that elapsed on your wall clock, is also 0. 66 seconds. If your computer is heavily loaded with other programs, the wall time may be much larger than the CPU time. Next we time exponentiation using the native Sage Integer type, which is implemented (in Cython) using the GMP library: sage: %time a = 1938^99484 CPU times: user 0. 04 s, sys: 0. 00 s, total: 0. 04 s Wall time: 0. 04 Using the PARI C-library interface: sage: %time a = pari(1938)^pari(99484) CPU times: user 0. 05 s, sys: 0. 00 s, total: 0. 05 s Wall time: 0. 05 GMP is better, but only slightly (as expected, since the version of PARI built for Sage uses GMP for integer arithmetic). You can also time a block of commands using the cputime command, as illustrated below: sage: sage: sage: sage: sage: 0. 4 t = cputime() a = int(1938)^int(99484) b = 1938^99484 c = pari(1938)^pari(99484) cputime(t) # somewhat random output sage: cputime? Return the time in CPU second since SAGE started, or with optional argument t, return the time since time t. 54 Chapter 3. The Interactive Shell Sage Tutorial, Release 5. 3 INPUT: t ââ¬â (optional) float, time in CPU seconds OUTPUT: float ââ¬â time i n CPU seconds The walltime command behaves just like the cputime command, except that it measures wall time. We can also compute the above power in some of the computer algebra systems that Sage includes. In each case we execute a trivial command in the system, in order to start up the server for that program. The most relevant time is the wall time. However, if there is a signi? cant difference between the wall time and the CPU time then this may indicate a performance issue worth looking into. sage: time 1938^99484; CPU times: user 0. 01 s, sys: 0. 00 s, total: Wall time: 0. 01 sage: gp(0) 0 sage: time g = gp(ââ¬â¢1938^99484ââ¬â¢) CPU times: user 0. 00 s, sys: 0. 00 s, total: Wall time: 0. 04 sage: maxima(0) 0 sage: time g = maxima(ââ¬â¢1938^99484ââ¬â¢) CPU times: user 0. 00 s, sys: 0. 00 s, total: Wall time: 0. 0 sage: kash(0) 0 sage: time g = kash(ââ¬â¢1938^99484ââ¬â¢) CPU times: user 0. 00 s, sys: 0. 00 s, total: Wall time: 0. 04 sage: mathematica(0) 0 sage: time g = mathematica(ââ¬â¢1938^99484ââ¬â¢) CPU times: user 0. 00 s, sys: 0. 00 s, total: Wall time: 0. 03 sage: maple(0) 0 sage: time g = maple(ââ¬â¢1938^99484ââ¬â¢) CPU times: user 0. 00 s, sys: 0. 00 s, total: Wall time: 0. 11 sage: gap(0) 0 sage: time g = gap. eval(ââ¬â¢1938^99484;;ââ¬â¢) CPU times: user 0. 00 s, sys: 0. 00 s, total: Wall time: 1. 02 0. 01 s 0. 00 s 0. 00 s 0. 00 s 0. 00 s 0. 00 s 0. 00 s Note that GAP and Maxima are the slowest in this test (this was run on the machine sage. ath. washington. edu). Because of the pexpect interface overhead, it is perhaps unfair to compare these to Sage, which is the fastest. 3. 5 Other IPython tricks As noted above, Sage uses IPython as its front end, and so you can use any of IPythonââ¬â¢s commands and features. You can read the full IPython documentation. Meanwhile, here are some fun tricks ââ¬â these are called ââ¬Å"Magic commandsâ⬠in IPython: â⬠¢ You can use %bg to run a command in the background, and then use jobs to access the results, as follows. 3. 5. Other IPython tricks 55 Sage Tutorial, Release 5. 3 The comments not tested are here because the %bg syntax doesnââ¬â¢t work well with S ageââ¬â¢s automatic testing facility. If you type this in yourself, it should work as written. This is of course most useful with commands which take a while to complete. ) sage: def quick(m): return 2*m sage: %bg quick(20) # not tested Starting job # 0 in a separate thread. sage: jobs. status() # not tested Completed jobs: 0 : quick(20) sage: jobs[0]. result # the actual answer, not tested 40 Note that jobs run in the background donââ¬â¢t use the Sage preparser ââ¬â see The Pre-Parser: Differences between Sage and Python for more information. One (perhaps awkward) way to get around this would be to run sage: %bg eval(preparse(ââ¬â¢quick(20)ââ¬â¢)) # not tested It is safer and easier, though, to just use %bg on commands which donââ¬â¢t require the preparser. â⬠¢ You can use %edit (or %ed or ed) to open an editor, if you want to type in some complex code. Before you start Sage, make sure that the EDITOR environment variable is set to your favorite editor (by putting export EDITOR=/usr/bin/emacs or export EDITOR=/usr/bin/vim or something similar in the appropriate place, like a . profile ? le). From the Sage prompt, executing %edit will open up the named editor. Then within the editor you can de? e a function: def some_function(n): return n**2 + 3*n + 2 Save and quit from the editor. For the rest of your Sage session, you can then use some_function. If you want to modify it, type %edit some_function from the Sage prompt. â⬠¢ If you have a computation and you want to modify its output for another use, perform the computation and type %rep: this will place the output from the previous command at the Sage prompt, ready for you to edit it. sage: f(x) = cos(x) sage: f(x). derivative(x) -sin(x) At this point, if you type %rep at the Sage prompt, you will get a new Sage prompt, followed by -sin(x), with the cursor at the end of the line. For more, type %quickref to get a quick reference guide to IPython. As of this writing (April 2011), Sage uses version 0. 9. 1 of IPython, and the documentation for its magic commands is available online. 3. 6 Errors and Exceptions When something goes wrong, you will usually see a Python ââ¬Å"exceptionâ⬠. Python even tries to suggest what raised the exception. Often you see the name of the exception, e. g. , NameError or ValueError (see the Python Reference Manual [Py] for a complete list of exceptions). For example, sage: 3_2 ââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âFile ââ¬Å"â⬠, line 1 ZZ(3)_2 ^ SyntaxError: invalid syntax 6 Chapter 3. The Interactive Shell Sage Tutorial, Release 5. 3 sage: EllipticCurve([0,infinity]) ââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬â ââ¬âââ¬âââ¬âTraceback (most recent call last): TypeError: Unable to coerce Infinity () to Rational The interactive debugger is sometimes useful for understanding what went wrong. You can toggle it on or off using %pdb (the default is off). The prompt ipdb> appears if an exception is raised and the debugger is on. From within the debugger, you can print the state of any local variable, and move up and down the execution stack. For example, sage: %pdb Automatic pdb calling has been turned ON sage: EllipticCurve([1,infinity]) ââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬â Traceback (most recent call last) ipdb> For a list of commands in the debugger, type ? at the ipdb> prompt: ipdb> ? Documented commands (type help ): ======================================== EOF break commands debug h a bt condition disable help alias c cont down ignore args cl continue enable j b clear d exit jump whatis where Miscellaneous help topics: ========================== exec pdb Undocumented commands: ====================== retval rv list n next p pdef pdoc pinfo pp q quit r return s step tbreak u unalias up w Type Ctrl-D or quit to return to Sage. 3. 7 Reverse Search and Tab Completion Reverse search: Type the beginning of a command, then Ctrl-p (or just hit the up arrow key) t o go back to each line you have entered that begins in that way. This works even if you completely exit Sage and restart later. You can also do a reverse search through the history using Ctrl-r. All these features use the readline package, which is available on most ? avors of Linux. To illustrate tab completion, ? st create the three dimensional vector space V = Q3 as follows: sage: V = VectorSpace(QQ,3) sage: V Vector space of dimension 3 over Rational Field You can also use the following more concise notation: 3. 7. Reverse Search and Tab Completion 57 Sage Tutorial, Release 5. 3 sage: V = QQ^3 Then it is easy to list all member functions for V using tab completion. Just type V. , then type the [tab key] key on your keyboard: sage: V. [tab key] V. _VectorSpace_generic__base_field V. ambient_space V. base_field V. base_ring V. basis V. coordinates V. zero_vector If you type the ? st few letters of a function, then [tab key], you get only functions that begin as indicated. sage: V. i[tab key] V. is_ambient V. is_dense V. is_full V. is_sparse If you wonder what a particular function does, e. g. , the coordinates function, type V. coordinates? for help or V. coordinates for the source code, as explained in the next section. 3. 8 Integrated Help System Sage features an integrated help facility. Type a function name followed by ? for the documentation for that function. sage: V = QQ^3 sage: V. coordinates? Type: instancemethod Base Class: String Form: Namespace: Interactive File: /home/was/s/local/lib/python2. /site-packages/sage/modules/f ree_module. py Definition: V. coordinates(self, v) Docstring: Write v in terms of the basis for self. Returns a list c such that if B is the basis for self, then sum c_i B_i = v. If v is not in self, raises an ArithmeticError exception. EXAMPLES: sage: M = FreeModule(IntegerRing(), 2); M0,M1=M. gens() sage: W = M. submodule([M0 + M1, M0 ââ¬â 2*M1]) sage: W. coordinates(2*M0-M1) [2, -1] As shown above, the output tells you t he type of the object, the ? le in which it is de? ned, and a useful description of the function with examples that you can paste into your current session. Almost all of these examples are regularly automatically tested to make sure they work and behave exactly as claimed. 58 Chapter 3. The Interactive Shell Sage Tutorial, Release 5. 3 Another feature that is very much in the spirit of the open source nature of Sage is that if f is a Python function, then typing f displays the source code that de? nes f. For example, sage: V = QQ^3 sage: V. coordinates Type: instancemethod Source: def coordinates(self, v): ââ¬Å"â⬠â⬠Write $v$ in terms of the basis for self. ââ¬Å"â⬠â⬠return self. coordinate_vector(v). list() This tells us that all the coordinates function does is call the coordinate_vector function and change the result into a list. What does the coordinate_vector function do? sage: V = QQ^3 sage: V. coordinate_vector def coordinate_vector(self, v): return self. ambient_vector_space()(v) The coordinate_vector function coerces its input into the ambient space, which has the effect of computing the vector of coef? cients of v in terms of V . The space V is already ambient since itââ¬â¢s just Q3 . There is also a coordinate_vector function for subspaces, and itââ¬â¢s different. We create a subspace and see: sage: V = QQ^3; W = V. span_of_basis([V. 0, V. 1]) sage: W. coordinate_vector def coordinate_vector(self, v): ââ¬Å"â⬠â⬠ââ¬Å"â⬠â⬠# First find the coordinates of v wrt echelon basis. w = self. echelon_coordinate_vector(v) # Next use transformation matrix from echelon basis to # user basis. T = self. echelon_to_user_matrix() return T. linear_combination_of_rows(w) (If you think the implementation is inef? cient, please sign up to help optimize linear algebra. ) You may also type help(command_name) or help(class) for a manpage-like help ? le about a given class. age: help(VectorSpace) Help on class VectorSpace class VectorSpace(__builtin__. object) | Create a Vector Space. | | To create an ambient space over a field with given dimension | using the calling syntax : : When you type q to exit the help system, your session appears just as it was. The help listing does not clutter up your session, unlike the output of function_name? som etimes does. Itââ¬â¢s particularly helpful to type 3. 8. Integrated Help System 59 Sage Tutorial, Release 5. 3 help(module_name). For example, vector spaces are de? ned in sage. modules. free_module, so type help(sage. modules. ree_module) for documentation about that whole module. When viewing documentation using help, you can search by typing / and in reverse by typing ?. 3. 9 Saving and Loading Individual Objects Suppose you compute a matrix or worse, a complicated space of modular symbols, and would like to save it for later use. What can you do? There are several approaches that computer algebra systems take to saving individual objects. 1. Save your Game: Only support saving and loading of complete sessions (e. g. , GAP, Magma). 2. Uni? ed Input/Output: Make every object print in a way that can be read back in (GP/PARI). 3. Eval: Make it easy to evaluate arbitrary code in the interpreter (e. g. , Singular, PARI). Because Sage uses Python, it takes a different approach, which is that every object can be serialized, i. e. , turned into a string from which that object can be recovered. This is in spirit similar to the uni? ed I/O approach of PARI, except it doesnââ¬â¢t have the drawback that objects print to screen in too complicated of a way. Also, support for saving and loading is (in most cases) completely automatic, requiring no extra programming; itââ¬â¢s simply a feature of Python that was designed into the language from the ground up. Almost all Sage objects x can be saved in compressed form to disk using save(x, filename) (or in many cases x. save(filename)). To load the object back in, use load(filename). sage: sage: [ 15 [ 42 [ 69 sage: A = MatrixSpace(QQ,3)(range(9))^2 A 18 21] 54 66] 90 111] save(A, ââ¬â¢Aââ¬â¢) You should now quit Sage and restart. Then you can get A back: sage: sage: [ 15 [ 42 [ 69 A = load(ââ¬â¢Aââ¬â¢) A 18 21] 54 66] 90 111] You can do the same with more complicated objects, e. g. , elliptic curves. All data about the object that is cached is stored with the object. For example, sage: sage: sage: sage: E = EllipticCurve(ââ¬â¢11aââ¬â¢) v = E. nlist(100000) save(E, ââ¬â¢Eââ¬â¢) quit # takes a while The saved version of E takes 153 kilobytes, since it stores the ? rst 100000 an with it. ~/tmp$ ls -l E. sobj -rw-rââ¬ârââ¬â 1 was was 153500 2006-01-28 19:23 E. sobj ~/tmp$ sage [ ] sage: E = load(ââ¬â¢Eââ¬â¢) sage: v = E. anlist(100000) # instant! (In Pytho n, saving and loading is accomplished using the cPickle module. In particular, a Sage object x can be saved via cPickle. dumps(x, 2). Note the 2! ) 60 Chapter 3. The Interactive Shell Sage Tutorial, Release 5. 3 Sage cannot save and load individual objects created in some other computer algebra systems, e. . , GAP, Singular, Maxima, etc. They reload in a state marked ââ¬Å"invalidâ⬠. In GAP, though many objects print in a form from which they can be reconstructed, many donââ¬â¢t, so reconstructing from their print representation is purposely not allowed. sage: a = gap(2) sage: a. save(ââ¬â¢aââ¬â¢) sage: load(ââ¬â¢aââ¬â¢) Traceback (most recent call last): ValueError: The session in which this object was defined is no longer running. GP/PARI objects can be saved and loaded since their print representation is enough to reconstruct them. sage: a = gp(2) sage: a. save(ââ¬â¢aââ¬â¢) sage: load(ââ¬â¢aââ¬â¢) 2 Saved objects can be re-loaded later on computers with different architectures or operating systems, e. g. , you could save a huge matrix on 32-bit OS X and reload it on 64-bit Linux, ? nd the echelon form, then move it back. Also, in many cases you can even load objects into versions of Sage that are different than the versions they were saved in, as long as the code for that object isnââ¬â¢t too different. All the attributes of the objects are saved, along with the class (but not source code) that de? nes the object. If that class no longer exists in a new version of Sage, then the object canââ¬â¢t be reloaded in that newer version. But you could load it in an old version, get the objects dictionary (with x. __dict__), and save the dictionary, and load that into the newer version. 3. 9. 1 Saving as Text You can also save the ASCII text representation of objects to a plain text ? le by simply opening a ? le in write mode and writing the string representation of the object (you can write many objects this way as well). When youââ¬â¢re done writing objects, close the ? le. sage: sage: sage: sage: sage: R. = PolynomialRing(QQ,2) f = (x+y)^7 o = open(ââ¬â¢file. txtââ¬â¢,ââ¬â¢wââ¬â¢) o. write(str(f)) o. close() 3. 10 Saving and Loading Complete Sessions Sage has very ? xible support for saving and loading complete sessions. The command save_session(sessionname) saves all the variables youââ¬â¢ve de? ned in the current session as a dictionary in the given sessionname. (In the rare case when a variable does not support saving, it is simply not saved to the dictionary. ) The resulting ? le is an . sobj ? le and can be loaded just like any other object that was saved. When you load the objects saved in a session, you get a dictionary whose keys are the variables names and whose values are the objects. You can use the load_session(sessionname) command to load the variables de? ed in sessionname into the current session. Note that this does not wipe out variables youââ¬â¢ve already de? ned in your current session; instead, the two sessions are merged. First we start Sage and de? ne some variables. 3. 10. Saving and Loading Complete Sessions 61 Sage Tutorial, Release 5. 3 sage: sage: sage: sage: _4 = E = EllipticCurve(ââ¬â¢11aââ¬â¢) M = ModularSymbols(37) a = 389 t = M. T(2003). matrix(); t. charpoly(). factor() (x ââ¬â 2004) * (x ââ¬â 12)^2 * (x + 54)^2 Next we save our session, which saves each of the above variables into a ? le. Then we view the ? le, which is about 3K in size. age: save_session(ââ¬â¢miscââ¬â¢) Saving a Saving M Saving t Saving E sage: quit [ emailà protected]:~/tmp$ ls -l misc. sobj -rw-rââ¬ârââ¬â 1 was was 2979 2006-01-28 19:47 misc. sobj Finally we restart Sage, de? ne an extra variable, and load our saved session. sage: b = 19 sage: load_session(ââ¬â¢miscââ¬â¢) Loading a Loading M Loading E Loading t Each saved variable is again available. Moreover, the variable b was not overwritten. sage: M Full Modular Symbols space for Gamma_0(37) of weight 2 with sign 0 and dimension 5 over Rational Field sage: E Elliptic Curve defined by y^2 + y = x^3 ââ¬â x^2 ââ¬â 10*x ââ¬â 20 over Rational Field sage: b 19 sage: a 389 3. 1 The Notebook Interface The Sage notebook is run by typing sage: notebook() on the command line of Sage. This starts the Sage notebook and opens your default web browser to view it. The serverââ¬â¢s state ? les are stored in $HOME/. sage/sage\_notebook. Other options include: sage: notebook(ââ¬Å"directoryâ⬠) which starts a new notebook server using ? les in the given dir ectory, instead of the default directory $HOME/. sage/sage_notebook. This can be useful if you want to have a collection of worksheets associated with a speci? c project, or run several separate notebook servers at the same time. When you start the notebook, it ? st creates the following ? les in $HOME/. sage/sage_notebook: 62 Chapter 3. The Interactive Shell Sage Tutorial, Release 5. 3 nb. sobj objects/ worksheets/ (the notebook SAGE object file) (a directory containing SAGE objects) (a directory containing SAGE worksheets). After creating the above ? les, the notebook starts a web server. A ââ¬Å"notebookâ⬠is a collection of user accounts, each of which can have any number of worksheets. When you create a new worksheet, the data that de? nes it is stored in the worksheets/username/number directories. In each such directory there is a plain text ? le worksheet. xt ââ¬â if anything ever happens to your worksheets, or Sage, or whatever, that human-readable ? le contains ev erything needed to reconstruct your worksheet. From within Sage, type notebook? for much more about how to start a notebook server. The following diagram illustrates the architecture of the Sage Notebook: ââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬â| | | | | firefox/safari | | | | javascript | | program | | | | | ââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬â| ^ | AJAX | V | ââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬â| | | sage | | web | ââ¬âââ¬âââ¬âââ¬â> | server | pexpect | | | | ââ¬âââ¬âââ¬âââ¬âââ¬âââ¬âââ¬â- SAGE process 1 SAGE process 2 SAGE process 3 (Python processes) For help on a Sage command, cmd, in the notebook browser box, type cmd? ). and now hit (not For help on the keyboard shortcuts available in the notebook interface, click on the Help link. 3. 11. The Notebook Interface 63 Sage Tutorial, Release 5. 3 64 Chapter 3. The Interactive Shell CHAPTER FOUR INTERFACES A central facet of Sage is that it supports computation with objects in many different computer algebra systems ââ¬Å"under one roofâ⬠using a common interface and clean programming language. The console and interact methods of an interface do very different things. For example, using GAP as an example: 1. gap. onsole(): This opens the GAP console ââ¬â it transfers control to GAP. Here Sage is serving as nothing more than a convenient program launcher, similar to the Linux bash shell. 2. gap. interact(): This is a convenient way to interact with a running GAP instance that may be ââ¬Å"full ofâ⬠Sage objects. You can import Sage objects into this GAP session (even from the interactive interface), etc. 4. 1 GP/PARI PARI is a compact, very mature, highly optimized C program whose primary focus is number theory. There are two very distinct interfaces that you can use in Sage: â⬠¢ gp ââ¬â the ââ¬Å"G o P ARIâ⬠interpreter, and â⬠¢ pari ââ¬â the PARI C libraxry. For example, the following are two ways of doing the same thing. They look identical, but the output is actually different, and what happens behind the scenes is drastically different. sage: gp(ââ¬â¢znprimroot(10007)ââ¬â¢) Mod(5, 10007) sage: pari(ââ¬â¢znprimroot(10007)ââ¬â¢) Mod(5, 10007) In the ? rst case, a separate copy of the GP interpreter is started as a server, and the string ââ¬â¢znprimroot(10007)ââ¬â¢ is sent to it, evaluated by GP, and the result is assigned to a variable in GP (which takes up space in the child GP processes memory that wonââ¬â¢t be freed). Then the value of that variable is displayed. In the second case, no separate program is started, and the string ââ¬â¢znprimroot(10007)ââ¬â¢ is evaluated by a certain PARI C library function. The result is stored in a piece of memory on the Python heap, which is freed when the variable is no longer referenced. The objects have different types: sage: type(gp(ââ¬â¢znprimroot(10007)ââ¬â¢)) sage: type(pari(ââ¬â¢znprimroot(10007)ââ¬â¢)) So which should you use? It depends on what youââ¬â¢re doing. The GP interface can do absolutely anything you could do in the usual GP/PARI command line program, since it is running that program. In particular, you can load complicated PARI programs and run them. In contrast, the PARI interface (via the C library) is much more restrictive. First, not all 65 Sage Tutorial, Release 5. 3 member functions have been implemented. Second, a lot of code, e. g. , involving numerical integration, wonââ¬â¢t work via the PARI interface. That said, the PARI interface can be signi? cantly faster and more robust than the GP one. (If the GP interface runs out of memory evaluating a given input line, it will silently and automatically double the stack size and retry that input line. Thus your computation wonââ¬â¢t crash if you didnââ¬â¢t correctly anticipate the amount of memory that would be needed. This is a nice trick the usual GP interpreter doesnââ¬â¢t seem to provide. Regarding the PARI C library interface, it immediately copies each created object off of the PARI stack, hence the stack never grows. However, each object must not exceed 100MB in size, or the stack will over? ow when the object is being created. This extra copying does impose a slight performance penalty. ) In summary, Sage uses the PARI C library to provide functionality similar to that provided by the GP/PARI interpreter, except with different sophisticated memory management and the Python programming language. First we create a PARI list from a Python list. age: v = pari([1,2,3,4,5]) sage: v [1, 2, 3, 4, 5] sage: type(v) Every PARI object is of type py_pari. gen. The PARI type of the underlying object can be obtained using the type member function. sage: v. type() ââ¬â¢t_VECââ¬â¢ In PARI, to create an elliptic curve we enter ellinit([1,2,3,4,5]). Sage is similar, except that ellinit is a method th at can be called on any PARI object, e. g. , our t\_VEC v. sage: e = v. ellinit() sage: e. type() ââ¬â¢t_VECââ¬â¢ sage: pari(e)[:13] [1, 2, 3, 4, 5, 9, 11, 29, 35, -183, -3429, -10351, 6128487/10351] Now that we have an elliptic curve object, we can compute some things about it. age: e. elltors() [1, [], []] sage: e. ellglobalred() [10351, [1, -1, 0, -1], 1] sage: f = e. ellchangecurve([1,-1,0,-1]) sage: f[:5] [1, -1, 0, 4, 3] 4. 2 GAP Sage comes with GAP 4. 4. 10 for computational discrete mathematics, especially group theory. Hereââ¬â¢s an example of GAPââ¬â¢s IdGroup function, which uses the optional small groups database that has to be installed separately, as explained below. sage: G = gap(ââ¬â¢Group((1,2,3)(4,5), (3,4))ââ¬â¢) sage: G Group( [ (1,2,3)(4,5), (3,4) ] ) sage: G. Center() Group( () ) 66 Chapter 4. Interfaces Sage Tutorial, Release 5. 3 sage: G. IdGroup() [ 120, 34 ] sage: G. Order() 120 # requires optional database_gap package We can do the same computation in Sage without explicitly invoking the GAP interface as follows: sage: G = PermutationGroup([[(1,2,3),(4,5)],[(3,4)]]) sage: G. center() Subgroup of (Permutation Group with generators [(3,4), (1,2,3)(4,5)]) generated by [()] sage: G. group_id() # requires optional database_gap package [120, 34] sage: n = G. order(); n 120 (For some GAP functionality, you should install two optional Sage packages. Type sage -optional for a list and choose the one that looks like gap\_packages-x. . z, then type sage -i gap\_packages-x. y. z. Do the same for database\_gap-x. y. z. Some non-GPLââ¬â¢d GAP packages may be installed by downloading them from the GAP web site [GAPkg], and unpacking them in $SAGE_ROOT/local/lib/gap-4. 4. 10/pkg. ) 4. 3 Singular Singular provides a massive and mature library for Grobner bases, multivariate polynomial gcds, bases of RiemannRoch spaces of a plane curve, and factorizations, among other things. We illustrate multivariate polynomial factorization using the Sage interface to Singular (do not type the ): sage: R1 = singular. ing(0, ââ¬â¢(x,y)ââ¬â¢, ââ¬â¢dpââ¬â¢) sage: R1 // characteristic : 0 // number of vars : 2 // block 1 : ordering dp // : names x y // block 2 : ordering C sage: f = singular(ââ¬â¢9*y^8 ââ¬â 9*x^2*y^7 ââ¬â 18*x^3*y^6 ââ¬â 18*x^5*y^6 + 9*x^6*y^4 + 18*x^7*y^5 + 36*x^8*y^4 + 9*x^10*y^4 ââ¬â 18*x^11*y^2 ââ¬â 9*x^12*y^3 ââ¬â 18*x^13*y^2 + 9*x^16ââ¬â¢) Now that we have de? ned f , we print it and factor. sage: f 9*x^16-18*x^13*y^2-9*x^12*y^3+9*x^10*y^4-18*x^11*y^2+36*x^8*y^4+18*x^7*y^5-18*x^5*y^6+9*x^6*y^4-18*x^ sage: f. parent() Singular sage: F = f. factorize(); F [1]: _[1]=9 _[2]=x^6-2*x^3*y^2-x^2*y^3+y^4 _[3]=-x^5+y^2 [2]: 1,1,2 sage: F[1][2] x^6-2*x^3*y^2-x^2*y^3+y^4 As with the GAP example in GAP, we can compute the above factorization without explicitly using the Singular interface (however, behind the scenes Sage uses the Singular interface for the actual computation). Do not type the : 4. 3. Singular 67 Sage Tutorial, Release 5. 3 sage: sage: sage: (9) * x, y = QQ[ââ¬â¢x, yââ¬â¢]. gens() f = 9*y^8 ââ¬â 9*x^2*y^7 ââ¬â 18*x^3*y^6 ââ¬â 18*x^5*y^6 + 9*x^6*y^4 + 18*x^7*y^5 + 36*x^8*y^4 + 9*x^10*y^4 ââ¬â 18*x^11*y^2 ââ¬â 9*x^12*y^3 ââ¬â 18*x^13*y^2 + 9*x^16 factor(f) (-x^5 + y^2)^2 * (x^6 ââ¬â 2*x^3*y^2 ââ¬â x^2*y^3 + y^4) 4. 4 Maxima Maxima is included with Sage, as well as a Lisp implementation. The gnuplot package (which Maxima uses by default for plotting) is distributed as a Sage optional package. Among other things, Maxima does symbolic manipulation. Maxima can integrate and differentiate functions symbolically, solve 1st order ODEs, most linear 2nd order ODEs, and has implemented the Laplace tr
Thursday, August 29, 2019
Linguistic Anthropology review Article Example | Topics and Well Written Essays - 750 words
Linguistic Anthropology review - Article Example However, this focus on the identity has pointlessly restrained the scope of enquiry, thus rendering research in the area ineffective and not in a position of addressing the wider semiotic process that produces sexuality, and disseminating it in language. Nevertheless, one of the essayââ¬â¢s major points is to suggest that what is seen as the differentiating performance from performativity, and how those two perspectives relate to language. Moreover, the focus of this critical study is on the fact that the ââ¬Ënoââ¬â¢ of a woman is restrained by the cultural demands and expectations of femininity (Kullick 494). The writer states that at several points in time, he noted where he thought that there are differences between a performance perspective and a performativity perspective. He however claims that there is a difference, which in his view is a critical one, which brings us back to the identity question. The difference is that while studies considered in a framework of perf ormance have a tendency to regard language in relation to identity, research designed as performative will focus more on identification. According to the writer, we find that the difference is in identity that in linguistic and sociolinguistic anthropology work is traditionally presented as a more or les cognizant claim-staking of a specific sociological position, and the identification that is concerned with the operations that constitutes the subject. The text is not so much fundamental to production of sexual case, but for materialization of a certain type of sexual instance whereby the sexual subjects produced are empowered and gendered differentially (Kullick 498). The writer states that a psychoanalytic platitude about the identifications is that they donââ¬â¢t make up a consistent relational system. Furthermore, they are not absolutely conscious. In contrast, identifications are merely as much structured by refusals, rejections as well as disavowals as their structuring is done by affirmations. It is essential not to fall the identification into identity as they are not the sane thing. More so, a performative linguistic phenomena approach does not begin or even end with identity. But instead, we find that a performative approach would review the process, by which some types of identifications are permitted, unmarked and legitimate, and others are not permitted, marked and not legitimate. Language, Race and White Public Space by Jane Hill The text ââ¬Å"Language, Race and White Public Space,â⬠is all about the issues of language and race in various societies. The construction of the story is done extensive review of the speech of racialized communities like the African Americans, Latinos and the Chicanos for linguistic disorderââ¬â¢s signs, and the invisibility of nearly similar signs in the Whiteââ¬â¢s speeches, whereby the mixing of language that is essential for the expression of a highly rated kind of colloquial persona, takes many for ms. An example of such forms is the Mock Spanish, which shows a complex semiotics. However, by direct indexicality, speakers are presented by the Mock Spanish as having desirable individual qualities. And by indirect indexicality, it produces racializing stereotypes of the Latinos and Chicanos that are highly negative (Hill 683). Furthermore, it also explores the question of the propensity for such usages to be redesigned to undermine the racial practicesââ¬â¢ order in discourse. According to the w
Wednesday, August 28, 2019
Organizational Theory Essay Example | Topics and Well Written Essays - 500 words
Organizational Theory - Essay Example Leaders should only choose conflicts that are fruitful endeavors for the company in that it one, focus on the future; secondly it is material, and lastly, it has a noble purpose (Joni and Beyer, 2009, p. 50-52). The researchers also were able to come up with their own assessment tool. Since this is a qualitative research, they exhaustively defined the use of their terms. For instance, to ââ¬Ëpursue a noble purposeââ¬â¢ means to ââ¬Å"make your fight about improving the lives of the customersâ⬠(Joni and Beyer, 2009, p. 51), and relates to the principles of corporate values, respect, and urgency. Focusing on the future is quite self-explanatory but they still define it as the ability of an organization to forget about the past power struggles and to move on and focus on what is ahead. It answers the principles of possibility, uncertainty, and charisma. Making it material answers the principles of value, complexity, and change (Joni and Beyer, 2009, p. 52- 53). It is define d as ââ¬Å"something that creates lasting value, leads to a noticeable and sustainable improvement, and addresses a complex challenge that has no easy answersâ⬠(Joni and Beyer, 2009, p. 50). Description of Procedures Because of the qualitative nature of the study, Joni and Beyer (2009) made use of primary sources from various companiesââ¬âpress releases, profiles, and case studies; and secondary sourcesââ¬âarticles from newspaper and business journals. These are then used throughout the study as examples and basis for their arguments.
Tuesday, August 27, 2019
Integration Paper (Operations Management) Essay Example | Topics and Well Written Essays - 500 words
Integration Paper (Operations Management) - Essay Example These two concepts when taken personally and professional are very much and related and cannot be really separated. Personally, ERP is something that one needs to learn in order to maximize the use of resources (financial and time). I know that I can relate on how specific inputs should be handled in order to get the most benefits. An example of this is the efficient allocation of budget which is very significant with the current economic situation. Professionally, the concepts of ERP and SCM should always be considered in any activity noting the profit maximizing goal of the firm. Thus, each employee should see to it that all resources should be put into best use. The most interesting lesson for the week is JIT and lean operations. I am really amazed by these concepts in operations management. I have always wondered why Dell Inc does not have retail distributors for their products. I thought it might have been just easy for them to stock their products and wait for walk-in customers to buy. However, with the discussion, I have appreciated this strategy of JIT where products are manufactured as they are ordered by customers.
Monday, August 26, 2019
Electronic Waste Management Approaches Essay Example | Topics and Well Written Essays - 250 words
Electronic Waste Management Approaches - Essay Example The disposal of electronic waste affects the health of humans in two ways. First, one can get contaminated through the food chain. Secondly, direct exposure to workers carrying out the duties at the disposal site. Since the discovery of toxic substance in electronic waste, there has been inadequate laws all over the world governing effective management of electronic waste. This has exposed the environment to risks. Large quantities of electronic waste are majorly recycled in developing nations. The number of landfills has been on the rise in both developing and developed countries. Presently there is extensive research on electronic waste management in order to minimize the problems, both at the international as well as the national levels. Research involves sorting components that could be precious metals and those that can be recycled. Several tools such as LCA, MCA, MFA and EPR approach can greatly improve most of the problems related electronic waste. Studies conducted using LCA in various countries indicate that, recycling is the most recommended plot for managing electronic waste. Finally to mitigate the electronic waste, its the role of every citizen to take responsibility in matters related disposal of electronic
Sunday, August 25, 2019
The Act of Union Essay Example | Topics and Well Written Essays - 1000 words
The Act of Union - Essay Example In eastern and Central Europe, many new nations were formed during the twentieth century and they ended up disregarding requirements in the Union agreements based upon relinquishing territorial membership.1 In 1707, the Act of Union was created so as to bind Scotland with the other nations constituting the United Kingdom. A number of other amendments were made to the Union with the first one being in 1801. Other Acts were also created to further specify the issues in the Act of Union and these included the Parliament Act, the people's Acts, the Scotland Act etc. In the Act of Union., Scotland is still recognised as a legal and political entity on is own. This is the reason some elements of the Scottish legal system are distinct to this part of the world. Additionally, this is the reason why Scotland is allowed to posses its own maritime system. On the other hand, there are certain things that Scotland as a state cannot institute. First of all, the Act of Union requires that the United Kingdom Parliament be the main body that legislates for the constituent countries. Additionally, the constitution also stipulates that only ministers from the UK parliament have the right to hold executive powers. In other words, the constitution stipulates that Scotland should operate under territorial rather than state-wide powers. The Act of Union is instrumental in spelling out the accountability of parliament to its people in the entire UK region. It also specifies how the Cabinet, Prime ministers and junior cabinet are to be structured. 2 In the legal system, the Act of Union allows Scottish courts to operate somewhat independently; however, it specifies that appeals must be directed to the Privy Council, the House of Lords or the UK Supreme court. It can therefore be said that the Act of Union acts as a check on the Scottish judiciary system. Through these territorial mechanisms, the Scottish legal system is kept under check because they are held accountable to these regional systems. If the Act of Union were to be disregarded, then chances are that some cases or issues that have been subject to appeal in the UK judicial system would be left unguarded and this may impede certain rights of the Scottish people. As the country is currently, the Act of Union has ensured that the Scottish judiciary is highly accountable and has thus improved its performance. The UK Parliament has been granted the ability to scrutinise the goings on in the government and the country at large. If the Act of Union were to be eliminated, then this function may be undermined. Scotland is in a position where it would require intense restructuring and revision in order to be able to carry out scrutiny of its government through an independent Parliament. The Act of Union is also relevant in terms of describing some of the rights and duties of employees or companies that operate within other borders within the United Kingdom. This constitution clearly states that the UK government is the one with the powers to scrutinise or enhance accountability within corporate bodies operating in the UK. Consequently, the Act of Union is important in preserving these rights. It specifies issues such as terms and conditions of employment, pay or compensation,
Saturday, August 24, 2019
An investigation into why e-businesses fail Essay
An investigation into why e-businesses fail - Essay Example This dissertà °tion used multi-cà °se studies à °s there were numerous exà °mples of fà °iled online businesses à °s well à °s successful ones. The results of the cà °se studies hà °ve shown thà °t stà °ff with experience in mà °rketing is vità °l to the success of the online business, à °s mà °rketing in online business encompà °sses most à °spects of the business, à °nd is not just confined to à °ttrà °cting à °nd retà °ining customers. Mà °rketing à °n online business à °lso involves mà °nà °ging the website itself à °nd ensuring thà °t the technicà °l à °spects à °re contributing to the customer experience. In the cà °se studies, it wà °s cleà °r thà °t experience wà °s the key to success in online businesses, à °s experience would influence other fà °ctors such à °s mà °rketing à °nd business plà °ns. Some online businesses mà °y need professionà °l help in mà °rketing, but only if they hà °ve not expertise within the teà °m. There fore it wà °s more importà °nt to recognise à °nd identify the shortcomings of the online business model before setting up the online business. This seemed to be à ° greà °ter determinà °nt of success, à °s à ° well-thought out business à °nd mà °rketing plà °n would à °nd should include experienced à °nd quà °lified personnel. The dissertà °tion à °lso highlighted the importà °nce of business pà °rtnerships especià °lly where the online business wà °s not à ° mà °nufà °cturer. Since the dà °wn of the internet, à ° lot of businesses à °nd individuà °ls set à °bout està °blishing online businesses in à ° bid to à °mà °ss mà °ssive profits. However, à °ccording to Crà °ine (2001) since the yeà °r 2000 à °pproximà °tely 200 online businesses went out of the business à °ccounting for more thà °n 50% of business closures. This high fà °ilure rà °te is of concern to the business à °nd finà °ncià °l community; à °s such closures will à °lso à °ffect stock mà °rkets à °nd shà °res. Some of the online
Friday, August 23, 2019
Progressive Era Through the Great Depression Research Paper
Progressive Era Through the Great Depression - Research Paper Example However, we can say that the timing was a bit different across various nations. This was the most wide spread, deepest and longest depression within the twentieth century. This period of immense depression started in the United States starting with a fall in stock prices and the subsequent crash of the stock market and then spread to the other nations of the world (Bernanke, 2000). This period of depression had devastating effects in many nations that it hit characterizing a plunge in international trade, a rise in the unemployment levels with magnificent falls in prices and profits. The various developmental industries got hit hard causing collapse of some. Historical turning points of the enormous depression mainly concentrated on the measures that brought about a halt that reversed the trend and effects of the depression. In most nations, the acclaimed depression recovery started at around the year 1933 and took over a decade to return the economy back to normal and stability. Rooseveltââ¬â¢s introduction of the new deals policies was the first principal cause and accelerator of the recovery process. However, they lacked aggressiveness to return the economy back to normal. Such policies were inclusive of the banking act of 1935. The advent of the World War II also favored the reverse of depression and raise in the economy as government spending on the war stopped and the funds reverted to rising of the economy.
Thursday, August 22, 2019
Listening Journals 4 Essay Example | Topics and Well Written Essays - 1500 words
Listening Journals 4 - Essay Example Chapter 10 Further focus is given the role that the minority groups in America played in developing America in this chapter, which is named ââ¬Å"Pacific Crossings: From Japan to the Land of "Money Trees"â⬠the writer sees Japan as a model to exemplify the role played by the Japanese in the Pacific crossing. At some point, the author was critical of the Japanese people and labeled their action as being ill-planned because their migration had actually constituted a movement from a more blissful and independent place to one that was not that much promising for them. Page 341-350 In the opinion of the writer, the World War II was not something that the Americans were prepared for. However, as a means of stamping their ever growing global dominance down, they needed to partake. This generally brought a dilemma on them as a people, of which there was the need for them to solve. It is for this reason the topic ââ¬Å"World War II: American Dilemmasâ⬠is selected for this compone nt of the book. Various ways in which America played the racial card to ensure that the African American and Japanese America population were put before the war was discussed. Page 359-361 The early parts of this chapter compares the Chinese to the Japanese in what the writer refers to as silence move to distort the Japanese propaganda. This is because for all that while, there had been a perception that the Americans had put the Japanese in a corner where self freedom used to promote personal development was not possible. But given the fact that most Chinese Americans had overcome this labeling was a means of touting that propaganda. The theme of ââ¬Å"Chinese Americans: To "Silence the Distorted Japanese Propaganda"â⬠selected by the writer can therefore be said to have fitted the title much perfectly. Page 380-382 When America undertook the Hiroshima bombings during the final stages of the World War II in 1945, they tried to justify their actions. But in the perspective of the writer, this was just another move of Holocaust that was experienced in Germany by the Nazi government and other parts of Europe. It is not surprising therefore that the title for this section of the 14th chapter was ââ¬Å"A Holocaust Called Hiroshimaâ⬠. This is because the writer sees the move as a calculated attempt to suppress the Japanese as a people, rather than other explanations that were given. Page 402-404 As part of the broader chapter title which bordered on Clamors of Change, the writer limits these pages to a unit titled ââ¬Å"Asian Americans: A "Model Minority" for Blacks?â⬠The comparison of races continues in these pages of the book as the writer compares the Asian American population with the Black population who were predominantly made up of Africans. In the opinion of the writer, the Asian Americans were a perfect model minority, exemplifying how possible it was for any minority group to come out of the shells of oppression to see personal transfor mation and growth. Page 411-418 Vietnam is modeled as a nation that would not allow just any form of oppression to overcome it. This is because the nation rises high on its own defenses, exhibiting what the writer refers to as a Dragonââ¬â¢s Teeth of Fire. The writer believed that this was a situation with both merits and demerits. The merit was in the fact that a nation should just not succumb to oppression while the demerit was that
Subscribe to:
Comments (Atom)