Input data type for fsolve() for PPL
|
06-29-2019, 12:27 PM
Post: #1
|
|||
|
|||
Input data type for fsolve() for PPL
I have a question when calling fsolve() in the program. When calling from cas screen, we can use fsolve() with the following:
fsolve(<equation>, <variable>) For example, fsolve(sin(x)/x = 0, x) When calling from program, what is the data type of <equation>, <variable>. I tried string, it doesn’t work. Any idea about this? |
|||
06-29-2019, 03:26 PM
Post: #2
|
|||
|
|||
RE: Input data type for fsolve() for PPL
When working with CAS commands in ppl, use the CAS command with quoted content, like this:
Code:
|
|||
06-29-2019, 05:48 PM
Post: #3
|
|||
|
|||
RE: Input data type for fsolve() for PPL
@DrD, thank you very much for your help. For the command you provided, it works.
However, if I write the code like this: Code:
It doesn’t work. It just return fsolve(equn). How can we have fsolve() or CAS.fsolve() accept the input from string variable? |
|||
06-30-2019, 05:15 PM
Post: #4
|
|||
|
|||
RE: Input data type for fsolve() for PPL
Try:
EXPORT temp() BEGIN // LOCAL x,y; LOCAL equn; equn:="[x^2+y-2,x+y^2-2],[x,y],[0,0]"; RETURN CAS.fsolve(EVAL(equn)); END; -road |
|||
07-01-2019, 07:17 PM
Post: #5
|
|||
|
|||
RE: Input data type for fsolve() for PPL
Thank you, roadrunner. That’s work! Why do we need to remove declaration of x, y variable?
|
|||
07-02-2019, 11:48 AM
Post: #6
|
|||
|
|||
RE: Input data type for fsolve() for PPL
I was getting this error message when I used local variables:
"fsolve([equations],[variables],[guesses]) Error: Bad Argument Value" I may be wrong, but I think when you call a CAS command from a program with local variables it used the value stored in the variable so it was really trying to do this: fsolve([0^2+0-2,0+0^2-2],[0,0],[0,0]) which generated that error message. It's best to use undefined variables for fsolve. -road |
|||
07-02-2019, 01:21 PM
Post: #7
|
|||
|
|||
RE: Input data type for fsolve() for PPL
ok. got the point. thank you
|
|||
07-02-2019, 07:11 PM
Post: #8
|
|||
|
|||
RE: Input data type for fsolve() for PPL
(07-01-2019 07:17 PM)teerasak Wrote: Thank you, roadrunner. That’s work! Why do we need to remove declaration of x, y variable? You can make the variables local to the entire scope of the program: Code:
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)