Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Quick programming question
#1
Is 3^-1 processed the same way as 1/3? I heard that multiplication functions are faster, and if typing out 3^-1 is processed as multiplication instead of division, then is it advantageous to use 3^-1, since it takes up more space?
Reply
#2
Give specific language in question and a use case scenario.
Reply
#3
[spoiler=].1((3(10^3))^-1M^2+3^-1M+.05I->Y
(10^-4)(3^-1M^2+3MQ+50I->Z

2(CD-D-C+2)H(AV(Y+Z))^-1->J

(Y-Z)^-1(Y-H(AVKD)^-1->E

(Y-Z)^-1(Y-H(AVK)^-1->F[/spoiler]
The above are the sections in question. I bolded the areas that I'm talking about.

According to Wikipedia, the language is unique to the calculator. It's called "TI-BASIC". I don't know what that means, but I know that each digit takes up 1 RAM.

My question is, would the program work faster, at the same speed, or slower if I write the above instead as the below:

[spoiler=].1(M^2/3000+M/3+.05I->Y
(10^-4)(M^2/3+3MQ+50I->Z

2(CD-D-C+2)H/(AV(Y+Z->J

(Y-H/(AVKD))/(Y-Z->E

(Y-H/(AVK))/(Y-Z->F[/spoiler]
Reply
#4
Google "never fails."

#1 result for "TI-BASIC multiply vs divide speed" goes to a page with all kinda benchmarks for different scenarios with that language. Here's the direct link to what you want though: http://tibasicdev.wikidot.com/timings#toc14
TI-Basic Developer Wrote:Conclusion: If you multiply, don't put the * sign.
TI-Basic Developer Wrote:Conclusion: When dividing two numbers, don't use the ^-1 operation. It goes really slow! But if you're only taking an inverse, use the ^-1 operation instead of dividing from 1.
Reply
#5
Sorry. I didn't really understand that article. Here are the tables:


FormatBarsPixelsTotal
A/B206166
AB^-1282226



FormatBarsPixelsTotal
1/B, when B=1150120
B^-1, when B=1141113
1/B, when B=pi202162
B^-1, when B=pi192154


How come in the first table, ^-1 worked really slowly, but in the second, it worked faster? I thought in a complex equation, the program groups each portion as a separate entity. How else would it account for operations grouped together with parentheses, like in the following example:

A(X+Y)^-1

Also, it's probably not the case, but what if A=1 in the first table?
Reply
#6
I think your questions are better asked and answered on a TI developer forum, but I'll try my best...

2147483647 Wrote:Sorry. I didn't really understand that article. Here are the tables:


FormatBarsPixelsTotal
A/B206166
AB^-1282226



FormatBarsPixelsTotal
1/B, when B=1150120
B^-1, when B=1141113
1/B, when B=pi202162
B^-1, when B=pi192154


How come in the first table, ^-1 worked really slowly, but in the second, it worked faster?
Truthfully, I don't know. It all depends on TI's compiler and the CPU architecture. But the best I can think of is:
  • In Table 1, case 2: the compiler/CPU is thinking of it as two operations going on instead of just one (e.g., take inverse of B -> now multiply A and B's inverse).

2147483647 Wrote:Also, it's probably not the case, but what if A=1 in the first table?
Again, I don't know. This is something you should actually test. It's possible that it will run slower because it needs to access the variable in memory -- there is going to be some kind of overhead for using a variable instead of a constant. I think it would take a lot of loops to cause a significant real world impact on performance though.

2147483647 Wrote:I thought in a complex equation, the program groups each portion as a separate entity. How else would it account for operations grouped together with parentheses, like in the following example:

A(X+Y)^-1
Yes, it should apply order of operations correctly. 1) X+Y, 2) take the inverse of the result of 1, and 3) A multiplied by the result of 2.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)