Chapter 5: The Automatic Algorithms Shaping Thoughts, Emotions & Behaviors
- Dr. Vikram Vaka & Dr. Sujasha Gupta Vaka

- May 30, 2025
- 11 min read
Updated: Jan 20

A Manual for Your Mind - The Mathematics Map
The user guide you should’ve gotten at birth
You just opened the instruction manual for the most chaotic, brilliant, occasionally unhinged machine you will ever own. Your brain.
This is not a sterile document written by a lab-coated neuroscientist who has never cried in a Target parking lot. This is the field notebook of someone who’s been debugging their own mind for years, equal parts insight, humor, and hard-earned truth.
Truth 1: Your brain is not a calm monk on a mountaintop. Due to modernity's many quirks and conveniences, it’s closer to a caffeinated squirrel addicted to tik-tok, a trauma history, and a talent for turning minor inconveniences into full-length emotional feature films with a soundtrack, a plot twist, and a post-credit scene.
But here’s the empowering part. You are not just trapped inside this system. You are running it. This manual is about learning how your inner operating systems work, how they fight for the steering wheel, and how to update them when they start crashing the whole day.
You are both the user and the programmer
Most people talk about “the mind” like it’s one thing. It’s not.
Your brain is a stack of systems layered on top of each other like messy software written by different teams across different centuries designed for a much older now defunct OS.
Ancient survival code
Childhood updates
Trauma patches
Social scripts downloaded from family, school, religion, culture
Random weird apps you picked up because they helped once, in 2013, in a specific situation, and your brain never deleted them.
These systems negotiate control constantly. Whoever speaks loudest gets the wheel.
Therapy has a name for this. Parts work.
Internal Family Systems (IFS) basically says, you’re not broken. You’re plural. Your mind is not a single CEO. It’s a large dynamic board meeting that includes:
an anxious protector scanning for danger
a critical manager cracking the whip
a numb firefighter shutting things down
a tired child who just wants to be held
a hopeful visionary still trying, somehow, after everything
None of these parts are evil.
But most are outdated.
Healing isn’t deleting parts. It’s updating roles. It’s turning a screaming alarm system into a smoke detector that only goes off when there’s actual smoke.
You’re not trying to become emotionless. You’re trying to become coordinated.
The core idea
Your brain runs algorithms
Not math-class algorithms. Cognitive algorithms that evolved over millions of years and were modified by decades of real world experiences.
Patterns that decide what you notice, what you fear, what you chase, what you avoid, what you replay at 3 a.m., and what you call “my personality.”
This manual breaks your mind into five interacting layers:
Behavioral algorithms
Emotional algorithms
Cognitive algorithms
Subconscious modifiers
Tribal and meaning systems
Each layer can help you or hijack you. Most suffering isn’t because you’re fundamentally flawed. It’s because the wrong layer is in charge for the situation you’re in. And with practice, you can learn to empower the most effective algorithms, rather than the first ones that arrive on scene.
1) Behavioral Algorithms
The reflex machine
Your reflex system is designed to keep you alive, not to keep you calm.
It reacts faster than thought.
When it detects threat, real or imagined, it launches a full-body protocol. Heart rate up. Muscles tense. Attention narrows. The world becomes a hallway and the only door says “danger.”
If your nervous system has been sensitized by trauma, chronic stress, or early invalidation, the threat detector becomes overclocked.
It starts seeing danger in:
raised voices
unread messages
subtle tone shifts
someone typing…and stopping
a slightly delayed reply
a neutral face that your brain decides is disgust
This is hypervigilance. The body running a war scan in peacetime.
Your brain learned that being alert kept you safe.
So now it stays alert even when you’re safe.
Debug tool
Exposure with safety
The fear is not logical, you likely already know that. But just telling yourself this isn't the fix. You don’t defeat fear by thinking it away.
You defeat fear by teaching your body, through experience, that you can survive.
If you avoid conflict, practice tiny disagreements.
If you avoid emails, open them for two minutes and stop.
If you avoid the gym, walk into the building and leave.
If a task is causing needless anxiety, break it down to the smallest easiest step that gets you started on it, and just do that one single starting step.
If you're anxious about a writing task, write one meaningful sentence and close the notebook. Once your brain sees how painless that was, you will likely automatically find yourself reopening it to add more.
The nervous system trusts repetition. Avoidance only reinforces the fear. But tiny inconsequential confrontations with the very things that you fear, that’s how fear unlearns itself. Not by force. With practice, and evidence.
(... to be expanded on)
2) Emotional Algorithms
The feels factory
Emotions aren’t random. They’re signals.
Anger protects boundaries. Fear protects safety. Sadness signals loss. Disgust protects against contamination. Joy signals alignment and reward. Shame signals social threat.
Shame is especially loud because, for most of human history, social rejection wasn’t “awkward.” Being outcast from your community usually meant death.
So your brain treats embarrassment like a predator. Trauma distorts the signal.
A raised eyebrow becomes rejection. Silence becomes abandonment. A friend canceling becomes proof you are unlovable.
Therapy calls this emotional reasoning. It feels true, so it must be true.
But emotions evolved for a world where rejection usually meant starvation and missing a threat was a death sentence. Thus, strong emotions take full reign and hyper-focus on avoiding the worst possible outcome, rather than reacting to the most likely one. Emotions are not court verdicts.
Debug tools
Name and normalize (DBT) - When you say, “I’m feeling anxious,” instead of “I’m in danger,” you create a gap. That gap is where choice lives, where your prefrontal cortex (the slower more contemplative rational reasoning mind) gets a word in as well.
Self-soothing through the senses - Warm tea. Soft blankets. Music. Gentle movement. Sunlight. A shower. A weighted blanket. This is not indulgence. This is nervous system regulation. A regulated nervous system thinks better. An unregulated nervous system writes horror stories based on vague shadows and reacts accordingly.
(... to be expanded on)
3) Cognitive Algorithms
The inner monologue
Thoughts are not facts. They’re hypotheses.
Your brain is a prediction engine. It uses the past to guess the future. If your past included criticism, neglect, chaos, or unpredictability, your prediction engine becomes biased toward threat.
It starts running the same scripts:
“They hate me.”
“I’m behind.”
“I’ll fail.”
“Something bad is coming.”
“I’m too much.”
“I’m not enough.”
CBT is basically the art of slowing the loop.
Debug tools
Cognitive defusion - Instead of “I’m unlovable,” you say, “I’m having the thought that I’m unlovable.” That tiny shift breaks the spell. It turns a thought from an order into a notification, one that other parts of your brain get a chance to fact check.
Behavioral experiments - If your brain predicts rejection, gather data.
Ask for help. Share a small truth. Set a boundary once. Watch what happens. Your brain trusts experience more than logic.
This is why trauma doesn’t dissolve when you “understand” it. It dissolves when your nervous system collects new evidence.
(... to be expanded on)
4) Subconscious Modifiers
The inner team, the shadow crew
Under the thoughts and feelings, there’s an entire backstage crew running defense mechanisms.
The critic isn’t trying to ruin you. It’s trying to prevent shame. The avoider isn’t lazy. It’s preventing overwhelm. The numb part isn’t cold. It’s preventing pain. The perfectionist isn’t arrogant. It’s trying to control uncertainty.
When you fight these parts, they fight harder.
When you thank them, they soften.
This is the weird paradox of healing.
The more compassion you give the protector parts, the less they need to protect.
Healing is not self-discipline. It’s internal diplomacy, channeled through contemplation and open acknowledgment of what's really troubling you. Diplomacy works better than civil war.
(... to be expanded on)
Maslow and the nervous system
Why you can’t “mindset” your way out of biology
When your basic needs are threatened, your brain locks you out of higher functions.
If sleep is wrecked, your prefrontal cortex becomes a weak manager. If you’re lonely, your threat system turns social cues into danger. If you’re unsafe, your mind becomes a radar, not a cathedral.
You cannot meditate your way out of hunger. You cannot journal your way out of isolation. You cannot “gratitude” your way out of chronic sleep deprivation.
So therapy often starts where people least want to start.
The basics.
Sleep. Nutrition. Movement. Connection. A stable environment.
Without these, every higher-level skill becomes harder.
Not because you’re failing.
Because the foundation is shaking.
(... to be expanded on)
Self-actualization
The growth engine
When the nervous system feels safe and the mind feels supported, something beautiful happens.
Curiosity returns and kindness builds.
You start asking: Not “how do I survive,”but “what do I want to build, achieve or contribute?” You get interested again. You get playful. You get brave. You want mastery. You want meaning. You want to make a positive impact on the universe.
It’s what the human system does when it’s no longer drowning. And it holds the keys to human thriving.
(... to be expanded on)
Final thought
You’re not broken, you’re running old code that is much faster than the newer code that you should be leveraging more.
Your brain is not a glitchy mess.
It’s a finely tuned product of evolution prioritizing software written for a world of predators, scarcity, and tribal judgment. Modern life is safer in many ways, but psychologically it can be more confusing, because threats are abstract, constant, and social. Your prefrontal cortex already has a variety of tools that are better suited to navigate it. It just needs a chance to get a word in.
So the next time your mind spirals into “everything is doomed” mode, pause.
Breathe.
Ask one question.
Which system is running the circus right now?
Is it the reflex machine?
The feels factory?
The inner monologue?
A defense mechanism?
Or your rational contemplative prefrontal cortex?
Just taking that time, to figure out which layer is driving, gives other parts of your brain a chance to make their voice heard as well.
That’s the point of this manual. To turn your mind from a haunted house reacting to shadows as if they were monsters, into a home you can actually live in, where all the parts of your brain get a say.
Why this section exists
This is a look at the mind, for the mathematical, analytical perspective, to translate everyday mental processes into the language of algorithms, without losing the humanity.
Neuroscience and computation give you the mechanics. Maslow and psychodynamics hint at underlying drives, and provide meaning.
This section treats the mind as layered code.
deterministic loops
probabilistic predictions
subconscious defense routines
social operating systems
meaning engines
And it shows how these layers interact to shape emotion, behavior, identity, and suffering.
These tools will be offered freely. Not as self-help glitter, but as practical debugging skills, the kind you can use in the moment when your brain is lying to you with confidence.
Anxiety and survival algorithms
The dose makes the poison
Some anxiety is useful. It sharpens focus. It motivates action. It keeps you awake at the wheel.
Too much anxiety becomes paralysis.
Your brain evolved to scan for danger and act fast. Modern life rarely includes lions. But your brain still reacts whenever your Maslow needs feel threatened, especially safety, belonging, and esteem.
So society needs better tools for this mismatch.
Any culture that frees citizens from constant survival stress will become smarter, kinder, and more creative, because nervous systems stop running on emergency power.
If your survival needs are met, someone near you may not be so lucky. And even small acts of support can change a life, because safety is contagious.
The promise and peril of automation
The machine can free us, or trap us
In theory, automation should remove drudgery and free attention.
In practice, it’s often used to increase friction.
hard to cancel
hard to get refunds
hard to get medical care
easy to be manipulated
easy to be scammed
That’s not “innovation.” That’s exploitation with better UI.
Those uses should be limited or banned, because the damage to wellbeing and productivity eventually outweighs the profit.
Governments have a responsibility to discourage abusive automation and encourage automation that supports human life.
Automation should be leveraged to minimize mindnumbing friction, and reduce cognitive waste, not increase it.
The necessity of imperfection
Why flawlessness is the real trap
Society will always be imperfect, and that’s not a flaw. As the Universe 25 chapter will further clarify, these imperfections are necessary for human survival.
Imperfection creates unpredictability, meaning, and growth. Individuals are also imperfect. Nobody lives up to fictional heroes. And media “perfect protagonist” tropes can train people to despise their own normal human limits.
One especially toxic trope is stubbornness as heroism.
In real life, everyone feels right. The rational view is to acknowledge how little any of us actually knows, about anything. Blind belief is not rational. Stubbornness locks people into destructive loops, even when loved ones are trying to help. It slowly destroys relationships while the person calls it “principle.”
Toward self-actualization
The real goal
The goal for individuals and societies is to help more people move upward.
That requires both personal effort and institutional design. Reduce unnecessary cognitive and emotional strain. Expand access to real mental health tools. Build environments that support nervous system stability, foster agency, novelty, creativity and opportunity.
Societies that do this will advance faster, with less suffering, than those that don’t.
Therapy Summary Table
Processes | Description | Therapy | Personal Changes | Social Changes (Future Chapters) |
Automatic Behavioral Algorithms | Reflexes, habits, addictions, behavioral loops | Behavioral Therapy | Replace triggers, reinforce new habits, start small | Social Planning, Increasing Access to Mental Health Care, Tuning Welfare Systems to Lead to Lasting Changes |
Automatic Emotional Algorithms | Emotions on autoplay | DBT | Use mindfulness, emotion regulation, and crisis skills | Increasing cultural knowledge of effective DBT skills versus counterproductive ones, Expanding Mental Health and Group Therapy |
Automatic Cognitive Algorithms | Thought patterns & inner critic, false negative beliefs | CBT | Catch, challenge, and reframe automatic thoughts | Increasing cultural knowledge of automatic negative thoughts beliefs. Expanding Access to Mental Health Care. Social Planning |
Subconscious Algorithmic Modifiers | Subconscious drives, self deception, defense mechanisms | IFS, Psycho-dynamic | Explore old patterns and integrate shadow parts | Increasing Psychodynamic Training Programs and Expanding Access to Psychotherapy, Revamp fines, jail & other punitive measures. |
Conscious Tribal Algorithms | A sense of belonging | Humanistic, Maslowian | Identify unmet needs and maladaptve patterns, set realistic plans to work on these needs, build better narratives, learn to identify and reject judgment, tribal thinking | Automate away processes that frequently contribute to stress (tax preparation, insurance hoops, childcare, bank fines, simplify the regulatory framework, move the DMV and similar organizations online, improve public transport) in order to minimize cognitive waste & friction, Expand community centers, Expand access to nature, Improve culture cohesion, Identify and address maladaptive paths that lead to school shootings and assassinations. |
Self Actualization Algorithms | Purpose & meaning | High Order Existential, Spiritual | Help others meet their needs, Minimize Cognitive Waste and Friction both in others and in yourself | Actively work towards a post-scarcity utopia, experiment with different ways to make the public active stakeholders and beneficiaries of improved efficiencies such as universal basic income, enable centrally planned corporate cities with alternate systems only as long as full transparency and public access is guaranteed |
Excerpted from ...
Part II: Mind Machines – Integrating Psychiatry & Cognitive Algorithms
Chapter 5: Automatic Algorithms governing Thoughts, Emotions & Behaviors
Automatic thoughts as default scripts
CBT as reprogramming logic loops
Survival, security, belonging as needs-based logic trees
Chapter 6: Subconscious Drives, Self Deceptions & Maslow's Needs
Bipolar disorder, schizophrenia, PTSD as logic errors
Goal-setting for healing: restoring hierarchy of needs
Freud’s subconscious needs vs. Maslow’s conscious ones
Chapter 7: The Maslow Protocol at Scale
Reframing human progress through Maslow’s hierarchy
Dramatic progress as an emergent property of partially self actualized components of our Multi-Conscious Organism utilizing the Scientific Method Algorithm
Recent setbacks due to tribal divisions leading to multitudes of Multi-Conscious Organisms fighting each other rather than working together
A shared purpose - Systemic improvements to make life fulfilling and fun.
Chapter 8: Automated Healing
Survival → Security → Belonging → Esteem → Actualization → Transcendence
Automation to meet bottom tiers
Behavioral therapy at scale
The future of therapy: AI-assisted CBT, DBT, and Behavioral Therapies
Educating people on AI-assisted Psychodynamic Therapy as a way to explore Subconscious Biases, Defense Mechanisms & Self Deceptions/Hidden Elephants
Exploring Maslowian Inspired Motivation Enhancement Therapy to help people end maladaptive patterns and take productive steps towards esteem, love and belonging.




Comments