GeistHaus
log in · sign up

bagelpour

Part of wordpress.com

mmmm bagels

stories
Taking an Inverse Position on Tesla
Uncategorized
I'm investing in a bunch of TSLS (inverse etf for tesla). This blog post somewhat explains why.
Show full content

I think the U.S. is in a bit of a bubble right now. I’m not the first to say this; many people have said the same thing already. But I can profit off of this belief, by finding particularly overvalued stocks and taking inverse positions — inverse etf’s have become readily available in the last 5 years or so. I’m taking a large (compared to my net worth) inverse position on Tesla by purchasing TSLS. This blog post serves three purposes:

  1. Explain what I was thinking so I can look back on it later, and hopefully learn something from the ways I was right and the ways I was wrong
  2. Force me to clarify my thoughts somewhat
  3. Allow me to say “called it!” when I make money on this 😛

Roughly speaking, there are five reasons I think Tesla is overvalued:

  1. It’s a meme stock
  2. The cars are not competitive
  3. The robotics play is going nowhere
  4. The AI play won’t save them
  5. The shareholders make bad decisions

It’s a Meme Stock

Elon Musk is infamous. He’s loud, gets involved with media in unconventional ways, and makes his opinions very public. They are often libertarian and conservative ideas, bold engineering claims, and things like that. Even the products are associated with political stances; the cybertruck is decidedly conservative. At the same time, many retail investors now invest just for laughs, or as an expression of personal beliefs (eg, the GME rally, the rise of r/wallstreetsbets, cancelling / supporting companies due to political stances, etc). This combination means TSLA has been supported by a lot of these investors.

None of this is attached to the fundamental performance of the company, so it carries the stock price above where it should be.

The Cars are Not Competitive

There are tons of competitors in the EV space now. Outside the US, BYD is famously affordable and feature-rich, and there are many other challengers that are just getting started. Tesla’s competition outside the US is both better and cheaper, so I think it is basically doomed internationally. Even within the US, many traditional car manufacturers have competitive EV options. Most options are now similar on big items like range and charge time, and the overall finish of vehicles is generally better from the traditional car manufacturers. If somebody wants an EV, a Tesla is no longer the clear choice. Tesla-as-a-car-company is no longer disrupting an established industry, and so should be priced similar to conventional car companies. I think it should be towards the low end due to its limited product selection, and heavy reliance on public whims. Scrolling through this list [1] in Nov 2025, the P/E ratio for traditional car manufacturers ranges from about 4-40. Tesla’s P/E ratio is at 262, so I’ll say it’s overvalued as a car company by roughly an order of magnitude. Tesla is not just a car company, but I do think it’s still primarily a car company. I’ll discuss its other products in later sections, but for now I’ll just say I don’t think the other products fully justify this valuation difference.

The Robotics Play is Going Nowhere

Consumer robotics is really hyped (in Nov 2025). But people who have been in the industry for a significant length of time have a much more restrained view of the short-term possibilities. The main thing we want from consumer robotics is functional interaction with the real world. We want robots to clean our table and put the dishes away, or to pick up the toys in a child’s room. And we want that for less than a housekeeper costs. But interaction with the real world is really hard. Humans have sensing across their whole bodies, if you brush somebody or a wall, you know it immediately. And when people lose sensing, this is a significant issue – when diabetic people don’t have feeling in their feet, it is a significant risk to their wellbeing! We take this kind of sensing for granted, and replicating this sort of thing is still decades off for robotics. Sensing pressure even at a small number of distinct places is expensive. Sensing over a large area with good location detection is practically non-existent, this is the realm of PhD projects. Without this sort of sensing, we will not have robots that can safely crack eggs, or carry your good dishes, or avoid stepping on your baby. If you want a more authoritative and in-depth discussion, here’s a good article from Rodney Brooks on the topic [2]

I have given a pessimistic outlook for consumer robotics in general in the next few decades. Tesla is even further behind. First, they have committed to a humanoid design, which is very much in the zeitgeist right now, but is just stupid. Balancing safely on legs is hard. We don’t need to add this sort of difficulty to an already difficult problem. And their demos have been mostly smoke and mirrors, with motions preplanned, or with robotics remotely piloted by people off-stage. The main tell-tale signs are the motion of the robots itself. The links move slowly, the feet don’t confidently touch the ground, it generally looks awkward. If the robot could walk confidently, it would be doing it. Look at the Boston Dynamics videos for a good example of more confident motion (and even those videos have elements of pre-planning). It is so much harder to move intelligently in a new space, without pre-planning or coordination in advance. Tesla’s robotics progress is impressive given how recently they began. But they are not going to magically overcome the difficulties that have plagued robotics for 40 years.

The AI Play Won’t Save Them

It’s not entirely clear what Tesla’s AI work is meant to do. Is it supposed to make self-driving cars a reality? Is it going to paper over the difficulties in manipulation for their robotics effort? Is it going to be a pure AI play? I don’t think it particularly matters, because it’s going to lose at all of these. There is no reason that Tesla’s self-driving capabilities will be any better as a service than the many competitors. Indeed, they seem to be losing to Waymo in this regard. The AI cannot overcome lack of sensing for the robotics case. And there are dozens of pure AI companies at this point, so the chance that Tesla wins significant market share there is very small. Indeed, Musk has his own distinct entry in this space (xAI). Overall, I see little promise for the AI efforts. I think they are fueled more by general AI optimism than by a well considered plan. 

The Shareholders Make Bad Decisions

Because TSLA behaves like a meme stock traded on ideals and emotions, shareholders often approve whatever Musk proposes. He was recently awarded a large pay package with plenty of contingencies. The contingencies make it nearly impossible for Musk to get the full possible reward, but the details of the package are themselves ridiculous. It expects Tesla to become the most valuable company in the world. The unrealistic plans were approved largely because Musk supported them. This is wasted effort, bad planning, and little accountability for Musk. Without anything keeping him in check, Musk is free to make poor decisions and extract value through any means possible. This is not good for the company.

Reasons I Could be Wrong

These are a couple ways I could foresee being wrong. First and most important, Tesla also has a solar and battery energy storage business. As time goes on, more and more competitors are popping up in these spaces, but I understand that Tesla’s offerings are genuinely pretty good. They were an early entrant into the space, and their head start in development will likely keep them ahead for a while. I don’t know whether they’ll maintain that lead, but I see this as the largest potential growth opportunity. Solar is exploding in demand, and I expect that to continue for a good while.

Second, even if Tesla fails as a company in its own right, Musk might direct one of his other enterprises to buy Tesla outright. He was accused of doing something like this for SolarCity. I don’t know enough to say whether the SolarCity acquisition was a bailout, but in either case it’s possible that he does it with Tesla. I don’t think this is a very large risk, because it doesn’t make good business sense. It would generally be better for him to let Tesla go bankrupt, and keep his losses separate from his profits. 

Third, if Tesla gets a lot of political favor, it might receive political support or subsidies despite weak product offerings. At this point I think this is unlikely; Musk has basically fallen out of Trump’s favor, and remains broadly popular mainly with staunch libertarians. 

Overall

I think there is broadly a bubble in the US economy, but Tesla is particularly overvalued. Its valuation is too high as a car company, and I don’t believe the robotics or AI will be profitable enough to “save” it. It may do well in renewable energy, but this is not enough to pin all its hopes on. Especially with the retail enthusiasm for the stock, and the poor financial decisions that the shareholders have allowed. When the bubble bursts, I think Tesla will be one of the harder hit stocks. Additionally, the EV shortcomings are already beginning to show, and are only going to get worse as BYD’s lead grows, so I think it will start falling in the near term (say within the next two years?). I am willing to hold an inverse (TSLS in this case) and wait for a couple years until this comes true.

