UI to mail NASA APOD image to inputted email [#2 NASA APOD Series]

I’ll be going through using Flask to create a 2-webpage website with a simple form on the first page that takes in your email, clicking the submit button sends an image of the latest NASA APOD image to the inputted email. For this, I’m using the script written and explained in the last post in this series, which can be found here. So in this post, I’ll be going through the flask templates i created, and my form functionality, which is pretty simple.

The first step is to create a .html page and a main.py file for our website. Here’s the code for the following.

<body> tag of .html file

So the image above shows the code I’ve written for the body tag, which is all that’s worth looking at. The form data returned in the main.py file is used to just show the form and a submit button, very simple functionality so I’m not going to go that much into detail for this part. We only have an email field and a submit button, clicking the submit button firstly checks whether or not the email field has a valid input. If it doesn’t, the field is cleared and a red outline is put on it. If it is, an email containing the latest NASA APOD image is mailed to the inputted email, and the user is redirected to another webpage.

This is the code in my main.py file. I’ve initialised my Flask app with the first line and given it a secret key (for forms). The send_email() function contains the code explained in the previous post. It’s called if and only if the submit button is clicked on the home page and a valid email address is filled out. If these conditions are satisfied, the send_email() function is called with the inputted email as the only argument. The code then redirects the user to the bye.html page, which is just a small html file displaying the words “bye.” I did it for the sake of seeing whether or not the send_email()function has been called inside home.

My functionality for setting up the email form is very simple. I use the wtforms module.. I’ve created emailButton class wherein the the email is set to a StringField object, and submit is set to a SubmitField object. The library provides validator methods. DataRequired() ensures that some data is inputted into the field, and Email() ensures that the given input is a properly formatted email.

This is what our webpage displays. After entering a valid email and clicking submit, here is what I’ve received in my inbox.

Next time I’ll have a more styled layout, and I’ll go through the countdown functionality that will send emails to inputted email addresses until the number of inputted days becomes zero. Project should ideally be complete when that’s done.

You can check out the full code here.

Using Python to email NASA APOD API data to a custom recipient [#1 NASA APOD Series]

I’m doing a mini-project as a learning experience. The first step here involved two sepearate functionalities that I’ve now combined and will explain here. Firstly, I had to write a few lines of code to actually use the API and save the image it returns to the current directory. This was really easy. I then had to learn how to use smtplib to send emails in python. I used this article on Real Python to do so. This post on Stack Overflow was also helpful in instructing me about attaching image files to an email. You can find the entire code in here, on my GitHub. I’ve been having some issues with WordPress plugins, so I’ve just attached screenshots of my code for this post.

right, so the first thing we’ll be looking at is accessing the NASA APOD API and storing the latest NASA Astronomy Picture of the Day Image in the current directory.

I firstly import the necessary modules. After that, we’ll access the API with our key. The url contains the link given in the offficial documentation for accessing latest image. The API returns a json object with keys pointing to a description of the image, a hd url, and a nominal quality url. I’ve used the urllib module to fetch and store the image to our current repo (stores to which repo we are in or we have changed to with os). Now comes the hard part.

You can take a look at all the modules I’ve imported in the GitHub link i’ve posted above.

Above, we start our smtp_server and initialize our port. I’ve used 587 because I’m using the TLS method, I think you’ll need to use 465 if you use the other method. I’ll be using mehulpy@gmail.com to send this email. This is a throwaway account I created with all security features turned off. I’m mailing it to mehuljangir42@gmail.com, which is one of the emails I use. We then input the password for the email we will be sending it from. Then, we’ll our message will be set to an instance of the MIMEMultipart objective with “alternative” as our input parameter. We then key in some values, like the email to use, the email to mail it to, and the Subject of our email. I’ve then specified html and plaintext messages for the email to contain.

I’ve attached both html and plaintext messages to our email. The procedure for attaching a .png file as an email attachmetn is very simple. Using the inbuilt open subroutine in python, we read the image. Then, we create an instance of the MIMEImage object where we key in the img_data we just read and input the path of our image file. os.path.basename returns your current path, kinda like the pythonic way of writing pwd.

A SSL context is created after that. Check out this Stack Overflow post to learn more about what an SSL context is. We then move into a try except condition, so that we can catch any errors that come our way. A server is established, and server.ehlo() is basically the equivalent of waving hi to your friend across the room. We then start tls, which is a method of encryption for safe and secure communication across the internet. Finally, as a method of the server instance, I send the email to the recipient. The finally block quits the server regardless of whether or not the email was sent and whether or not an error was thrown.

I’ll now create a webpage where you can input your email, and a python script sends the current NASA APOD image to your email. So stay hooked for #2!

Also, FYI, here’s what the email looks like:

Conducting an online MUN and Presiding over the SC.

This weekend, I had the opportunity of presiding over a simulation of the Security Council and being Secretary General of our school’s and my city’s first ever online MUN. I made a commitment to organizing a conference way back in August, at the start of my tenure as MUN Club President. COVID-19 provided me with a unique opportunity, the chance to conduct a virtual conference unlike other MUNs in how effective I wanted it to be and the fact that all committees would be working together to come up with solutions for the current pandemic. We had crisis updates in the General Assembly impacting proceedings in the Security Council, speeches PM Modi being broadcast in the GA, and the Security Council and WHO having a joint crisis on the basis of Iranian bioweapons allegedly supplied by China. It was truly a wonderful experience.

I had the idea of conducting such a conference over a month ago. I immediately reached out to my peers and teachers, and got the planning underway. We made a team, divided all the work, and got everything done very quickly. In fact, the hard work each team member put into the event, whether it was our logistics heads texting every single delegate, or our Vice-chairs who were tasked with working on Background guides, is commendable. Now, more about what I did.

As President of a Security Council meeting that was investigating COVID-19’s origins and evaluating the possibility of it being a bio-weapon, the fact that it was a simulation did not draw away from how serious the situation was. Debate started with the Russian Federation introducing a verified, reliable research paper that clearly proved how COVID-19 couldn’t be artificial. I then urged our committee to investigate some more pressing prospects such as COVID-19 being a natural outbreak intentionally allowed to get out of hand and it being a sort of evolved form of SARS for which a vaccine already existed (concealed by the Chinese). After a round of statement speeches, I introduced the first crisis of the day, a video of a worker in the Wuhan virological center stating how the virus was laboratory made and intentionally released. Not soon after, one of our MUN mentors who has now graduated high school joined as the guest delegate of Japan, accused China of approaching him in informal session with an offer to trade the formula for the vaccine for economic and financial support, and abruptly left; committee had just livened up. Allegations flew across the floor during formal session, and insults during informal session. China became a sort of punching bag for the rest of the committee, soaking up countless jibes and taunts and resorting to reminding the other delegates about what I said and the source Russia provided.

I then took it a step further by releasing another video made by a resident in Wuhan claiming they were receiving ‘magic medicine’ from the authorities, and that all who refused to take it were being welded shut into their homes. This effectively meant that the Chinese had a vaccine, or had discovered an accidental cure. In either case, it meant China was concealing something important from the rest of the committee. This marked the end of the first day. However, at midnight, the General Assembly convened for a midnight crisis (a fascinating aspect of MUNing I saw happen for the first time), and witnessed PM Modi deliver a speech on how an Indian lab had created the vaccine. We then received an informal tip-off hinting upon a US-India partnership involving the US and India distributing the vaccine to their civilian populations before the rest of the world, and reaping the economic benefits of selling a highly demanded product to 189 countries at a very high price. I took this opportunity to text all members of my committee with a midnight update, alerting them to what had just transpired.

Committee convened again at 8 am in the morning. We debated on the draft resolution at hand for the first two sessions, cut away more than 80% of it and ultimately vetoed it, so 5 hours of effort went down the drain, not because we failed to pass a resolution, but because I failed to engage delegates in the resolution drafting process. Judging the results of an informal vote and what I believed to be best for committee, I decided to have a series of crisis updates for the last two sessions.

The first of these was an announcement by the Indian chief of army staff, detailing how the sole laboratory with the cure for COVID-19 had been blown up via a terrorist attack, and that the delegate of India to the Security Council had been assassinated. Dealing with the fact that the only verifiable vaccine was gone, and that China had a potential vaccine, all blocs split apart as China, Russia, and the US faced a series of allegations. This was followed by an announcement by the Russian Federation detailing how they had obtained the vaccine and were prepared to sell it to all other countries at subsidized prices, but would mass produce it in the public sector and not distribute the formula so as to reap colossal economic benefit.

So, that’s how committee ended. While we certainly didn’t have any progress towards satisfying our agendas, we had that kind of accusation-abundant, intense debate where blocs don’t really matter that brought out the best in our delegates. It was incredibly interesting to see our delegates handle incredibly absurd and riveting crisis updates, and do so while coping with incredibly arcane unmods. Conducting eJPISMUN was a brilliant experience, and the way our conference turned out exceeded the aspirations I had for it when I came up with the entire idea.

What is Intelligence?

Reading Homo Deus by Yuval Harari really made me think about some stuff. Here’s what I concluded about the nature of intelligence:

I’m going to go out on a limb and say drawing conclusions from a given amount of data can be defined as a reasonable metric for intelligence. For instance, in math classrooms the most intelligent students are those who can work through problems with ease and in the absence of exterior help. However, machines can do the same in a matter of nanoseconds. In fact, machines have already replaced humans in terms of calculation, with pocket calculators now a classroom tool and supercomputers enabling us to explore much larger numbers like the googolplex. Now, machine learning is replacing humans in the broad area of problem solving. Artificial Intelligence is being used to diagnose patients with various maladies, effectively reducing a doctor’s job from diagnosis and cure to just cure, which may be cut down even more due to the development of robotic surgery tools.

It’s safe to say machines are more intelligent than humans in the modern world. Machines are already pioneering and establishing new frontiers for humankind. From Mars, where mechanical probes are more commonplace than humans, to the Marianas Trench, where remotely piloted submarines have been before us. The advent of artificial intelligence will seal what is surely the intellectual dominion of computers over humankind. This begs a very important question, what makes us unique?

The first two candidates that come to mind are curiosity and sentience. On a side note, Octopuses display both those traits. With a separate brain in each of their eight tentacles, a camouflaging ability that puts chameleons to shame, and a profound tendency to form emotional bonds with everyone they meet and memorise them. Octopuses are to us what velociraptors were to Dr Alan Grant in Jurassic Park; thank god they dwell in the ocean and not on the surface.

Another pressing question isn’t whether or not sentience makes us unique, but whether or not it makes us weak. Machines lack emotions, most people call that a drawback, but is it? Imagine this scenario:

It’s the year 2050, and humankind has a noticeable presence on Mars, with upto ten thousand people calling themselves ‘Martians.’ A disease outbreak the likes of which have never been seen before occurs, killing every single Martian. A ship departs from Mars, bound for Earth. Now, a human gateway operator in a space station orbiting Earth has two alternatives, destroy the ship from Mars using a nuclear warhead to prevent a potential outbreak on Earth, or let it pass and risk an extinction-level event. Here’s a twist, his wife and kids are aboard the ship. This creates a situation where there’s room for doubt, which leads to potential for catastrophe, and when a few lives come in the way of all life, catastrophe does occur. Now imagine a benevolent AI operating the space station. Weighing the

lives of those aboard the ship against life on planet Earth, it would pull the trigger and hence end the risk of another outbreak.

Movies and books about future civilizations and artificial intelligence always contain fascinating plot twists where all of a sudden love emerges as the differentiator between humans and machines. Machines go haywire, and the humans win. Interstellar ends with love ‘transcending reality,’ and being the one ‘force’ that saves the entire planet from starving. Why? Because a father loved his daughter very much. Imagine an artificial intelligence program in place of Darth Vader, would it have given in to fatherly love, killed the Emperor, and ensured the victory of the light side in ​The Return of the Jedi?​

What makes machines efficient is their lack of emotional judgement. Did Curiosity, the rover, ever feel lonely on a planet from which Earth is visible as nothing more than a speck? No, it didn’t. Computers’ lack of sentience and their astounding computational and logical powers make them dominant over us.

Implementing Univariate Linear Regression in Python

The objective of this post is to explain the steps I took to implementing univariate linear regression in Python. Do note that I’m not using libraries with inbuilt ML models like sklearn and sci-py here.

Here is our gradient descent function, utilising mean squared error as the cost function.

def gradientDescent(theta, alpha, iterations):
    
    m = ex1data.shape[0]  # finding the number of trial examples
    n = ex1data.shape[1]  # finding the number of features + 1
    
    for iteration in range(iterations):
        
        total0 = 0
        total1 = 0
        
        for row in range(m): # iterating over each training example
        
            hypothesis = 0
            
            for val in range(n-1):
                hypothesis += ex1data.values[row][val] * theta[val][0] 
                
            load = hypothesis - ex1data.values[row][n-1]
            total0 += load*ex1data.values[row][0]
            total1 += load*ex1data.values[row][1]
            
        temp0 = theta[0][0] - ((alpha*total0)/m)
        temp1 = theta[1][0] - ((alpha*total1)/m)
        theta = [[round(temp0, 4)], [round(temp1, 4)]]
        
    return theta

We carry out gradient descent 1500 times here, by setting iterations equal to 1500. Our starting values of theta are 0. Now, for those of you who don’t know how gradient descent works, here’s a short explanation that attempts to cover the crux of it. Intuitively, we subtract each of our output values as given by the hypothesis function by the target value we’re trying to predict, then square the difference. The gradient descent update rule subtracts the partial derivative of this (beyond us mortals for now) from the existing values of theta – updating them. This entire process repeats 1500 times until gradient descent converges to an optimal value of theta, or the minimum point of the cost function.

Now, we plot our data to see what it looks like.

m = ex1data.shape[0]
print ('No. of training examples --> {}'.format(m)) # outputting the number of traning examples for the user
eye = []

for i in range(0,m): 
    eye.append(1)  # creating an array of 1s and adding it to X
    
if len(ex1data.columns) == 2:  # to avoid an error wherein ex1data already has the column of 1s
    ex1data.insert(0, "feature1", eye)
    
print ('here is theta (initial)')
theta = [[0], [0]]
matrix_print(theta)

Now, we firstly add a column vector consisting entirely of 1s, of dimensions m by 1, to our feature matrix. Hence, we have a feature matrix of m by 2, where one column pertains to our variable data and another to a column vector of 1s. We then initialise both values of theta to 0. Our learning rate, alpha, will be set to 0.01 for gradient descent, and we will execute gradient descent 1500 times. After running gradient descent and plotting our predicted values against the actual dataset, this is what we get:

Pretty cool, right?

This entire example was based on solving the Week 1 problem set of Andrew Ng’s machine learning course on coursera.org through Python. So credits to Stanford University. Stay quarantined, stay safe!

Summary of Reading – March ’20

Homo Deus, Yuval Noah Harari – Scary, impactful, dire, and exciting. As Harari clearly stated towards the end, the book outlines probabilities and not prophecies for the future, but each advancement in technology and each step forward in dataism he predicts bifurcates into multiple, significant impacts on us, humankind. The book pens down paths towards everything from extinction events akin to humans wiping out animal populations, to a downfall of liberalism and a completely deskilled society. Being a practitioner of data science, Harari’s message was something that just didn’t have deep implications, but also seemed real enough to be taken seriously. Another thing that stood out for me is Harari’s explanation of capitalism as a distributed data processing system, and how no single person knows the great machine works, but the great machine keeps on working; how politicians are genuinely oblivious to the working of their nations, because the working of their nation is dependant on how everything falls together and how social forces interact. I compared this to the Foundation Saga as well, where individuals play no role in the greater scheme of things, but what Harari predicts is of a much larger magnitude: humans will play no role at all.

Astrophysics for People in a Hurry, Neil deGrasse Tyson – Worth a read. I had a decent idea about the stuff Tyson talks about in this book beforehand, but that didn’t prevent it from being enjoyable. I especially loved the descriptions of various elements in the cosmic sense: where they came from and their role within the universe. His entire commentary on dark matter and dark energy was also catching, especially how the effect of both counter-acts Einstein’s cosmological constant, which I’ve never heard of before. I especially remember Tyson pointing out how Einstein’s greatest blunder wasn’t the cosmological constant, but instead labelling the cosmological constant as his greatest blunder. He doesn’t betray the purpose of his book, delivering the wonder of the cosmos to all audiences, which is unique given how most books of the non-fiction, science genre pretend to be easy to grasp for anyone at all but end up being warped and confusing for most.

Taking a look at the past and the future of Mechanical Engineering.

Arguably humankind’s greatest engineering and technological accomplishment, the Apollo Program landed a human on a body other than planet Earth for the first time. Constructing and using the command and lunar modules was a major engineering feat. As per the Lunar Rendezvous method, the command module remained in orbit (with one occupant), and the lunar module went down and came back up (carrying two astronauts) – an elegant solution. Making the lunar module was a humongous challenge; it needed to be as lightweight as possible without compromising on any of its functions. In the end, NASA engineers ended up removing the seats themselves.

The construction of the Saturn V rocket is another impressive landmark. It burned 15 tons of fuel per second at lift-off, generated 7.5 million tons of thrust, and stood as tall as a third of the Empire State Building.

Personally, I find how NASA used archaic computer systems to process data and monitor the mission, doing everything from calculating trajectories and ensuring constant communication between Houston and the Eagle, pretty awesome. Do note that these computer systems, today, would be less powerful than an Apple Watch.

However, the most significant impact of the Apollo Program deviates hugely from the engineering and technological advancements it made. It showed Humankind an image of the Earth as seen from the Moon. Seeing this pale blue dot from afar, so small that it could be covered with the back of your thumb, had a profound, overbearing impact on people.

Concerning the future, I think the greatest feat of engineering in the next 100 years will be constructing a human colony on planet Mars. Doing so will require the development of means to transport thousands of tons of equipment, materials, and resources (along with humans) to Mars. We’ll need to set up basic infrastructure on Mars, and build habitats/shelters that enable humans to survive the harsh environment of the Red Planet; a thin atmosphere, dangerously high radiation levels, and wildly fluctuating temperatures.

Transporting materials and humans there will require space travel infrastructure. The sheer amount of traffic involved could warrant the construction of the first spaceport outside of planet Earth, on the Moon, from where taking off would be significantly easier due to a weaker gravitational pull. Reusable rockets will be key, so they must endure trips of upto 2 years upto ten times throughout their lifespans.

Providing water, food, and breathable air to future Martians will require technological innovation. Lab-based agriculture will not not be enough to feed an entire population, so alternate sources of food must be developed. Habitats would need to counter wildly fluctuating temperatures by cooling the system during the night, and heating the system during the day. Furthermore, setting up energy infrastructure on Mars will be even more hard. Solar is a viable option, but is rendered ineffective during dust storms. The current alternative, in my opinion, is nuclear fusion, given that the 100 years of progress that take us to a position where we can construct a colony on Mars also give us the means to harness the awesome power of nuclear fusion.

Summary of Reading – February ’20

Talking to Strangers; Malcolm Gladwell – I think Gladwell set the bar too high with Outliers and David and Goliath. Don’t get me wrong, talking to strangers is a wonderful book but it’s in no way as impactful or as relatable as the two aforementioned books. What made outliers stand out is that it resonated with our desire to succeed and be the outlier in a group of people. What made David and Goliath stand out is the simple fact that everyone has faced a ‘Goliath’ per say at some point in their lives. Gladwell’s primary point over the course of the book is that we really don’t know how to talk to strangers, and while that is elaborated on, the book just isn’t as good as outliers. I think this is a textbook case of an author trying to unsuccessfully grow out of his own shadow. Regarding the book itself, it’s definitely an interesting read. The main lesson I took away from it is that I shouldn’t default to truth and trust everyone I talk to on face value, but also shouldn’t assume everyone is something they don’t appear to be. There’s a broad grey area in there, that’s where I should operate socially. Also, another thing I took away is that jumping to conclusions on what is clearly insufficient data isn’t really comprehensive, and mowing down on it will be helpful.

Origin; Dan Brown – The ending destroys the entire book. Brown spends the entire book building up to a huge scientific discovery, over which people have been killed and monarchs have been allegated, but throws all that tension and suspense down the drain with a discovery that fails to honor the time and effort that went into making it look exciting. Brown tries to balance science, religion, and technology, yet fails miserably. The twist at the end that Winston conducted and oversaw everything, especially the assassination of his creator, is pretty harrowing and way more impactful than the premise of the book itself. I also loved Kirsch’s character, everything from how he collected his old PCs to his Tesla publicity stunts and his pure attention-grabbing nature (relatable). Also, the king’s secret, a.k.a, his gay relationship with the bishop seemed like a complete publicity stunt to me, totally redundant and added nothing at all to the story. Seemed like an attempt at creating something that was barely marketable.

Artemis; Andy Weir – Definitely had the same level of complexity as The Martian, but fails to be as impactful. Really suffered from the protagonist giving too many personal anecdotes, which either came off as either funny or jargon. Also suffered from doing stuff that was either over-explained, or totally unnecessary. Artemis is a continuation of that long tradition of authors not being able to grow out of the shadow of their best-sellers. On the other hand, I loved the setting, and the attention to detail when it came to depicting Artemis. That entire union between a purely sci-fi world and the politics that dominates everyday life on modern day planet Earth is beautiful. The effort that goes into preventing Artemis from being entangled into the web that is crime syndicates and gang wars is also commendable.

Ready Player One; Ernest Cline – Hands down one of the best books I’ve ever read. The pure geekiness, the thrill of playing the game, and all that energy throughout the book are contagious. Every little detail, from Parzival’s X-Wing to countless DnD references. The story, in itself, is quite a rollercoaster. Cline takes the simplicity of solving a series of challenges and applies it to an endless virtual world that is the largest economic asset in reality. Countless planets, endless possibilities; everything from playing your way through movies as the lead character, to programming decades-old computers. There’s a subtle commentary, through the inclusion of the IOI, on how excessive regulation and order (being told what to do the entire time) is deplorable, and doing things for the fun of it is many times more rewarding. Definitely the type of book that can get someone hooked onto programming to a greater extent, and heaven for gamers. It played on my inner tech-savvy personality.

Summary of Reading – Dec’19/Jan ’20

A Century is Not Enough (Sourav Ganguly) – Focused primarily on Ganguly’s fighting spirit during his toughest times, and how he got himself to bounce back no matter how low the odds seemed to be. While we do get an interesting snapshot of his cricketing journey, it definitely would’ve been much more exciting had he spent more words on the IPL, or about his life before representing India. What the book conveys, in my opinion, is don’t give up no matter how much you’ve already done, don’t take your position for granted. On a general basis, not that good a book because it focuses solely on the mental aspects of Ganguly’s game, and has sparsely located personal anecdotes and experiences.

Prelude to Foundation (Isaac Asimov) – A step as compared to Foundation’s Edge and Foundation and Earth. What I took away from the initial stages of the book was the contrast between what psychohistory is in the main trilogy, and how unsure Seldon is of it in the book. Really just showed no matter how improbably or irrelevant something seems at the start, its potential really can’t be measured. The different cultures/societies introduced was also fascinating, especially Dahl. What made Dahl stand out, for me, was just how close equality seemed to be, but the irony involved with Dahlites both wanting equality with other sectors across Trantor, and having factions/ranks within their own societal order (no heatsinkers in the house etc.). The ending was also pretty awesome, especially with Hummin being revealed as Demerzel, but then being revealed as Daneel (robot) who was implementing the zeroth law of robotics the entire time. That part where Daneel reveals who also has another plan he doesn’t want Seldon to know about is also pretty telling, with him obviously referring to Gaia. Really served as the sort of reference that made everything much more connected to the later books (chronological).

The Culture Code (Daniel Coyle) – Not that bad, but not excessively good either. The monotone style of writing made reading the book a tad hard (although a short length rescued it). It was interesting reading about how having techniques that promoted open-mindedness in the form of having the ability to question anything, even the management, was pretty interesting. Some parts were inspirational, not that good a read but still worthy trying, especially if you’re taking a shot at being an effective leader.

Forward the Foundation (Isaac Asimov) – Nearly not as good as Prelude to Foundation. I hated how lonely Seldon became at the end. Plus, I’m not a huge fan of Dors being a robot from the very start. How Seldon’s love “made her human” was pretty emotional, but that reveal was way too forged. Also didn’t like Raych and family moving away, and then Seldon sending Wanda away for her own good. Huge difference between the Seldon here, and the Seldon portrayed in the original Foundation book. Also wanted a closer look at Gaal Dormick. I think the Foundation Saga would’ve been decisively better without the two prequel books, they seem like dead weight to me.

Taking a Look at the Entire Foundation Saga

I finished reading Asimov’s Foundation Saga yesterday, and truth is, it has blown my mind. The sheer number of characters, worlds, plot-lines, and events dotted throughout the entire saga is insane. Science fiction doesn’t get any better than this.

Having a story that spans over half a millennium inadvertently led to tons of characters being introduced and cast away. I think what really stood out for me here is that the individual really is powerless, and effectively irrelevant in the larger scheme of things. What one person does can’t ever impact what larger social and economic forces will eventually do. The best example here is the collapse of the empire’s effort to encircle and besiege the Foundation, regardless of the main characters of the time who tried to play their parts as heroes but later realized they have no position within Seldon’s timeline.

I really wanted Asimov to dive deeper into how psychohistory works. We really don’t know anything, apart from the fact that the prime radiant is the single most important tool available to the Second Foundation, and that it’s a predictive science. The only semblance of ‘work’ we have is people like Yugo Amaryl and Seldon staying locked in their offices almost the entire time (with the story detailing what happens when they’re not working). Another thing that I really didn’t get was the contrast between the Trantor we see at the start of the first Foundation book, and the Trantor we see at the end of the second prequel series book. Foundation started off with depicting Trantor as this colossal metallic world, technologically advanced and densely populated with vibrant civilians. However, the Trantor we see at the end of Forward the Foundation is a bleak, dull world with no semblance of life. A world stumbling in its own steps. In fact, the entire premise of the first book was that the glory of Trantor would be tarnished with time and large forces, but the second prequel presents an already worn out Trantor. Lastly, I really don’t see how the empire’s “slow” disintegration into barbarism takes place over a single lifetime. While the Foundation grows strong over hundreds of years, the entire galactic empire splits apart within a maximum of fifty years. Weird.

However, the entire saga clearly had its highs. I absolutely loved Foundation and Empire and Second Foundation. Here are some of my favorite moments from the entire saga:

  1. Bayta Darell shoots Ebling Mis/Reveals the Mule’s identity – Maybe the most well-executed twist I’ve ever seen in writing. Executed to perfection, such that every single event that occurred before seemed to fall into place and conform to this obvious pattern everyone missed. What struck me even more was the Mule leaving Bayta free of being manipulated by his psychic powers simply because she was the first person in his life who genuinely showed caring for him. Powerful. I think what Asimov meant to convey here was that emotions can play a huge role too in any story. Succeeded to some extent.
  2. The Mule finally conquers Terminus – I really adore the twist that comes with Seldon’s recording being not even remotely close to what’s actually happening. It’s utterly shocking, and after two books which kept Seldon and his psychohistory as the bedrock of the entire story, pretty impactful too. Really just conveys the gravity of the situation, and how big a threat the Mule is.
  3. Seldon’s hearing – Seldon vs Trantor, or rather the Empire is entertaining. It’s a classic play on those science versus politics debates we still have today. Seldon’s assertion of how “Scientific Truth is beyond loyalty or disloyalty” is also pretty chilling.
  4. The Mule’s showdown with the Second Foundation – I enjoyed this entire scene just for the thrill it provided. Psychic powers versus psychic powers was pretty eventful. Really caught my attention. Every person trying to double cross the other and control the situation as per his plan, and every single move turning out to be part in a different person’s setup, so much so that even the reader didn’t know who was who until the Mule was defeated. However, I was a bit shocked by how the Second Foundation sacrificed the people of an entire planet just to defeat the Mule.
  5. The Second Foundation’s location is revealed – I think this is the zenith of the entire saga. Everything really just falls down from here. At this point, everyone is wondering whether the Second Foundation is located at Terminus, Trantor, or another obscure world in an infinitesimally large galaxy. I sort of spoiled it for myself by flipping through the first book, and realizing how Seldon told Gaal Dornick that some would stay behind for another purpose. The part of this entire reveal that really struck me wasn’t the reveal itself, but how Trantor is the place where the “Stars end,” which is quite poetic and somewhat stunning. Brought out some nostalgia as well.
  6. Salvor Hardin subdues Anacreon – Liked this thing simply because of the way Hardin brought an entire empire to its knees using the wonder of science, or rather the dependency of an entire empire on it. A bit like Rick bringing down the value of the galactic currency to null.
  7. Foundation’s Ending – The dialogue about the sun and spear was brilliant. Really put the notion of this ant that the Foundation was at the point facing the mammoth that was the empire, set the tone perfectly for the second book in the series (admittedly this drops off a bit at the start of the second book). I view this entire thing as a giant octopus unfurling its tentacles.

What I loved about the saga was the fact that it explored nearly every facet of human existence, and the sheer quality of science fiction it had. Countless characters; degrading and improving technology; falling and rising galactic empires.