C++ Help
|
2015-10-12, 15:49
Post: #1
|
|||||||
|
|||||||
C++ Help
Eyo people,
I need some help with C++ based stuff. I have to make a problem that solves a biquadratic equation (ax4 +bx2+c=0), but I can only figure out how to make a program that solves a quadratic equation (ax2+bx+c=0). If someone is willing to help me how to make a program which solves a biquadratic equation, I would be very thankful. P.S. If you need it, that's the code for the program that solves a quadratic equation. |
|||||||
|
|||||||
2015-10-12, 16:12
Post: #2
|
|||||||
|
|||||||
RE: C++ Help
oh god... didnt see this crap for a long time.
dont u basically just need to do a substitution. replace x2 with y. than u get a quadratic equation what u r alrdy able to solve. in the end you re-substitute. thats all i remember lol xD also format your code properly. will get messy longterm. tab all lines after a bracket. |
|||||||
|
|||||||
2015-10-12, 16:25
Post: #3
|
|||||||
|
|||||||
RE: C++ Help
I tried doing that, but couldn't manage to get it working. I was able to find y1,y2, but then couldn't re-substitute because it was showing some errors.
|
|||||||
|
|||||||
2015-10-12, 16:56
Post: #4
|
|||||||
|
|||||||
RE: C++ Help
post the non-working code (as text, not picture) plus the errors
|
|||||||
|
|||||||
2015-10-12, 17:44
Post: #5
|
|||||||
|
|||||||
RE: C++ Help
Hmm, I thought it would work with that, but I guess I've done something wrong again.. I tried substituting y=x*x, but it said x isn't initialized.
That's the code: Code: #include <iostream> |
|||||||
|
|||||||
2015-10-12, 19:37
Post: #6
|
|||||||
|
|||||||
RE: C++ Help
It prints x1=NAN (not a number) because y1 is negative and sqrt() function can not calculate squareroot of negative numbers.
In first post you wrote: Quote:ax4 +bx2+c=0I assume you meant: a(x^4) +b(x^2)+c=0 ? With the input from your screenshot: a=1 b=4 c=1 The graph looks like this: => This function has no solution. Try entering some other values, plot the graph, and compare, might be that your program is already correct? |
|||||||
|
|||||||
2015-10-13, 16:07
Post: #7
|
|||||||
|
|||||||
RE: C++ Help
Okay, I've finally done it. Figured out a way to use as many if and else's as possible, and it seems to work. That's the code:
Code: #include <iostream> Cheers for the help guys! |
|||||||
|
|||||||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)
Powered By MyBB, © 2002-2024 MyBB Group