oe, ## 2201 That every tongue says beauty should look so. ## 2202 ## 2203 CXXVIII ## 2204 ## 2205 How oft when thou, my music, music play'st, ## 2206 Upon that blessed wood whose motion sounds ## 2207 With thy sweet fingers when thou gently sway'st ## 2208 The wiry concord that mine ear confounds, ## 2209 Do I envy those jacks that nimble leap, ## 2210 To kiss the tender inward of thy hand, ## 2211 Whilst my poor lips which should that harvest reap, ## 2212 At the wood's boldness by thee blushing stand! ## 2213 To be so tickled, they would change their state ## 2214 And situation with those dancing chips, ## 2215 O'er whom thy fingers walk with gentle gait, ## 2216 Making dead wood more bless'd than living lips. ## 2217 Since saucy jacks so happy are in this, ## 2218 Give them thy fingers, me thy lips to kiss. ## 2219 ## 2220 CXXIX ## 2221 ## 2222 The expense of spirit in a waste of shame ## 2223 Is lust in action: and till action, lust ## 2224 Is perjur'd, murderous, bloody, full of blame, ## 2225 Savage, extreme, rude, cruel, not to trust; ## 2226 Enjoy'd no sooner but despised straight; ## 2227 Past reason hunted; and no sooner had, ## 2228 Past reason hated, as a swallow'd bait, ## 2229 On purpose laid to make the taker mad: ## 2230 Mad in pursuit and in possession so; ## 2231 Had, having, and in quest, to have extreme; ## 2232 A bliss in proof,-- and prov'd, a very woe; ## 2233 Before, a joy propos'd; behind a dream. ## 2234 All this the world well knows; yet none knows well ## 2235 To shun the heaven that leads men to this hell. ## 2236 ## 2237 CXXX ## 2238 ## 2239 My mistress' eyes are nothing like the sun; ## 2240 Coral is far more red, than her lips red: ## 2241 If snow be white, why then her breasts are dun; ## 2242 If hairs be wires, black wires grow on her head. ## 2243 I have seen roses damask'd, red and white, ## 2244 But no such roses see I in her cheeks; ## 2245 And in some perfumes is there more delight ## 2246 Than in the breath that from my mistress reeks. ## 2247 I love to hear her speak, yet well I know ## 2248 That music hath a far more pleasing sound: ## 2249 I grant I never saw a goddess go,-- ## 2250 My mistress, when she walks, treads on the ground: ## 2251 And yet by heaven, I think my love as rare, ## 2252 As any she belied with false compare. ## 2253 ## 2254 CXXXI ## 2255 ## 2256 Thou art as tyrannous, so as thou art, ## 2257 As those whose beauties proudly make them cruel; ## 2258 For well thou know'st to my dear doting heart ## 2259 Thou art the fairest and most precious jewel. ## 2260 Yet, in good faith, some say that thee behold, ## 2261 Thy face hath not the power to make love groan; ## 2262 To say they err I dare not be so bold, ## 2263 Although I swear it to myself alone. ## 2264 And to be sure that is not false I swear, ## 2265 A thousand groans, but thinking on thy face, ## 2266 One on another's neck, do witness bear ## 2267 Thy black is fairest in my judgment's place. ## 2268 In nothing art thou black save in thy deeds, ## 2269 And thence this slander, as I think, proceeds. ## 2270 ## 2271 CXXXII ## 2272 ## 2273 Thine eyes I love, and they, as pitying me, ## 2274 Knowing thy heart torment me with disdain, ## 2275 Have put on black and loving mourners be, ## 2276 Looking with pretty ruth upon my pain. ## 2277 And truly not the morning sun of heaven ## 2278 Better becomes the grey cheeks of the east, ## 2279 Nor that full star that ushers in the even, ## 2280 Doth half that glory to the sober west, ## 2281 As those two mourning eyes become thy face: ## 2282 O! let it then as well beseem thy heart ## 2283 To mourn for me since mourning doth thee grace, ## 2284 And suit thy pity like in every part. ## 2285 Then will I swear beauty herself is black, ## 2286 And all they foul that thy complexion lack. ## 2287 ## 2288 CXXXIII ## 2289 ## 2290 Beshrew that heart that makes my heart to groan ## 2291 For that deep wound it gives my friend and me! ## 2292 Is't not enough to torture me alone, ## 2293 But slave to slavery my sweet'st friend must be? ## 2294 Me from myself thy cruel eye hath taken, ## 2295 And my next self thou harder hast engross'd: ## 2296 Of him, myself, and thee I am forsaken; ## 2297 A torment thrice three-fold thus to be cross'd: ## 2298 Prison my heart in thy steel bosom's ward, ## 2299 But then my friend's heart let my poor heart bail; ## 2300 Whoe'er keeps me, let my heart be his guard; ## 2301 Thou canst not then use rigour in my jail: ## 2302 And yet thou wilt; for I, being pent in thee, ## 2303 Perforce am thine, and all that is in me. ## 2304 ## 2305 CXXXIV ## 2306 ## 2307 So, now I have confess'd that he is thine, ## 2308 And I my self am mortgag'd to thy will, ## 2309 Myself I'll forfeit, so that other mine ## 2310 Thou wilt restore to be my comfort still: ## 2311 But thou wilt not, nor he will not be free, ## 2312 For thou art covetous, and he is kind; ## 2313 He learn'd but surety-like to write for me, ## 2314 Under that bond that him as fast doth bind. ## 2315 The statute of thy beauty thou wilt take, ## 2316 Thou usurer, that putt'st forth all to use, ## 2317 And sue a friend came debtor for my sake; ## 2318 So him I lose through my unkind abuse. ## 2319 Him have I lost; thou hast both him and me: ## 2320 He pays the whole, and yet am I not free. ## 2321 ## 2322 CXXXV ## 2323 ## 2324 Whoever hath her wish, thou hast thy 'Will,' ## 2325 And 'Will' to boot, and 'Will' in over-plus; ## 2326 More than enough am I that vex'd thee still, ## 2327 To thy sweet will making addition thus. ## 2328 Wilt thou, whose will is large and spacious, ## 2329 Not once vouchsafe to hide my will in thine? ## 2330 Shall will in others seem right gracious, ## 2331 And in my will no fair acceptance shine? ## 2332 The sea, all water, yet receives rain still, ## 2333 And in abundance addeth to his store; ## 2334 So thou, being rich in 'Will,' add to thy 'Will' ## 2335 One will of mine, to make thy large will more. ## 2336 Let no unkind 'No' fair beseechers kill; ## 2337 Think all but one, and me in that one 'Will.' ## 2338 ## 2339 CXXXVI ## 2340 ## 2341 If thy soul check thee that I come so near, ## 2342 Swear to thy blind soul that I was thy 'Will', ## 2343 And will, thy soul knows, is admitted there; ## 2344 Thus far for love, my love-suit, sweet, fulfil. ## 2345 'Will', will fulfil the treasure of thy love, ## 2346 Ay, fill it full with wills, and my will one. ## 2347 In things of great receipt with ease we prove ## 2348 Among a number one is reckon'd none: ## 2349 Then in the number let me pass untold, ## 2350 Though in thy store's account I one must be; ## 2351 For nothing hold me, so it please thee hold ## 2352 That nothing me, a something sweet to thee: ## 2353 Make but my name thy love, and love that still, ## 2354 And then thou lov'st me for my name is 'Will.' ## 2355 ## 2356 CXXXVII ## 2357 ## 2358 Thou blind fool, Love, what dost thou to mine eyes, ## 2359 That they behold, and see not what they see? ## 2360 They know what beauty is, see where it lies, ## 2361 Yet what the best is take the worst to be. ## 2362 If eyes, corrupt by over-partial looks, ## 2363 Be anchor'd in the bay where all men ride, ## 2364 Why of eyes' falsehood hast thou forged hooks, ## 2365 Whereto the judgment of my heart is tied? ## 2366 Why should my heart think that a several plot, ## 2367 Which my heart knows the wide world's common place? ## 2368 Or mine eyes, seeing this, say this is not, ## 2369 To put fair truth upon so foul a face? ## 2370 In things right true my heart and eyes have err'd, ## 2371 And to this false plague are they now transferr'd. ## 2372 ## 2373 CXXXVIII ## 2374 ## 2375 When my love swears that she is made of truth, ## 2376 I do believe her though I know she lies, ## 2377 That she might think me some untutor'd youth, ## 2378 Unlearned in the world's false subtleties. ## 2379 Thus vainly thinking that she thinks me young, ## 2380 Although she knows my days are past the best, ## 2381 Simply I credit her false-speaking tongue: ## 2382 On both sides thus is simple truth suppressed: ## 2383 But wherefore says she not she is unjust? ## 2384 And wherefore say not I that I am old? ## 2385 O! love's best habit is in seeming trust, ## 2386 And age in love, loves not to have years told: ## 2387 Therefore I lie with her, and she with me, ## 2388 And in our faults by lies we flatter'd be. ## 2389 ## 2390 CXXXIX ## 2391 ## 2392 O! call not me to justify the wrong ## 2393 That thy unkindness lays upon my heart; ## 2394 Wound me not with thine eye, but with thy tongue: ## 2395 Use power with power, and slay me not by art, ## 2396 Tell me thou lov'st elsewhere; but in my sight, ## 2397 Dear heart, forbear to glance thine eye aside: ## 2398 What need'st thou wound with cunning, when thy might ## 2399 Is more than my o'erpress'd defence can bide? ## 2400 Let me excuse thee: ah! my love well knows ## 2401 Her pretty looks have been mine enemies; ## 2402 And therefore from my face she turns my foes, ## 2403 That they elsewhere might dart their injuries: ## 2404 Yet do not so; but since I am near slain, ## 2405 Kill me outright with looks, and rid my pain. ## 2406 ## 2407 ## 2408 CXL ## 2409 ## 2410 Be wise as thou art cruel; do not press ## 2411 My tongue-tied patience with too much disdain; ## 2412 Lest sorrow lend me words, and words express ## 2413 The manner of my pity-wanting pain. ## 2414 If I might teach thee wit, better it were, ## 2415 Though not to love, yet, love to tell me so;-- ## 2416 As testy sick men, when their deaths be near, ## 2417 No news but health from their physicians know;-- ## 2418 For, if I should despair, I should grow mad, ## 2419 And in my madness might speak ill of thee; ## 2420 Now this ill-wresting world is grown so bad, ## 2421 Mad slanderers by mad ears believed be. ## 2422 That I may not be so, nor thou belied, ## 2423 Bear thine eyes straight, though thy proud heart go wide. ## 2424 ## 2425 CXLI ## 2426 ## 2427 In faith I do not love thee with mine eyes, ## 2428 For they in thee a thousand errors note; ## 2429 But 'tis my heart that loves what they despise, ## 2430 Who, in despite of view, is pleased to dote. ## 2431 Nor are mine ears with thy tongue's tune delighted; ## 2432 Nor tender feeling, to base touches prone, ## 2433 Nor taste, nor smell, desire to be invited ## 2434 To any sensual feast with thee alone: ## 2435 But my five wits nor my five senses can ## 2436 Dissuade one foolish heart from serving thee, ## 2437 Who leaves unsway'd the likeness of a man, ## 2438 Thy proud heart's slave and vassal wretch to be: ## 2439 Only my plague thus far I count my gain, ## 2440 That she that makes me sin awards me pain. ## 2441 ## 2442 CXLII ## 2443 ## 2444 Love is my sin, and thy dear virtue hate, ## 2445 Hate of my sin, grounded on sinful loving: ## 2446 O! but with mine compare thou thine own state, ## 2447 And thou shalt find it merits not reproving; ## 2448 Or, if it do, not from those lips of thine, ## 2449 That have profan'd their scarlet ornaments ## 2450 And seal'd false bonds of love as oft as mine, ## 2451 Robb'd others' beds' revenues of their rents. ## 2452 Be it lawful I love thee, as thou lov'st those ## 2453 Whom thine eyes woo as mine importune thee: ## 2454 Root pity in thy heart, that, when it grows, ## 2455 Thy pity may deserve to pitied be. ## 2456 If thou dost seek to have what thou dost hide, ## 2457 By self-example mayst thou be denied! ## 2458 ## 2459 CXLIII ## 2460 ## 2461 Lo, as a careful housewife runs to catch ## 2462 One of her feather'd creatures broke away, ## 2463 Sets down her babe, and makes all swift dispatch ## 2464 In pursuit of the thing she would have stay; ## 2465 Whilst her neglected child holds her in chase, ## 2466 Cries to catch her whose busy care is bent ## 2467 To follow that which flies before her face, ## 2468 Not prizing her poor infant's discontent; ## 2469 So runn'st thou after that which flies from thee, ## 2470 Whilst I thy babe chase thee afar behind; ## 2471 But if thou catch thy hope, turn back to me, ## 2472 And play the mother's part, kiss me, be kind; ## 2473 So will I pray that thou mayst have thy 'Will,' ## 2474 If thou turn back and my loud crying still. ## 2475 ## 2476 CXLIV ## 2477 ## 2478 Two loves I have of comfort and despair, ## 2479 Which like two spirits do suggest me still: ## 2480 The better angel is a man right fair, ## 2481 The worser spirit a woman colour'd ill. ## 2482 To win me soon to hell, my female evil, ## 2483 Tempteth my better angel from my side, ## 2484 And would corrupt my saint to be a devil, ## 2485 Wooing his purity with her foul pride. ## 2486 And whether that my angel be turn'd fiend, ## 2487 Suspect I may, yet not directly tell; ## 2488 But being both from me, both to each friend, ## 2489 I guess one angel in another's hell: ## 2490 Yet this shall I ne'er know, but live in doubt, ## 2491 Till my bad angel fire my good one out. ## 2492 ## 2493 CXLV ## 2494 ## 2495 Those lips that Love's own hand did make, ## 2496 Breathed forth the sound that said 'I hate', ## 2497 To me that languish'd for her sake: ## 2498 But when she saw my woeful state, ## 2499 Straight in her heart did mercy come, ## 2500 Chiding that tongue that ever sweet ## 2501 Was us'd in giving gentle doom; ## 2502 And taught it thus anew to greet; ## 2503 'I hate' she alter'd with an end, ## 2504 That followed it as gentle day, ## 2505 Doth follow night, who like a fiend ## 2506 From heaven to hell is flown away. ## 2507 'I hate', from hate away she threw, ## 2508 And sav'd my life, saying 'not you'. ## 2509 ## 2510 CXLVI ## 2511 ## 2512 Poor soul, the centre of my sinful earth, ## 2513 My sinful earth these rebel powers array, ## 2514 Why dost thou pine within and suffer dearth, ## 2515 Painting thy outward walls so costly gay? ## 2516 Why so large cost, having so short a lease, ## 2517 Dost thou upon thy fading mansion spend? ## 2518 Shall worms, inheritors of this excess, ## 2519 Eat up thy charge? Is this thy body's end? ## 2520 Then soul, live thou upon thy servant's loss, ## 2521 And let that pine to aggravate thy store; ## 2522 Buy terms divine in selling hours of dross; ## 2523 Within be fed, without be rich no more: ## 2524 So shall thou feed on Death, that feeds on men, ## 2525 And Death once dead, there's no more dying then. ## 2526 ## 2527 CXLVII ## 2528 ## 2529 My love is as a fever longing still, ## 2530 For that which longer nurseth the disease; ## 2531 Feeding on that which doth preserve the ill, ## 2532 The uncertain sickly appetite to please. ## 2533 My reason, the physician to my love, ## 2534 Angry that his prescriptions are not kept, ## 2535 Hath left me, and I desperate now approve ## 2536 Desire is death, which physic did except. ## 2537 Past cure I am, now Reason is past care, ## 2538 And frantic-mad with evermore unrest; ## 2539 My thoughts and my discourse as madmen's are, ## 2540 At random from the truth vainly express'd; ## 2541 For I have sworn thee fair, and thought thee bright, ## 2542 Who art as black as hell, as dark as night. ## 2543 ## 2544 CXLVIII ## 2545 ## 2546 O me! what eyes hath Love put in my head, ## 2547 Which have no correspondence with true sight; ## 2548 Or, if they have, where is my judgment fled, ## 2549 That censures falsely what they see aright? ## 2550 If that be fair whereon my false eyes dote, ## 2551 What means the world to say it is not so? ## 2552 If it be not, then love doth well denote ## 2553 Love's eye is not so true as all men's: no, ## 2554 How can it? O! how can Love's eye be true, ## 2555 That is so vexed with watching and with tears? ## 2556 No marvel then, though I mistake my view; ## 2557 The sun itself sees not, till heaven clears. ## 2558 O cunning Love! with tears thou keep'st me blind, ## 2559 Lest eyes well-seeing thy foul faults should find. ## 2560 ## 2561 CXLIX ## 2562 ## 2563 Canst thou, O cruel! say I love thee not, ## 2564 When I against myself with thee partake? ## 2565 Do I not think on thee, when I forgot ## 2566 Am of my self, all tyrant, for thy sake? ## 2567 Who hateth thee that I do call my friend, ## 2568 On whom frown'st thou that I do fawn upon, ## 2569 Nay, if thou lour'st on me, do I not spend ## 2570 Revenge upon myself with present moan? ## 2571 What merit do I in my self respect, ## 2572 That is so proud thy service to despise, ## 2573 When all my best doth worship thy defect, ## 2574 Commanded by the motion of thine eyes? ## 2575 But, love, hate on, for now I know thy mind; ## 2576 Those that can see thou lov'st, and I am blind. ## 2577 ## 2578 CL ## 2579 ## 2580 O! from what power hast thou this powerful might, ## 2581 With insufficiency my heart to sway? ## 2582 To make me give the lie to my true sight, ## 2583 And swear that brightness doth not grace the day? ## 2584 Whence hast thou this becoming of things ill, ## 2585 That in the very refuse of thy deeds ## 2586 There is such strength and warrantise of skill, ## 2587 That, in my mind, thy worst all best exceeds? ## 2588 Who taught thee how to make me love thee more, ## 2589 The more I hear and see just cause of hate? ## 2590 O! though I love what others do abhor, ## 2591 With others thou shouldst not abhor my state: ## 2592 If thy unworthiness rais'd love in me, ## 2593 More worthy I to be belov'd of thee. ## 2594 ## 2595 CLI ## 2596 ## 2597 Love is too young to know what conscience is, ## 2598 Yet who knows not conscience is born of love? ## 2599 Then, gentle cheater, urge not my amiss, ## 2600 Lest guilty of my faults thy sweet self prove: ## 2601 For, thou betraying me, I do betray ## 2602 My nobler part to my gross body's treason; ## 2603 My soul doth tell my body that he may ## 2604 Triumph in love; flesh stays no farther reason, ## 2605 But rising at thy name doth point out thee, ## 2606 As his triumphant prize. Proud of this pride, ## 2607 He is contented thy poor drudge to be, ## 2608 To stand in thy affairs, fall by thy side. ## 2609 No want of conscience hold it that I call ## 2610 Her 'love,' for whose dear love I rise and fall. ## 2611 ## 2612 CLII ## 2613 ## 2614 In loving thee thou know'st I am forsworn, ## 2615 But thou art twice forsworn, to me love swearing; ## 2616 In act thy bed-vow broke, and new faith torn, ## 2617 In vowing new hate after new love bearing: ## 2618 But why of two oaths' breach do I accuse thee, ## 2619 When I break twenty? I am perjur'd most; ## 2620 For all my vows are oaths but to misuse thee, ## 2621 And all my honest faith in thee is lost: ## 2622 For I have sworn deep oaths of thy deep kindness, ## 2623 Oaths of thy love, thy truth, thy constancy; ## 2624 And, to enlighten thee, gave eyes to blindness, ## 2625 Or made them swear against the thing they see; ## 2626 For I have sworn thee fair; more perjur'd I, ## 2627 To swear against the truth so foul a lie! ## 2628 ## 2629 CLIII ## 2630 ## 2631 Cupid laid by his brand and fell asleep: ## 2632 A maid of Dian's this advantage found, ## 2633 And his love-kindling fire did quickly steep ## 2634 In a cold valley-fountain of that ground; ## 2635 Which borrow'd from this holy fire of Love, ## 2636 A dateless lively heat, still to endure, ## 2637 And grew a seeting bath, which yet men prove ## 2638 Against strange maladies a sovereign cure. ## 2639 But at my mistress' eye Love's brand new-fired, ## 2640 The boy for trial needs would touch my breast; ## 2641 I, sick withal, the help of bath desired, ## 2642 And thither hied, a sad distemper'd guest, ## 2643 But found no cure, the bath for my help lies ## 2644 Where Cupid got new fire; my mistress' eyes. ## 2645 ## 2646 CLIV ## 2647 ## 2648 The little Love-god lying once asleep, ## 2649 Laid by his side his heart-inflaming brand, ## 2650 Whilst many nymphs that vow'd chaste life to keep ## 2651 Came tripping by; but in her maiden hand ## 2652 The fairest votary took up that fire ## 2653 Which many legions of true hearts had warm'd; ## 2654 And so the general of hot desire ## 2655 Was, sleeping, by a virgin hand disarm'd. ## 2656 This brand she quenched in a cool well by, ## 2657 Which from Love's fire took heat perpetual, ## 2658 Growing a bath and healthful remedy, ## 2659 For men diseas'd; but I, my mistress' thrall, ## 2660 Came there for cure and this by that I prove, ## 2661 Love's fire heats water, water cools not love. ## 2662 ## 2663 ## 2664 ## 2665 ## 2666 ## 2667 ## 2668 ## 2669 ## 2670 ## 2671 ## 2672 End of Project Gutenberg's Shakespeare's Sonnets, by William Shakespeare ## 2673 ## 2674 *** END OF THIS PROJECT GUTENBERG EBOOK SHAKESPEARE'S SONNETS *** ## 2675 ## 2676 ***** This file should be named 1041.txt or 1041.zip ***** ## 2677 This and all associated files of various formats will be found in: ## 2678 http://www.gutenberg.org/1/0/4/1041/ ## 2679 ## 2680 Produced by Joseph S. Miller and Embry-Riddle Aeronautical ## 2681 University Library. HTML version by Al Haines. ## 2682 ## 2683 ## 2684 Updated editions will replace the previous one--the old editions ## 2685 will be renamed. ## 2686 ## 2687 Creating the works from public domain print editions means that no ## 2688 one owns a United States copyright in these works, so the Foundation ## 2689 (and you!) can copy and distribute it in the United States without ## 2690 permission and without paying copyright royalties. Special rules, ## 2691 set forth in the General Terms of Use part of this license, apply to ## 2692 copying and distributing Project Gutenberg-tm electronic works to ## 2693 protect the PROJECT GUTENBERG-tm concept and trademark. Project ## 2694 Gutenberg is a registered trademark, and may not be used if you ## 2695 charge for the eBooks, unless you receive specific permission. If you ## 2696 do not charge anything for copies of this eBook, complying with the ## 2697 rules is very easy. You may use this eBook for nearly any purpose ## 2698 such as creation of derivative works, reports, performances and ## 2699 research. They may be modified and printed and given away--you may do ## 2700 practically ANYTHING with public domain eBooks. Redistribution is ## 2701 subject to the trademark license, especially commercial ## 2702 redistribution. ## 2703 ## 2704 ## 2705 ## 2706 *** START: FULL LICENSE *** ## 2707 ## 2708 THE FULL PROJECT GUTENBERG LICENSE ## 2709 PLEASE READ THIS BEFORE YOU DISTRIBUTE OR USE THIS WORK ## 2710 ## 2711 To protect the Project Gutenberg-tm mission of promoting the free ## 2712 distribution of electronic works, by using or distributing this work ## 2713 (or any other work associated in any way with the phrase "Project ## 2714 Gutenberg"), you agree to comply with all the terms of the Full Project ## 2715 Gutenberg-tm License available with this file or online at ## 2716 www.gutenberg.org/license. ## 2717 ## 2718 ## 2719 Section 1. General Terms of Use and Redistributing Project Gutenberg-tm ## 2720 electronic works ## 2721 ## 2722 1.A. By reading or using any part of this Project Gutenberg-tm ## 2723 electronic work, you indicate that you have read, understand, agree to ## 2724 and accept all the terms of this license and intellectual property ## 2725 (trademark/copyright) agreement. If you do not agree to abide by all ## 2726 the terms of this agreement, you must cease using and return or destroy ## 2727 all copies of Project Gutenberg-tm electronic works in your possession. ## 2728 If you paid a fee for obtaining a copy of or access to a Project ## 2729 Gutenberg-tm electronic work and you do not agree to be bound by the ## 2730 terms of this agreement, you may obtain a refund from the person or ## 2731 entity to whom you paid the fee as set forth in paragraph 1.E.8. ## 2732 ## 2733 1.B. "Project Gutenberg" is a registered trademark. It may only be ## 2734 used on or associated in any way with an electronic work by people who ## 2735 agree to be bound by the terms of this agreement. There are a few ## 2736 things that you can do with most Project Gutenberg-tm electronic works ## 2737 even without complying with the full terms of this agreement. See ## 2738 paragraph 1.C below. There are a lot of things you can do with Project ## 2739 Gutenberg-tm electronic works if you follow the terms of this agreement ## 2740 and help preserve free future access to Project Gutenberg-tm electronic ## 2741 works. See paragraph 1.E below. ## 2742 ## 2743 1.C. The Project Gutenberg Literary Archive Foundation ("the Foundation" ## 2744 or PGLAF), owns a compilation copyright in the collection of Project ## 2745 Gutenberg-tm electronic works. Nearly all the individual works in the ## 2746 collection are in the public domain in the United States. If an ## 2747 individual work is in the public domain in the United States and you are ## 2748 located in the United States, we do not claim a right to prevent you from ## 2749 copying, distributing, performing, displaying or creating derivative ## 2750 works based on the work as long as all references to Project Gutenberg ## 2751 are removed. Of course, we hope that you will support the Project ## 2752 Gutenberg-tm mission of promoting free access to electronic works by ## 2753 freely sharing Project Gutenberg-tm works in compliance with the terms of ## 2754 this agreement for keeping the Project Gutenberg-tm name associated with ## 2755 the work. You can easily comply with the terms of this agreement by ## 2756 keeping this work in the same format with its attached full Project ## 2757 Gutenberg-tm License when you share it without charge with others. ## 2758 ## 2759 1.D. The copyright laws of the place where you are located also govern ## 2760 what you can do with this work. Copyright laws in most countries are in ## 2761 a constant state of change. If you are outside the United States, check ## 2762 the laws of your country in addition to the terms of this agreement ## 2763 before downloading, copying, displaying, performing, distributing or ## 2764 creating derivative works based on this work or any other Project ## 2765 Gutenberg-tm work. The Foundation makes no representations concerning ## 2766 the copyright status of any work in any country outside the United ## 2767 States. ## 2768 ## 2769 1.E. Unless you have removed all references to Project Gutenberg: ## 2770 ## 2771 1.E.1. The following sentence, with active links to, or other immediate ## 2772 access to, the full Project Gutenberg-tm License must appear prominently ## 2773 whenever any copy of a Project Gutenberg-tm work (any work on which the ## 2774 phrase "Project Gutenberg" appears, or with which the phrase "Project ## 2775 Gutenberg" is associated) is accessed, displayed, performed, viewed, ## 2776 copied or distributed: ## 2777 ## 2778 This eBook is for the use of anyone anywhere at no cost and with ## 2779 almost no restrictions whatsoever. You may copy it, give it away or ## 2780 re-use it under the terms of the Project Gutenberg License included ## 2781 with this eBook or online at www.gutenberg.org ## 2782 ## 2783 1.E.2. If an individual Project Gutenberg-tm electronic work is derived ## 2784 from the public domain (does not contain a notice indicating that it is ## 2785 posted with permission of the copyright holder), the work can be copied ## 2786 and distributed to anyone in the United States without paying any fees ## 2787 or charges. If you are redistributing or providing access to a work ## 2788 with the phrase "Project Gutenberg" associated with or appearing on the ## 2789 work, you must comply either with the requirements of paragraphs 1.E.1 ## 2790 through 1.E.7 or obtain permission for the use of the work and the ## 2791 Project Gutenberg-tm trademark as set forth in paragraphs 1.E.8 or ## 2792 1.E.9. ## 2793 ## 2794 1.E.3. If an individual Project Gutenberg-tm electronic work is posted ## 2795 with the permission of the copyright holder, your use and distribution ## 2796 must comply with both paragraphs 1.E.1 through 1.E.7 and any additional ## 2797 terms imposed by the copyright holder. Additional terms will be linked ## 2798 to the Project Gutenberg-tm License for all works posted with the ## 2799 permission of the copyright holder found at the beginning of this work. ## 2800 ## 2801 1.E.4. Do not unlink or detach or remove the full Project Gutenberg-tm ## 2802 License terms from this work, or any files containing a part of this ## 2803 work or any other work associated with Project Gutenberg-tm. ## 2804 ## 2805 1.E.5. Do not copy, display, perform, distribute or redistribute this ## 2806 electronic work, or any part of this electronic work, without ## 2807 prominently displaying the sentence set forth in paragraph 1.E.1 with ## 2808 active links or immediate access to the full terms of the Project ## 2809 Gutenberg-tm License. ## 2810 ## 2811 1.E.6. You may convert to and distribute this work in any binary, ## 2812 compressed, marked up, nonproprietary or proprietary form, including any ## 2813 word processing or hypertext form. However, if you provide access to or ## 2814 distribute copies of a Project Gutenberg-tm work in a format other than ## 2815 "Plain Vanilla ASCII" or other format used in the official version ## 2816 posted on the official Project Gutenberg-tm web site (www.gutenberg.org), ## 2817 you must, at no additional cost, fee or expense to the user, provide a ## 2818 copy, a means of exporting a copy, or a means of obtaining a copy upon ## 2819 request, of the work in its original "Plain Vanilla ASCII" or other ## 2820 form. Any alternate format must include the full Project Gutenberg-tm ## 2821 License as specified in paragraph 1.E.1. ## 2822 ## 2823 1.E.7. Do not charge a fee for access to, viewing, displaying, ## 2824 performing, copying or distributing any Project Gutenberg-tm works ## 2825 unless you comply with paragraph 1.E.8 or 1.E.9. ## 2826 ## 2827 1.E.8. You may charge a reasonable fee for copies of or providing ## 2828 access to or distributing Project Gutenberg-tm electronic works provided ## 2829 that ## 2830 ## 2831 - You pay a royalty fee of 20% of the gross profits you derive from ## 2832 the use of Project Gutenberg-tm works calculated using the method ## 2833 you already use to calculate your applicable taxes. The fee is ## 2834 owed to the owner of the Project Gutenberg-tm trademark, but he ## 2835 has agreed to donate royalties under this paragraph to the ## 2836 Project Gutenberg Literary Archive Foundation. Royalty payments ## 2837 must be paid within 60 days following each date on which you ## 2838 prepare (or are legally required to prepare) your periodic tax ## 2839 returns. Royalty payments should be clearly marked as such and ## 2840 sent to the Project Gutenberg Literary Archive Foundation at the ## 2841 address specified in Section 4, "Information about donations to ## 2842 the Project Gutenberg Literary Archive Foundation." ## 2843 ## 2844 - You provide a full refund of any money paid by a user who notifies ## 2845 you in writing (or by e-mail) within 30 days of receipt that s/he ## 2846 does not agree to the terms of the full Project Gutenberg-tm ## 2847 License. You must require such a user to return or ## 2848 destroy all copies of the works possessed in a physical medium ## 2849 and discontinue all use of and all access to other copies of ## 2850 Project Gutenberg-tm works. ## 2851 ## 2852 - You provide, in accordance with paragraph 1.F.3, a full refund of any ## 2853 money paid for a work or a replacement copy, if a defect in the ## 2854 electronic work is discovered and reported to you within 90 days ## 2855 of receipt of the work. ## 2856 ## 2857 - You comply with all other terms of this agreement for free ## 2858 distribution of Project Gutenberg-tm works. ## 2859 ## 2860 1.E.9. If you wish to charge a fee or distribute a Project Gutenberg-tm ## 2861 electronic work or group of works on different terms than are set ## 2862 forth in this agreement, you must obtain permission in writing from ## 2863 both the Project Gutenberg Literary Archive Foundation and Michael ## 2864 Hart, the owner of the Project Gutenberg-tm trademark. Contact the ## 2865 Foundation as set forth in Section 3 below. ## 2866 ## 2867 1.F. ## 2868 ## 2869 1.F.1. Project Gutenberg volunteers and employees expend considerable ## 2870 effort to identify, do copyright research on, transcribe and proofread ## 2871 public domain works in creating the Project Gutenberg-tm ## 2872 collection. Despite these efforts, Project Gutenberg-tm electronic ## 2873 works, and the medium on which they may be stored, may contain ## 2874 "Defects," such as, but not limited to, incomplete, inaccurate or ## 2875 corrupt data, transcription errors, a copyright or other intellectual ## 2876 property infringement, a defective or damaged disk or other medium, a ## 2877 computer virus, or computer codes that damage or cannot be read by ## 2878 your equipment. ## 2879 ## 2880 1.F.2. LIMITED WARRANTY, DISCLAIMER OF DAMAGES - Except for the "Right ## 2881 of Replacement or Refund" described in paragraph 1.F.3, the Project ## 2882 Gutenberg Literary Archive Foundation, the owner of the Project ## 2883 Gutenberg-tm trademark, and any other party distributing a Project ## 2884 Gutenberg-tm electronic work under this agreement, disclaim all ## 2885 liability to you for damages, costs and expenses, including legal ## 2886 fees.   LIMITED RIGHT OF REPLACEMENT OR REFUND - If you discover a ## 2895 defect in this electronic work within 90 days of receiving it, you can ## 2896 receive a refund of the money (if any) you paid for it by sending a ## 2897 written explanation to the person you received the work from. If you ## 2898 received the work on a physical medium, you must return the medium with ## 2899 your written explanation. The person or entity that provided you with ## 2900 the defective work may elect to provide a replacement copy in lieu of a ## 2901 refund. If you received the work electronically, the person or entity ## 2902 providing it to you may choose to give you a second opportunity to ## 2903 receive the work electronically in lieu of a refund. If the second copy ## 2904 is also defective, you may demand a refund in writing without further ## 2905 opportunities to fix the problem. ## 2906 ## 2907 1.F.4. Except for the limited right of replacement or refund set forth ## 2908 in paragraph 1.F.3, this work is provided to you 'AS-IS', WITH NO OTHER ## 2909 WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ## 2910 WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PURPOSE. ## 2911 ## 2912 1.F.5. Some states do not allow disclaimers of certain implied ## 2913 warranties or the exclusion or limitation of certain types of damages. ## 2914 If any disclaimer or limitation set forth in this agreement violates the ## 2915 law of the state applicable to this agreement, the agreement shall be ## 2916 interpreted to make the maximum disclaimer or limitation permitted by ## 2917 the applicable state law. The invalidity or unenforceability of any ## 2918 provision of this agreement shall not void the remaining provisions. ## 2919 ## 2920 1.F.6. INDEMNITY - You agree to indemnify and hold the Foundation, the ## 2921 trademark owner, any agent or employee of the Foundation, anyone ## 2922 providing copies of Project Gutenberg-tm electronic works in accordance ## 2923 with this agreement, and any volunteers associated with the production, ## 2924 promotion and distribution of Project Gutenberg-tm electronic works, ## 2925 harmless from all liability, costs and expenses, including legal fees, ## 2926 that arise directly or indirectly from any of the following which you do ## 2927 or cause to occur: (a) distribution of this or any Project Gutenberg-tm ## 2928 work, (b) alteration, modification, or additions or deletions to any ## 2929 Project Gutenberg-tm work, and (c) any Defect you cause. ## 2930 ## 2931 ## 2932 Section 2. Information about the Mission of Project Gutenberg-tm ## 2933 ## 2934 Project Gutenberg-tm is synonymous with the free distribution of ## 2935 electronic works in formats readable by the widest variety of computers ## 2936 including obsolete, old, middle-aged and new computers. It exists ## 2937 because of the efforts of hundreds of volunteers and donations from ## 2938 people in all walks of life. ## 2939 ## 2940 Volunteers and financial support to provide volunteers with the ## 2941 assistance they need are critical to reaching Project Gutenberg-tm's ## 2942 goals and ensuring that the Project Gutenberg-tm collection will ## 2943 remain freely available for generations to come. In 2001, the Project ## 2944 Gutenberg Literary Archive Foundation was created to provide a secure ## 2945 and permanent future for Project Gutenberg-tm and future generations. ## 2946 To learn more about the Project Gutenberg Literary Archive Foundation ## 2947 and how your efforts and donations can help, see Sections 3 and 4 ## 2948 and the Foundation information page at www.gutenberg.org ## 2949 ## 2950 ## 2951 Section 3. Information about the Project Gutenberg Literary Archive ## 2952 Foundation ## 2953 ## 2954 The Project Gutenberg Literary Archive Foundation is a non profit ## 2955 501(c)(3) educational corporation organized under the laws of the ## 2956 state of Mississippi and granted tax exempt status by the Internal ## 2957 Revenue Service. The Foundation's EIN or federal tax identification ## 2958 number is 64-6221541. Contributions to the Project Gutenberg ## 2959 Literary Archive Foundation are tax deductible to the full extent ## 2960 permitted by U.S. federal laws and your state's laws. ## 2961 ## 2962 The Foundation's principal office is located at 4557 Melan Dr. S. ## 2963 Fairbanks, AK, 99712., but its volunteers and employees are scattered ## 2964 throughout numerous locations. Its business office is located at 809 ## 2965 North 1500 West, Salt Lake City, UT 84116,<PHONE_NUMBER>. Email ## 2966 contact links and up to date contact information can be found at the ## 2967 Foundation's web site and official page at www.gutenberg.org/contact ## 2968 ## 2969 For additional contact information: ## 2970 Dr. Gregory B. Newby ## 2971 Chief Executive and Director ## 2972<EMAIL_ADDRESS>## 2973 ## 2974 Section 4. Information about Donations to the Project Gutenberg ## 2975 Literary Archive Foundation ## 2976 ## 2977 Project Gutenberg-tm depends upon and cannot survive without wide ## 2978 spread public support and donations to carry out its mission of ## 2979 increasing the number of public domain and licensed works that can be ## 2980 freely distributed in machine readable form accessible by the widest ## 2981 array of equipment including outdated equipment. Many small donations ## 2982 ($1 to $5,000) are particularly important to maintaining tax exempt ## 2983 status with the IRS. ## 2984 ## 2985 The Foundation is committed to complying with the laws regulating ## 2986 charities and charitable donations in all 50 states of the United ## 2987 States. Compliance requirements are not uniform and it takes a ## 2988 considerable effort, much paperwork and many fees to meet and keep up ## 2989 with these requirements. We do not solicit donations in locations ## 2990 where we have not received written confirmation of compliance. To ## 2991 SEND DONATIONS or determine the status of compliance for any ## 2992 particular state visit www.gutenberg.org/donate ## 2993 ## 2994 While we cannot and do not solicit contributions from states where we ## 2995 have not met the solicitation requirements, we know of no prohibition ## 2996 against accepting unsolicited donations from donors in such states who ## 2997 approach us with offers to donate. ## 2998 ## 2999 International donations are gratefully accepted, but we cannot make ## 3000 any statements concerning tax treatment of donations received from ## 3001 outside the United States. U.S. laws alone swamp our small staff. ## 3002 ## 3003 Please check the Project Gutenberg Web pages for current donation ## 3004 methods and addresses. Donations are accepted in a number of other ## 3005 ways including checks, online payments and credit card donations. ## 3006 To donate, please visit: www.gutenberg.org/donate ## 3007 ## 3008 ## 3009 Section 5. General Information About Project Gutenberg-tm electronic ## 3010 works. ## 3011 ## 3012 Professor Michael S. Hart was the originator of the Project Gutenberg-tm ## 3013 concept of a library of electronic works that could be freely shared ## 3014 with anyone. For forty years, he produced and distributed Project ## 3015 Gutenberg-tm eBooks with only a loose network of volunteer support. ## 3016 ## 3017 Project Gutenberg-tm eBooks are often created from several printed ## 3018 editions, all of which are confirmed as Public Domain in the U.S. ## 3019 unless a copyright notice is included. Thus, we do not necessarily ## 3020 keep eBooks in compliance with any particular paper edition. ## 3021 ## 3022 Most people start at our Web site which has the main PG search facility: ## 3023 ## 3024 www.gutenberg.org ## 3025 ## 3026 This Web site includes information about Project Gutenberg-tm, ## 3027 including how to make donations to the Project Gutenberg Literary ## 3028 Archive Foundation, how to help produce our new eBooks, and how to ## 3029 subscribe to our email newsletter to hear about new eBooks. ``` --- # Reading text (cont.) ### Scroll: more and less The `more` and `less` commands provide extra functionality over `cat`. For example, they allow you to move through long text one page at a time. - Try this yourself with `$ more examples/sonnets.txt` - You can move forward and back using the "f" and "b" keys, and quit by hitting "q". ### Preview: head and tail The `head` and `tail` commands let you limit yourself to a preview of the text, down to a specified number of rows. (The default is 10 rows if you don't specify a number.) ```bash $ head -n 3 examples/sonnets.txt ## First 3 rows $ # head examples/sonnets.txt ## First 10 rows (default) ``` ``` ## The Project Gutenberg EBook of Shakespeare's Sonnets, by William Shakespeare ## ## This eBook is for the use of anyone anywhere at no cost and with ``` --- # Reading text (cont.) ### Preview: head and tail (cont.) `tail` works very similarly to `head`, but starting from the bottom. For example, we can see the very last row of a file as follows ```bash $ tail -n 1 examples/sonnets.txt ## Last row ``` ``` ## subscribe to our email newsletter to hear about new eBooks. ``` -- However, there's one other neat option that I want to show you. By using the `-n +N` option, we can specify that we want to preview all lines starting from row N *and after*. E.g. ```bash $ tail -n +3024 examples/sonnets.txt ## Show everything from line 3024 ``` ``` ## www.gutenberg.org ## ## This Web site includes information about Project Gutenberg-tm, ## including how to make donations to the Project Gutenberg Literary ## Archive Foundation, how to help produce our new eBooks, and how to ## subscribe to our email newsletter to hear about new eBooks. ``` --- # Find patterns: grep To find patterns in text, we can use regular expression-type matching with `grep`. For example, say we want to find the famous opening line to Shakespeare's [Sonnet 18](https://en.wikipedia.org/wiki/Sonnet_18). - I'm going to include the `-n` ("number") flag to get the line that it occurs on. ```bash $ grep -n "Shall I compare thee" examples/sonnets.txt ``` ``` ## 336: Shall I compare thee to a summer's day? ``` -- By default, `grep` returns all matching patterns. - What happens if you run `$ grep -n "summer" examples/sonnets.txt`? - Or, for that matter, `$ grep -n "the" examples/sonnets.txt`? --- # Find patterns: grep (cont.) Note that `grep` can be used to identify patterns in a group files (e.g. within a directory) too. - This is particularly useful if you are trying to identify a file that contain, say, a function name. Here's a simple example: Which days will I eat pasta this week? - I'm using the `R` (recursive) and `l` (just list the files; don't print the output) flags. ```bash $ grep -Rl "pasta" examples/meals ``` ``` ## examples/meals/monday.csv ``` -- What about muesli? And pizza? -- Take a look at the `grep` man or cheat file for other useful examples and flags (e.g. `-i` for ignore case). PS — Another cool (and very fast) shell utility along these lines is [the silver searcher](https://github.com/ggreer/the_silver_searcher). Check it out. --- # Manipulate text: sed and awk There are two main commands for manipulating text in the shell, namely `sed` and `awk`. - Both of these are very powerful and flexible (`awk` is particularly good with CSVs). I'm going to show two basic examples without going into depth, but I strongly encourage you to explore more on your own. (Mac users: See [here](https://unix.stackexchange.com/questions/13711/differences-between-sed-on-mac-osx-and-other-standard-sed).) -- **Example 1.**  Find and count the 10 most commonly used words in Shakespeare's Sonnets. - Note: We'll learn more about the pipe operator (`|`) in a few slides. ```bash $ sed -e 's/\s/\n/g' < examples/sonnets.txt | sort | uniq -c | sort -nr | head -10 ``` ``` ## 8884 ## 513 the ## 456 of ## 401 to ## 341 my ## 338 in ## 327 I ## 316 and ## 252 thy ## 248 that ``` -- </br> PS — You can also use double quotes (") instead of single ones (') for `sed` and `awk` commands. This can sometimes run you into trouble with special symbols or patterns in the text, though. (Mostly, I want you to be mindful of accidental matching or closing quotation mark pairs.) --- # Sorting and removing duplicates: sort We can remove duplicate lines in various ways in Bash, but I'll demonstrate using `sort`. ```bash $ cat examples/reps.txt ``` ``` ## Sometimes I repeat myself. ## Sometimes I repeat myself. ## Other times not so much. ## But I try to be good. ## Other times not so much. ## Sometimes I repeat myself. ``` There's a fair bit of repetition in this file (and a double entendre). Let's fix that. - Note the use of the `-u` ("unique") flag to remove duplicates. I'll also add a `-r` ("reverse") flag, but only because `sort` orders alphabetically and this makes less sense for this simple example. ```bash $ sort -ur examples/reps.txt ``` ``` ## Sometimes I repeat myself. ## Other times not so much. ## But I try to be good. ``` --- class: inverse, center, middle name: pipes # Redirecting and pipes <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # Redirect: > You can send output from the shell to a file using the redirect operator `>` For example, let's print a message to the shell using the `echo` command. ```bash $ echo "At first, I was afraid, I was petrified" ``` ``` ## At first, I was afraid, I was petrified ``` -- If you wanted to save this output to a file, you need simply redirect it to the filename of choice. ```bash $ echo "At first, I was afraid, I was petrified" > survive.txt $ find survive.txt ## Show that it now exists ``` ``` ## survive.txt ``` --- # Redirect: > (cont.) If you want to *append* text to an existing file, then you should use `>>`. - Using `>` will try to overwrite the existing file contents. ```bash $ echo "'Kept thinking I could never live without you by my side" >> survive.txt $ cat survive.txt ``` ``` ## At first, I was afraid, I was petrified ## 'Kept thinking I could never live without you by my side ``` -- </br> (Don't be shy. You can hum the rest of the song to yourself now.) -- </br> Aside: I often use this sequence when adding files to my .gitignore. E.g. `$ echo "*.csv" >> .gitignore`. --- # Pipes: | The pipe operator `|` is one of the coolest features in Bash. - It lets you send (i.e. "pipe") intermediate output to another command. - In other words, it allows us to chain together a sequence of simple operations and thereby implement a more complex operation. (Remember the Unix philosophy!) Let me demonstrate using a very simple example. ```bash $ cat -n examples/sonnets.txt | head -n100 | tail -n10 ``` ``` ## 91 Despite of wrinkles this thy golden time. ## 92 But if thou live, remember'd not to be, ## 93 Die single and thine image dies with thee. ## 94 ## 95 IV ## 96 ## 97 Unthrifty loveliness, why dost thou spend ## 98 Upon thy self thy beauty's legacy? ## 99 Nature's bequest gives nothing, but doth lend, ## 100 And being frank she lends to those are free: ``` --- # Pipes: | (cont.) An exercise: Say I want to pull out all of text from (but limited to) Sonnet 18. - How might you go about this task using the pipe and other Bash commands?  ## Thou art more lovely and more temperate: ## Rough winds do shake the darling buds of May, ## And summer's lease hath all too short a date: ## Sometime too hot the eye of heaven shines, ## And often is his gold complexion dimm'd, ## And every fair from fair sometime declines, ## By chance, or nature's changing course untrimm'd: ## But thy eternal summer shall not fade, ## Nor lose possession of that fair thou ow'st, ## Nor shall death brag thou wander'st in his shade, ## When in eternal lines to time thou grow'st, ## So long as men can breathe, or eyes can see, ## So long lives this, and this gives life to thee. ``` --- # Pipes: | (cont.) A final aside about pipe the friends: You can use it to search through your Bash command history. - Every shell command you type is stored in a `~/.bash_history` file.<sup>1</sup> What happens if you type `$ cat ~/.bash_history | grep head`? .footnote[ <sup>1</sup> The file might change depending on your preferred shell. E.g. For Zsh it's `~/.zhistory`. ] -- </br> FWIW, I use this approach often to remind myself of certain shell commands that I tend to forget. A related and extremely useful command is [`Ctrl`+`R`](https://unix.stackexchange.com/questions/73498/how-to-cycle-through-reverse-i-search-in-bash), which lets you search and cycle through your shell history. --- class: inverse, center, middle name: iteration # Iteration (_for_ loops) <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # _for_ loop syntax _for_ loops in Bash work similarly to other programming languages that you are probably familiar with. The basic syntax is ```bash for i in LIST do OPERATION $i ## the $ sign indicates a variable in bash done ``` -- We can also condense things into a single line by using ";" appropriately. ```bash for i in LIST; do OPERATION $i; done ``` -- I find the top approach more readable, but I may use single line approach in these slides to save vertical space. - Note: Using ";" isn't limited to _for loops_. Semicolons are a standard way to denote line endings in Bash. --- # Example 1: Print a sequence of numbers To help make things concrete, here's a simple _for_ loop in action. ```bash $ for i in 1 2 3 4 5; do echo $i; done ``` ``` ## 1 ## 2 ## 3 ## 4 ## 5 ``` -- FWIW, we can use bash's brace expansion (`{1..n}`) to save us from having to write out a long sequence of numbers. ```bash $ for i in {1..5}; do echo $i; done ``` ``` ## 1 ## 2 ## 3 ## 4 ## 5 ``` --- name: combine_csvs # Example 2: Combine CSVs Here's a more realistic _for_ loop use-case that I use quite often: Combining (i.e. concatenating) multiple CSVs. -- Say we want to combine all the "daily" files in the `examples/meals` directory into a single CSV, which I'll call `mealplan.csv`. Here's one attempt that incorporates various bash commands and tricks that we've learned so far. The basic idea is: 1. Create a new (empty) CSV 2. Then, loop over the relevant input files, appending their contents to our new CSV ```bash ## create an empty CSV $ touch examples/meals/mealplan.csv ## loop over the input files and append their contents to our new CSV $ for i in $(ls examples/meals/*day.csv) > do > cat $i >> examples/meals/mealplan.csv > done ``` -- Did it work? (See next slide.) --- # Example 2: Combine CSVs (cont.) ```bash $ cat examples/meals/mealplan.csv ``` ``` ## day,breakfast,lunch,dinner ## friday,pancakes,ramen,stew ## day,breakfast,lunch,dinner ## monday,muesli,sandwich,pasta ## day,breakfast,lunch,dinner ## saturday,muesli,sandwich,pad thai ## day,breakfast,lunch,dinner ## sunday,muesli,roast,leftovers ## day,breakfast,lunch,dinner ## thursday,muesli,salad,tacos ## day,breakfast,lunch,dinner ## tuesday,muesli,soup,roast ## day,breakfast,lunch,dinner ## wednesday,muesli,sandwich,pizza ``` -- Hmmm. Sort of, but we need to get rid of the repeating header. -- Can you think of a way? - Answer on the next slide. (_Hint:_ `tail` and `head`...) --- # Example 2: Combine CSVs (cont.) Let's try again. First delete the old file so we can start afresh. ```bash $ rm -f examples/meals/mealplan.csv ## delete old file ``` -- Here's our adapted gameplan: - First, create the new file by grabbing the header (i.e. top line) from any of the input files and redirecting it. No need for `touch` this time. - Next, loop over all the input files as before, but this time only append everything _after_ the top line. ```bash ## create a new CSV by redirecting the top line of any file $ head -1 examples/meals/monday.csv > examples/meals/mealplan.csv ## loop over the input files, appending everything after the top line $ for i in $(ls examples/meals/*day.csv) > do > tail -n +2 $i >> examples/meals/mealplan.csv > done ``` --- # Example 2: Combine CSVs (cont.) It worked! ```bash $ cat examples/meals/mealplan.csv ``` ``` ## day,breakfast,lunch,dinner ## friday,pancakes,ramen,stew ## monday,muesli,sandwich,pasta ## saturday,muesli,sandwich,pad thai ## sunday,muesli,roast,leftovers ## thursday,muesli,salad,tacos ## tuesday,muesli,soup,roast ## wednesday,muesli,sandwich,pizza ``` -- We still have to sort the correct week order, but that's an easy job in R (or Stata, Python, etc.) - The explicit benefit of doing the concatenating in the shell is it is _much_ more efficient, since all the files don't simultaneously have to be held in memory (i.e RAM). - This doesn't matter here, but can make a dramatic difference once we start working with lots of files (or even a few really big ones). We'll revisit this idea later in the big data section of the course. --- class: inverse, center, middle name: scripting # Scripting <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # Hello World! Writing code and commands interactively in the shell makes a lot of sense when you are exploring data, file structures, etc. However, it's also possible (and often desirable) to write reproducible shell scripts that combine a sequence of commands. - These scripts are demarcated by their `.sh` file extension. -- Let's look at the contents of a short shell script that I've included in the examples folder. ```bash $ cat examples/hello.sh ``` ``` ## #!/bin/sh ## echo -e "\nHello World!\n" ``` -- I'm sure that you already have a good idea of what this script is meant to do, but it will prove useful to quickly go through some things together. --- # Hello World! (cont.) ```bash *#!/bin/sh echo -e "\nHello World!\n" ``` - `#!/bin/sh` is a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix), indicating which program to run the command with (here: any Bash-compatible shell). However, it is typically ignored (note that it begins with the hash comment character.) --- count: false # Hello World! (cont.) ```bash #!/bin/sh *echo -e "\nHello World!\n" ``` - `#!/bin/sh` is a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix), indicating which program to run the command with (here: any Bash-compatible shell). However, it is typically ignored (note that it begins with the hash comment character.) - `echo -e "\nHello World!\n"` is the actual command that we want to run. --- count: false # Hello World! (cont.) ```bash #!/bin/sh echo -e "\nHello World!\n" ``` - `#!/bin/sh` is a [shebang](https://en.wikipedia.org/wiki/Shebang_(Unix), indicating which program to run the command with (here: any Bash-compatible shell). However, it is typically ignored (note that it begins with the hash comment character.) - `echo -e "\nHello World!\n"` is the actual command that we want to run. The `-e` flag tells bash that we want to evaluate an expression rather than a file. To run this simple script, you can just type in the file name and press enter. ```bash $ examples/hello.sh $ # bash examples/hello.sh ## Also works ``` ``` ## ## Hello World! ``` --- name: rscript # Rscript It's important to realise that we aren't limited to running shell scripts in the shell. The exact same principles carry over to other programs and files. The most relevant case for this class is the [`Rscript`](https://stat.ethz.ch/R-manual/R-devel/library/utils/html/Rscript.html) command for (you guessed it) executing R scripts and expressions. For example: ```bash $ Rscript -e "cat('Hello World, from R!')" ``` ``` ## Hello World, from R! ``` -- Of course, the more typical `Rscript` use case is to execute full length R scripts. An optional, but very useful feature here is the ability to pass extra arguments from the shell to your R script. Consider the `hello.R` script that I've bundled in the examples folder. ```bash $ cat examples/hello.R ``` ``` ## args = commandArgs(trailingOnly = TRUE) ## i = args[1]; j = args[2] ## ## cat('Hello World, from R!\n', ## i, '+', j, '=', as.integer(i) + as.integer(j)) ``` --- # Rscript (cont.) The key step for using additional `Rscript` arguments is held within the top two lines. ```r args = commandArgs(trailingOnly = TRUE) i = args[1]; j = args[2] ``` These tell Rscript to capture any trailing arguments (i.e. after the file name) and then pass them on as objects that can be used within R. -- Let's run the script to see it in action. ```bash $ Rscript examples/hello.R 12 9 ``` ``` ## Hello World, from R! ## 12 + 9 = 21 ``` -- Again, including trailing arguments is entirely optional. You could run `Rscript myfile.R` without any problems. But it often proves very useful for the type of work that you'd likely be using `Rscript` for (e.g. batching big jobs). --- # Editing and writing scripts in the shell Say you want to edit my (amazing) `hello.sh` script. - Maybe you want to add some additional lines of text, or maybe you're bothered by the fact that there should be a comma after "Hello". (It's a salutation!) We have already seen how to append text lines to a file. But when it comes to more complicated editing work, you're better off using a dedicated shell editor. - I use [**vim**](https://missing.csail.mit.edu/2020/editors/). Extremely powerful, but a steep learning curve. - An easier starting point is [**nano**](https://www.nano-editor.org/). (**Windows users**, see [here](https://stackoverflow.com/questions/36802996/bash-nano-command-not-found-at-windows-git-bash).) Open up my script in nano by typing `$ nano examples/hello.sh`. - Note that the functionality is more limited than a normal text editor. - Once you are finished editing, hit "Ctrl+X", then "y" and enter to exit. - Finally, run the edited version of the script. -- If you've been having trouble executing this script (or want to limit who else can execute it), then you need to alter its permissions. Which takes us neatly on to our final section... --- class: inverse, center, middle name: permissions # User roles and file permissions <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # Disclaimer *This next section is tailored towards Unix-based operating systems, like Linux or MacOS, which is why I have saved it for the end. <b>Windows users:</b> Don't be suprised if some commands don't work, especially if you haven't installed the [WSL](#windows)...* *Regardless, the things we learn here will become relevant to everyone (even Windows users) once we start interacting with Linux servers, spinning up Docker containers, etc. later in the course.* --- # The superuser: root, sudo, etc. There are two main user roles on a Linux system: 1. Normal users 2. A superuser (AKA "root") Difference is one of priviledge. - Superusers can make system changes, install software, browse through different users' home folders, etc. Normal users are much more restricted in what they can do. - Explains why Unix-based OS's are much more resilient to security threats like viruses. Need superuser priviledges to install (potentially malicious) software. --- # The superuser: root, sudo, etc. (cont.) You *can* log in as the superuser<sup>1</sup>... but this is generally considered very poor practice, since you needlessly risk messing up your system. - There are no safety checks and no "undo" options. .footnote[ <sup>1</sup> Hit "p" on this slide if you really want to know how. ] ??? To switch over to the superuser, you can type `sudo -s`. - Note the extra visual cue: root's command prompt is a `#` (not a `$`). ``` root@laptop:~# ``` Remember to type `exit` to switch back! (Close these presenter notes by hitting "p" again.) -- **Question:** How, then, can normal users perform meaningful system operations (including installing new programs and updating software)? -- **Answer:** Invoke temporary superuser status with `sudo`. - Stands for "superuser do". - Simply prepend `sudo` to whatever command you want to run. ```bash grant@laptop:~$ ls /root ## fails grant@laptop:~$ sudo ls /root ## works ``` ??? Note that you have to be a "permitted" user to invoke `sudo`. - This should be enabled by default on your personal laptop, but if not see [here](https://www.thegeekstuff.com/2010/09/sudo-command-examples/embed/) or [here](https://www.digitalocean.com/community/tutorials/how-to-create-a-sudo-user-on-ubuntu-quickstart). --- # Changing permissions and ownership Let's think back to the `ABC/` directory that we saw previously while exploring the ls command. ```bash drwxr-xr-x 2 grant users 4.0K Jan 12 22:12 ABC ``` We can change the permissions and ownership of this folder with the `chmod` and `chown` commands, respectively. We'll now review these in turn. - Note that I'm going to use the "recursive" option (i.e. `-R`) in the examples that follow, but only because `ABC/` is a directory. You can drop that when modifying individual files. -- PS — I'm going to skip writing out the full path for this next section to save on typing. Now is a a good time to move into the `examples/` directory if you want to follow along with my commands literally. ```bash $ cd examples ``` --- # chmod Changing permissions using `chmod` depends on how those permissions are represented. There are two options: 1) Octal notation and 2) Symbolic notation. - We'll go into more detail on the next slide, but let's see some examples first. - (Test the results yourself using the `ls -lh` command afterwards.) -- **Example 1: rwxrwxrwx.** Read, write and execute permission for all users. - Octal: `$ chmod -R 777 ABC` - Symbolic: `$ chmod -R a=rwx ABC` -- **Example 2: rwxr-xr-x.** Read, write and execute permission for the main user (i.e. owner) of the file. For all other users, read and execute permission only. - Octal: `$ chmod -R 755 ABC` - Symbolic: `$ chmod -R u=rwx,g=rx,o=rx ABC` -- Now that we've seen some examples, let's get into the logic behind them. --- # chmod (cont.) ### Octal notation Takes advantage of the fact that `4` (for "read"), `2` (for "write"), and `1` (for "execute") can be combined in unambiguous ways. - 7 (= 4 + 2 + 1) means read, write and execute permission. - 5 (= 4 + 0 + 1) means read and execute permission, but not write permission. - etc. - Note that Octal notation requires a number for each of the three user types: owner, owner's group, and all others. E.g. `$ chmod 777 myfile.txt` ### Symbolic notation Links permissions to different symbols (i.e. abbreviations). - Users: `u` ("User/owner"), `g` ("Group"), `o` ("Others""), `a` ("All") - Permissions: `r` ("read"), `w` ("write"), `x` ("execute") - Changes: `+` ("add permissions"), `-` ("remove permissions"), `=` ("set new permissions") --- # chmod (cont.) Here's a quick comparison table with some common permission levels. | Octal value | Symbolic value | Permission level | |:-----------:|:-----------------:|:----------------:| | 777 | a+rwx | rwxrwxrwx | | 770 | u+rwx,g+rwx,o-rwx | rwxrwx--- | | 755 | a+rwx,g=rw,o=rw | rwxrwxrwx | | 700 | u+rwx,g-rwx,o-rwx | rwx------ | | 644 | u=rw,g=r,o=r | rw-r--r-- | -- </br> PS — Note the Symbolic method allows for relative changes, which means that you don't necessarily need to write out the whole entry in the table above. E.g. To go from the first line to the second line, you'd only need `$ chmod o-rwx myfile`. --- # chown Changing file ownership is somewhat easier than changing permissions, because you don't have to remember the different Octal and Symbolic notation mappings. - E.g. Say there is another user on your computer called "alice", then you could just assign her ownership of the ABC subfolder using: ```bash $ chown -R alice ABC ``` Things get a little more interesting when we want to add new users and groups, or change an existing users group. - I'll save that for a later lecture on cloud servers, though. --- class: inverse, center, middle name: steps # Next steps <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # Things we didn't cover today I know we covered a _lot_ of ground today. I hope that I've given you a sense of how Bash works and how powerful it is. - My main goal has been to "demystify" the shell, so that you aren't intimidated when we use shell commands later on. At the same time, there's loads that we didn't cover. - Environment variables, SSH, memory management (e.g. [top](https://ss64.com/bash/top.html) and [htop](https://hisham.hm/htop/)), GNU parallel, etc. - We'll get to some of these topics in the later lectures, but please try to work some of the suggested exercises on the next slide and make use of the recommended readings. --- # Next steps ### Exercises Navigate to the `examples/` sub-directory associated with this lecture. I want you to play around with the contents using some of the different Bash commands we practiced today. - Change the permissions on an indivdual file or a whole directory. - Read in (or fix) some lines of text from one file and pipe them to another file. - Count the number of times Shakespeare refers to "mistress" or "love" in his Sonnets. - Write a new bash script and execute it. - Etc. ### Further reading - [The Unix Shell](http://swcarpentry.github.io/shell-novice/) (Software Carpentery) - [The Unix Workbench](https://seankross.com/the-unix-workbench/) (Sean Kross) - [Data Science at the Command Line](https://www.datascienceatthecommandline.com/) (Jeroen Janssens) - [Using AWK and R to parse 25tb](https://livefreeordichotomize.com/2019/06/04/using_awk_and_r_to_parse_25tb/) (Nick Strayer) --- class: inverse, center, middle # Next class: *R* language basics <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- class: inverse, center, middle name: windows # Appendix (Windows users only) <html><div style='float:left'></div><hr color='#EB811B' size=1px width=796px></html> --- # Bash on Windows Windows users have two options: ### 1. [Git Bash](https://gitforwindows.org/) - **Pros:** You should already have installed this as part of the previous lecture. - **Cons:** Functionality is limited to Git-related commands, so various things that we're going to practice today won't work. ### 2. [Windows Subsystem for Linux (WSL)](https://docs.microsoft.com/en-us/windows/wsl/install-win10) - **Pros:** A self-contained Linux image (terminal) that allows full Bash functionality. - **Cons:** Must be installed first and only available to Windows 10 users. I'm going to go out on a limb and recommend option 2 (WSL) if available to you. It's more overhead, but I think worth it. See the next two slides for instructions and tips... .footnote[(Back to [table of contents](#toc).)] --- name:wsl # WSL The basic WSL installation guide is [**here**](https://docs.microsoft.com/en-us/windows/wsl/install-win10). - Follow the guide to install your preferred Linux distro. [Ubuntu](https://www.microsoft.com/en-us/p/ubuntu/9nblggh4msv6) is a good choice. - Then, once you've restarted your PC, come back to these slides. After installing your chosen WSL, you need to navigate to today's lecture directory to run the examples. You have two options: #### Option (i) Access WSL through RStudio (*recommended*) If you access WSL through RStudio, then it will conveniently configure your path to the present working directory. So, here's how to make WSL your default [RStudio Terminal](https://support.rstudio.com/hc/en-us/articles/115010737148-Using-the-RStudio-Terminal): - In RStudio, navigate to: *Tools > Terminal > Terminal Options...*. \[[Screenshot](pics/wsl-rstudio-1.png).\] - Click on the dropdown menu for *New terminals open with* and select "Bash (Windows Subsystem for Linux)", Then click *OK*. \[[Screenshot](pics/wsl-rstudio-2.png).\] - Refresh your RStudio terminal (`Alt+Shift+R`). \[[Screenshot](pics/wsl-rstudio-3.png).\] - You should see the WSL Bash environment with the path automatically configured to the present working director, mount point and all. \[[Screenshot](pics/wsl-rstudio-4.png).\] --- name: wsl-rstudio # WSL (cont.) #### Option (ii) Go directly through the WSL Presumably, you've cloned the course repo somewhere on your C drive. - The way this work is that Windows drives are mounted on the WSL's `mnt` directory. (More [here](https://www.howtogeek.com/261383/how-to-access-your-ubuntu-bash-files-in-windows-and-your-windows-system-drive-in-bash/).) - Say you cloned the repo to "C:\\Users\\Grant\\ec607\\lectures". - The WSL equivalent is "/mnt/c/Users/Grant/ec607/lectures". - So, then you can navigate to today's lecture through the WSL with: `$ cd /mnt/c/Users/Grant/ec607/lectures/03-shell`. Adjust as needed. .footnote[(Back to [table of contents](#toc).)] -- ### Which option to choose? Both are fine, but I recommend option **(i)**. As a Windows user, being able to access a true Bash shell (i.e. terminal) conveniently from RStudio will make things *much* easier for you in my class. You can always revert back to a different shell later if you want.


