ShinyGardevoir wrote:
Is there a way to find the gamma function of a complex number on a TI-84 Plus CE?

Yes, the routine for the beta function I used in this post works for complex numbers as well.



If you just want to calculate the gamma function, then you can simplify it to this:

Code:
A→Z
If 0>real(A
1-Z→Z
e^((Z-.5)ln(Z+8.5)-Z-8.5+ln(√(2π)(1+sum({5716.4001882743,-14815.304267684,14291.492776575,-6348.1602176415,1301.6082860583,-108.17670535144,2.6056965056118,-0.0074234525,5.38413610^-8,-4.0235310^-9}/(Z-1+cumSum(binomcdf(9,0
If 0>real(A
2πi/Ans/(2isin(πA

Where the input is in A and Γ(A) is stored to Ans.
Michael2_3B wrote:
Find and Replace Text in String
Replaces all occurrences of a specific search text in a string with desired replacement text.
This has no doubt been attempted before, but here is my take on it.

Inputs:
Str1- main string
Str2- search string
Str3- replacement string


Outputs:
Str1- the string that gets modified


Code:
length(Str2->J
While inString(Str1,Str2
   inString(Str1,Str2->I
   Str3
   If I>1
   sub(Str1,1,I-1)+Ans
   If I+J<1+length(Str1
   Ans+sub(Str1,I+J,1+length(Str1)-(I+J
   Ans->Str1
End

This one doesn't destroy any other variables and may be faster.
You can replace "X" with any character you know won't be in Str2.

Code:
"X"+Str1+"X"
While inString(Ans,Str2
sub(Ans,1,inString(Ans,Str2)-1)+Str3+sub(Ans,inString(Ans,Str2)+length(Str2),length(Ans)-inString(Ans,Str2)-length(Str2)+1
End
sub(Ans,2,length(Str1)-1)->Str1
Sentence to list of words
Converts a sentence in string format into a list of words without spaces.
Only works on 68k/Nspire calcs


Code:
wlist(str)
Func
Local j
{""}→j
While instring(str," ")>0
augment(j,{left(str,instring(str," ")-1)})→j
right(str,dim(str)-instring(str," "))→str
EndWhile
augment(seq(j[n],n,2,dim(j)),{str})→j
Return j
EndFunc

Code:
abs(DeltaList(Anscos(picumSum(not(0Ans

Sums up every pair of elements in Ans, a list. By "Logical Joe" on the Cemetech Discord, golfing the version I wrote last year for a Calc I Riemann-sum solver:

Code:
abs(DeltaList(Ansi^(2cumSum(binomcdf(dim(Ans)-1,0


Golfed-ish but non-radians-dependent version, for what it's worth:

Code:
abs(DeltaList(Ansi^(2cumSum(not(0Ans
String to StRiNg
Highly useful routine used to mock a string.
Will convert "Python is the best language" into "PyThOn iS ThE BeSt lAnGuAgE"


TI-84 BASIC fragment:

Code:
"*
For(i,1,length(Str1),2
Ans+sub(" ABCDEFGHIJKLMNOPQRSTUVWXYZ",remainder(inString(" abdcefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ",sub(Str1,i,1)),27),1
If i!=length(Str1)
Ans+sub(Str1,i+1,1
End
sub(Ans,2,length(Ans)-1


68k BASIC function:

Code:
mock(n)
Func
Local out,i
""->out
For i,1,dim(n),2
out&mid(" ABCDEFGHIJKLMNOPQRSTUVWXYZ",remainder(inString(" abdcefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ",mid(Str1,i,1)),27),1)->out
If i!=dim(n)
out&mid(n,i+1,1)->out
EndFor
out
EndFunc
Split String by Delimiter Character

Displays an input string in Str1, using a delimiter ({) as a newline character

Code:
1→B
inString(Str1,"{→A
While A
If A>1
Disp sub(Str1,B,A-B
A+1→B
inString(Str1,"{",B→A
End
If B<length(Str1
Disp sub(Str1,B,length(Str1)-B+1


Split String by Delimiter Character 2

Displays an input string in Str1, using a delimiter ({) as a newline character if it is known that the input string will not begin or end with a delimiter character

Code:
1→B
inString(Str1,"{→A
While A
Disp sub(Str1,B,A-B
A+1→B
inString(Str1,"{",B→A
End
Disp sub(Str1,B,length(Str1)-B+1

Both of these will work if the input string contains no delimiters.
ATAN2()
Just as in most programming languages like C++ all TI calculators have an atan2() function. It's just hidden away.
For the equation: atan2(x,y) use

Code:
R►Pθ(y,x)

Example: tan α = (cos ε sin L)/ cos L
Where ε = 23.43949 and L = 229.24429 degrees.
Solve: R►Pθ(cos L,cos ε sin L) = R►Pθ(cos(229.24429),cos(23.43949)sin(229.24429))
Result: -133.2085302 = 226.7914698 degrees

If you had used tan⁻() instead the result would have been 46.7914698 which is wrong by 180 degrees.
Move a character at the homescreen in random directions.

Input:
Press any key to exit the loop
(or build in a other condition or use a for( loop)
Output:
Character at the homescreen which moves in random directions.
Possible directions:
stay, left, right, up, down, diagonal (left-up, right-up, left-down, right-down).
If the character reaches the edge of the screen, the possible directions will be reduced,
so that the position wont get outside of the screen.

This is the fastest way, using the finance vars I% and N:

Code:
ClrHome
5→N
MAGENTA→I%
Repeat getKey
Output(N,I%,"
N+zufInt(-(Ś≥2),N≤9→N
I%+zufInt(-(I%≥2),I%≤25→I%
Output(N,I%,"X
End


And this way is a bit slower, but takes less memory (14 bytes less):

Code:
ClrHome
5→R
MAGENTA→C
Repeat getKey
Output(R,Ans,"
R+zufInt(-(R≥2),R≤9→R
C+zufInt(-(C≥2),C≤25→C
Output(R,Ans,"X
End


This routines can be used of course not only at the homescreen,
change the right parameters to adapt it for other borders.
DAVID-19 wrote:

Code:

ClrHome
5→R
13→C
Repeat getKey
Output(R,C," "
R+randInt((R>1),R<10→R
C+randInt((C>1),C<26→C
Output(R,C,"X
End

This won't work. All you are doing is adding 1 to R and C until the character is off screen...
Try this instead:

Code:
ClrHome
{5,13
Repeat getKey
Output(Ans(1),Ans(2),"
Ans+randInt(~1,1,2
Ans+2not(Ans)-2(Ans={11,27
Output(Ans(1),Ans(2),"X
End
Oh, I`m so sorry, I forgot to put the -'s before (R>1) and (C>1).
I edited my code above, so that it will work now correctly.

I also replaced the >'s and <'s with ≥'s and ≤'s,
this is (like I know) a very bit faster and takes 1 byte less, because R<10 is now R≤9 (one digit less)

And I tried out your version.
Yours takes only 3 bytes more and takes < 0.01 sec more time per loop than my version,
but I measured this only with a simple loop time calculation program in TI Basic.
If it`s important for you to know exactly which version is the fastest then you have maybe a better way to measure the speed.

Nevertheless, both versions are fast enought.
For drawing a random moving character at the homescreen it`s actually too fast,
because the character will be in a light greyscale and hard to see,
but the routines can be changed to use them for other things
You're right, I assumed lists would be faster because of parser overhead and the horrible speed of randInt but it seems that's not the case.
At the end,

Code:
Output(R,C,"X

Should be

Code:
Output(R,Ans,"X

Since Ans is faster than a real var.
In fact, if you really want to save some speed, replace the R variable with a system variable like the finance vars or recursive N. Those save about 0.5ms per call at the cost of 1 byte each (because its a 2-byte token).
You could also replace "13→C" with "MAGENTA→C" if you're on a color calc, which will save 0.07ms.
Parsing Ans(1) / Ans(2) is like parsing two list values which takes more time than parsing just R / C.

But replacing the C's in the Output( commands with a simple Ans saves ~0.3 ms.

In my post above are now two versions of the routine.

Using finance vars is the fastest way, but takes some bytes more like you already said.
(of course MAGENTA→N instead of 13→N)
(and I didn`t replace I%'s in the Output( commands with Ans, cause in this case takes Ans more time)
A version might have been posted somewhere before, but because dayOfWk( doesn't handle leap days (as in, dayOfWk(2020,2,29 returns Domain) here is a version that does.
This takes advantage of the fact that dayOfWk(Y,M,0 is valid.
dayOfWk( With Leap-day Support in 15 bytes

Code:
int(8fPart(pi+pidayOfWk(Y,M,D-1
That's awesome, I wonder if they know about that bug? Seems like something obvious, I'm surprised they missed that before releasing the OS.

Also:
iPhoenix wrote:
what the heck how does that work
8fpart(pi+pi(stuff)????
Remove All Duplicate Characters/Tokens From A String

Takes Str1 as an input and modifies it to not have any duplicate characters.

Code:
DelVar I"inString(Str1,sub(Str1,I,1),I+1->|u
"length(Str1->|v
Repeat I=|v
I+1->I
While |u
sub(Str1,1,|u-1
If |u<|v
Ans+sub(Str1,|u+1,|v-|u
Ans->Str1
End
End


Examples:

Code:
"Cemetech" becomes "Cemtch"
"MR WOMP WOMP" becomes "MR WOP"
"AABbCC" becomes "ABbC"
Michael2_3B wrote:
Remove All Duplicate Characters/Tokens From A String

Takes Str1 as an input and modifies it to not have any duplicate characters.

Code:
DelVar I"inString(Str1,sub(Str1,I,1),I+1->|u
"length(Str1->|v
Repeat I=|v
I+1->I
While |u
sub(Str1,1,|u-1
If |u<|v
Ans+sub(Str1,|u+1,|v-|u
Ans->Str1
End
End


Examples:

Code:
"Cemetech" becomes "Cemtch"
"MR WOMP WOMP" becomes "MR WOP"

You are losing a couple bytes by using |v... Its also a little bit slower to use |v so I would just do this instead.


Code:
DelVar I"inString(Str1,sub(Str1,I,1),I+1->|u
Repeat I=length(Str1
I+1->I
While |u
sub(Str1,1,|u-1
If |u<length(Str1
Ans+sub(Str1,|u+1,length(Str1)-|u
Ans->Str1
End
End
mr womp womp wrote:
Michael2_3B wrote:
Remove All Duplicate Characters/Tokens From A String

Takes Str1 as an input and modifies it to not have any duplicate characters.

Examples:
Code:
"Cemetech" becomes "Cemtch"
"MR WOMP WOMP" becomes "MR WOP"
"AABbCC" becomes "ABbC"

You are losing a couple bytes by using |v... Its also a little bit slower to use |v so I would just do this instead.

Am I missing something?

Code:
sub(Str1,1,1
For(A,2,length(Str1
If not(inString(Ans,sub(Str1,A,1
Ans+sub(Str1,A,1
End
Ans->Str1
LogicalJoe wrote:
Am I missing something?

Code:
sub(Str1,1,1
For(A,2,length(Str1
If not(inString(Ans,sub(Str1,A,1
Ans+sub(Str1,A,1
End
Ans->Str1

That's awesome, way simpler and smaller than mine lol. I don't know why I didn't think of that but nice work
Maybe there is a really easy and dumb way to do this that I'm not realizing but I just thought of a short & sweet way to check if your code is running on a CSE or a CE (without trying to time stuff like a degenerate).
It relies on the fact that TI pushed the clock forward on the CE but foolishly did not adjust the bound for how low you can set the date (Jan 1st 1997)

Detect model of color calc (CSE or CE)
Inputs:
none
Output:
Model in Ans (1 = CSE, 0 = CE)


Code:
setDate(1997,1,1
|E6>startTmr


Obviously you lose the current date so you could reset it if you really don't want to lose it.

Code:
getDate->L1
setDate(1997,1,1
|E6>startTmr
L1:setDate(Ans(1),Ans(2),Ans(3
Laplace Transform (68k)
Performs a Laplace integral transform ℒ{f}(s) of a function f(t)

I have included this not because it is terribly useful for your average TI-89 user, but that the methods I had to take to make the CAS operate properly for this function to work ended up being very funny.


Code:
lap(f)
Func
Local y
part(part(∫(when(s!=0,f*e^(-s*t),0),t,0,inf),2),2)*-1->y
Return y*1
EndFunc
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page Previous  1, 2, 3 ... , 13, 14, 15  Next
» View previous topic :: View next topic  
Page 14 of 15
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement