Incomplete easy-to-use math solver and PDF generator.

Overview

Math Expert

Let me do your work

Preview

preview.mp4

Introduction

Math Expert is our (@salastro, @younis-tarek, @marawn-mogeb) math high school graduation project. The project tackles the problem of generating beautiful, quick, and useful mathematics. While most software can either only generate beautiful formatted PDF (i.e. LaTeX) or sufficiently solve mathematical problems (e.g. Wolfram|Alpha). There may be, however, alternatives to these tools, yet they can not fully grasp the potential of either of them or are slow and hard to use. Therefore, this project tries to do what others failed.

Inner Workings

Our approach was to create an easy-to-use graphical user interface (GUI) that uses different components to reach our goal. LaTeX is the main PDF generation backend due to its indubitable abilities and speed; it is the universal standard for mathematical notation. However, it is reasonably hard to use making it difficult to use in a short-term practical context. This makes the application even more useful. It was mainly interacted with through PyLaTeX; it provides a usable set of commands that make use of LaTeX's capabilities. The standard article document class with numbered math alignment environment and TikZ drawings was used.

Although both SymPy and NumPy were used, the focus was on SymPy due to its nature of symbolic manipulation and its alignment with the goals of the project. The latter is powerful in mathematical evaluations, which — although supported — is not the focus of this project. The results of all functions, other than Evaluate, are performed through SymPy. It provides more than one function to perform some of the operations at hand, but the one that proves to be the most effective is used. For example, there are integrate and manualintegrate, and although the latter can show steps (non-human-readable), the former was chosen for its wide variety of solutions.

Unlike the previous two, the choice of a GUI framework was not a straightforward decision. Kivy was a serious candidate, but due to its own unique syntax for designing being its bedrock and lack of some convenient Python capabilities use, it was not feasible. Another option was Tkinter, which is considered the main framework for Python. However, it is very lacking some modern UI design features and is not plain sailing in some considerable aspects. The final option was PyQt5, which is a Python binding for the Qt cross-platform framework. Basically utilizing all of the powerful aspects of the Qt framework, which avoids the aforementioned limitations, while maintaining a usable toolkit. A highly programmable interface that is easily integrable into other environments was the product of this decision.

Philosophy

Although the infamous it just works are spread throughout the codebase, which is not ideal for a structured project, the goal of our is to define a great code that follows best practices (e.g. PEP 8) to have a readable, maintainable, and legacy-free codebase to stand in the way of passing time for the longest. As such, a minimal amount of code is necessary to avoid using breakable functions; a suitable modus operandi is the suckless philosophy. On the other hand, extensibility and customizability are as important. Unix philosophy is the one method that is well-regarded as the jewel in the crown.

Object orientation was used due to its inheritance, encapsulation, and other proprieties; some of which can not be achieved through modularity alone resulting in a more complex codebase. In addition, the structural way PyLaTeX handles documents would make it even harder to avoid object-oriented programming, despite its known disadvantages. However, parts of SymPy and NumPy code were written more procedurally.

Codebase

As mentioned above, the goals of the code are minimalism, functionality, extensibility, and customizability. The program is divided into 3 separate files: gui.py for all of the UI elements, func.py for all the operations on documents, and main.py for the main program and linking of the two. This was to ease the switching of undesired modules and separate development based on the working context.

func.py was mainly structured as one class (MathDoc) with multiple methods for document manipulation (e.g. Inte, Diff, etc). The class is instantiated and used in main.py in the __name__ == "__main__" if statement after the imports outside the conditional; on every button click the corresponding method is called. In contrast, explicit mentions of gui.py are rare (besides the linkage ones) since all of its handlings is in the file itself.

Properties

Advantages

  • Easy-to-use
  • Fast
  • Accurate
  • Concise Formatting
  • Extensible
  • Programmable

Disadvantages

  • poor error handling
  • limited syntax input
  • limited operations
  • no-preview before add
  • undoable actions

Neutral

  • Unappealing UI
  • No indication when unsolvable

Future plans

See issues

Usage

Although the interface is obvious, some clarifications may need to be made.

  • First text input is the file name without extension
  • Second text input is the document title
  • Third text input is the author(s) title
  • Fourth (and last) text input is the mathematical expression to be operated on
    • Euler's number should be written as exp(x) instead of e^(x)
    • log is the natural logarithm.
    • Multiplication should be written in the form 2*x
  • After defining all the previous inputs, click Generate PDF
  • Choose the type of operation you want to perform, then click Generate PDF again

Dependences

Building

Running

COCOMO estimates

Using scc