Deep Daze is a simple command line tool for text to image generation using OpenAI's CLIP and Siren.
It is created by Phil Wang (@lucidrains), you can found the source repository here.
This will require that you have an Nvidia GPU or AMD GPU
Python must be installed
The process is not using your graphical card because CUDA is not available. Install manually.
loss:
/ epochs


Ocala events
-
ground transportation newark nj to brooklyn
Germany - Physical map of Germany
Physical map of Germany 2009, Germany Physical Map 1994, Physical map of Germany. Germany topographic map 2006, Germany physical map, Physical .
http://www.zonu.com/Europe/Germany/Physical_en.htmlGermany Physical Map
Physical map of Germany shows all the major physical features of the country. Map showing location of the mountain ranges, deserts, oceans, rivers, lakes, .
http://www.mapsofworld.com/physical-map/germany.htmlPhysical Map of Germany, Austria, Switzerland, Liechtenstein ...
Austria is a small mountainous landlocked country in South Central Europe. It is bound by Germany and the Czech Republic to the north, Slovakia to the .
http://www.atlapedia.com/online/maps/physical/Germany_etc.htm
g w laboratories suit Upcoming events in Ocala
penny pack nursing home Hottest Tickets
-
Apr 11actual 2 girls one cup video
Amway Center -
Apr 28jeanette ashman powhatan va
Amway Center -
Jun 25tony emmerich development corp
Bob Carr Performing Arts Center -
Mar 30montgomery co al genweb
Amway Center -
Aug 27stefania's boutique cranston ri
Amway Center -
Jun 21what did beethoven die from
Amway Center -
Sep 13new maternity ward at ucl
Francis Field -
Mar 17beer by alchol content
St Augustine Amphitheatre -
Oct 8advanced laser center at sunset
Amway Center -
May 4kona luau combination activitis
Bob Carr Performing Arts Center
Ocala's best venues
-
Physical Map of Germany in German
Classroom map of Germany in German showing physical features, cities and towns.
http://www.wall-maps.com/Classroom/Foreign-Language-Maps/PhysicalGermanyInGerman.asp -
Physical Map of Germany
We recommend these other travel resources: The physical map of Germany is a great way to understand the variety of the German landscape. If you are a .
http://www.maps-of-germany.co.uk/physical-map-of-Germany.htm -
Germany - physical geography : map of Germany, area, lands ...
Germany : geography, maps, flag, statistics, photos and cultural information about Germany.
http://www.studentsoftheworld.info/pageinfo_pays.php3?Pays=GERaustin tx real estate free
98 people's favorite
-
Google Map of Munich, Bavaria, Germany - Nations Online Project
Searchable map/satellite view of Munich, the capital of Bavaria state, Germany. . Satellite view is showing Munich (in German: München), the capital city of Bavaria (German Federal State) in Germany, located in . Terrain for a physical map.
http://www.nationsonline.org/oneworld/map/google_map_Munich.htm -
1846 Perthes Physical Map of Germany - Geographicus
Description: This is a fascinating example of the 1850 Justus Perthes physical map of Germany and its neighboring countries. It covers from Denmark to the .
http://www.geographicus.com/P/AntiqueMap/GermanyMountainsRivers-perthes-1854