[1] https://companiesmarketcap.com/automakers/automakers-ranked-by-pe-ratio/

[2] https://rodneybrooks.com/why-todays-humanoids-wont-learn-dexterity/

http://bagelpour.wordpress.com/?p=211
Extensions
Advice For a New Business
Uncategorized
I feel I’ve learned a lot from running a small business. I have some advice for people who are just starting a business, or are considering doing so.
Show full content

I run a small business (Dragonskin, we sell stingray-resistant booties) with a friend, and I feel I’ve learned a lot from my time doing this. I have a lot of advice I want to give to people who are just starting a business, or are considering doing so. I do want to add a disclaimer that we are mostly a d2c hardware business. I think some of this advice will be different for b2b businesses, and for software or service businesses.

Use Standard Tools When Possible

You’ll be tempted to reinvent how things are done frequently. We have an LLC, and we’ve basically written our operating agreement from scratch, because we thought we could do better. In retrospect, this was really dumb, I think we should have used a standard version we found on the internet. It’s possible that our invented agreement is better, but at this point we’ve spent weeks revising it to get to something we all agree on, and I’m sure there are still some sharp edges that we haven’t gotten to yet. I wish we had copied a standard operating agreement, read through it and made any important edits, and mostly just accepted the standard rules. I think that would make disagreements less dramatic, and reduce situations where the rules are unclear. Similar temptations will come up frequently, you might disagree with some business practice, or dislike standard accounting methods, or something like that. But unless it is the core service you’re offering, I strongly recommend to use whatever is standard. Good business should mostly be boring.

Customer Service is Incredibly Important

It’s probably more important than you realize. We have extremely good reviews, and of course we do care about our product, but I think the main reason we have good reviews is because we have incredible customer service. When people call for support, they get to speak with me directly. People love this. We also stay connected to our customers’ problems in an incredibly direct way. 

I think the importance of customer service probably increases as you move up to more premium products. If you can, I think you should run customer service directly yourself, for as long as you can. As Paul Graham says, “Do things that don’t scale”

Small Distractions Will Kill You

There are a billion things to do, and new businesses are of course very small. Dragonskin is particularly small, with only two people right now (just me and my friend). Prioritization is in my opinion even more important in scenarios like this, because if we aren’t focusing on the “most important things”, then nobody is. 

For example, filing taxes is an incredibly painful waste of time – it gives our business literally no value, it’s just something we have to do. It costs us a couple days for no reason every quarter. There are many things like this: bikeshedding color palettes, spending too long on blog posts, getting the social media posts just right, etc. You can often find an excuse to say “well no, the thing I’m doing right now is actually super important, even though it doesn’t seem like it”. If you find yourself saying things like this, I think you’re usually lying to yourself. You should be ruthless with how you invest your time. 

Think About How you Will Sell

Before you start a business, you should know how you will make sales. Are you going to set up a stand in your yard? Are you going to make a website? Why will people come to your website? Why will the people that have a need for your product specifically come to your site? Why will they trust you to sell them this product. 

I believe this is standard advice, but I think we overlooked it for a long time, and we’re basically just lucky that it seems to be working out. My main message here is: having an idea and execution is not enough, you also need a venue to get your product to the people that want (or will want) your product. 

It’s Hard to Value Your Time Appropriately

You may value your time too highly, pay for lots of services, and then get to the end of the runway with no business. You might alternatively value your time too low, force yourself to do tons of manual labor, and then you can’t make progress because there’s not enough time to focus on what really matters. You may even value your time perfectly, and still find that you’re running out of money – this means that you’ve learned there is no viable business with this idea, right now, with this team.

As one example, I think we tend to undervalue our time. We did some stupid stuff like shipping the product ourselves for way too long. In retrospect, I would try to move to a third party logistics provider much sooner, perhaps after we shipped the first 300 booties or something. But it is really hard to figure out the right way to value your time, in the moment. We were trying to “do things that don’t scale”, but it meant that we did basically no engineering or advertising for many months, which was not the right tradeoff. So how do you figure out the right way to value your time? I don’t have a bulletproof solution, but here’s my suggestions:

  1. You should have a list of big business goals, and have a guess at the time investment needed, and the relative importance. If you find you’re working on something that doesn’t have the highest importance-per-time, then you’re probably evaluating this wrong.
  2. Non-business things also matter – visiting family, eating well, working out, etc. You should maintain your baseline mental and physical health no matter what. If you die, the business will not succeed. And, god forbid, that won’t create any shareholder value.
  3. If you grew up poor, you probably undervalue your time. If you’re cooking dried beans, sewing clothing repairs, etc, you’re probably doing it wrong. To be clear, I’m not throwing shade, I just think it’s the wrong choice unless they help you maintain mental health or happiness. Sometimes I just want to cook beans. But canned beans (or even restaurant beans) are cheaper than the labor of making beans. 
You Probably Won’t Get Your Dream Cofounder

The very first important characteristic of a cofounder is that they are willing to start a business with you. There is a certain level of craziness that most people don’t have. Your wicked smart friend who double majored at MIT probably won’t be willing to take a big risk with their future, to do accounting themselves, to run ads, to photoshop media when contractors don’t deliver, etc. Your best cofounder will probably be somebody who’s slightly worse than your first choice, but will at least go in to it with you. If your most brilliant, closest friend is also crazy enough to start a business with you, you are exceptionally lucky. Most teams are born out of compromise.

Iterate Faster

Focus is really important. Iterating fast is really important, especially as a young company. You need each iteration to have real improvements over the last one, and you need enough time with customers to get real feedback on each iteration. But anything slower than this is wasted time. Perfection is something that can only be attained asymptotically, as time approaches infinity. You should never be aiming for perfection in any specific revision. If you think you’ve obtained perfection, then this means you significantly overinvested in one area, and are probably neglecting marketing, expansion into new markets, or something like that.

You’ll Get Mad, and That’s Ok

I’m sometimes mad at my business partners. They’re sometimes mad at me. We get mad because we care about the decisions we’re making, they’re important decisions, and we can’t see eye-to-eye. On top of this, we usually have limited time to discuss, and it’s difficult to have the full context on anything. I think you have to accept that you’re going to get mad, talk about this with your partner, and reiterate that you’ll still be friends even when you’re mad at each other. It will be uncomfortable, but good things often are. You can choose not to give up on each other as friends, and if you just don’t give up, then you’ll always be friends.

Do Less

It’s common advice that you should start in a niche, and expand from there. I think you can more generally aim for the smallest, most important thing, and grow from there. Maybe your product only works 90% of the time when you first ship. Maybe it’s really ugly. Maybe your did horrible accounting for the first year, and you’ll have to hire a tax person to clean it up for you in a year. This is all fine. Your product will be an MVP, and your business will be as well. Don’t get caught up setting up all the things you think a business does. You should focus only on what’s most essential for the business, and when you establish that it’s working and you have some space, then you can go fill in that other stuff.

http://bagelpour.wordpress.com/?p=200
Extensions
Amazon LP Suggestions
PhilosophyUncategorized
My shortlist of suggested changes to the present Amazon LP's
Show full content

