Hey guys, I'm trying to write a code that will calculate this equation y^3=x^2+4
I've got it sorta figured out, but I'm having some problems with cbrt function.
There should be two answers first one is i=2, and the second one would be i=5.
But it seems that the code doesn't work properly for some reason, it gives me only i=2 but not the second solution, any suggestions why?
Any help would be appreciated.
There are so many questions I have about this code.
If you have an equation with 2 variables, why are you solving for only 1 variable?
If you have variables in your equation named x and y, why does your code use a variable named i? Line 19 looks goofy in this regard.
Your value "i" is actually the x value in your equation.
The values a and b are actually the "y" value in your equation, where a is the actual value and b is the floor of the actual value. What you are checking for in line 18 is that the value y is an integer (has no decimal places). Not only is this not what you are trying to do, it is an unsafe way to make that determination.
I'm guessing what you are trying to find is the solution of x^3 = x^2 + 4. The value 2 is a solution to this equation, but 5 is not.
Edit: I started my reply before @JLBorges's reply was posted. That response helps me understand the problem description, and I agree with that solution.
Solved it myself, but anyway thanks guys for the help.
Don't worry Doug4, there are two solutions, just didn't really formulated the sentece when I said that there are two i's . Here check the code for yourself.
Here is the solved issue in the code.