───────────────────────────────────────────────────────────────────────────────
Language                 Files     Lines   Blanks  Comments     Code Complexity
───────────────────────────────────────────────────────────────────────────────
Python                       4       465       36        24      405         17
───────────────────────────────────────────────────────────────────────────────
Total                        4       465       36        24      405         17
───────────────────────────────────────────────────────────────────────────────
Estimated Cost to Develop (organic) $10,457
Estimated Schedule Effort (organic) 2.431055 months
Estimated People Required (organic) 0.382159
───────────────────────────────────────────────────────────────────────────────
Processed 19228 bytes, 0.019 megabytes (SI)
───────────────────────────────────────────────────────────────────────────────
Comments
  • Better logs

    Better logs

    They look ugly and increase loc with a lot of repetition. I am not used to using it so it will take me some time until I discover how to get around the logs.

    enhancement 
    opened by salastro 2
  • Code refactoring

    Code refactoring

    Some aspects of the code are written badly.

    For reference:

    • https://stackoverflow.com/questions/20873259/pyqt-how-to-dynamically-update-widget-property-on-outer-variable-value-change
    enhancement 
    opened by salastro 2
  • Automated tests

    Automated tests

    They basically exist in the __main__ in func.py For reference:

    • https://www.youtube.com/watch?v=DhUpxWjOhME
    • https://stackoverflow.com/questions/27954702/unittest-vs-pytest
    • https://docs.python.org/3/library/unittest.html
    • https://docs.pytest.org/
    enhancement 
    opened by salastro 1
  • Better define methods in `main.py`

    Better define methods in `main.py`

    Currently, exec is used, which is very unpythonic and inefficient. There should be a way to get all the functions in the func.py and link them accordingly.

        operations = ["inte", "diff", "lim", "fact", "sol",
                      "simp", "eval", "plot", "generate_pdf", "generate_latex"]
    
        for func in operations:
            exec(f"""
                \n@pyqtSlot()
                \ndef on_{func}_bt_clicked(self):
                \n    self.mathdoc.{func}(self.expression.toPlainText().\
                    replace(" ", ""))
            """)
    
    bug 
    opened by salastro 1
  • Show steps

    Show steps

    Since the functions that do not operate on a human level are more advanced in solving problems, it would be great if it is possible to check if the problem is solvable with human steps and then use the function that shows the results. Mainly integration and differentiation are my concern.

    enhancement 
    opened by salastro 0
  • Integration hangs

    Integration hangs

    Sometimes when integration is unsolvable (even by other more advanced calculators) it just halts.

    Possible solutions are:

    • restricting the computational resources of the process
    • adding a timeout (e.g. of 10 seconds) for the process
    • creating an external watchdog for the management of the program flow
    bug 
    opened by salastro 1
  • LaTeX dependency

    LaTeX dependency

    Tests on my machine went smoothly on both Linux and Windows. However, it was not as smooth for both @marawan-mogeb and @younis-tarek. The only unique thing in my setup on both OSs is having LaTeX (texlive-full on void Linux and MikTeX on Windows) while both do not. The size of a TeX distro is yet to be confirmed, but since there is no advanced PDF formatting (e.g. Arabic support) TinyTeX should work. @younis-tarek plans to further test this in the future.

    bug documentation 
    opened by salastro 2
Releases(0.2)
Owner
SalahDin Ahmed
A computers magician who uses simple spells.
SalahDin Ahmed
Simple Linear 2nd ODE Solver GUI - A 2nd constant coefficient linear ODE solver with simple GUI using euler's method

Simple_Linear_2nd_ODE_Solver_GUI Description It is a 2nd constant coefficient li

:) 4 Feb 5, 2022
PyTorch implementation for COMPLETER: Incomplete Multi-view Clustering via Contrastive Prediction (CVPR 2021)

Completer: Incomplete Multi-view Clustering via Contrastive Prediction This repo contains the code and data of the following paper accepted by CVPR 20

XLearning Group 72 Dec 7, 2022
Continuous Query Decomposition for Complex Query Answering in Incomplete Knowledge Graphs

Continuous Query Decomposition This repository contains the official implementation for our ICLR 2021 (Oral) paper, Complex Query Answering with Neura

UCL Natural Language Processing 71 Dec 29, 2022
A PyTorch Implementation of "SINE: Scalable Incomplete Network Embedding" (ICDM 2018).

Scalable Incomplete Network Embedding ⠀⠀ A PyTorch implementation of Scalable Incomplete Network Embedding (ICDM 2018). Abstract Attributed network em