I’ve worked at Amazon doing consumer robotics for close to 5 years now. Call me a teacher’s pet, but I really like the Amazon LP’s. I spend a good amount of time thinking about what I’d change. Here’s my short-list of suggestions:

  1. There should be an LP around iterating faster. Amazon is obsessed with mechanisms, and this can lead to lots of bureaucracy. Additionally, “Insist on the Highest Standards” often leads to demanding perfection in MVP’s. In theory this problem should be balanced out by “Bias for Action” and “Invent and Simplify”, but my claim is that this balance isn’t working. I want an LP specifically saying “Do it faster! Reduce cycle times! Iterate faster!”. So that’s my proposal for a new LP: “Iterate faster!”
  2. I want an LP modeled around this one element of the Hacker News guidelines [1]:
    Please respond to the strongest plausible interpretation of what someone says, not a weaker one that's easier to criticize. Assume good faith.
    I love this principle, because it implies that discussions only get stronger, never reducing to squabbling over details. I feel it is common at Amazon for people to fight to prove they are technically correct, without actually addressing the important points of a discussion. This pains me greatly — it is a very unpleasant experience, and it doesn’t even accomplish much. In theory this behavior could be counteracted by “Earn Trust”, however any squabblers will likely say they are just trying to “Insist on the Highest Standards”. I want a nuclear option to end these debates. My proposal for a punchy rewording is “Steel-man your opponent”. If you haven’t heard of “Steel-manning” there’s a devoted section in the Wikipedia article on “Straw Man” [2]
  3. We need to workshop the new feel-good LPs. I think they were added primarily for the PR boost, and they really are a product of their times. I’m talking explicitly about “Success and Scale Brings Broad Responsibility” and “Strive to be Earth’s Best Employer”. These essentially boil down to an exhortation “try and help others in this specific subset of ways”. I think everybody should consider their own morals, and figure out what they feel obliged to do for the world. But these LPs give overly specific rules about what individuals should aim for, and those rules won’t match everybody’s personal morality. I would be ok with something more vague like “Do Something Good”, but we’re really approaching Google territory with that.

These changes are meant to be taken relative to the LP’s presently in existence — March 2025.

[1] https://news.ycombinator.com/newsguidelines.html

[2] https://en.wikipedia.org/wiki/Straw_man

http://bagelpour.wordpress.com/?p=190
Extensions
Articles I like
Uncategorizedarticles
This is a list of articles/videos/authors that I like. In the case of articles and videos, the entries are good enough that I'd reread them. In the case of authors, the entries are good enough that I subscribe and regularly read their content.
Show full content

This is a list of articles/videos/authors that I like. In the case of articles and videos, the entries are good enough that I’d reread them. In the case of authors, the entries are good enough that I subscribe and regularly read their content.

When to move between roles, importance of communication, how to continually learn, how to set incentives

One approach to do great things

How to build the future

How to decide what to build

An inspirational article, how to aim higher, etc

Predicting the future is hard, so how can you plan to improve chances if success?

What kind of growth is realistic from new companies/products/marketing campaigns

Key ingredients / constraints for small businesses

How to make progress when you’re just beginning, with minimal resources, connections, and experience

(One take on) how you should think about developing successful products

How should you spend your life? A definitive guide in only ~2000 words! 🙂

Easy rookie mistakes to avoid when starting a business

A clever way to prioritize features

I regularly read / watch:

  1. Product for Engineers — a newsletter about startups in general, but I feel the focus is product design, marketing strategies, and scaling up
  2. DevTools Brew — a newsletter about new companies making tools for developers
  3. Bits about Money — a newsletter talking about financial infrastructure. It frequently changes my understanding of banks, risk, loans, etc, in ways that I think may be useful
  4. Patrick Boyle’s videos — a good way to stay up to date on finance, with a pretty sober and realistic perspective (imo)

http://bagelpour.wordpress.com/?p=167
Extensions
GPT3 Can’t Write Blogposts For Me
WebappsAIfinancial planner
I try to get gpt3 to write a blogpost about tarot, my toy webapp. In short, it's not very good.
Show full content

Initially, I wanted to make some claim about all the excitement around AI. I wanted to say it’s overhyped, or at least the excitement around ChatGPT and LLMs is too much. People seem to believe that AI can replace all sorts of skilled labor without much evidence for that view. I think a lot of the arguments presented contain specific examples and then a giant leap of faith – something like “It found the derivative of this function, so of course it’s good at calculus”. But I can’t point out the errors in everyone’s arguments in finite time. And I think there really are tons of use cases that are perfect for AI! “AI” is a catch-all name for a wide variety of tools, and the proof is in the pudding – if the tool does the job well enough to meet the requirements, then it’s good at that job. If it can’t… then it’s not. So here’s a use case that I think I can evaluate it for, and (spoilers!) my conclusion: GPT3 can’t write the kind of blog posts that I want.

The Setup

My last blogpost was an explanation of how my webapp tarot works. I think this is the kind of thing that GPT3 could be relatively useful for in theory:

  1. GPT3 seems to have the capabilities to write this kind of thing:
    1. GPT3 can understand (some amount of) code
    2. GPT3 can explain some things clearly to humans
  2. As a developer, I don’t want to spend human time understanding a codebase. If AI can give me a good overview, that saves me time and makes me more productive — so this seems useful!

Here’s what I did:

  1. Made a quick python script to concatenate all the files used for tarot together, with labels at the start and end of every file
  2. Wrote an introduction for GPT3, to explain what I’m expecting it to do. I thought this was pretty generous:
    1. I made a simple financial planning webapp named tarot, built using django and deployed using heroku. Please write a summary of the project, in the style of a blog post. The summary should be 5-6 paragraphs long, and focus on interesting technical aspects of the project. Among other things, please discuss:
      1. The use of decorators, and how  they reduced the amount of code I needed to write
      2. The use of the django-guest-user library
      3. The assumptions about how the user will save and invest their money
      4. Some financial scenarios that wouldn’t fit tarot’s assumptions about saving and investing
      5. How the plots in the homepage are made
    2.  Here are the contents of the most important files:
  3. Pass in the prompt, along with the giant concatenated file to a couple different models, which will give us back a blog post. I tested:
    1. Gpt-3.5-turbo-16k in June 2023, without giving an explicit list of things to discuss
    2. Gpt-3.5-turbo-16k in June 2023, with the prompt as discussed above
    3. Gpt-3.5-turbo-16k in September 2023, with the prompt as discussed above
  4. Read through the results, see how I like them

Caveats:

  1. There might be a difference between ‘me liking the results for my blog’ and ‘useful to save developer time’. I’m just using my blog requirements as an approximation.
  2. I would have liked to test on gpt4, but I don’t have access to that. I’ll update this if I do get access
  3. Any other changes I should make, to get better results? Let me know!

You can look at the results in the following sections – sorry, some of them are rather long. I added footnotes on features of the writing that I thought were interesting, and on things that were plain wrong. I’m going to put my conclusions first, so you don’t have to read all the way to the end for them.

Conclusions
  1. If I don’t give it significant help, it’s writing kindof sucks – see the first example
  2. Related to the above, it only talks about things that I explicitly included in the instructions
  3. Sometimes it’s just wrong. Of course, humans do this too.
  4. It’s pretty eager to talk about a product launch. I asked it for a blog post about the interesting details of the project, not a product announcement – I think it’s missing the assignment a bit here.
  5. I feel the writing is a bit to clinical for a blog post — I want more character. This is probably my fault, I could have asked it to write in a certain style.
  6. None of the outputs were really usable, and I ended up writing the blog post manually. It turns out the hardest part of writing that blog post was trying to get gpt3 to write it for me ¯\_(ツ)_/¯

