= to ==, why? [SOLVED]
12-10-2016, 05:46 AM (This post was last modified: 12-10-2016 05:55 AM by Han.)
Post: #4
 Han Senior Member Posts: 1,877 Joined: Dec 2013
RE: = to ==, why?
(12-09-2016 10:15 PM)compsystems Wrote:
Quote:rather than passing things back and forth between your main CAS program and non-CAS subroutines?
A principle of programming is to split an algorithm into sub-functions, my code should work

Quote:Why not just (within the CAS program) do
eq1:= a*x^2+b*x+c = 0;
eq1:= eq1*4*a;
print(eq1)

The first version of my code is in, it works fine.

Your first version worked fine because everything was kept on the CAS side. The problem is not that you used sub-functions. The problem is that you are using non-CAS commands (I erred and wrote 'subroutines' in my first response; but I meant commands) and therefore there is a lot of conversion/translation between CAS and non-CAS environments that are resulting in unwanted outputs. The problem is your equ:=expr(...) statement in your str2expr() subroutine. My modification of your code also uses sqrt() and does not exhibit the issue that you have.

EDIT: I still do not understand why you are doing all your calculations using strings when you have direct access to symbolic calculations by the fact that your program is a CAS program. It is as if you had an HP48 installed with an emulator, and the emulator is emulating the HP48. What is the reason for the seemingly unnecessary "extra layer" ?

Graph 3D | QPI | SolveSys
 « Next Oldest | Next Newest »

 Messages In This Thread = to ==, why? [SOLVED] - compsystems - 12-09-2016, 05:53 PM RE: = to ==, why? - Han - 12-09-2016, 07:58 PM RE: = to ==, why? - compsystems - 12-09-2016, 10:15 PM RE: = to ==, why? - Han - 12-10-2016 05:46 AM RE: = to ==, why? - compsystems - 12-10-2016, 07:07 PM RE: = to ==, why? - Han - 12-10-2016, 09:39 PM RE: = to ==, why? - compsystems - 12-11-2016, 03:08 PM

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