Checking parallelism PROBLEM... (SOLVED!)
04-11-2015, 04:31 PM (This post was last modified: 04-12-2015 04:36 AM by Spybot.)
Post: #1
 Spybot Member Posts: 176 Joined: Feb 2015
Checking parallelism PROBLEM... (SOLVED!)
Hello Everyone!

Can Anyone help me with this little program? I'm trying to determine if these lines are parallel (I know they're not) but I want the program to tell it to me, I'm expecting to get a zero as result, but I'm actually getting some kind of error. I'm typing the syntax just as the calculator's help section says. I wonder what Am I doing wrong?

EXPORT test1()
BEGIN
LOCAL AA,x,y;
AA:=is_parallel(line(3*x+5*y=3),line(4*x-8*y=7));
PRINT();
PRINT(AA);
END;

Thank you.

Spybot.

Spybot.
04-11-2015, 06:03 PM
Post: #2
 Han Senior Member Posts: 1,882 Joined: Dec 2013
RE: Checking parallelism question...
You are creating a non-CAS program. Therefore, the LINE command is the non-CAS command and expects arguments that would enable it to draw a line on the screen.

Graph 3D | QPI | SolveSys
04-11-2015, 08:14 PM (This post was last modified: 04-11-2015 08:19 PM by Spybot.)
Post: #3
 Spybot Member Posts: 176 Joined: Feb 2015
RE: Checking parallelism question...
Hi Han!

OK, so what is a CAS-Program? what are CAS commands? and what are Non-CAS commands? Do we have a list indicating which commands are CAS and which are not? I just wanna know if the lines are parallel, I'm not trying to draw anything, that's just the way the command reference says the syntax for this particular command should be! but now it turns into something much more complicated thing! all I'd like to know is how do I make this command to work from inside of a program.

Thank you!

Spybot.

Spybot.
04-11-2015, 09:34 PM
Post: #4
 rprosperi Super Moderator Posts: 5,434 Joined: Dec 2013
RE: Checking parallelism question...
(04-11-2015 08:14 PM)Spybot Wrote:  Hi Han!

OK, so what is a CAS-Program?

First, read Han's excellent CAS Programming tutorial here.

Once you read that, you will better understand that the answers to your subsequent questions can be complex, but you'll understand why.

--Bob Prosperi
04-12-2015, 01:08 AM (This post was last modified: 04-12-2015 01:26 AM by Spybot.)
Post: #5
 Spybot Member Posts: 176 Joined: Feb 2015
RE: Checking parallelism question...
Hi rprosperi!

I've read the Han's tutorial you suggested and I found it very interesting, in fact now I undestand what a CAS "function" is, but he explains the different methods to create CAS and Non-CAS "FUNCTIONS". I mean:

EXPORT myprogram(args)
BEGIN
.
.
[CODE]
.
.
END;

or

#cas
myprog(args):=
BEGIN
.
.
[CODE]
.
.
END;
#end

In my case I'm developing a more than 25 hundred line interactive program(not a function), my prog doesn't require arguments to be run, it starts with a CHOOSE menu, then it'll start asking for arguments. So Han's tutorial doesn't help that much, maybe he could make another one only for programs that doesn't require arguments.

I insist! if someone can help me to make the: is_parallel(); command run from within a program that doesn't require arguments, I'll appreciate it so much! because that would be more illustrative than 100 tutorials.

Another thing, I don't understand. Why Hp Prime commands behave differently when run in (Home or CAS views) and inside of a program? HP-4X calculators, treated commands equally in both environments.

Spybot.

Spybot.
04-12-2015, 01:49 AM
Post: #6
 Han Senior Member Posts: 1,882 Joined: Dec 2013
RE: Checking parallelism PROBLEM!
Programs don't have to have any arguments. Those are completely optional. A "program" is essentially a collection of "functions" that are called by some "main" function. You can create two kinds of functions: CAS and non-CAS. If you plan to do any computations that require the CAS (basically anything symbolic) then it may be best to create a CAS function (or subroutine) to specifically handle those computations.

Code:
#cas paraexample():= begin local result; result:=is_parallel(line(3*x+5*y=3),line(4*x-8*y=7)); return(result); end; #end

would create a subroutine named paraexmple that takes no arguments and simply returns a 1 or 0. That's a pure CAS function. If you prefer to not have to create a pure CAS function, you could do:

Code:
paraexample() begin local result; result:=CAS("is_parallel(line(3*x+5*y=3),line(4*x-8*y=7))"); return(result); end;

Graph 3D | QPI | SolveSys
04-12-2015, 02:28 AM
Post: #7
 Spybot Member Posts: 176 Joined: Feb 2015
RE: Checking parallelism PROBLEM!
Hi Han!

I'm sorry to bother... but none of the above codes even run on either the calculator or the emulator, I think I got your point about functions and programs, but still there is a missing piece in all this. Something I ignore and that it could make this code to actually run.

Spybot.

Spybot.
04-12-2015, 02:53 AM
Post: #8
 Han Senior Member Posts: 1,882 Joined: Dec 2013
RE: Checking parallelism PROBLEM!
(04-12-2015 02:28 AM)Spybot Wrote:  Hi Han!

I'm sorry to bother... but none of the above codes even run on either the calculator or the emulator, I think I got your point about functions and programs, but still there is a missing piece in all this. Something I ignore and that it could make this code to actually run.

Spybot.

For the CAS version, make sure to type paraexample() <-- the parentheses are important, otherwise it just spits back the actual function (calling a CAS function by its name without the parenthesis, which force the parser to handle it as a function, is essentially like recalling the contents of a CAS variable).

For the non-CAS version, it was presented as a subroutine. If you want to run it, you need to add in EXPORT in front of the function name.

Graph 3D | QPI | SolveSys
04-12-2015, 04:36 AM
Post: #9
 Spybot Member Posts: 176 Joined: Feb 2015
RE: Checking parallelism PROBLEM!
OK!

Finally Got it!

here's the code for getting the: is_parallel(); command to work from inside of a non-CAS program.

EXPORT test()
BEGIN
LOCAL a1,b1,c1,a2,b2,c2,aa;
INPUT({{a1,[0],{7,15,1}},{b1,[0],{35,15,1}},{c1,[0],{64,15,1}},{a2,[0],{7,15,2}},{b2,[0],{35,15,2}},{c2,[0],{64,15,2}}},"I HAVE...",{"A₁:","B₁:","C₁:","A₂:","B₂:","C₂:"},{"Enter Coefficient A: (Any Real Number.)","Enter Coefficient B: (Any Real Number.)","Enter Coefficient C: (Any Real Number.)","Enter Coefficient A₂: (Any Real Number.)","Enter Coefficient B₂: (Any Real Number.)","Enter Coefficient C₂: (Any Real Number.)"});
aa:="is_parallel(line("+a1+"*x+"+b1+"*y+"+c1+"=0)"+",line("+a2+"*x+"+b2+"*y+"+c2+"=0))";
aa:=CAS(aa);
print();
print(aa);
END;

I have to thank Han for his personal support and also to rprosperi for referring me to Han's tutorial.

Thank you all!

Spybot.

Spybot.
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)