Attempt 1: Gpt-3.5-turbo-16k in June 2023

Note: I didn’t give it an explicit list of things to discuss in this prompt

Tarot: A Simple Financial Planning Webapp

By [Your Name]

I am excited to announce the launch of Tarot, a web application designed to help users plan their financial future. Tarot is built using Django and deployed using Heroku, making it easily accessible to users.

One of the interesting technical aspects of this project is the use of Django’s admin.py file. This file allows for easy management of the application’s models in the Django admin interface. In Tarot, the admin.py file is used to register the models, including WorkCashflow, ChangeInIncome, ChangeInExpenses, and Goal. This simplifies the process of adding, editing, and deleting data in the application.

Another technical aspect1 is the use of forms.py to define the forms used in the application. Tarot utilizes several forms, including WorkCashflowForm, ChangeInIncomeForm, ChangeInExpensesForm, GoalForm, and RecordDatapointForm. These forms are used to collect user input and validate the data before it is saved to the database. The forms also provide helpful hints and labels to guide users in filling out the fields correctly.

In the models.py file, Tarot defines several models, such as WorkCashflow, ChangeInIncome, ChangeInExpenses, Goal, and Datapoint. These models represent the different aspects of a user’s financial plan, such as their income, expenses, savings, and goals. The models include fields for storing data such as starting savings, yearly income, and retirement growth rate. They also define relationships between models, such as the foreign key relationship between User and WorkCashflow2.

The views.py file contains the logic for handling user requests and rendering the appropriate templates. It includes functions for displaying the index page, about page, and home page, as well as functions for handling forms related to income, expenses, goals, and observations. One interesting aspect is the use of the Plotly library to generate interactive plots of the user’s financial projections based on their inputs.

Overall, Tarot is a simple yet powerful financial planning web application built using Django and deployed using Heroku. It provides users with a user-friendly interface for planning their financial future and includes features such as income and expense tracking, goal setting, and investment projections. With its intuitive design and helpful features, Tarot aims to make financial planning accessible to everyone.

Attempt 2: Gpt-3.5-turbo-16k in June 2023

Introducing Tarot: A Simple Financial Planning Webapp

We’re excited to announce the launch of Tarot, a web application designed to help you plan your financial future. With Tarot, you can easily estimate your future finances and make informed decisions about saving and investing. Built using Django and deployed on Heroku, Tarot offers a user-friendly interface and a range of useful features.

One of the interesting technical aspects of Tarot is the use of decorators, which greatly reduce the amount of code needed to be written. Decorators are used to define the behavior of certain views and functions, making the code more concise and modular. This allows for easier maintenance and scalability of the application.

Another notable feature of Tarot is the integration of the django-guest-user library. This library enables the creation of guest users, allowing users to explore the application without the need for registration or login. This enhances the user experience and encourages users to try out Tarot without any barriers.

Tarot makes certain assumptions about how the user will save and invest their money. It assumes that the user’s income will first cover their expenses, then be used to build an emergency fund, contribute to retirement, and finally, invest any remaining funds. While these assumptions may not fit every individual’s financial situation, they provide a simple framework for planning and can be easily modified as needed3.

However, it’s important to note that there are some financial scenarios that may not fit Tarot’s assumptions. For example, if a user plans to make significant withdrawals during retirement or has specific investment strategies that deviate from the assumptions, Tarot may not accurately reflect their financial future. In such cases, it’s recommended to consult with a financial advisor or customize the calculations in Tarot to better align with individual goals.

The plots on Tarot’s homepage are generated using the Plotly library. The data for the plots is calculated based on the user’s input and assumptions. The plots show the projected net worth, savings, retirement funds, and other investments over time. These visualizations provide a clear overview of the user’s financial trajectory and can help in making informed financial decisions.

In conclusion, Tarot is a simple and user-friendly financial planning webapp built using Django and deployed on Heroku. It offers interesting technical aspects such as the use of decorators and the integration of the django-guest-user library4. While Tarot makes certain assumptions about saving and investing, it provides a useful framework for financial planning. However, it’s important to consider individual financial scenarios that may not fit these assumptions. The plots on the homepage are generated using the Plotly library and offer visual representations of the user’s financial future. Explore Tarot today and start planning your financial journey with ease!

Attempt 3:  Gpt-3.5-turbo-16k in September 2023

Tarot: A Simple Financial Planning Webapp

I recently built a simple financial planning webapp called Tarot using Django and deployed it using Heroku. Tarot is a tool that allows users to estimate their future finances and plan for their financial goals. In this blog post, I will discuss some interesting technical aspects of the project.

1. Use of Decorators: I used decorators in Django to reduce the amount of code I needed to write. One decorator I used is the `allow_guest_user` decorator, which allows users to access certain views even if they are not logged in. This decorator is useful for the homepage, where users can try out the demo without having to create an account.

2. Use of the django-guest-user library: To implement the guest user functionality, I used the django-guest-user library. This library provides a decorator that allows users to access views as a guest user without creating an account. This is useful for the homepage, where users can try out the demo without having to create an account.

3. Assumptions about saving and investing money: Tarot makes certain assumptions about how users will save and invest their money. It assumes that users will first cover their expenses, then save up an emergency fund in their savings account, contribute to their retirement, and finally invest any remaining money. This assumption is based on the common practice of prioritizing expenses, savings, and investments in financial planning.

4. Scenarios that don’t fit Tarot’s assumptions: Tarot’s assumptions about saving and investing money may not fit all financial scenarios. For example, Tarot does not account for variations in income or expenses over time, such as changes in salary or unexpected expenses5. It also does not consider more complex investment strategies or other financial goals that may not fit the assumed pattern of saving and investing.

5. Plots on the homepage: The plots on the homepage of Tarot are generated using the Plotly library. The plots show the projected net worth, savings, retirement, and other investments based on the user’s input. The plots are interactive and allow users to explore their financial projections by zooming in or out and hovering over data points for more information.

In conclusion, Tarot is a simple financial planning webapp that allows users to estimate their future finances and plan for their financial goals. The project incorporates interesting technical aspects such as the use of decorators, the django-guest-user library, and the generation of interactive plots using Plotly. While Tarot makes certain assumptions about saving and investing money, it may not fit all financial scenarios. Future improvements to the project could include additional features and enhancements based on user feedback.

Attempt 4: Gpt-3.5-turbo-16k in September 2023 (again)

Tarot: A Simple Financial Planning Webapp

I am excited to announce the launch of my new project, Tarot, a simple financial planning webapp built using Django and deployed using Heroku. Tarot aims to help users estimate their future finances and make informed decisions about their money. In this blog post, I will highlight some interesting technical aspects of the project.

One interesting aspect of Tarot is the use of decorators, which allowed me to reduce the amount of code I needed to write. For example, I used the `allow_guest_user` decorator to allow users to access certain pages without logging in. This eliminated the need for separate views and templates for logged-in and guest users, simplifying the codebase.

Another interesting aspect of Tarot is the use of the django-guest-user library. This library provides a simple way to handle guest users in Django by automatically creating and managing guest user accounts. This allowed me to implement guest user functionality in Tarot without having to write custom code or modify the Django authentication system.

Tarot makes certain assumptions about how the user will save and invest their money. It assumes that users will first cover their expenses, then save up an emergency fund, contribute to retirement, and finally invest any remaining money. This pattern is commonly followed by many people and provides a simple framework for financial planning.