🚫 DISCLAIMER: You must use all the methods in this book under the supervision of your doctor. This book is for informational purposes only. It is not intended to constitute or be a substitute for professional medical advice, diagnosis, or treatment.
You can do the same as we did!
Only those who have experienced an ulcer fully realize their problems.
With our experience, you can cure a gastrointestinal ulcer on your own. This is a true story from our life.
The book explains in detail why we did not seek medical help and engaged in self-treatment.
We have extensively researched numerous self-treatment recipes and meticulously crafted our own, ensuring optimal effectiveness.
You need to be patient, persistent, and consistent if you want to replicate our experience. The reward will be a radical improvement in the quality of your life.
We not only provide advice, but also explain why it is correct, based on a clear understanding of human biology, physiology, and pharmacology.
We used leeches in the treatment process. This book covers the experience of keeping leeches at home, treating gastrointestinal ulcers with leeches, treating wounds after leech bites, and applying leeches to a person. But you do not suppose to use them to get full revocer, it is optional.
The protagonist of this novel had multiple ulcers in his duodenum, weighed 57 kilograms at a height of 176 centimeters, and even carrot juice and plain water caused him pain. Now he has gained significant weight and can even eat garlic.
The information in the book will give you a complete idea of which foods can be eaten without pain. You will also learn how to prepare these foods. Moreover, these dishes will provide you with a complete nutrition that ulcer patients are deprived of.
Get rid of ulcer: 20$ Donation for Our eBook
Stop struggling! Ask your questions from 13$
Trial version:
Get out of Ulcer Now!
eBook for just $20 donation
© GetOutofUlcer, 2023
Commenting people’s reviews on the ulcer treatment
After I googled “how to heal ulcers," I've got this list on the first page:
TreatmentThere are too many mentions of “antibiotics” and “medications,” don't you think so? You can do it all in a natural, healthy way to make you feel better and live longer.


