using diff() in a program
|
05-08-2016, 09:18 AM
(This post was last modified: 05-08-2016 09:49 AM by hpfx.)
Post: #1
|
|||
|
|||
using diff() in a program
Hi,
I made a program that need to derivate a function, I don't understand why it does not work. when I'm in home, I can type diff(3*X+1) I get the expected result. But when I do the same in a program, I got error. I tried all kind of possible syntax to make it work. here is a simple example : Code: EXPORT ABCD() but I get this : "program(X,0,3)" instead. is it a bug ??? FW version 10077 |
|||
05-08-2016, 11:15 AM
Post: #2
|
|||
|
|||
RE: using diff() in a program
Try these changes:
1. change X to lower case 2. use double quotes for the equation 3. store it in a local variable 4. run diff from the CAS Code: EXPORT ABCD() Everything mentioned may not be required, but those are rules I generally follow. In the articles section Mr. Han has a good post about running CAS functions from a program. -road |
|||
05-08-2016, 01:13 PM
Post: #3
|
|||
|
|||
RE: using diff() in a program
(05-08-2016 11:15 AM)roadrunner Wrote: Try these changes:does not work Leo |
|||
05-08-2016, 02:13 PM
(This post was last modified: 05-08-2016 02:54 PM by informach.)
Post: #4
|
|||
|
|||
RE: using diff() in a program
Hi!, hpfx:
Syntax: diff(Expr,[Var or ListVar]) Description: Returns, the derivative, of an expression, with respect to, a given variable. d/dx=(3*x+1)=3 Kind Regards. informach. |
|||
05-08-2016, 03:03 PM
Post: #5
|
|||
|
|||
RE: using diff() in a program
Code:
|
|||
05-08-2016, 08:47 PM
Post: #6
|
|||
|
|||
RE: using diff() in a program
Thank you,
But I still have an issue, in fact the expression comes from an input. in that case, I saw that I must use a very strange INPUT syntax {{var,[2]}} in someone else post. but when I do that : Code:
my a var is supposed to be a string, like F9 in DrD code ? I don't get the logic here... Also INPUT builtin help is incomplete and wrong. syntax : INPUT(var,...) *1st form syntax and var -> { var_name, [allowed_type_matrix] ... } *2nd form of var definition. according this, I should be able to type INPUT({var_name},[types]}) but it gives an error ! I must type INPUT({{var_name, [types]}}) also, help is not complete, where is the list of types ? how can we guess ? |
|||
05-08-2016, 09:46 PM
(This post was last modified: 05-08-2016 10:06 PM by DrD.)
Post: #7
|
|||
|
|||
RE: using diff() in a program
Code:
Use: 3*X+1 as input to a ==> returns 3 |
|||
05-08-2016, 11:56 PM
(This post was last modified: 05-09-2016 12:53 AM by roadrunner.)
Post: #8
|
|||
|
|||
RE: using diff() in a program | |||
05-09-2016, 12:14 AM
(This post was last modified: 05-09-2016 01:05 PM by informach.)
Post: #9
|
|||
|
|||
RE: using diff() in a program
Hi!, hpfx:
You can see, this link of (Eddie Shore), for learn, the use, of INPUT ... http://edspi31415.blogspot.com.ar/2014/0...mmand.html However, it's are some examples and the 6030 version. Kind Regards. informach. |
|||
05-09-2016, 05:16 AM
Post: #10
|
|||
|
|||
RE: using diff() in a program
Hello
>in that case, I saw that I must use a very strange INPUT syntax {{var,[2]}} in someone else post. INPUT is a home command, and in home, you can not use a variable that has not been defined. so, INPUT is (normally) unable to let you enter an equation in 'x' if 'x' does not exits. INPUT takes as first argument a variable and let you request it from the user. but INPUT can also take 2 or more variables, using {var1,.. varn} syntax. Furthermore, you can tell INPUT that the variable requested have to follow a given type or types. This is done by placing the variable in a list and having the allowed types as a matrix in the 2nd element of the list. It is only to make it easier for the system to distinguish between the use of the 3 syntaxes that you are forced, if you want to specify the type for one single variable to still create a list of list... anyhow, here the 2 means string. So it forces the input to be a string. and strings, contrary to expression can contain anything you want, including the text of undefined variables. This is why you use {{var [2]}} Cyrille Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP. |
|||
05-09-2016, 12:52 PM
Post: #11
|
|||
|
|||
RE: using diff() in a program
(05-08-2016 11:56 PM)roadrunner Wrote:version 10077(05-08-2016 01:13 PM)jrozsas Wrote: does not workThat's strange, it works here. What version software are you running? I'm running 8151. Leo |
|||
05-09-2016, 01:05 PM
Post: #12
|
|||
|
|||
RE: using diff() in a program
Jrozsas,
Cyrille's document explains everything, located here: http://www.hpmuseum.org/forum/thread-6218.html Below is a modified program that works with 10077: Code: EXPORT ABCD() -road |
|||
05-10-2016, 09:56 AM
Post: #13
|
|||
|
|||
RE: using diff() in a program
There are some citations I found very important.
1) Cas function calls from home, using fully qualified names or not, have all the parameters defined as ‘do not evaluate’. ->This seems to be the main subject to change in the latest update. You need to EVAL() the local variable for the call. Otherwise it is just the name that is used. That is where EVAL() and QUOTE() come in. 2) This is solved by allowing you to use strings as parameters for the CAS. These strings will be parsed at the time of the CAS function call. ->As usual I would say 3 -(local variables) These are temporary and local to this specific call of the function. ->Something that personally I was not aware of. My intuition dictated that a local variable would be passed by value, but it seems that a local variable is indeed invisible outside the function. Please correct me if I am talking nonsense. i don't want to baffle people but sometimes the view of a different person can be enlightening. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)