However, there may be some financial scenarios that don’t fit Tarot’s assumptions. For example, users who have different investment strategies or prioritize different financial goals may find that Tarot’s projections are not accurate for their specific situation. It’s important for users to consider their unique circumstances and make adjustments to Tarot’s assumptions as needed.

One of the key features of Tarot is the plots on the homepage, which provide a visual representation of the user’s projected net worth, savings, retirement, and other investments over time. These plots are generated using the Plotly library, which allows for interactive and customizable data visualization. The plots are based on the user’s input for income, expenses, investment plans, and recorded observations.

In conclusion, Tarot is a simple financial planning webapp that aims to help users estimate their future finances and make informed decisions about their money. It leverages Django and the django-guest-user library to simplify development and provide a seamless user experience. While Tarot makes certain assumptions about saving and investing, users can customize and adjust the projections to better fit their specific financial goals and strategies. The plots on the homepage provide a visual representation of the user’s projected financial journey, helping them track their progress and make informed decisions.

Footnotes

1What is it with this wording? “One of the interesting technical aspects”, “Another technical aspect” — this sounds like early high school writing :/

2Its explanation of forms, views, and models shows that it understands how django works, but really says very little about tarot itself. I think it’s just regurgitating what it knows about django projects.

3gpt43 is incorrect here — the assumptions about the order in which the user allocates their money cannot be modified by the user. It is hardcoded into the design.

4just more high-school level writing

5This is false — you can record changes in expenses or income in tarot

http://bagelpour.wordpress.com/?p=157
Extensions
Financial Planning Webapp: Part 2
Webappsfinancial planner
I made a financial planning webapp, and it's live! I'm the only customer, but that's ok.
Show full content