Overview¶
Qiskit Aqua Chemistry is a set of tools and algorithms that enable experimenting with chemistry problems via quantum computing. Aqua Chemistry translates chemistry-specific problems into inputs for an algorithm from the Aqua Quantum Algorithms library, which in turn uses Qiskit Terra for the actual quantum computation.
Aqua Chemistry allows users with different levels of experience to execute chemistry experiments and contribute to the quantum computing chemistry software stack. Users with pure chemistry background can continue to configure chemistry problems according to their favorite computational chemistry software packages, called drivers. These users do not need to learn the details of quantum computing; Aqua Chemistry translates any chemistry program configuration entered by those users in one of their favorite drivers into quantum-specific input. For these to work, the following simple requirements must be met:
- The driver chosen by the user should be installed on the same system in which Aqua Chemistry is also installed.
- The appropriate software license for that driver must be in place.
- An interface to that driver must be built in Aqua Chemistry as a
BaseDriver
extension point.
Currently, Aqua Chemistry comes with interfaces prebuilt for the following four computational chemistry software drivers:
- Gaussian™ 16, a commercial chemistry program
- PSI4, an open-source chemistry program built on Python
- PySCF, an open-source Python chemistry program
- PyQuante, a pure Python cross-platform open-source chemistry program
Additional chemistry drivers can easily be added via the BaseDriver
extension point. Once an interface
for a driver installed in the system has been implemented, that driver will be automatically loaded at run time
and made available in Qiskit Quantum Chemistry for running experiments.
Once Aqua Chemistry has been installed, a user can execute chemistry experiments on a quantum machine by using either the GUI or Command Line supplied tools, or the Programmable Interface. Either option enforces schema-based configuration correctness.
Contributing to Aqua Chemistry
Instead of just accessing Aqua Chemistry as a tool to experiment with chemistry problems on a quantum machine, a user may decide to contribute to Aqua Chemistry by providing new algorithms, algorithm components, input translators, and driver interfaces. Algorithms and supporting components may be programmatically added to Aqua: A Library of Quantum Algorithms, which was designed as an extensible, pluggable framework in order to address the needs of research and developers interested in Contributing to Aqua. Aqua Chemistry utilizes a similar framework for drivers and the core computation performed at the input-translation layer.
If you would like to contribute to Aqua Chemistry, please follow the Aqua Chemistry contribution guidelines.
Modularity and Extensibility¶
Aqua Chemistry is built on top of Aqua: A Library of Quantum Algorithms. Just like Aqua, it is specifically designed to be extensible at each level of the software stack. This allows different users with different levels of expertise and different scientific interests to contribute to, and extend, the Aqua Chemistry software stack at different levels. In addition to the extension points offered by the underlying Aqua library, Aqua Chemistry allows a user to plug in new algorithms and new operators for translating classical inputs into inputs for quantum algorithms.
Input Generation¶
At the application level, Aqua allows for classical computational software to be used as the quantum application front end. This module is extensible; new computational software can be easily plugged in. Behind the scenes, Aqua lets that software perform some initial computations classically. The results of those computations are then combined with the problem configuration and translated into input for one or more quantum algorithms, which invoke the Qiskit code Application Programming Interfaces (APIs) to build, compile and execute quantum circuits.
The following code is the configuration file, written in Gaussian™ 16, of a molecule of hydrogen, whose two hydrogen atoms are placed at a distance of \(0.735\) Å:
# rhf/STO-3G scf(conventional)
h2 molecule
0 1
H 0.0 0.0 -0.3675
H 0.0 0.0 0.3675
Aqua Chemistry uses this molecular configuration as an input to the computational chemistry software — in the case above, Gaussian 16. The computational chemistry software package is executed classically — not to compute the ground-state energy, dipole moment, or excited states of the given molecule, since these expensive computations are delegated to the underlying quantum machine, but only to the extent necessary to compute some intermediate data which, combined with the molecular configuration above, can later be used to form the input to the quantum algorithm in Aqua. The information that needs to be extracted from the computational chemistry software is configured when building the interface between to the computational software package from within Aqua.
The intermediate data extracted from the classical computational software consists of the following:
- One- and two-body integrals in Molecular Orbital (MO) basis
- Dipole integrals
- Molecular orbital coefficients
- Hartree-Fock energy
- Nuclear repulsion energy
Once extracted, the structure of this intermediate data is independent of the computational chemistry software that was used to compute it. However, the level of accuracy of such data does depend on the computational chemistry software; more elaborate software packages are more likely to produce more accurate data.
Aqua Chemistry offers the option to serialize this data in a binary format known as Hierarchical Data Format 5 (HDF5). This is done to enable future reuse of previously computed input data. This feature also enables researchers to exchange input data among each other — which turns out to be particularly useful to researchers who may not have particular computational chemistry drivers installed on their computers. HDF5 is configured as a prebuilt driver in Aqua Chemistry because it allows for chemistry input to be passed into the computation.
Input Translation¶
The problem configuration and the additional intermediate data
obtained from the classical execution of one of computational chemistry drivers are
combined and then transformed to form the input to the quantum system. This phase, known as translation,
is also extensible. Practitioners interested in providing more efficient
translation operators may do so by extending this layer of the Aqua software
stack with their own implementation of the ChemistryOperator
class.
In the reference implementation provided by Aqua Chemistry, the translation phase takes the input generated by the classical execution of the computational chemistry driver and generates first a fermionic operator, and from this a qubit operator, which becomes the input to one of the quantum algorithms in Aqua.
Novel Features¶
Aqua Chemistry present some unique advantages in terms of usability, functionality, and configuration-correctness enforcement.
User Experience¶
Allowing classical computational chemistry software at the front end has its own important advantages. In fact, at the top of the Aqua Chemistry software stack are chemists who are most likely very familiar with existing computational chemistry software. These practitioners may be interested in experimenting with the benefits of quantum computing in terms of performance, accuracy and reduction of computational complexity, but at the same time they might be unwilling to learn about the underlying quantum infrastructure. Ideally, such practitioners would like to use a computational chemistry driver they are used to as a front end to the quantum computing system, without having to learn a new quantum programming language of new APIs. It is also likely that such practitioners may have collected, over time, numerous chemistry problem configurations, corresponding to various experiments. Aqua Chemistry is designed to accept those configuration files with no modifications, and without requiring a chemist to have to learn a quantum programming language. This approach has a clear advantage in terms of usability.
Functionality¶
If Aqua Chemistry had been designed to interpose a quantum programming language or new APIs between the user and the classical computational chemistry software drivers, it would not have been able to fully exploit all the features of those drivers unless all such features had been exposed by the higher programming-language or API. In other words, in order to drive the classical execution of any interfaced computational chemistry driver to perform the most precise computation of the intermediate data needed to form the quantum input, the advanced features of that driver would have had to be configurable through Aqua Chemistry. The ability of Aqua to directly interface classical computational software allows that software to compute the intermediate data needed to form the quantum input at its highest level of precision.
To better illustrate this point, consider the ability of popular computational chemistry Drivers, such as Gaussian™ 16, PSI4 and PySCF — all interfaced by Aqua Chemistry — to accept the configuration of a molecule where different atoms are represented in different basis sets, as opposed to having to necessarily impose one single basis set for all the atoms. As an example, the following code snippet, written in the PSI4 language, configuring the basis sets for a molecule of benzene, whose chemical formula is \(C_6H_6\), indicating the fact that the molecule comprises six atoms of carbon and six of hydrogen:
basis {
assign DZ
assign C 3-21G
assign H1 STO-3G
assign C1 STO-3G
}
Here, the chemist has chosen to use basis DZ for all atoms via the first assignment. The second assignment overwrites such statement for all six carbon atoms, which will be represented via the 3-21G basis set. The third statement assigns basis set STO-3G to one particular hydrogen atom — the one with index 1 — while all the other five hydrogen atoms keep basis set DZ. Finally, the last statement assigns basis set STO-3G to the one carbon atom with index 1, leaving the remaining five carbon atoms with basis set 3-21G as per the second assignment.
Aqua Chemistry would have no problem supporting this fine-grained basis set specification, since it allows the computational chemistry drivers to be the front end to the system, with no additional layer on top of them. Conversely, other systems that have chosen to interpose a new programming language or new APIs in front of the computational drivers currently do not support the assignment of different basis sets to different atoms in the same molecules. In order to support such advanced, fine-grained configurations, those systems will have to support the APIs for the different basis sets to be specified, and map them to all of the underlying drivers.
Fine-grained basis-set specification is only one example of the functionality of the computational chemistry drivers directly exposed by Aqua Chemistry. Another — perhaps even more important — example has to do with the Hartree-Fock wave function, which is computed by the underlying driver and allows for the computation of the one- and two-body MO integrals, which in turn are used to determine the full Configuration Interaction (CI) wave function and the Unitary Coupled Cluster Singles and Doubles (UCCSD) wave function, among other things. Computational chemistry software drivers expose configuration parameters to make the computation of the Hartree-Fock wave function converge, should the default parameter values fail. Aqua Chemistry has no problem supporting such advanced configuration parameters, which would be passed directly into the configuration file as an input to the underlying driver. Conversely, solutions that have chosen to interpose a new programming language or new APIs between the user and the underlying drivers currently do not support customizing the parameters for facilitating the convergence of the computation of the Hartree-Fock wave function. In order for these alternative solutions to allow for this type of customization, the parameters would have to be exposed through the programming language or the APIs. As a result, such alternative solutions may not be able to get the integrals that need to be used in the full CI or UCCSD calculations.
Let us consider yet another example illustrating why a direct use of the classical computational chemistry software is superior to the choice of interposing a new programming language or API between the user and the driver. It has been demonstrated that taking into account a molecule’s spatial symmetries can be used to reduce the number of qubits necessary to model that molecule and compute its energy properties. Computational chemistry software packages allow for configuring spatial symmetries in their input files. Thus, Aqua Chemistry can immediately take direct advantage of such feature exposed by the underlying computational software packages and obtain from those packages intermediate data that is already optimized with respect to the symmetries configured by the user. As a result, energy computations performed by Aqua Chemistry require fewer qubits when a spatial symmetries are present in a molecule. Conversely, other solutions that interpose a new programming language or APIs fail to expose this configuration feature to their users unless an ad-hoc symmetry API is constructed, which must then be mapped to all the underlying software packages interfaced by those solutions. To make things more complicated, for any new software package that is interfaced by those solutions, that symmetry API will have to be programmatically mapped to the package’s symmetry configuration feature.
In essence, interposing a new language or new APIs between the user and the underlying classical drivers severely limits the functionality of the whole system, unless the new language or APIs interfacing the drivers match the union of all the configuration parameters of all the possible computational drivers that are currently supported by the system, or that will be supported in the future.
Configuration Correctness¶
Aqua Chemistry offers another unique feature. Given that Aqua Chemistry allows traditional software to be executed on a quantum system, configuring a chemistry experiment definitely requires setting up a hybrid configuration, which involves configuring both chemistry- and quantum-specific parameters. The chances of introducing configuration errors, making typos, or selecting incompatible configuration parameters are very high, especially for people who are expert in chemistry but new to the realm of quantum computing.
For example, the number of qubits necessary to compute the ground-state energy or a molecule depends on the number of spin orbitals of that molecule. The total number of qubits may be reduced by applying various optimization techniques, such as the novel parity-map-based precision-preserving two-qubit reduction. Further reductions may be achieved with various approximations, such as the freezing of the core and the virtual-orbital removal. The number of qubits to allocate to solve a particular problem should be computed by the system and not exposed as a configuration parameter. Letting the user configure the number of qubits can easily lead to a configuration parameter mismatch.
Another scenario in which a user could misconfigure a problem would involve the user associating algorithm components (such as optimizers and trial functions for quantum variational algorithms) to algorithms that do not support such components.
To address such issues, in Aqua the problem-specific configuration information and the quantum-specific configuration information are verified for correctness both at configuration time and at run time, so that the combination of classical and quantum inputs is resilient to configuration errors. Very importantly, configuration correctness is dynamically enforced even for components that are dynamically discovered and loaded.
Contributors (in Alphabetical Order)¶
Aqua was inspired, authored and brought about by the collective work of a team of researchers. Aqua continues now to grow with the help and work of many people, listed here in alphabetical order, who contribute to the project at different levels:
- Panagiotis Barkoutsos
- Sergey Bravyi
- Chun-Fu (Richard) Chen
- Antonio Córcoles-Gonzalez
- Jay Gambetta
- Jen Glick
- Tanvi Gujarati
- Shaohan Hu
- Takashi Imamichi
- Tal Kachman
- Peng Liu
- Manoel Marques
- Antonio Mezzacapo
- Nikolaj Moll
- Giacomo Nannicini
- Marco Pistoia
- Julia Rice
- Raymond Harry Putra Rudy
- Ivano Tavernelli
- Stephen Wood
License¶
This project uses the Apache License Version 2.0 software license.
Some code supplied by Aqua Chemistry for interfacing to external chemistry Drivers has additional licensing:
- The Gaussian™ 16 driver contains work licensed under the Gaussian Open-Source Public License.
- The PyQuante driver contains work licensed under the modified BSD license.


