function solve (){
var p,q,wo,w1,b;
p = trim(document.getElementById('pi').value); 
q = trim(document.getElementById('qi').value);
w0 = trim(document.getElementById('w0i').value);
w1 = trim(document.getElementById('w1i').value);
b = trim(document.getElementById('bi').value);

if(/\.{2,}/.exec(p) || /\.{2,}/.exec(q) || /\.{2,}/.exec(w0) || /\.{2,}/.exec(w1) || /\.{2,}/.exec(b)
|| isNaN(p) || isNaN(q) || isNaN(w0) || isNaN(w1) || isNaN(b)) {
alert(unescape('%DCberpr%FCfen Sie Ihre Eingabe: Ein Parameter ist keine Zahl!\r\nCheck your input: One of the parameters is no number!')); return;}

p = parseFloat(p);
q = parseFloat(q);
w0 = parseFloat(w0);
w1 = parseFloat(w1);
b = parseFloat(b);

a1=Math.abs(p);a5=Math.abs(q);b3=Math.abs(w0);c3=Math.abs(w1);b1=Math.abs(b);c1 = b1;
sp0='\u2009', sp1='\u2009';

a0 = '+';
a4 = '+';
b0 = '';
b2 = '';
c0 = '';
c2 = '';
a2 = 'f'; a3 = '\u2032';
a6 = 'f';

if(p < 0) a0 = '-';
if(p == 0) {a0 = ''; a1=''; a2 = ''; a3 = ''; sp0 = '';}
if(p == 1 || p == -1) {a1 = ''; sp0 = '';}
if(q < 0) a4='-';
if(q == 0) {a4 = ''; a5 = ''; a6 = ''; sp1 = '';}
if(q == 1 || q == -1) {a5 = ''; sp1 = '';}

document.getElementById('a0').firstChild.nodeValue = a0;
document.getElementById('a1').firstChild.nodeValue = a1+sp0;
document.getElementById('a2').firstChild.nodeValue = a2;
document.getElementById('a3').firstChild.nodeValue = a3;
document.getElementById('a4').firstChild.nodeValue = a4;
document.getElementById('a5').firstChild.nodeValue = a5+sp1;
document.getElementById('a6').firstChild.nodeValue = a6;

if(b < 0) {b0 = '-'; c0 = '-'; d7 = '+'; d16 = '+'; e7 = '+'; e16 = '+';}
document.getElementById('b0').firstChild.nodeValue = b0;
document.getElementById('c0').firstChild.nodeValue = c0;
document.getElementById('b1').firstChild.nodeValue = b1;
document.getElementById('c1').firstChild.nodeValue = c1;

if(w0 < 0) b2 = '-';
document.getElementById('b2').firstChild.nodeValue = b2;
document.getElementById('b3').firstChild.nodeValue = b3;

if(w1 < 0) c2 = '-';
document.getElementById('c2').firstChild.nodeValue = c2;
document.getElementById('c3').firstChild.nodeValue = c3;

/*###################################*/

D = p*p/4-q;

if(D == 0) {
clear ();
x1 = -p/2;

r1 = w0+b*(x1*w0-w1);
r2 = w1-x1*w0;

if(r1 != 0) {
d1 = '';
if(Math.abs(r1) != 1 || x1 == 0) d1 = Math.round(1000*Math.abs(r1))/1000+'\u2009';
if(r1 < 0) d0 = '-';
if(x1 != 0) {
d11 = 'e'; d15 = 'X';
if(x1 < 0) d12 = '-';
if(Math.abs(x1) != 1) d13 = Math.round(1000*Math.abs(x1))/1000+'\u2009';
if(b != 0) {d17 = Math.round(1000*Math.abs(b))/1000; d16 = '-'; if(b < 0) d16 = '+';}
if(b != 0 && Math.abs(x1) != 1) {d14 = '('; d18 = ')';}
if(b != 0 && x1 == -1) {d16 = '+'; if(b < 0) d16 = '-';}
}
}

if(r2 != 0) {
if(r1 == 0) d1 = '';
e1 = 'X'+'\u2009';
if(Math.abs(r2) != 1) e0 = Math.round(1000*Math.abs(r2))/1000+'\u2009';
if(r1 != 0) d19='+';
if(r2 < 0) d19 = '-';
if(x1 != 0) {
e11 = 'e'; e15 = 'X';
if(x1 < 0) e12 = '-';
if(Math.abs(x1) != 1) e13 = Math.round(1000*Math.abs(x1))/1000+'\u2009';
if(b != 0) {e17 = Math.round(1000*Math.abs(b))/1000; e16 = '-'; if(b < 0) e16 = '+';}
if(b != 0 && Math.abs(x1) != 1) {e14 = '('; e18 = ')';}
if(b != 0 && x1 == -1) {e16 = '+'; if(b < 0) e16 = '-';}
}
}
}

/*###################################*/

if(D > 0) {
clear ();
x1 = -p/2+Math.sqrt(D);
x2 = -p/2-Math.sqrt(D);

r1 = (w1-w0*x2)/(x1-x2);
r2 = (w1-w0*x1)/(x2-x1);

if(r1 != 0) {
d1 = '';
if(Math.abs(r1) != 1 || x1 == 0) d1 = Math.round(1000*Math.abs(r1))/1000+'\u2009';
if(r1 < 0) d0 = '-';
if(x1 != 0) {
d11 = 'e'; d15 = 'X';
if(x1 < 0) d12 = '-';
if(Math.abs(x1) != 1) d13 = Math.round(1000*Math.abs(x1))/1000+'\u2009';
if(b != 0) {d17 = Math.round(1000*Math.abs(b))/1000; d16 = '-'; if(b < 0) d16 = '+';}
if(b != 0 && Math.abs(x1) != 1) {d14 = '('; d18 = ')';}
if(b != 0 && x1 == -1) {d16 = '+'; if(b < 0) d16 = '-';}
}
}

if(r2 != 0) {
if(r1 == 0) d1 = '';
if(Math.abs(r2) != 1 || x2 == 0) e0 = Math.round(1000*Math.abs(r2))/1000+'\u2009';
if(r1 != 0) d19 ='+';
if(r2 < 0) d19 = '-';
if(x2 != 0) {
e11 = 'e'; e15 = 'X';
if(x2 < 0) e12 = '-';
if(Math.abs(x2) != 1) e13 = Math.round(1000*Math.abs(x2))/1000+'\u2009';
if(b != 0) {e17 = Math.round(1000*Math.abs(b))/1000; e16 = '-'; if(b < 0) e16 = '+';}
if(b != 0 && Math.abs(x2) != 1) {e14 = '('; e18 = ')';}
if(b != 0 && x2 == -1) {e16 = '+'; if(b < 0) e16 = '-';}
}
}
}

/*###################################*/

if(D < 0) {
clear();
u = -p/2;
v = Math.sqrt(-D);

r1 = Math.round(1000*(w1-w0*u)/v)/1000;
r2 = Math.round(1000*w0)/1000;


if(r2 != 0) d1 = '';
if(r1 != 0 && r2 > 0) d19 = '+';
if(r2 < 0) d19 = '-';

if(r1 != 0) {
d4 = Math.round(v*1000)/1000+'\u2009';
d2 = 'sin';
d3 ='(';
d10 = ')';
d6 = 'X';
if(b != 0){d7 = '-'; d8 = c1;}
if(b != 0 && v != 1) {d5 = '('; d9 = ')';}
if(v == 1) d4 = '';
if(v == 1 && b == 0) {d3 =''; d10 = ''; d6 = '';}
if(b < 0) d7 = '+';
d1 = '';
if(Math.abs(r1) != 1) d1 = Math.abs(r1)+'\u2009';
if(r1 < 0) d0 = '-';

if(u != 0) {
d11 = '\u2009'+'e'; d15 = 'X'; d13 = Math.abs(Math.round(u*1000)/1000)+'\u2009';
if(Math.abs(u) == 1) d13 = '';
if(b != 0) {d17 = c1; d16 = '-';}
if(b != 0 && Math.abs(u) != 1) {d14 = '('; d18 = ')';}
if(b < 0) d16 = '+'; 
if(b > 0 && u == -1) d16 = '+';
if(b < 0 && u == -1) d16 = '-';
if(u < 0) d12 = '-';
}
}

if(r2 != 0) {
e4 = Math.round(v*1000)/1000+'\u2009';
e2 = 'cos';
e3 = '(';
e10 = ')';
e6 = 'X';
if(b != 0){e7 = '-'; e8 = c1;}
if(b != 0 && v != 1) {e5 = '('; e9 = ')';}
if(v == 1) e4 = '';
if(v == 1 && b == 0) {e3 = ''; e10 = ''; e6 = '';}
if(b < 0) e7 = '+';
e0 = '';
if(Math.abs(r2) != 1) e0 = Math.abs(r2)+'\u2009';

if(u != 0) {
e11 = '\u2009'+'e'; e15 = 'X'; e13 = Math.abs(Math.round(u*1000)/1000)+'\u2009';
if(Math.abs(u) == 1) e13='';
if(b != 0) {e17 = c1; e16 = '-';}
if(b != 0 && Math.abs(u) != 1) {e14 = '('; e18 = ')';}
if(b < 0) e16 = '+';
if(b > 0 && u == -1) e16 = '+';
if(b < 0 && u == -1) e16 = '-';
if(u < 0) e12 = '-';
}
}
}

document.getElementById('d0').firstChild.nodeValue = d0;
document.getElementById('d1').firstChild.nodeValue = d1;
document.getElementById('d2').firstChild.nodeValue = d2;
document.getElementById('d3').firstChild.nodeValue = d3;
document.getElementById('d4').firstChild.nodeValue = d4;
document.getElementById('d5').firstChild.nodeValue = d5;
document.getElementById('d6').firstChild.nodeValue = d6;
document.getElementById('d7').firstChild.nodeValue = d7;
document.getElementById('d8').firstChild.nodeValue = d8;
document.getElementById('d9').firstChild.nodeValue = d9;
document.getElementById('d10').firstChild.nodeValue = d10;
document.getElementById('d11').firstChild.nodeValue = d11;
document.getElementById('d12').firstChild.nodeValue = d12;
document.getElementById('d13').firstChild.nodeValue = d13;
document.getElementById('d14').firstChild.nodeValue = d14;
document.getElementById('d15').firstChild.nodeValue = d15;
document.getElementById('d16').firstChild.nodeValue = d16;
document.getElementById('d17').firstChild.nodeValue = d17;
document.getElementById('d18').firstChild.nodeValue = d18;
document.getElementById('d19').firstChild.nodeValue = d19;
document.getElementById('e0').firstChild.nodeValue = e0;
document.getElementById('e1').firstChild.nodeValue = e1;
document.getElementById('e2').firstChild.nodeValue = e2;
document.getElementById('e3').firstChild.nodeValue = e3;
document.getElementById('e4').firstChild.nodeValue = e4;
document.getElementById('e5').firstChild.nodeValue = e5;
document.getElementById('e6').firstChild.nodeValue = e6;
document.getElementById('e7').firstChild.nodeValue = e7;
document.getElementById('e8').firstChild.nodeValue = e8;
document.getElementById('e9').firstChild.nodeValue = e9;
document.getElementById('e10').firstChild.nodeValue = e10;
document.getElementById('e11').firstChild.nodeValue = e11;
document.getElementById('e12').firstChild.nodeValue = e12;
document.getElementById('e13').firstChild.nodeValue = e13;
document.getElementById('e14').firstChild.nodeValue = e14;
document.getElementById('e15').firstChild.nodeValue = e15;
document.getElementById('e16').firstChild.nodeValue = e16;
document.getElementById('e17').firstChild.nodeValue = e17;
document.getElementById('e18').firstChild.nodeValue = e18;

document.all.eq.update();
}

function clear (){
d0='';d1='0';d2='';d3='';d4='';d5='';d6='';d7='';d8='';d9='';d10='';d11='';d12='';d13='';d14='';d15='';d16='';d17='';d18='';d19='';
e0='';e1='';e2='';e3='';e4='';e5='';e6='';e7='';e8='';e9='';e10='';e11='';e12='';e13='';e14='';e15='';e16='';e17='';e18='';
}

function trim (s){
s1 = s.slice(1);
while(/\-/.exec(s1)) s1=s1.replace(/\-/,'');
s = s.substr(0,1)+s1;
s1 = s.slice(1);
while(/\+/.exec(s1)) s1=s1.replace(/\+/,'');
s = s.substr(0,1)+s1;
while(/,/.exec(s)) s=s.replace(/,/,'.');
return s;
}
