<script language="JavaScript">
function Validate(form) {
if(!form.Zo.value) {
alert("Enter Value for Zo.");
form.Zo.focus();
return false;
}
return true;
}
function Compute(form) {
with(Math) {
var Vout = Number(form.Vout.value);
var A = Number(form.A.value);
var R1 = Number(form.R1.value);
var V1= Number(form.V1.value);
var V2= Number(form.V2.value);
var Vp = Number(form.Vp.value);
var Vn = Number(form.Vn.value);
var R2;
var R3;
var R4;
var Vout1; // contribution due to V1
var Vout2; // contribution due to V2
var Precision= 3;
if(A>0) A= -A;
if(Vn==Vp) Vn= -Vp;
if(Vn>Vp) {
temp=Vp;
Vp= Vn;
Vn= temp;
}
if(Vn>0.0) Vn= 0;
R2= -A*R1;
R3= R1;
Vout1= A*V1;
Vout2= Vout-Vout1;
//R4= Vout2*(R1/(V2*(R1+R2)))*R3 / (1-Vout2*(R1/(V2*(R1+R2))));
R4= R3*(1-Vout2*R1/((R1+R2)*V2))/ (Vout2*R1/((R1+R2)*V2));
form.R2.value= R2.toPrecision(Precision);
form.R3.value= R3.toPrecision(Precision);
form.R4.value= R4.toPrecision(Precision);
form.Vp.value= Vp.toPrecision(Precision);
form.Vn.value= Vn.toPrecision(Precision);
form.A.value= A.toPrecision(Precision);
}
}
</script>