Benedek Rozemberczki 69 Sep 22, 2022
Source Code for DialogBERT: Discourse-Aware Response Generation via Learning to Recover and Rank Utterances (https://arxiv.org/pdf/2012.01775.pdf)

DialogBERT This is a PyTorch implementation of the DialogBERT model described in DialogBERT: Neural Response Generation via Hierarchical BERT with Dis

Xiaodong Gu 67 Jan 6, 2023
The official implementation of NeMo: Neural Mesh Models of Contrastive Features for Robust 3D Pose Estimation [ICLR-2021]. https://arxiv.org/pdf/2101.12378.pdf

NeMo: Neural Mesh Models of Contrastive Features for Robust 3D Pose Estimation [ICLR-2021] Release Notes The offical PyTorch implementation of NeMo, p

Angtian Wang 76 Nov 23, 2022
This repo provides the official code for TransBTS: Multimodal Brain Tumor Segmentation Using Transformer (https://arxiv.org/pdf/2103.04430.pdf).

TransBTS: Multimodal Brain Tumor Segmentation Using Transformer This repo is the official implementation for TransBTS: Multimodal Brain Tumor Segmenta

Raymond 247 Dec 28, 2022
PGPortfolio: Policy Gradient Portfolio, the source code of "A Deep Reinforcement Learning Framework for the Financial Portfolio Management Problem"(https://arxiv.org/pdf/1706.10059.pdf).

This is the original implementation of our paper, A Deep Reinforcement Learning Framework for the Financial Portfolio Management Problem (arXiv:1706.1

Zhengyao Jiang 1.5k Dec 29, 2022
A Lighting Pytorch Framework for Recommendation System, Easy-to-use and Easy-to-extend.

Torch-RecHub A Lighting Pytorch Framework for Recommendation Models, Easy-to-use and Easy-to-extend. 安装 pip install torch-rechub 主要特性 scikit-learn风格易用

Mincai Lai 67 Jan 4, 2023
The MATH Dataset

Measuring Mathematical Problem Solving With the MATH Dataset This is the repository for Measuring Mathematical Problem Solving With the MATH Dataset b

Dan Hendrycks 267 Dec 26, 2022
Code for Graph-to-Tree Learning for Solving Math Word Problems (ACL 2020)

Graph-to-Tree Learning for Solving Math Word Problems PyTorch implementation of Graph based Math Word Problem solver described in our ACL 2020 paper G

Jipeng Zhang 66 Nov 23, 2022
MWPToolkit is a PyTorch-based toolkit for Math Word Problem (MWP) solving.

MWPToolkit is a PyTorch-based toolkit for Math Word Problem (MWP) solving. It is a comprehensive framework for research purpose that integrates popular MWP benchmark datasets and typical deep learning-based MWP algorithms.

null 119 Jan 4, 2023
this is a lite easy to use virtual keyboard project for anyone to use

virtual_Keyboard this is a lite easy to use virtual keyboard project for anyone to use motivation I made this for this year's recruitment for RobEn AA

Mohamed Emad 3 Oct 23, 2021
A collection of easy-to-use, ready-to-use, interesting deep neural network models

Interesting and reproducible research works should be conserved. This repository wraps a collection of deep neural network models into a simple and un

Aria Ghora Prabono 16 Jun 16, 2022
BTC-Generator - BTC Generator With Python

Что такое BTC-Generator? Это генератор чеков всеми любимого @BTC_BANKER_BOT Для

DoomGod 3 Aug 24, 2022
Simple ONNX operation generator. Simple Operation Generator for ONNX.

sog4onnx Simple ONNX operation generator. Simple Operation Generator for ONNX. https://github.com/PINTO0309/simple-onnx-processing-tools Key concept V

Katsuya Hyodo 6 May 15, 2022
Efficient electromagnetic solver based on rigorous coupled-wave analysis for 3D and 2D multi-layered structures with in-plane periodicity

Efficient electromagnetic solver based on rigorous coupled-wave analysis for 3D and 2D multi-layered structures with in-plane periodicity, such as gratings, photonic-crystal slabs, metasurfaces, surface-emitting lasers, nano-antennas, and more.

Alex Song 17 Dec 19, 2022
High performance, easy-to-use, and scalable machine learning (ML) package, including linear model (LR), factorization machines (FM), and field-aware factorization machines (FFM) for Python and CLI interface.

What is xLearn? xLearn is a high performance, easy-to-use, and scalable machine learning package that contains linear model (LR), factorization machin

Chao Ma 3k Jan 3, 2023
High performance, easy-to-use, and scalable machine learning (ML) package, including linear model (LR), factorization machines (FM), and field-aware factorization machines (FFM) for Python and CLI interface.

What is xLearn? xLearn is a high performance, easy-to-use, and scalable machine learning package that contains linear model (LR), factorization machin

Chao Ma 2.8k Feb 12, 2021