I was bored in math class, so I started to do... math
anyways, i came up with this equation:
The solution for all real answers is relatively easy. You just multiply both sides by y^2 and x^2, factor out the y, then divide by the coefficient to get it into f(x)=y form.
However, it doesn't end at that! Afterwards, you can factor out the square root of negative one, and get f(x)=yi. Once you've done that, you might as well replace x with a constant times i, so that you get f(xi)=y. Once you factor out an i again, you get f(xi)=yi.
So, by this method, you can get every single real and imaginary solution for x. Where x and y are both real, where x is imaginary and y is real, where x is real and y is imaginary, and where x is imaginary and y is imaginary.
Why is this so cool? Here, allow me to show super duper awesome pictures.
I have checked my work a ton, and it does work out correctly for all solutions shown.
But those are just still images. I've attached the executable, and here's the DBPro source code for it. The line drawing is done using cloggy's dll (i used lines for plotting because it makes a smoother graph, and the built in line commands are slow), so you'll need that to run it.
Press space to change both a and b based on the mouse position, and press space and click at the same time to change a and c. Since a, b, and c are coefficients on the top, the graph is the same as a=1.2, c=1.6, b=1.5, when a=12, c=16, and b=15.
global pixels_per_unit = 100
x as float
x=0
y as float
y=0
lx as float
lx=0
ly as float
ly=0
sync on
a as float
b as float
c as float
a=-30
b=30
c=30
do
if spacekey()
a=mousex()-screen width()/2
if mouseclick()
c=mousey()-screen height()/2
else
b=mousey()-screen height()/2
endif
endif
cls
text 0,0,"a="+str$(a/30.0,4)
text 0,16,"b="+str$(b/30.0,4)
text 0,32,"c="+str$(c/30.0,4)
text 0,48,"Red line: Real solutions; f(x)=y"
text 0,64,"Blue line: Imaginary solutions; f(x)=yi"
text 0,80,"Green line: Imaginary solutions; f(xi)=y"
text 0,96,"Purple line: Imaginary solutions; f(xi)=yi"
drawGraphPaper(pixels_per_unit,screen width()/2,screen height()/2,4)
ly=0
lx=0
for x=-4 to 4 step 0.01
y1#=x*sqrt(-b*(c*x^2-a))/(c*x^2-a)
if (c*x^2-a<>0) and (-b*(c*x^2-a)>=0) and dist2(lx,ly,x,y1#)<4.0
drawLine(lx,ly,x,y1#,pixels_per_unit,screen width()/2,screen height()/2,rgb(255,0,0))
endif
lx=x
ly=y1#
next x
lx=0
ly=0
for x=-4 to 4 step 0.01
y2#=-x*sqrt(-b*(c*x^2-a))/(c*x^2-a)
if (c*x^2-a<>0) and (-b*(c*x^2-a)>=0) and dist2(lx,ly,x,y2#)<4.0
drawLine(lx,ly,x,y2#,pixels_per_unit,screen width()/2,screen height()/2,rgb(255,0,0))
endif
lx=x
ly=y2#
next x
lx=0
ly=0
for x=-4 to 4 step 0.01 //imaginary, the y axis is bi, ie f(x)=bi
y1#=x*sqrt(b*(c*x^2-a))/(c*x^2-a)
if c*x^2-a<>0 and b*(c*x^2-a)>=0 and dist2(lx,ly,x,y1#)<4.0
drawLine(lx,ly,x,y1#,pixels_per_unit,screen width()/2,screen height()/2,rgb(0,0,255))
endif
lx=x
ly=y1#
next x
lx=0
ly=0
for x=-4 to 4 step 0.01
y2#=-x*sqrt(b*(c*x^2-a))/(c*x^2-a)
if c*x^2-a<>0 and b*(c*x^2-a)>=0 and dist2(lx,ly,x,y2#)<4.0
drawLine(lx,ly,x,y2#,pixels_per_unit,screen width()/2,screen height()/2,rgb(0,0,255))
endif
lx=x
ly=y2#
next x
lx=0
ly=0
for x=-4 to 4 step 0.01
y2#=x*sqrt(-b*(c*x^2+a))/(-c*x^2-a)
if (-c*x^2-a<>0) and (-b*(c*x^2+a)>=0) and dist2(lx,ly,x,y2#)<4.0
drawLine(lx,ly,x,y2#,pixels_per_unit,screen width()/2,screen height()/2,rgb(0,255,0))
endif
lx=x
ly=y2#
next x
lx=0
ly=0
for x=-4 to 4 step 0.01
y2#=-x*sqrt(-b*(c*x^2+a))/(-c*x^2-a)
if (-c*x^2-a<>0) and (-b*(c*x^2+a)>=0) and dist2(lx,ly,x,y2#)<4.0
drawLine(lx,ly,x,y2#,pixels_per_unit,screen width()/2,screen height()/2,rgb(0,255,0))
endif
lx=x
ly=y2#
next x
lx=0
ly=0
for x=-4 to 4 step 0.01
y2#=x*sqrt(b*(c*x^2+a))/(-c*x^2-a)
if (-c*x^2-a<>0) and (b*(c*x^2+a)>=0) and dist2(lx,ly,x,y2#)<4.0
drawLine(lx,ly,x,y2#,pixels_per_unit,screen width()/2,screen height()/2,rgb(255,0,255))
endif
lx=x
ly=y2#
next x
lx=0
ly=0
for x=-4 to 4 step 0.01
y2#=-x*sqrt(b*(c*x^2+a))/(-c*x^2-a)
if (-c*x^2-a<>0) and (b*(c*x^2+a)>=0) and dist2(lx,ly,x,y2#)<4.0
drawLine(lx,ly,x,y2#,pixels_per_unit,screen width()/2,screen height()/2,rgb(255,0,255))
endif
lx=x
ly=y2#
next x
inc pixels_per_unit, mousemovez()/20.0
sync
loop
function drawLine(x1 as float, y1 as float,x2 as float, y2 as float, PPU as integer, midx as integer, midy as integer,color as dword)
newx1#=x1*PPU
newy1#=y1*PPU
newx2#=x2*PPU
newy2#=y2*PPU
d3d_line newx1#+midx,newy1#+midy,newx2#+midx,newy2#+midy,color
endfunction
function dist2(x1 as float, y1 as float, x2 as float, y2 as float)
d#=(x1-x2)^2+(y1-y2)^2
endfunction d#
function drawGraphPaper(PPU as integer, midx as integer, midy as integer, subUnits as integer)
if subunits<=0 then subunits=1
if PPU<=0 then ppu=300
subDist as float
subDist=PPU*1.0/subUnits
counter1 as float =
counter1=-PPU
counter2 as float = 0
w=screen width()
h=screen height()
ink rgb(0,0,40)
d3d_line 0,h/2,w,h/2,rgb(0,0,40)
ink rgb(0,40,0)
d3d_line w/2,0,w/2,h,rgb(0,40,0)
while (counter1+midx<w) or (midx-counter1>0)
inc counter1, PPU
counter2=0
while (counter2<PPU)
inc counter2, subDist
ink rgb(150,150,150),0
d3d_line midx+counter1+counter2,midy-2,midx+counter1+counter2,midy+2
d3d_line midx-counter1+counter2,midy-2,midx-counter1+counter2,midy+2
endwhile
ink rgb(255,255,255),0
d3d_line midx+counter1,midy-5,midx+counter1,midy+5
d3d_line midx-counter1,midy-5,midx-counter1,midy+5
endwhile
counter1=-PPU
counter2=0
while (counter1+midy<w) or (midy-counter1>0)
inc counter1, PPU
counter2=0
while (counter2<PPU)
inc counter2, subDist
ink rgb(150,150,150),0
d3d_line midx-2,midy+counter1+counter2,midx+2,midy+counter1+counter2
d3d_line midx-2,midy-counter1-counter2,midx+2,midy-counter1-counter2
endwhile
ink rgb(255,255,255),0
d3d_line midx-4,midy+counter1,midx+4,midy+counter1
d3d_line midx-4,midy-counter1,midx+4,midy-counter1
endwhile
ink rgb(255,255,255),0
endfunction
It's really just four different functions, each with plus or minus signs (so eight lines). The long if statements and seperate code for each line is necessary. When you graph something that rapidly goes to infinity using points, you get a broken "fuzzy" line. when you use lines to connect the dots, you get ugly straight vertical lines (i guess 1/0 graphs as 0).