I made a financial planning webapp about 1 year ago, and had a lot of fun working on it. Documenting progress was less fun, but some sort of update is overdue. I’ll try to give a snapshot of how the webapp works now, in May 2023 (it’s live at https://www.bageldreams.com/tarot/!). You can see all of the currently deployed code at https://github.com/baghelp/tarot, and this post will just highlight the most interesting / important bits.

Layout

There are now three different django apps, packaged under the same django project:

  1. The actual financial planning webapp (tarot)
  2. An accounts management system
  3. A separate webapp, meant to help with learning c++ (code_immersion)

These are organized in this way because I didn’t want to pay for additional heroku dynos – these all use a single dyno. Having the accounts management system in a devoted app separate from the main tarot app makes things a bit cleaner and easier to maintain. Additionally, it made it very easy to integrate django-guest-user, an app that automatically handles converting visitors into users without deleting the progress they made before making an account. 

The account management system is not yet implemented for code_immersion, so it still has no login – anyone can use it, but it doesn’t save their progress. Honestly I’m not sure if I’ll ever build the saving functionality – it’s nice to be able to see your progress, but is really not necessary for practicing C++.

Here’s the folder structure. I had to simplify this a bit so it’s actually readable:

tarot
├── accounts
│   ├── migrations
│   └── templates
│   ├── guest_user
│   └── tarot_accounts
├── code_immersion_app
│   ├── migrations
│   ├── static
│   │   ├── code_immersion
│   │   └── img
│   └── templates
│         └── code_immersion
├── common_templates
├── staticfiles
│   ├── admin
│   ├── code_immersion
│   │   └── node_modules
│   │     └── diff
│   ├── codemirror
│   ├── img
│   └── tarot
├── tarot
└── tarot_app
     ├── migrations
     ├── static
     │   ├── img
     │   └── tarot
     └── templates 
          └── tarot

When I started doing stuff with django, I didn’t understand why I would want to have multiple apps under the same project. I’ve found this quite useful though – the division of responsibilities makes it much easier to know the ‘right place’ for things, and simplifies working with other libraries.

This diagram for tarot (made with django-schema-graph) shows how some different parts of the app are connected. Tarot makes some very strict assumptions about the user’s financial plan, which allows the data for a user’s to be stored in very few models – the ‘Goal’, ‘Datapoint’, ‘WorkCashflow’, ‘ChangeInIncome’, and ‘ChangeInExpenses’ models are enough for a user’s finances. If it was more general-purpose, there would need to be a lot more pieces to this. Nonetheless, I think this method covers ~50% of cases – we’ll get to the limitations in a bit.

Assumptions About User’s Investments

Tarot doesn’t handle taxes, so the user has to enter their post-tax income. Some retirement accounts are funded with pre-tax money in the real world, so this assumption isn’t perfect, but it makes everything a lot simpler. Tarot assumes that the user’s (post-tax) income is used:

  1. First, to cover expenses
  2. Second, to save up an “emergency” fund in their savings account
  3. Third, to contribute to their retirement (the user will provide a guess for this growth rate)
  4. Finally, the rest is invested in some other way (user will provide a guess for this growth rate as well)

I like this pattern. It’s quite simple, and I think it could help people who feel that finance is too hard or confusing – a lot of my family feels this way. At the same time, it enforces some sound principals on the user’s spending. It forces the user to decide how much they’d need for an emergency fund, and emphasizes the importance of contributing to retirement before other investments. 

 Some people will have more complicated desires, such as:

  1. Modeling compensation in RSU’s (which may grow or shrink before vesting)
  2. Including other investment strategies – houses, startups, things for which they don’t want to guess at a single yearly return.
  3. Analyzing correlation between their investments, their retirement, and/or their income
  4. Who knows! I’m sure there’s more

Tarot just doesn’t handle these features. I think it would be difficult to incorporate these in a clear, seamless manner, and it would make tarot more intimidating to beginners. Additionally, there are often workarounds that the user can come up with if they really want to. For instance, if some of your pay is in RSU’s, you can guess at their value, and calculate your expected income incorporating that.

All of the functionality we’ve been talking about starts with a ‘WorkCashflow’ model, where the user specifies:

  1. their yearly income
  2. their yearly expenses
  3. the amount in their emergency fund
  4. the yearly amount put into retirement
  5. their assumptions about the growth of their retirement accounts and their other investment accounts

Using this information, we make a plot of how their different buckets of money will grow given those assumptions. They can schedule changes in expenses or income with ‘ChangeInExpense’ and ‘ChangeInIncome’ models respectively. Additionally, they can use the ‘Goal’ model to specify some monetary goal, and provide a guess at the inflation rate so the goal grows to keep pace. The end result is a plot like this:

I really like this. I can change the assumptions to quickly answer questions like:

  1. When can I retire?
  2. If I want to buy a house in five years, what kind of price range would I be looking at?
  3. How big is the impact of taking a lower paying job?
  4. How big is the impact of cutting back my expenses?

The only other feature to discuss is the observations. When I use tarot, I find I’m curious whether reality is keeping pace with my assumptions or not. Observations allow the user to log individual observations of their retirement or investment accounts, so in a couple years they can see whether the true growth has matched their assumptions.

Other Technical Bits

I learned about function decorators through this project. Decorators are functions which take other functions are arguments, and modify the behavior. This may seem silly, but predefined decorators can add very useful functionality to your code without you writing anything! For example, this list discusses decorators which speed up code by caching and implement just-in-time compilation for python, among other functionality. 

This project also taught me about lazy user registration, where you allow the user to use the webapp before signing up, and convert them to a normal user at a later time. This is much more convenient for users that want to ‘try before they buy’, and don’t want to lose their progress if they sign up later. The django-guest-user library made this very easy to implement.

Finally, this project uses very little javascript. It is almost entirely HTML/CSS and python. The plots are made with plotly offline, and saved as png’s on the heroku server. The relevant png is then placed in the user’s homepage. This has been working well, though loading is a bit slow – I imagine this would be faster if I just used plotly in javascript. But then I’d have to use javascript 😛

Final Thoughts

I’m the only user of this webapp. Nonetheless, I enjoy using it and working on it, and it helps me with my financial planning. I intend to continue supporting it and adding features if / when they help me. I would be happy if others used the app, but there are a few things that make a significant increase in adoption unlikely:

  1. I don’t want to do the (hard) work of advertising, iterating on customer feedback, etc
  2. There are better apps already (though I feel they have a steeper learning curve)
  3. Most people don’t care that much about personal finance
  4. If they do care about personal finance, they likely already have a working solution

These could be overcome, but I don’t think I could ever really make this a full-time job, so it’s hard to justify that work right now. We’ll see though – It’s cheap enough to just keep it running for now, and if I’m ever really interested in it again I can return to make more improvements.

http://bagelpour.wordpress.com/?p=153
Extensions
Some Short Fiction
Short Fiction
About 4 years ago I wrote some silly short fiction that I kindof liked. It was partially motivated by watching classmates obsess over technical accuracy in their writing. This is just that short story.
Show full content

This is some short fiction I wrote about 4 years ago. It was partially motivated by some classmates that were consumed by the technical minutiae of their writing, trying to give reasonable explanations for every event, describing locations with extreme accuracy, and obsessing over accurate usage of foreign words. I got to read this to them during class one day, and it was super fun. I’m pretty happy with it.

Space Adventure

After millennia of travel, Endaurus materialized above the dark, cold, lifeless planet that was KX11. At its helm sat Captain Blips, a renowned adventurer, a folk hero to folk heros, and the Linderm on whom the future of the Mondif system depended. His appendages trembled as he finally gazed out onto the surface of the planet that held the last hope for his kind. 

He manipulated a gyrating complex of nested semicircles, turning on the speakers located throughout Endaurus. His voice wavered as it crept into his mic, carrying with it the hopes of uncountable throngs of sentient beings. The significance of his words was clear as they fell like lead through the speakers:

“Glip. Glop.”

A moment of silence.

Throughout the ship, other linderms turned toward the windows, Olfards extended their libules, and Furlands sent a rumbling pulse through the surrounding space, all anxious to catch a glimpse of what might be their salvation. Legend held that on this planet was the Lopdisc, an ancient artifact holding the power to reignite a dying star, or possibly — if used sparingly — to fend off the famine that had ravaged the Mondif system for a lifetime. 

Families embraced each other hopefully as the ship’s moiles scanned over the surface of the planet, searching for the stuff of legend.

“Glip glop,” mothers crooned soothingly to their children, worried by the unnatural silence.

Murmurs carried through the mess hall as anxious workers felt their lives’ ambitions nearing an end. “Glip glop?” asked hushed voices. “Glip glop,” the consistent answer returned. What more could be said?

On the main deck, Captain Blips cast a glance towards Officer Flimp — his sister, not through lineage, but through their shared trials, sufferings, and joys. They had traveled together since they were but plofards, and their shared devotion could not be rivaled by any other on Endaurus. In an ordinary situation, such a glance would be meaningless, but shared between Captain Blips and Officer Flimp as they hovered above KX11, it was different. Here it carried so much. “Glip glop,” it said. “Gilp glop.”

“Glip Glop!” an excited technician yelled. Captain Blips felt overwhelmed. He had half expected that the legend would not hold true. Once again he spoke into the mic:

“Glip glop! Glip glop: Glip! Glop!”

Shouts of joy echoed through the corridors of the ship. At Captain Blips’ order, the lembrif expanded the Lopdisc into existence on the main deck. It was carefully placed in the padded exhibit that would serve as its refuge until they returned to the Mondif system. 

All throughout the ship boxes of rare treats from home were opened in celebration, and soon the hallways were filled with the warm laughter of half-drunken creatures. The helm was no exception, and the officers happily slurped their intoxicants as they admired the fine etching on the Lopdisc. When the lights were turned off it glowed faintly, showcasing its beautiful design against the thick darkness of space. Such craftsmanship was unheard of.

But it was too beautiful. Even as Endaurus was united in joy, individuals captivated by its beauty couldn’t help but wonder: “glip glop?” After all, its power would last longer if only harnessed by a few.

Mere hours after the Lopdisc had been brought on board, Endaurus was filled with the sound of lasers as splintering mutinies infected the passageways. The main deck had been sealed off after the first shots rang out, but it was ineffective. Even among the officers there was dissension. Captain Blips, Officer Flimp, and some other loyal individuals set up a barricade around the Lopdisc, and other detachments did likewise in their corners of the room. 

Day after day the rebellion wore on, with each orbit around the planet bringing more needless death. And after so many days of erratic, sleep deprived potshots and desperate, reckless dashes for cover, the unthinkable had happened. Flimp was dead. Her convictions, her dedication, and her heroism meant nothing to the hot plasma that flew through her body as she twisted unnaturally, trying to dance around the pain. Her face had been disfigured for a few moments, too horrible for even Captain Blips to watch, until finally death brought her peace.

“Glip glop! Glip glop!” Cried out the distraught captain in an unheard of display of raw emotion, but still the fighting would not cease. Captain Blips’ vision narrowed as passion rose within him, then turned to a despairing hatred, and finally cooled to a numb resolution. Disregarding the lasers shaving past his body, he took the necessary actions with a heartless, mechanical precision, and when he was done he once again sat behind the mic to speak to Endaurus.

“Glip glop. Glip glop glip.” 

And the fighting died. The lembrif collapsed, sending the Lopdisc and Flimp’s body out into space.

It was fitting that Flimp should be buried in this way, holding the Lopdisc that contained the hopes of her people. And yet it was so vastly not enough. The pair rotated ever so slightly above the silhouette of KX11 — still cold and still dark, but even more lifeless now with the addition of one that used to be alive.

In the proceeding hours, the ship was brought back to order under the merciless command of Captain Blips, the dead were sent to join Flimp, and Endaurus set off to return home. After the years of travel, after the sleepless nights and mechanical failures, after difficult work and days of despair, after all their effort, the epic journey of Endaurus could be summed up in two words.

“Glip glop.”

And they were so meaningless.

http://bagelpour.wordpress.com/?p=141
Extensions
Simple Robust Control Design
Control TheoryUncategorizedLQRRobust Control
I show a relatively easy way to design a controller that works for a range of systems.
Show full content

The control design process I’ve seen in the consumer electronics industry generally goes like this:

  1. Measure or estimate system parameters (inertia, friction, efficiency, etc) for our device.
  2. Design a controller for the nominal parameters.
  3. Check that our controller works in simulation
  4. Test our controller under a bunch of conditions and on multiple real-world devices, to check that the behavior is acceptable in as many scenarios as feasible, and possibly retune if the behavior is not acceptable.

I think there should be an obvious concern when reading the last two steps of that process — we only confirm that everything is ok in a finite number of scenarios which we’re able to recreate! In the field, it’s likely that our device will encounter conditions we didn’t test on. Additionally, if we’re mass producing devices, there can be significant variation in system parameters due to unit-to-unit variation. We can’t practically test all of the possibilities we’d like to, and at some point we just say “this testing is good enough; we have decent confidence it will work”. For many applications this works well enough, but there is another way! “Robust Control” attempts to deal with variation during the design stage, so that we can have confidence about the performance as long as system parameters stay within certain bounds. The real-world testing is still important so that we don’t miss some silly math or modelling error, but I hope you can see the benefit of using robust control when designing our controller.

There are multiple approaches to robust control design, but the easiest method I’ve seen was during a lecture series by Professor Mauricio de Oliveira. This post will be a practical introduction to the method he showed, using quadratic stability. It involves one jump in knowledge over LQR control design, but you don’t have to understand all the theory to use the method — you can still use it in practice even if you don’t understand all the math. If you can presently do state space control design, then by the end of this post you should be able to set up an optimization problem to design a (specific kind of) robust controller.

Necessary Background Knowledge

You’ll need to be able to read and understand some math nomenclature to follow along. I’m going to list the key results you need. I won’t give proofs for these, but will try to explain the meaning of the symbols. Proofs can be found in the lecture notes from Professor de Oliveira, linked in sources at the end of this post.

First, we should explain the concept of Linear Matrix Inequalities (LMIs). LMIs are very similar to inequalities on scalar values, which I’m sure you’re familiar with. In LMIs, we’re going to write things like {M>0}, where {M} is a matrix. For a matrix {M}, we need to understand the following meanings:

  1. {M>0}” is read as “M is positive definite”. It means {x^\intercal Mx >0} for all vectors {x}. Equivalently, {M} only has eigenvalues which are greater than zero.
  2. {M<0}” is read as “M is negative definite”. It means {x^\intercal Mx <0} for all vectors {x}. Equivalently, {M} only has eigenvalues which are less than zero.
  3. {M\ge0}” is read as “M is positive semi-definite”. It means {x^\intercal Mx \ge0} for all vectors {x}. Equivalently, {M} only has eigenvalues which are greater than or equal to zero.
  4. {M\le0}” is read as “M is negative semi-definite”. It means {x^\intercal Mx \le0} for all vectors {x}. Equivalently, {M} only has eigenvalues which are less than or equal to zero.

LMIs are linear, meaning that our variables can only be added and scaled — they cannot be multiplied by each other. For instance, if {A} and {B} are constant but {X} and {Y} are variables, the following is an LMI:

\displaystyle AX + BY>0

With those same variables and constants, here’s an example of something that isn’t an LMI, because it isn’t linear:

\displaystyle XX^\intercal + AX + BY>0

Second, if we have a system {\dot{x} = Ax + Bu} which is stabilizable, we can find controllers which stabilize the system by solving the following Linear Matrix Inequality:

\displaystyle X > 0, AX + XA^\intercal+BL + L^\intercal B^\intercal < 0

The stabilizing controllers are {u = Kx}, where {K = LX^{-1}}. Note that this gives us controllers which stabilize the system, but we can’t use this to minimize a cost function like we’d usually be able to do in “vanilla” LQR control design.

Finally, assume a stabilizable system {\dot{x} = Ax + B_{u}u + B_{\omega}\omega, z = Cx+Du}, where {D^\intercal D >0}, and {\omega} is zero-mean gaussian white noise with posive definite covariance {W}. Then, we can use LMIs in conjunction with an optimization problem to find a stabilizing controller that minimizes the cost function

\displaystyle J = \underset{t\rightarrow \inf}{lim} E(z^\intercal z) = \underset{t \rightarrow \inf}{lim} E(x^\intercal C^\intercal Cx + u^\intercal D^\intercal Du + 2x^\intercal C^\intercal Du)

We have the same freedom to choose the weightings as in LQR control design, by selecting {C} and {D}. In order to find a controller which stabilizes this system and minimizes {J}, we must minimize {trace(ZW)} subject to

\displaystyle \begin{bmatrix} AX + XA^\intercal+B_{u}L + L^\intercal B_{u}^\intercal & XC^\intercal + L^\intercal D^\intercal \\ CX^\intercal + DL & -I \end{bmatrix} \le 0,

\displaystyle \begin{bmatrix} Z & B_{\omega}^\intercal \\ B_{\omega} & X \end{bmatrix}\ge0,

\displaystyle X > 0

Then the resulting controller is {u = Kx}, where {K = LX^{-1}}. It turns out that our cost function {J = trace(ZW)} in the above LMI, so if the optimization problem can be solved, we also minimize our cost function.

Just for clarity, I’ll explicitly call out that the variables in the above LMI are {X}, {L}, and {Z}, and the other matrices are specified by our assumed system. In reality, we may not care or know about the values of {W} and {B_\omega}, but we do need those matrices for this optimization to work. In the absence of other information, just put in something reasonable — noise is certainly being injected into your real system somehow, so just make a best guess.

Stabilizing Multiple Systems

Let’s try to find one controller which stabilizes two different systems. To put this into math, our goal is to find a controller of the form {u = Kx} such that both {\dot{x_1} = A_1x_1 + B_1u} and {\dot{x_2} = A_2x_2 + B_u} are stable. We use the same optimization problem described above on the parameters for both systems, and enforce only a single controller by enforcing a single X, L, and Z matrix:

minimize {trace(ZW)} subject to

\displaystyle \begin{bmatrix} A_1X + XA_1^\intercal+B_{u1}L + L^\intercal B_{u1}^\intercal & XC^\intercal + L^\intercal D^\intercal \\ CX^\intercal + DL & -I \end{bmatrix} \le 0,

\displaystyle \begin{bmatrix} Z & B_{\omega 1}^\intercal \\ B_{\omega 1} & X \end{bmatrix}\ge0,

\displaystyle \begin{bmatrix} A_2X + XA_2^\intercal+B_{u2}L + L^\intercal B_{u2}^\intercal & XC^\intercal + L^\intercal D^\intercal \\ CX^\intercal + DL & -I \end{bmatrix} \le 0,

\displaystyle \begin{bmatrix} Z & B_{\omega 2}^\intercal \\ B_{\omega 2} & X \end{bmatrix}\ge0,

\displaystyle X > 0

Since this optimization gives us only one {X} and one {L}, we can calculate our single controller {u = Kx} where {K = LX^{-1}}. I’ve glossed over the fact that this optimization still includes {C}, {D}, {B_\omega} and {W}, but you get to define these in the same way you did for the original optimization. In this case, {trace(ZW)} doesn’t equal the cost function for either system, but is an upper bound on the cost for each.

We know {u = Kx} stabilizes both systems, so that

\displaystyle \dot{x_1} = (A_1 + B_1K)x_1

\displaystyle \dot{x_2} = (A_2 + B_2K)x_2

are both stable, and the eigenvalues of

\displaystyle (A_1 + B_1K)

\displaystyle (A_2 + B_2K)

are both strictly negative. From the section on positive/negative-definite matrices, this also means

\displaystyle x^\intercal(A_1 + B_1K)x <0 \text{ for all x}

\displaystyle x^\intercal(A_2 + B_2K)x<0 \text{ for all x}

What if we have some system that is a linear combination of our two different systems?

\displaystyle \dot{x_3} = (\alpha A_1+\beta A_2)x_3 + (\alpha B_1 + \beta B_2)u

\displaystyle =(\alpha A_1+\beta A_2)x_3 + (\alpha B_1 + \beta B_2)Kx_3

\displaystyle =(\alpha A_1+\beta A_2 + \alpha B_1K + \beta B_2K)x_3

\displaystyle = (\alpha A_1+\alpha B_1K)x_3 + (\beta A_2 + \beta B_2K)x_3

\displaystyle = \Big(\alpha(A_1+B_1K) + \beta(A_2 + B_2K)\Big)x_3

We can show that {\Big(\alpha(A_1+B_1K) + \beta(A_2 + B_2K)\Big)} is also negative definite (and therefore has strictly negative eigenvalues, and is stable) for many choices of {\alpha} and {\beta}!

\displaystyle x^\intercal \Big(\alpha(A_1+B_1K) + \beta(A_2 + B_2K)\Big) x

\displaystyle = x^\intercal\alpha(A_1+B_1K)x + x^\intercal\beta(A_2 + B_2K) x

\displaystyle = \alpha x^\intercal(A_1+B_1K)x + \beta x^\intercal(A_2 + B_2K) x

since we know {x^\intercal(A_1 + B_1K)x <0} and {x^\intercal(A_2 + B_2K)x <0}, this means our combined system {\alpha x^\intercal(A_1+B_1K)x + \beta x^\intercal(A_2 + B_2K)x <0 } for all {\alpha, \beta >0}. Therefore, any positive linear combination of our two systems is also stable with this same controller! We can do this same exercise to achieve a single controller that works with multiple different systems, and get the same result — any positive linear combination of the systems will be stabilized by that controller!

Practical Application

We’ve seen that we can design a single controller which stabilizes a range of different systems, and does a similar optimization as in LQR control design. In practice, we could modify our control design process to use this new tool:

  1. Measure or estimate a range of system parameters (inertia, friction, efficiency, etc) for our device. Ideally, this would include parameters at the extreme ends of our operating conditions and unit-to-unit variation.
  2. Using the optimizations and LMIs discussed above, design a controller which stabilizes all those systems, as well as positive linear combinations of those systems.
  3. Check that our controller works in simulation
  4. Test our controller under a bunch of conditions and on multiple real-world devices, to check that the behavior is acceptable in as many scenarios as feasible, and possibly retune if the behavior is not acceptable.

The great thing about this process is that we can explicitly design for unit-to-unit variation and extreme operating conditions. We are often unable to replicate these issues in manual testing, so accounting for them in the design stage can save us significant effort.

If this was interesting to you, I strongly recommend you check out Professor de Oliveira’s lecture notes, linked below. They are dense but very informative.

sources:

  1. Lecture notes on LMIs
  2. Lecture notes on using LMIs for LQR control design
  3. Lecture notes on some clever uses of LMIs for control design problems
  4. Wikipedia page on robust control

http://bagelpour.wordpress.com/?p=96
Extensions
Financial Planning Webapp: Part 1
Webappsfinancial plannerwebapp
Setting up the groundwork for a financial planning webapp.
Show full content

This series is intended to walk you through the process of making a simple webapp with django.

prerequisites: practical knowledge of python and the command-line, access to linux or a linux subsystem with python3 installed, some basic familiarity with html and css, and willingness to figure-things-out.

First, work through the default django tutorial here:https://docs.djangoproject.com/en/4.0/intro/tutorial01/. It’s pretty clear, and will give you an understanding of how django actually works. If you don’t do this, you will probably be confused enough that you’ll need to revisit it soon anyways

I’m going to make a virtual environment to track all of the dependencies for this project. You can learn more about virtual environments here.

 If you don’t have virtualenv installed already, get it with “python3 -m pip install –user virtualenv”

To setup a virtual environment with the name financial_planner, run “python3 -m venv financial_planner”. A folder should show up with the name “financial_planner” to access this environment, you want to run “source [path to financial_planner]/bin/activate”

Install django: “pip install django”. I got django 4.0.3, so that’s what this guide will be using 🙂

We’re essentially going to follow the default django tutorial for the next few steps. 

To create a django project, run “django-admin startproject financial_planner_site”

cd into financial_planner_site and run “python manage.py runserver” to verify that everything is working thus far. If you type localhost:8000 into your address bar, you should see something like this:

Make the financial planning app by running “python manage.py startapp financial_planner_app”. Note this step is distinct from creating the django project!

Now we’re going to make a simple view, using an html file. In financial_planner_app make a folder named “templates” and a folder in that named “financial_planner”. Inside templates/financial_planner, put the following html file:

Modify the views.py file to match this:

Add the homepage to the urls.py file in financial_planner_app:

Finally connect the app to the site by adding “financial_planner_app” to the installed apps in financial_planer_site / settings.py:

With those changes we should be able to see this at localhost:8000/home

Let’s also make registration and login pages. I’ll leave these basically empty right now, but just put something in the place. You need to duplicate some of the steps above:

If we want to reduce the amount of html copy-and-pasted from one page to another, we’ll want to use an html template to hold the most repeated html stuff. This guide explains how to do this in more detail. The quick summary is that we’ll make a header.html file, and then each of our other html files will extend the header file. 

Make the same changes in your login and register page. Now the header.html file can contain all our css styling so it’s consistent across the website, and there is less code to retype or copy-paste every time.

I like andy brewer’s mvp.css. I’m going to change the stylesheet in our header to <link rel=”stylesheet” href=”https://unpkg.com/mvp.css“>. 

I’m going to add a stylesheet configuring the mvp.css settings as well. In the financial_planner_app directory, make a folder named “static”, and another inside that named “financial_planner”, then make style.css within that. For now I’m using a lot of burgundy, on an off-white background. We can fine-tune these settings later on.

Now that we’ve spent a good amount of time setting up styling that we can easily modify, let’s add some actual functionality :).

