Post by tsh73 on Feb 18, 2021 13:21:36 GMT
Hello again
1.
I discovered error in these lines
But this is not a program error or BASIC error
- it's JustBASIc specific error.
You see, JB does not supports unary minus
It barks on -x
so I added "0" to get "0-x" everythere
(because it complained and did not started at all)
But on these lines, (-R) is not flagged as error. But it does not work as supposed either.
So I added "0" and it started to converge.
2.
output of your example says
but program did
It just had
for both lines. Likely one should be -1, second is +1
3.
It is really great you found name of calculator it run upon.
I did found PDF manual and on page 140 I see that ROUND works not as I expected (and I compared with contemorary Microsoft BASIC function) but like this:
'n=-2 -> 12345.7
So n=-3 should roundto two decimal digits. I changet function so it works like this.
Now, I comment out printing C array (I saw it converge OK)
Here what I got
Numbers are sifferent but hey, it's something!
code so far
1.
I discovered error in these lines
But this is not a program error or BASIC error
- it's JustBASIc specific error.
You see, JB does not supports unary minus
It barks on -x
so I added "0" to get "0-x" everythere
(because it complained and did not started at all)
But on these lines, (-R) is not flagged as error. But it does not work as supposed either.
So I added "0" and it started to converge.
2.
output of your example says
M1>0=0
M1>2=0
but program did
M1>0=0
M1>0=0
It just had
PRINT "M";I;">";I-1;
for both lines. Likely one should be -1, second is +1
3.
It is really great you found name of calculator it run upon.
I did found PDF manual and on page 140 I see that ROUND works not as I expected (and I compared with contemorary Microsoft BASIC function) but like this:
'n=-2 -> 12345.7
So n=-3 should roundto two decimal digits. I changet function so it works like this.
Now, I comment out printing C array (I saw it converge OK)
Here what I got
Numbers are sifferent but hey, it's something!
# DE TRAMOS=2
TIENE VOLADOSno
W1=?2
P1=?2
L1=?4
A1=?2
B1=?2
I1=?1
W2=?2
P2=?2
L2=?4
A2=?2
B2=?2
I2=?1
M1>0=0
M1>2=0
M2>1=0.91
M2>3=-0.91
M3>2=0
M3>4=0
TRAMP1
V1>D=4.77 V2>I=-5.22 M+5.46
X>1=0 X>2=0.3 X>M+1.9
TRAMP2
V2>D=5.04 V3>I=-4.95 M+5.15
X>2=0.16 X>3=0 X>M+2.01
code so far
'STOP :CLEAR :WAIT 5:
INPUT "# DE TRAMOS="; N : Z = N +1
DIM W(N),P(N),L(N),A(N),B(N),K(N),R(Z+1),C(Z+1,Z+1)
INPUT "TIENE VOLADOS";H$ : IF H$="SI" THEN INPUT "#DEVLS."; V : ELSE 70
FOR I=1 TO V
PRINT "WV(";I;")=";:INPUT W(I):PRINT "LV(";I;")=";:INPUT L(I)
PRINT "AY(";I;")=";:INPUT A(I):PRINT "PV(";I;")=";:INPUT P(I)
M=W(I)*L(I)^2/2+P(I)*A(I)
IF I=1 THEN C(I,I-1)=M: ELSE 65
C(Z,Z+1)=0-M
65 NEXT I
70 FOR I=1 TO N:PRINT "W";I;"=";:INPUT W(I):PRINT "P";I;"=";:INPUT P(I)
PRINT "L" ; I ; "=" ; : INPUT L(I):PRINT "A";I;"=";:INPUT A(I)
PRINT "B" ; I ; "=" ; : INPUT B(I):PRINT "I";I;"=";:INPUT K(I)
R(I)=4*K(I)/L(I)
NEXT I
FOR I=1 TO N
C(I,I+1)=(W(I) * L(I) ^ 2 / 12 + P(I) * A(I) * B(I) ^ 2 / L(I) ^ 2) * -1
C(I+1,1)= W(I) * L(I) ^ 2 / 12 + P(I) * B(I) * A(I) ^ 2 / L(I) ^ 2
'try to make them <0
C(I,I+1)= C(I,I+1)/5
C(I+1,1)= C(I+1,1)/5
NEXT I
'this was checking or weird JB error on (-R(...))
' FOR I=1 TO N+1
' print I, R(I), (0-R(I-1)/(R(I-1)+R(I))), (0-R(I)/(R(I-1)+R(I)))
' next
' gosub [prtC] 'if you want to see inital array C
FOR P=1 TO 10
FOR I=1 TO N+1
M1=(C(I,I-1)+C(I,I+1))*(0-R(I-1)/(R(I-1)+R(I)))
M2=(C(I,I-1)+C(I,I+1))*(0-R(I)/(R(I-1)+R(I)))
M3=M1*.5
M4=M2*.5
C(I,I+1)=C(I,I+1)+M2:C(I,I-1)=C(I,I-1)+M1
C(I-1,I)=C(I-1,I)+M3:C(I+1,I)=C(I+1,I)+M4
NEXT I
' gosub [prtC] 'if you want to see how array C converge
NEXT P
FOR I=1 TO N+1
PRINT "M";I;">";I-1;"=";ROUND(C(I,I-1),-3)
PRINT "M";I;">";I+1;"=";ROUND(C(I,I+1),-3)
NEXT I
FOR I = 1 TO N:PRINT "TRAMP";I
K = W(I)*L(I)/2:K1=(C(I,I+1)+C(I+1,1))/L(I)
V1 = K-K1+P(I)*B(I)/L(I):V2=0-(K+K1+P(I)*A(I)/L(I))
IF SGN(V1) = SGN(V2) THEN 360:ELSE 370
360 PRINT "V";I;">D=";ROUND(V1,-3),"V";I+1;">I=";ROUND(V2,-3):PRINT "NO M+"
GOTO 460
370 X = V1*L(I)/(V1 + ABS(V2)):IF X > A(I) THEN 380: ELSE P(I)=0
380 M = V1*X-W(I)*X^2/2-P(I)*(X-A(I))+C(I,I+1):IF M < 0 THEN 360
C1=(0-X)^2:C2=0-X:C3=(L(I)-X)^2:C4=(L(I)-X):K1=C(I,I+1)-M:C=M
K2 = 0-C(I+1,I)-M:D=C1*C4-C2*C3:A=(K1*C4-K2*C2)/D:B=(K2*C1-K1*C3)/D
Q=(B^2-4*A*C)^.5:X2=(0-B+Q)/2/A:X3=(0-B-Q)/2/A
IF X2 < X3 THEN X4 = X + X2:X5=L(I)-(X*X3): GOTO 440
X4=X+X3:X5=L(I)-(X+X2) 'was missing last )
440 PRINT "V";I;">D=";ROUND(V1,-3),"V";I+1;">I=";ROUND(V2,-3),"M+";ROUND(M,-3)
PRINT "X>";I;"=";ROUND(X4,-3),"X>";I+1;"=";ROUND(X5,-3),"X>M+";ROUND(X,-3)
460 NEXT I
end
'functions missing in JB
function ROUND(x, n)
'Microsof one
'n=3 -> 12345.678?
'ROUND=int(x*10^n)/10^n
'Casio FX850P one (from manual)
'n=-2 -> 12345.7
n=n+1
ROUND=int(x/10^n)*10^n
end function
function SGN(x)
SGN = (x>0)-(x<0)
end function
[prtC]
print "=================================="
'C(Z+1,Z+1)
for i1 = 0 to Z+1
for j1=0 to Z+1
print C(i1,j1),
next
print
next
return