# HP Forums

Full Version: Few questions and again if statement
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi, it has passed a few months since my last post.

I'm wondering is there a Chi table, Z table and T tables in the calculator from witch I can pull values ?
If there isn't is there a way to insert them and pull values.

2. Question I'm having a bit trouble again with the if statement.

The code is.
Code:
``` EXPORT A1,A2,A3; EXPORT TST() BEGIN A3:=(A2)^(-1)*A1*(A2)^(-1); local a1,a2,b1,b2,r1,r2; a1:=SQRT((A1(1,1))); a2:=SQRT((A1(2,2))); b1:=SQRT((A1(3,3))); b2:=SQRT((A1(4,4))); r1:=SQRT((A1(1,1)-A1(2,2))^2+4*(A1(1,2))^2); r2:=SQRT((A1(3,3)-A1(4,4))^2+4*(A1(3,4))^2); local l1,l2,l3,l4; l1:=0.5*(A1(1,1)+A1(2,2)+r1); l2:=0.5*(A1(1,1)+A1(2,2)-r1); l3:=0.5*(A1(3,3)+A1(4,4)+r2); l4:=0.5*(A1(3,3)+A1(4,4)-r2); local q1,q2,p1,p2,q3,q4; q1:=atan((l1-A1(1,1))/A1(1,2)); q2:=atan((l3-A1(3,3))/A1(3,4)); p1:=A1(1,2)/(SQRT(A1(1,1)*A1(2,2))); p2:=A1(3,4)/(SQRT(A1(3,3)*A1(4,4))); local t1,t2,t3,t4; local t1:=SQRT(l1); local t2:=SQRT(l2); local t3:=SQRT(l3); local t4:=SQRT(l4); local q3,q4; IF(q1<0) THEN q3:=p1+180; END; PRINT ("Rezultati su ispod"); PRINT("SxA ="+a1); PRINT("SyA ="+a2); PRINT("A λ1="+l1); PRINT("A λ2="+l2); PRINT("a (A)="+t1); PRINT("b (A)="+t2); PRINT("R (A)="+r1); PRINT({"A θ="+→HMS(q3)}); PRINT("----------B----------"); PRINT("SxA ="+b1); PRINT("SyA ="+b2); PRINT("A λ1="+l3); PRINT("A λ2="+l4); PRINT("a (B)="+t3); PRINT("b (B)="+t4); PRINT("R (B)="+r2); PRINT({"B θ="+→HMS(q4)}); END;```

The issue is my q1 and q2 variables can be negative and that is a no go. If it's negative i have to add +180.
When I write

Code:
``` IF(q1<0) THEN q3:=p1+180; END;```

It correctly fixes the value of p1 if its negative. But I want to do that also if the q2 ends up being negative so I write:

Code:
```IF(q1<0) THEN q3:=p1+180; END; IF(q2<0) THEN  q4:=p2+180; END;```
In this case the result for q1(q3) is correct, but q2(q4) ends up being 0. And that is not correct.

What I want it to do is to:
Test if q1 is negative, it it is fix it by adding +180
Test if q2 is negative, if it is fix it by adding +180
If the q1 or q2 are positive don't touch their values, just print them. ( q1 and q2 are independent of each other)

Also I have forgot how or why. When I input the values into M1, M2 matrix ( default matrices that are in calculator).
Then I pull values like ( M1(1,1), M1(2,4) ) from matrices(M1,M2) to local variables a1,a2,b1,b2...
But it doesn't let me. ->I have to first store M1->A1, M2->A2
It doesn't let me for some reason. If i write in program M instead A ( matrix) to run the program i get an error.

My goal is to Input values to default matrix of calculator (M0-M9)
- Pull values from Matrix ( M0-M9) to local variable
Compute
A3:=(A2)^(-1)*A1*(A2)^(-1);
In prefered case
M3:=(M2)^(-1)*M1*(M2)^(-1);
So the product of operation from matrices M1, M2 is stored into default Matrix M3 for easy viewing.
1. There are no tables in the prime, but check out the functions:

CHISQUARE(d,x),
NORMALD([μ, σ,] x), and
STUDENT(d,x)

2. As far as your program i think you want an if then else statement:

IF(q1<0)
THEN
q3:=p1+180;
ELSE
q3:=p1;
END;

IF(q2<0)
THEN
q4:=p2+180;
ELSE
q4:=p2;
END;

3. What you want to do with the built in matrix variables should work. Here is an example program that puts two random matrixes in M1 and M2, then calculates M3 with your formula and prints M3(3,3)

Code:
```EXPORT mattest() BEGIN  M1:=randMat(3,3);  M2:=randMat(3,3);  M3:=(M2)^(-1)*M1*(M2)^(-1);  PRINT(M3(3,3));  M3; END;```

Ah now I understand, thank you once again!
(12-25-2021 01:36 PM)Amer7 Wrote: [ -> ]I'm wondering is there a Chi table, Z table and T tables in the calculator from witch I can pull values ?
If there isn't is there a way to insert them and pull values.

If you have a recent firmware, check out the new Probability Wizard which allows you to interactively enter values. You can find it in the Toolbox / Math / Probability menu.
(12-28-2021 08:06 PM)Wes Loewer Wrote: [ -> ]
(12-25-2021 01:36 PM)Amer7 Wrote: [ -> ]I'm wondering is there a Chi table, Z table and T tables in the calculator from witch I can pull values ?
If there isn't is there a way to insert them and pull values.

If you have a recent firmware, check out the new Probability Wizard which allows you to interactively enter values. You can find it in the Toolbox / Math / Probability menu.

Yes, I have checked it. Its very useful. Thumbs up from me. Thank you all.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :