Git Product home page Git Product logo

computorv1's Introduction

ComputorV1

This project aims to make you code a simple equation solving program. It will take polynomial equations into account. These equations will only require exponents. No complex function. The program will have to display its solution(s).

The program must solve a polynomial of second or lower degree equation and show at least:
• The equation in its reduced form.
• The degree of the equation.
• It’s solution(s) and the polarity of the discriminant if it makes sens.

Bonus:
• Manage entry mistakes
• Display the intermediate steps
• Display solution as an irreducible fraction if it's interesting

Compile

CMake -B build && cd build
make all

Usage

./computor [string]

String has to have the following structer:
• every term has this form a * x^n
• were n is an exponent of value 0, 1 or 2
Example: "5 * X^0 + 4 * X^1 - 9.3 * X^2 = 1 * X^0"

Output

./computor  "5 * X^0 + 4 * X^1 - 9.3 * X^2 = 1 * X^0"
Reduced form: 4 * X^0 + 4 * X^1 - 9.3 * X^2 = 0
Polynomial degree: 2
Discriminant is strictly positive, the two solutions are:

a = -9.3 ,b = 4 , c = 4
Discriminant = b * b - 4 * a * c
Discriminant = 4 * 4 - 4 * -9.3 * 4
Discriminant = 164.8

x = (-b + sqrt(discriminant))/2 * a
x = (-4 + sqrt(164.8)) / (2 * -9.3)
x = 8.83745 / -18.6
x = -0.475131

x = (-b - sqrt(discriminant))/2 * a
x = (-4 - sqrt(164.8)) / (2 * -9.3)
x = -16.8374 / -18.6
x = 0.905239

Tester

./test/computor_test

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.