Mathematic Equation solving app/website

Guys I am working on a simple project and it's about a website that can solve many kinds of mathematical problems. Generally the user will be able to choose 1 or 2 variables and then they need to make an equation or expression using symbols (+,-,/,*,mod etc) and the program will return the solution pair for the given equation/expression by testing out some numbers within a range. The user will also be able to modify the number range. If anyone is interested about this project then let me know
18 Replies
anic17
anic172mo ago
Adding modular arithmetic it is going to be quite harder than just basic arithmetic operations
Mushfiqur
MushfiqurOP2mo ago
Not really. Solving an equation is much harder I was able to code the core part but there's many things left
anic17
anic172mo ago
The equation is limited to linear equations?
Mushfiqur
MushfiqurOP2mo ago
Nope
anic17
anic172mo ago
I'm guessing you're using Newton's method for it
Mushfiqur
MushfiqurOP2mo ago
No I am just using brute force method usually the computer will test the numbers from 1 to 10000 to check whether the number satiesfies the equation. Then when the solution is found the program wil return the values which will pass the test and show it in the html page
anic17
anic172mo ago
Bro That's probably the least efficient mrghkd existing And what if a solution is -3 or ⅔
Mushfiqur
MushfiqurOP2mo ago
it will only work with integer solutions at the first stage. after that I will try to work with non-integer numbers also
anic17
anic172mo ago
And that is the problem Trying out every number from 0 to 10000 is very, very, very slow I'd strongly suggest you to use Newton's method or the bisection one to help you find the roots easily I have done an equation solver before and those were by far the best methods
Mushfiqur
MushfiqurOP2mo ago
Yep I faced the problem I reduced the default limit. Thanks for the suggestion though
anic17
anic172mo ago
That's not what I'm saying you should attempt And you'll probably discover (if you haven't already) the precision errors of 64-bit doubles
Mushfiqur
MushfiqurOP2mo ago
Yep I am getting some kind of error even though I don't know what is it Can you tell me about it?
anic17
anic172mo ago
It's a bit complicated to explain in simple terms but basically doubles lose precision due to their internal representation
Mushfiqur
MushfiqurOP2mo ago

results = {}; // Reset results
let epsilon = 1e-6; // Define a tolerance value for floating-point comparison
if (expressionArray.includes('x') && expressionArray.includes('y')) {
// Loop through array to find pairs of (x, y)
for (let i = 0; i < array.length; i++) {
results[`temp${i}`] = []; // Create a new array to store results for each 'i'

for (let j = 0; j < array.length; j++) {
let x = array[i];
let y = array[j];

let expression = expressionArray.join('')
.replace(/x/g, x)
.replace(/y/g, y);

let result = eval(expression);

results = {}; // Reset results
let epsilon = 1e-6; // Define a tolerance value for floating-point comparison
if (expressionArray.includes('x') && expressionArray.includes('y')) {
// Loop through array to find pairs of (x, y)
for (let i = 0; i < array.length; i++) {
results[`temp${i}`] = []; // Create a new array to store results for each 'i'

for (let j = 0; j < array.length; j++) {
let x = array[i];
let y = array[j];

let expression = expressionArray.join('')
.replace(/x/g, x)
.replace(/y/g, y);

let result = eval(expression);
this is the core logic of this program does this include the fault you are taking about?
anic17
anic172mo ago
yeah
Mushfiqur
MushfiqurOP2mo ago
I solved the problem 👍 its just working fine now. except it can seek values which are only integer and numbers from 1 to 500
anic17
anic172mo ago
Have you looked up any numerical method for solving equations
Mushfiqur
MushfiqurOP2mo ago
nope just the brute force.
Want results from more Discord servers?
Add your server