![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Quick programming question - Printable Version +- Southperry.net (https://www.southperry.net) +-- Forum: Maplers Helping Maplers (https://www.southperry.net/forumdisplay.php?fid=9) +--- Forum: Technical Help (https://www.southperry.net/forumdisplay.php?fid=84) +--- Thread: Quick programming question (/showthread.php?tid=29049) |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Quick programming question - 2147483647 - 2010-08-15 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? Quick programming question - Eos - 2010-08-15 Give specific language in question and a use case scenario. Quick programming question - 2147483647 - 2010-08-15 [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] Quick programming question - singularity - 2010-08-16 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. Quick programming question - 2147483647 - 2010-08-16 Sorry. I didn't really understand that article. Here are the tables:
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? Quick programming question - singularity - 2010-08-16 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:Truthfully, I don't know. It all depends on TI's compiler and the CPU architecture. But the best I can think of is:
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: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. |