I think that you are not ready to create an extension yet.
Before trying to create an extension, try creating a reusable
component that provides the math notepad functionality.
’Reusable’ is the keyword. You seems to try to include the index action of the site controller into your math notepad extension, but you should not do it. Your math notepad must be usable in any other project. So you have to divide the code in your index action and index view into 2 parts: one that belongs to the widget and the other that belongs to the current project. And then make a
component from the former, and use it in your current project. Then the
component can easily be used in other projects. And then, only then, you are ready to create an extension.