HP Forums
Input function - bad argument value - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: HP Prime (/forum-5.html)
+--- Thread: Input function - bad argument value (/thread-20063.html)



Input function - bad argument value - Amer7 - 06-07-2023 05:04 PM

Hi,
Folks I have a problem, my tasks became to complicated for me to calculate it all by hand ( I don't have enough time to complete the task)

How can I input a function like:
a1=d1*cos(alpha)+X
a2=d1*sin(beta)+Y
a3=d2*cos(beta)
a4=d3*sin(beta) ....

I can have Xx amount of these functions

And then tell the program to derivation of functions by variable that in input.
like alpha, beta, d1, d2

[Image: attachment.php?aid=12224]
As you can see these are stored in matrix
The issue is when I write the input program it doesn't let me input the function.
How can I make this on Prime?

1. Issue is how do I make first input screen to let me enter the numbers of how many inputs spaces I need.
2. How do I input the function


RE: Input function - Amer7 - 06-07-2023 08:05 PM

https://youtu.be/qSY6RXvAHuw

I will try this tomorrow maybe with a string?
will give feedback


RE: Input function -Bad argument value - Amer7 - 06-08-2023 08:52 AM

EXPORT CAK()
BEGIN

LOCAL a,i,c,b;
INPUT({{a,[-1]}},"String");
return a;

END;

Value -1, -2 allow me to input my function d*cos(alpha)

Now I need to ask the user how many input he wants, and then proceed to new input screen with
input fields that user declared.

I have tried to set this with simple IF loop.


This part somehow doesnt work
Code:
BEGIN
LOCAL a,i,c,b;
INPUT({a},"test", {"a"});  /// Input from user number
PRINT();
if(a!=0)
THEN
INPUT({{b,c,[2]}},"b","c");     /// new inpt
PRINT(b);
PRINT(c);
ELSE
PRINT("input cant be 0");       /// Eror if user inputs 0
END;

END;

The problem is if I enter 1, or any number it just throws me to the Error line, it doesnt offer me a new input screen.

EDIT; When i write it like this, I get input screen one, enter value, input screen two
Code:
EXPORT CAK()
BEGIN

LOCAL a,i,c,b;
INPUT({{a,[-1]}},"Varijabla");

INPUT({{b,[-1]}},"Varijabla");
i:=diff(a,b);

return(i);
END;

I get as a result bad argument value

Inputs are D1*cos(Alpha), D1

When I'm in calculator (HOME) and I input diff(D1*cos(alpha),D1) i get correct value of cos(Alpha)


RE: Input function - bad argument value - Amer7 - 06-10-2023 08:02 PM

Is there any way to write the function in a matrix like
d1*cos(alpha),d2*cos(alpha)... without it returning an Error?

Ok, when I MAKEMAT(0,3,1) and then i view it, end I edit the 0 to be my function. I can save it to some variable like Ss0. It will appear in matrix menu. I vectorize it.
But when i do the diff(Ss0(1)/Ss1(1)) it again throws an error bad argument value

"(expression,variable=value) Error Bad Argument Value"

[attachment=12230]
[attachment=12231]

I need to make this but with functions in x and y
[Image: 43b8c31f61f8b2bbe6f0df4d62012d8ba86ba420]

vector by vector derivative matrix

Guys I found some code for jacobian matrix, it compiles no Errors, but I doesn't want to run

Code:
#cas
jacob2(args):=
// Jacobian Matrix by Salvo Micciché
// input vectorial expression, vector of variables
BEGIN
local argv, argc, mat, f, var, fn, fg, j, k, gr, vd;
argv:=args;
argc:=size(argv);
IF argc !=2 THEN
return "Input:[f1(x),f1(y),f1(z)...], [x,y,z,...]";
ELSE
f:=argv(1);
var:=argv(2);
fn:=size(f);
vd:=size(var);
IF fn:=1 THEN
fg:=grad(f(1),var);
f:=fg;
fn:=size(f);
END;
mat:=makemat(0,fn,vd);
FOR j FROM 1 TO fn DO // gradients
gr:=grad(f(j),var);
FOR k FROM 1 TO vd DO // items
mat[j,k]:=factor(gr(k));
END; // for k
END; // for j
return mat;
END; // if-else
END;
#end

https://www.hpmuseum.org/forum/thread-3852.html

Ahhh, just type jacob() in home

EDIT: I think this solves my issue.