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"""
                \[email protected]()
                \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
Official code of the paper "Expanding Low-Density Latent Regions for Open-Set Object Detection" (CVPR 2022)

OpenDet Expanding Low-Density Latent Regions for Open-Set Object Detection (CVPR2022) Jiaming Han, Yuqiang Ren, Jian Ding, Xingjia Pan, Ke Yan, Gui-So

csuhan 64 Jan 07, 2023
PyTorch implementation of Deformable Convolution

Deformable Convolutional Networks in PyTorch This repo is an implementation of Deformable Convolution. Ported from author's MXNet implementation. Buil

411 Dec 16, 2022
Source code for the GPT-2 story generation models in the EMNLP 2020 paper "STORIUM: A Dataset and Evaluation Platform for Human-in-the-Loop Story Generation"

Storium GPT-2 Models This is the official repository for the GPT-2 models described in the EMNLP 2020 paper [STORIUM: A Dataset and Evaluation Platfor

Nader Akoury 27 Dec 20, 2022
Empower Sequence Labeling with Task-Aware Language Model

LM-LSTM-CRF Check Our New NER Toolkit 🚀 🚀 🚀 Inference: LightNER: inference w. models pre-trained / trained w. any following tools, efficiently. Tra

Liyuan Liu 838 Jan 05, 2023
Really awesome semantic segmentation

really-awesome-semantic-segmentation A list of all papers on Semantic Segmentation and the datasets they use. This site is maintained by Holger Caesar

Holger Caesar 400 Nov 28, 2022
codebase for "A Theory of the Inductive Bias and Generalization of Kernel Regression and Wide Neural Networks"

Eigenlearning This repo contains code for replicating the experiments of the paper A Theory of the Inductive Bias and Generalization of Kernel Regress

Jamie Simon 45 Dec 02, 2022
Unofficial Pytorch Implementation of WaveGrad2

WaveGrad 2 — Unofficial PyTorch Implementation WaveGrad 2: Iterative Refinement for Text-to-Speech Synthesis Unofficial PyTorch+Lightning Implementati

MINDs Lab 104 Nov 29, 2022
Flexible-CLmser: Regularized Feedback Connections for Biomedical Image Segmentation

Flexible-CLmser: Regularized Feedback Connections for Biomedical Image Segmentation The skip connections in U-Net pass features from the levels of enc

Boheng Cao 1 Dec 29, 2021
PyTorch implementation of Spiking Neural Networks trained on surrogate gradient & BPTT using snntorch.

snn-localization repo PyTorch implementation of Spiking Neural Networks trained on surrogate gradient & BPTT using snntorch. Install Dependencies Orig

Sami BARCHID 1 Jan 06, 2022
[NeurIPS 2021] Towards Better Understanding of Training Certifiably Robust Models against Adversarial Examples | ⛰️⚠️

Towards Better Understanding of Training Certifiably Robust Models against Adversarial Examples This repository is the official implementation of "Tow

Sungyoon Lee 4 Jul 12, 2022
This code provides various models combining dilated convolutions with residual networks

Overview This code provides various models combining dilated convolutions with residual networks. Our models can achieve better performance with less

Fisher Yu 1.1k Dec 30, 2022
A Deep Learning based project for creating line art portraits.

ArtLine The main aim of the project is to create amazing line art portraits. Sounds Intresting,let's get to the pictures!! Model-(Smooth) Model-(Quali

Vijish Madhavan 3.3k Jan 07, 2023
HeartRate detector with ArduinoandPython - Use Arduino and Python create a heartrate detector.

Syllabus of Contents Syllabus of Contents Introduction Of Project Features Develop With Python code introduction Installation License Developer Contac

1 Jan 05, 2022
Atif Hassan 103 Dec 14, 2022
CycleTransGAN-EVC: A CycleGAN-based Emotional Voice Conversion Model with Transformer

CycleTransGAN-EVC CycleTransGAN-EVC: A CycleGAN-based Emotional Voice Conversion Model with Transformer Demo emotion CycleTransGAN CycleTransGAN Cycle

24 Dec 15, 2022
Script for getting information in discord

User-info.py Script for getting information in https://discord.com/ Instalação: apt-get update -y apt-get upgrade -y apt-get install git pkg install

Moleey 1 Dec 18, 2021
Mini-hmc-jax - A simple implementation of Hamiltonian Monte Carlo in JAX

mini-hmc-jax This is a simple implementation of Hamiltonian Monte Carlo in JAX t

Martin Marek 6 Mar 03, 2022
code for TCL: Vision-Language Pre-Training with Triple Contrastive Learning, CVPR 2022

Vision-Language Pre-Training with Triple Contrastive Learning, CVPR 2022 News (03/16/2022) upload retrieval checkpoints finetuned on COCO and Flickr T

187 Jan 02, 2023
FCN (Fully Convolutional Network) is deep fully convolutional neural network architecture for semantic pixel-wise segmentation

FCN_via_Keras FCN FCN (Fully Convolutional Network) is deep fully convolutional neural network architecture for semantic pixel-wise segmentation. This

Kento Watanabe 48 Aug 30, 2022
Pytorch implementation of

EfficientTTS Unofficial Pytorch implementation of "EfficientTTS: An Efficient and High-Quality Text-to-Speech Architecture"(arXiv). Disclaimer: Somebo

Liu Songxiang 109 Nov 16, 2022