Next: Atomic Time: TAI
Up: EXPLANATION AND EXAMPLES
Previous: The Hipparcos Catalogue and the ICRS
SLALIB provides for conversion between several timescales, and involves
use of one or two others. The full list is as follows:
- TAI: International Atomic Time
- UTC: Coordinated Universal Time
- UT: Universal Time
- GMST: Greenwich Mean Sidereal Time
- LAST: Local Apparent Sidereal Time
- TT: Terrestrial Time
- TDB: Barycentric Dynamical Time.
Three obsolete timescales should be mentioned here to avoid confusion.
- GMT: Greenwich Mean Time - can mean either UTC or UT.
- ET: Ephemeris Time - more or less the same as either TT or TDB.
- TDT: Terrestrial Dynamical Time - former name of TT.
Next: Atomic Time: TAI
Up: EXPLANATION AND EXAMPLES
Previous: The Hipparcos Catalogue and the ICRS
SLALIB --- Positional Astronomy Library
Starlink User Note 67
P. T. Wallace
12 October 1999
E-mail:ptw@star.rl.ac.uk


The Internet is the defining technology of our time And historic revolution in communications for the human race that is changing the world. The Internet enables millions of people with personal computers to communicate and connect. It is also the world's largest marketplace and shopping mall and it’s a link to websites the world over with information for every aspect of life and even the life after.
"The internet could be a very positive step towards education, organisation and participation in a meaningful society"


Skate.js Demonstration
Item 1
Item 2
Item 3
Item 4
Ice by
Costel Slincu
Ice by
Massimo Margagnoni
Ice Show by
Nicholas A. Tonelli
Ice Crystal by
Andreas Brandmaier


Add the markup you want to test and press the Fill Testbox button. Selection markers are not allowed as text.
If you want to test a certain selection use following syntax to mark selection begin and end.
[{ data-start only one occurrence allowed. Defines begin of the
selection.
]} data-end only one occurrence allowed. Defines end of the selection.


Navigate to web page by typing url in address input.
You can memorize page in current session using button with ♥ symbol.
To forget memorized page click button with × symbol.
Visit my awesome blog at forallx.ru