# Trouble representing an equation

I'm having trouble representing the following as an equation

 Ids[Vgs_,Vds_,Vtn_,kn_] := \[Piecewise]    0   Vgs < Vtn
kn * ((Vgs-Vtn) * Vds - 1/2 * Vds^2)   Vgs >= Vtn && Vds < Vgs - Vtn
kn/2* (Vgs - Vtn)^2    Vgs >= Vtn && Vds >= Vgs - Vtn

ModeOfOperation[Vgs_, Vds_, Vtn_, kn_] := \[Piecewise] "Cutoff"    Vgs < Vtn
"Triode"   Vgs >= Vtn && Vds < Vgs - Vtn
"Saturation"   Vgs>= Vtn && Vds >= Vgs - Vtn

Rd = 0.2
Vin = 5
eq1 = Ids[Vin, V0, 1 , 1] = (5 - 2 - V0)/Rd

Solve[eq1, V0] // N


I've already defined Rd =.2 and Vin = 5. But I get the following error:

"5.(3-V0) is not a quantified system of equations and inequalities."

and

"5(3. -1.V0) is not a quantified system of equations and inequalities"

Why is eq1 not a valid expression? I understand what I'm trying to do is use the values for Vin, Rd and select the right equation from the piecewise for the left side and then solve for V0 using the right hand side.

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign!
– user9660
Nov 13, 2014 at 17:24
• Try to use == instead of = Nov 13, 2014 at 17:42
• reference.wolfram.com/language/ref/Equal.html Nov 13, 2014 at 17:43
• I tried eq1 = Ids[Vin,V0,1,1] == (5-2-V0)/Rd but its just returning True... Nov 13, 2014 at 17:45

Your Piecewise functions should be written as follows

Ids[Vgs_, Vds_, Vtn_, kn_] :=
Piecewise[{
{0, Vgs < Vtn},
{kn*((Vgs - Vtn)*Vds - 1/2*Vds^2), Vgs >= Vtn && Vds < Vgs - Vtn},
{kn/2*(Vgs - Vtn)^2, Vgs >= Vtn && Vds >= Vgs - Vtn}}];

ModeOfOperation[Vgs_, Vds_, Vtn_, kn_] :=
Piecewise[{
{"Cutoff", Vgs < Vtn},
{"Triode", Vgs >= Vtn && Vds < Vgs - Vtn},
{"Saturation", Vgs >= Vtn && Vds >= Vgs - Vtn}}];

Rd = 0.2;
Vin = 5;
eq1 = Ids[Vin, V0, 1, 1] == (5 - 2 - V0)/Rd;

Solve[eq1, V0][[1]]


{V0 -> 1.85857}

• Thanks. I'm still learning Mathematica and the "scoping" (right side blue line) was also a huge source of my issues but I finished my assignment. Thank you for your help. Marius too. Nov 13, 2014 at 19:19

An equation is of the form lhs == rhs. When you write eq1 = (5 - 2 - V0)/Rd you just set the "value" of eq1.

• I've taken a look at reference.wolfram.com/language/tutorial/… but setting eq1 = Ids[Vin,V0,1,1] == (5-2-V0)/Rd just returns true for the above code and not the value for V0. Nov 13, 2014 at 17:57