what kind of variable would you use to represent these?
what kind of variable would you use to represent these?
an imaginary one?
is there a type of variable you could use to represent them? i dont really know a lot about imaginary numbers and i need to use them in a program i have to write
not that i can remember, but what is stopping you from creating your own class to represent imaginary numbers?
C Code. C Code Run. Run Code Run... Please!
"Love is like a blackhole, you fall into it... then you get ripped apart"
ok you got me.......i feel like an idiot but what exactly is an imaginary number?
C Code. C Code Run. Run Code Run... Please!
"Love is like a blackhole, you fall into it... then you get ripped apart"
std::complex maybe?
For imaginary numbers only i suppose you could set the real part to zero. Ive only used i as part of a complex number never alone.
Free the weed!! Class B to class C is not good enough!!
And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi
I think the proper way to think about it is that an imaginary number is a complex number that isn't a real number, so it is always a complex number, regardless if the real part of it is zero or not.
...edit...
maybe not, the FAQ above explains:
"Imaginary numbers are numbers that can be written as a real number times i."
"Complex numbers are numbers like 7 + .4i; they're a real number plus an imaginary number."
Last edited by JasonD; 04-15-2003 at 04:02 PM.
ok i get what imaginary numbers are now. i have to write a program that solves the quadratic formula and i need to include imaginary numbers in the program......what do these numbers have to do with solving the quadratic formula?
Think of this. The square root of a negative number has to be imaginary. So
y=4a+3b+4 would be written.
Use what you learned in those tutorials to figure out how you would evaluate the problem above.Code:(-3(+/-)(sqrt((squared(3))-(4*4*4))))/(4*2) assume #define squared(x) x*x
Last edited by Extol; 04-17-2003 at 03:24 PM.
The quadratic formula will tell you the two roots of the equation. For example, for the quadratic y = x^2 - 1, the graph would intersect the x-axis at -1 and 1. These are the roots. If the graph were y = x^2 + 1 on the other hand, there would be no real roots because the graph of the quadratic doesn't intersect the x-axis. In this case you would have two imaginary roots, -i and i. We get this from the quadratic formula:
-b +/- sqrt( b^2 -4(a)(c)) / 2a
=
+/- sqrt(-4) / 2 = +/- 2i / 2 = +/- i
(remember i is the sqrt(-1))
I'm a beginner at programming myself, so I don't know which header it is that has support for complex numbers, but this is why you would need them.
Extol: remember that in your example, 4, 3, and 4 are equal to a, b, and c. I believe you want x's where you have your a and b
so to declare an imaginary number......i could just do this right?
double i = sqrt(-1);
Oh gosh. Yea, isn't it 4x^2+3x+4 even. I don't remember.
alright i think i actually need to use complex numbers......is therea way to declare these?