In this second course, we begin with the solution of circuits in AC steady state using phasor analysis. This is the tutorial (recitation) for this first part of the course.
I prefer working in radians mode when I'm in CAS. It is safer, in my experience. But when I need to enter a complex number in polar form I use // Polar to Rec // Input: complex number in polar form (abs,arg in degrees) // Output: complex number in rectangular mode EXPORT p2r(m,degrees) BEGIN LOCAL a,b,mode; mode:=HAngle; HAngle:=1; a:=m*cos(degrees); b:=m*sin(degrees); HAngle:=mode; RETURN(a+i*b); END;
I also use these other two (again, I set my CAS to radians), // Rec to Polar // Input: complex number in rectangular format // Output: list with {abs,arg in degrees} // ...... of the complex number in polar form. EXPORT r2p(a) BEGIN LOCAL m,t,anglemode; anglemode:=HAngle; HAngle:=0; m:=abs(a); t:=arg(a)*180/pi; HAngle:=anglemode; RETURN({m,t}); END; // argument in degrees // Input: complex number // Output: argument (degrees) EXPORT argd(a) BEGIN LOCAL mode:=HAngle,x; HAngle:=0; x:=arg(a)*180/pi; HAngle:=mode; RETURN(x); END;
Professor Linares, thank you for your videos. They are incredible!
You're very welcome! Thank you for the feedback. I really appreciate it.
Thanks Professor L.
You are welcome!
p2r ? Is that a function you define to make complex numbers work in CAS?
I prefer working in radians mode when I'm in CAS. It is safer, in my experience. But when I need to enter a complex number in polar form I use
// Polar to Rec
// Input: complex number in polar form (abs,arg in degrees)
// Output: complex number in rectangular mode
EXPORT p2r(m,degrees)
BEGIN
LOCAL a,b,mode;
mode:=HAngle; HAngle:=1;
a:=m*cos(degrees);
b:=m*sin(degrees);
HAngle:=mode;
RETURN(a+i*b);
END;
I also use these other two (again, I set my CAS to radians),
// Rec to Polar
// Input: complex number in rectangular format
// Output: list with {abs,arg in degrees}
// ...... of the complex number in polar form.
EXPORT r2p(a)
BEGIN
LOCAL m,t,anglemode;
anglemode:=HAngle;
HAngle:=0;
m:=abs(a); t:=arg(a)*180/pi;
HAngle:=anglemode;
RETURN({m,t});
END;
// argument in degrees
// Input: complex number
// Output: argument (degrees)
EXPORT argd(a)
BEGIN
LOCAL mode:=HAngle,x;
HAngle:=0;
x:=arg(a)*180/pi;
HAngle:=mode;
RETURN(x);
END;
@@rolinychupetin Thank you for sharing.