Today We are going to talk about Quadratic Equations. First, we want to tell you that this is not only a Mathematical lesson. There are several tricks to solving quadratic equations. But here we use programming. And here we use Python Programming language to it.
Content Map
01) How can we solve this manually?
02) Let's convert it to an algorithm!
02) Code it and use it
How can we solve this manually?
There are many tricks to solve this. but here we want to create a program for it. So we use the quadratic formula. Let's made it. And also here we don't try to focus mainly on the manual method. Anyway, let's start.
This is the calculation of the isolation of x. If you can't study this well you can watch this video by clicking here.
Let's convert it to an algorithm!
In the above, we solve quadratic equations in the manual method. But actually, we want to create a program for it. So we have to make a master plan for this😎. And the plan is...
Algorithm So let's make an algorithm for this process.
Input details
First, we have to know the values of a, b and c. So this is the input of this program.
The logical part
next, we have made the logical part of this. Now we have values of a, b and c. And we made the formula to find x using the above variables. But we can't make this yet. because sometimes quadratic equations give two values for this. Then what do we have to do?
We can make this for several ways. But we use a more simple algorithm for this.
First we can identify the part of equation that gives two values.
👈 So, this is the part. In here you can see this mathematical expression gives (+) value and (-) value. Now we can assign the value of this expression to a variable. And then we can get the two values by multiplying the variable by (+1) and (-1).
In here we use the variable name as "y".
Next we have to make two expressions to print two values by using variable "y".
y = square root of (b^2 - 4ac) ;
so we can substitute "y" for the places with the above expression. So we can make the final expression as,
(y - b) / (2a) and according to above, y change to (-y) and (y). then now we have two final equations as;
f1 = (y - b) / (2a) and
f2 = ((-1 * y) - b) / (2a)
(*f1 and f2 is final answer variables )
And this two equations can be equal. So,
if the value of both equations are equal we can write it as;
f1 = f2 then
there are no two answers so, there is only one answer and the answer is one of these variables.
because both of variable values are equal. Now we have an algorithm so, let's code the program.
Code it and use it
1) First of all let's assign the known values for the variables.
a = input("Enter a :")
b = input("Enter b :")
c = input("Enter c:")
2) Define variable data types for a, b and c.
a = float(a)
b = float(b)
c = float(c)
3) Create y, f1 and f2 variables to assign mathematical expressions.
y = ((b*b) - (4*a*c))**(1/2)
f1 = (y - b) / (2*a)
f2 = ((y*-1) - b) / (2*a)
4) Create the logical part.
if f1 == f2:
print("x is :" , f1)
else:
print("x is :" , f1)
print("or x is :" , f2)
The whole code like this 👇
a = input("enter a ")
b = input("enter b ")
c = input("enter c ")
a = float(a)
b = float(b)
c = float(c)
y = ((b*b) - (4*a*c))**(1/2)
f1 = (y - b) / (2*a)
f2 = ((y*-1) - b) / (2*a)
if f1 == f2:
print("x is :" , f1)
else:
print("x is :" , f1)
print("or x is :" , f2)
Let's see the outputs by video 👇 (low quality for speed loading)
If you want to do this using Pascal programming language follow our video in above 👇
That's all for now! And thank you all for read this!
and please comment your idea about the post and subscribe us on 👉YouTube👈
See you soon from another article..! 👋
and please comment your idea about the post and subscribe us on 👉YouTube👈
See you soon from another article..! 👋
Great 👍
ReplyDeletePost a Comment