Hey, everyone! While writing a polynomial differentiation program, I've come across a problem that I can't figure out. Say I have "4AX^3" set to Str1, and A = 3. How can I set the string to "12X^3" with TI-BASIC?

Here is the beginning of my program:

Code:
:Disp "X^4 COEFFICIENT:"
:Input A
:Disp "X^3 COEFFICIENT:"
:Input B
:Disp "X^2 COEFFICIENT:"
:Input C
:Disp "X COEFFICIENT:"
:Input D
:Disp "Y-INTERCEPT:"
:Input E
:
:"AX^4"→Str1
:"BX^3"→Str2
:"CX^2"→Str3
:"DX"→Str4
:"E"→Str5


Next, the program stitches these strings together to create an equation. This is bulky, so I didn't write out the code in this post. Ultimately, some variant of "AX^4+BX^3+CX^2+DX+E" is set to Str6 and then to y1. (If any of the coefficients equal 0, then the term is removed from the string.)

Here is why I used strings. Next, I want the program to calculate the derivative of the equation using the Power Rule. So here is what follows:

Code:
:"4AX^3"→Str1
:"3BX^2"→Str2
:"2CX"→Str3
:"D"→Str4
:"0"→Str5

I run the string stitching part of the program again, and ultimately, some variant of "4AX^3+3BX^2+2CX+D" is set to Str6 and then to y2.

Notice that the variables stay in y1 and y2, and I want the values of these variables in there rather than the letters.

If I try

Code:
"4AX^3"→Str1
then string 1 is literally "4AX^3".

If I try

Code:
4AX^3→Str1
then there is a data type mismatch error.

I've also looked at the commands expr, inString, but they also give me data type mismatches when I try to set them to a string. My final plan was to edit some lists, run a cubic regression, set RegEQ to y1, and use Equ►String to set it to a string. However, [RegEQ] is only available on the Cemetech SourceCoder 3, and when it's evaluated, it gives me something like "0.3rr0207," where r is the radian sign. I have a TI-84 Plus Silver Edition.

Any ideas?
It depends on what you are trying to do.
It would be simpler to say something like "Text(1,1,4AX^3," Is the Equation"
or something like that.
Storing it into a string would not be too useful, just type the equation into an "Output(", "Disp", or "Text(" command
I just edited the original post clarifying my question. I hope my intentions are more clear now.
I suggest doing the math with real variables, then converting to a string using this (no libraries needed):


Code:

{X,0}->L1
{0,X}->L2
LinReg(a+bx) L1,L2,Y1
EQU>String(Y1,STR1)
sub(STR1,1,length(STR1)-4)->STR1
DelVar Y1
DelVar L1
DelVar L2

The variable, which was in X, is in Str1 now.
LinReg(a+bx) can be found in one of the List menus, or in the catalogue.

If you have DCS, you can use some library to do it with only one command, but I don't know it off the top of my head.
This helps immensely! Here's my plan:

Code:
:{1,2,3,4,5,6,7,8,9,10}→L1
:A(L1)^4+B(L1)^3+C(L1)^2+D(L1)+E→L2
:QuartReg L1,L2,Y1

Then I won't have to use strings to create my equation. Thanks, Luxen! All I have to do is to convert crazy decimals within a RegEQ like 0.99999999999999 to integers like 1.
Actually, I'm having a lot of trouble rounding the coefficients... When I do this:

Code:
:1→A
:2→B
:0→C
:-1→D
:9.49→E
{1,2,3,4,5,6,7,8,9,10}

:QuartReg L1,L2,Y1

Y1 ends up being something like

Code:
X^4+2.000000000000045X^3+3.4E-12X^2-.99999999999958X+9.4900000000000632
RegEQ is not affected by Fix 0 or round(, and it's impossible to set the statistical a, b, c, d, and e. I was trying to do some fancy work with strings, but I only found a way to round integers. I guess having really long coefficients will have to suffice, unless someone knows how to fix this.
  
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
Page 1 of 1
» 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