Part 2 of this series will eventually discuss adding the functionality, though it might be a while till I post that.

http://bagelpour.wordpress.com/?p=85
Extensions
Expecting Skilled Results, While Specializing Less
PhilosophyImpactWork
I think we limit ourselves by the goals we set. Right now, I think I can do more in a different field, so I'm going to try and move further into software.
Show full content

I think we often limit ourselves by setting our goals too low. I don’t believe that you can only be good at one thing, or that it takes years of effort to achieve something meaningful in a given field. I swear I’ve read a post by Patrick Collison on this, but am having trouble finding it right now — the closest I can find is this. Here’s a brief list of people that I believe illustrate this fact:

  • Elon Musk has had influential roles in reforming payments, cars, and space travel — fields which are fairly distinct
  • Ken Jeong was successful as both a doctor and an actor
  • Many of the famous figures at Bell Labs did foundational work in numerous fields
  • My dad worked in Chemistry / Microbiology for many years, then did a PhD in botany from ODTU (a competitive school, located in Ankara, Turkey), and then worked full time teaching completely unrelated things
  • The Collison brothers have both done amazing work in an incredibly short time

I worry about my impact. I’ve done work in Mechanical Design and in Control and Estimation, but I’m not sure that I’m working on problems that meaningfully impact people’s lives. A lot of the theory has already been developed in these fields, so I feel that I should be working on meaningful implementations, and I’m not independently wealthy enough to work on these problems just for my satisfaction. I can work on them in a large company, but:

  • I don’t get to work on the problems that I feel are most important
  • navigating bureaucracy pains me
  • even if I do work through the bureaucracy, the necessary rubber-stamping slows things down

There’s also the option to join a startup working on problems that I feel are important. This really excites me, but it’s too early in my career for me to take that risk — hopefully in a couple years I can say different.

In the meantime, I think I should move further into software, hopefully balancing my experience from controls and hardware design with new skills. I get the impression that there is so much need for software skills, so I think this will open up a lot of new areas that I can contribute to.

In the short term this may mean working on purely software projects, without direct impact in the physical world. In the long term, I hope I can make things that interact with physical space as well. I would love to improve quality of life for some of the world’s poorer people, and physical change is usually what humans care about at the end of the day — video games don’t satisfy a hungry stomach. I don’t believe that my relevant skills will atrophy, but I guess time will tell if I’m mistaken.

http://bagelpour.wordpress.com/?p=68
Extensions