calculator icon indicating copy to clipboard operation
calculator copied to clipboard

[Feature] Calculate: Find Roots of an Equation

Open aminoxix opened this issue 3 years ago • 14 comments

Hey folks! 👋🏼 Do we have any feature to find the roots of an equation (whether it will a quadratic or linear equation) in one tap?

A quadratic equation is a second-order polynomial equation of a variable say x. The general form of a quadratic equation is given as:

a*x2 + b*x + c = 0

Where a,b and c are real known values and,
a can't be zero.

A quadratic equation has two roots. The roots of a quadratic equation can be easily obtained by using the quadratic formula:

roots = (-b ± √(b2 - 4ac))/2a

Derivation:

ax2 + bx + c = 0

or, ax2 + bx = -c

or, x2 + (b/a)x = -(c/a)

or, x2 + (b/a)x + (b2/4a2) - (b2/4a2) = -(c/a)

or, x2 + (b/a)x + (b2/4a2) = -(c/a) + (b2/4a2)

or, (x + b/2a)2  = -(c/a) + (b2/4a2)

or, (x + b/2a)2  = (b2  - 4ac) /4a2

or, (x + b/2a) = ± √(b2 - 4ac) /2a

or, x = (-b ± √(b2 - 4ac))/2a

There arises three cases as described below while finding the roots of a quadratic equation:

If b2 < 4ac, then roots are complex
(not real).
For example, roots of x2 + x + 1 = 0 are
-0.5 + i1.73205 and -0.5 - i1.73205

If b2 = 4ac, then roots are real 
and both roots are same.
For example, roots of x2 - 2x + 1 = 0 are 1 and 1

If b2 > 4ac, then roots are real 
and different.
For example, roots of x2 - 7x - 12 = 0 are 3 and 4

I didn't have any clue whether, that features is already there or not? If its not, Can I proceed to work on it? Pl help me look out!

aminoxix avatar Apr 10 '21 18:04 aminoxix

This is your friendly Microsoft Issue Bot. I've seen this issue come in and have gone to tell a human about it.

MicrosoftIssueBot avatar Apr 12 '21 09:04 MicrosoftIssueBot

This pitch looks like it has everything it needs for review. In the meantime, we'll keep this idea open for discussion so the community has the chance to provide feedback. Check out our New Feedback Process for more info on the user-centered process we follow for new feature development.

ghost avatar Apr 15 '21 05:04 ghost

Sir, I've a blue-print code for this, but doesn't know how to implement it with Microsoft modules/features? Can I take this issue & enhance my knowledge, & work on same issue further?

aminoxix avatar Apr 15 '21 08:04 aminoxix

Cubic and quartic equations should also be covered. Closed form solutions exist for them. Linear and quadratic equations can be solved in memory, if the coefficients are "nice". Cubics and quartics - not so easily. And that's a job for Calculator.

TrangOul avatar Apr 27 '21 17:04 TrangOul

Can I know @TrangOul, like, specifically what are you talking about? I get, this issue is reg. calculate roots of equations, and you're basically talking about Cubic & Quartics ie, under functions & ranges..

You may refer this, Sir.

aminoxix avatar Apr 27 '21 17:04 aminoxix

I mean the equations ax^3 + bx^2 + cx + d = 0 and ax^4 + bx^3 + cx^2 + dx + e = 0, with known complex coefficients a, b, c, d, e. Closed form solutions exist: cubic and quartic. They look messy, indeed, but we can extract and re-use partial results, just like we substitute Δ = b^2 - 4ac in quadratic equation.

TrangOul avatar Apr 27 '21 17:04 TrangOul

Yeah, it sounds good ! & may be.. this reduce our work for an instant as function.. right I agree with you.. but this functions are only applicable for Cubic, Quartic & Quintic equations, let me know if we find multiple roots from this method?

Declaration as per theory : x3 + ax2 + bx + c = 0 : Cubic equation x4 + ax3 + bx2 + cx + d = 0: Quartic equation x5 + ax4 + bx3 + cx2 + dx + e = 0 = 0: Quintic equation

aminoxix avatar Apr 27 '21 18:04 aminoxix

Quintics have a form ax^5 + bx^4 + cx^3 + dx^2 + ex + f (notice the fifth power) and they do not have a general solution. The provided code solves them (and quartics) numerically. Also, you've missed terms with x in 3rd and 4th degree equations.

TrangOul avatar Apr 27 '21 18:04 TrangOul

Yeah, I get your point, basically I'm dealing with quadratic in example, but we can stick with Cubic, Quartic and Quintic equation as well.. Thats great! If these functions, fulfill our needs, we like to recommend for a single button for all kinds of equations.. <3

aminoxix avatar Apr 27 '21 19:04 aminoxix

@amino19 Have you created any PR for this till now?

Swastyy avatar Aug 02 '21 03:08 Swastyy

@Swastyy : Nope, take it up! :slightly_smiling_face:

aminoxix avatar Aug 02 '21 19:08 aminoxix

Can I work on this issue?

Meenakshi-gthub avatar Jan 03 '22 18:01 Meenakshi-gthub

Can I work on this issue?

If @Swastyy is not working on this issue!

aminoxix avatar Mar 20 '22 13:03 aminoxix

Can I work on this issue?

If @Swastyy is not working on this issue!

There is not much work done, so @Meenakshi-gthub can start doin it.

Swastyy avatar Mar 21 '22 09:03 Swastyy