How would I make a program that would find the inverse of a function? What I mean is, I know how to make it, but I don't know how to make the calculator solve the specific problem.
To get the inverse function, you can use string manipulation to replace all instances of X with Y and Y with X. However, solving it is more difficult, since you'd have to somehow manipulate the function to be in the form of Y=stuff. I doubt that's possible for all functions, and it'll be very difficult to do for even some functions, without writing a whole symbolic manipulating library.
You could graph it by evaluating Y at each value of X within a range, and if the function was linear, quadratic, etc. you could approximate it based on the points generated, but that's about all you could do.
Hope this helps. If you'd like some pseudo-code to help explain what I mean, let me know.
You could graph it by evaluating Y at each value of X within a range, and if the function was linear, quadratic, etc. you could approximate it based on the points generated, but that's about all you could do.
Hope this helps. If you'd like some pseudo-code to help explain what I mean, let me know.
magicdanw wrote:
To get the inverse function, you can use string manipulation to replace all instances of X with Y and Y with X. However, solving it is more difficult, since you'd have to somehow manipulate the function to be in the form of Y=stuff. I doubt that's possible for all functions, and it'll be very difficult to do for even some functions, without writing a whole symbolic manipulating library.
You could graph it by evaluating Y at each value of X within a range, and if the function was linear, quadratic, etc. you could approximate it based on the points generated, but that's about all you could do.
Hope this helps. If you'd like some pseudo-code to help explain what I mean, let me know.
You could graph it by evaluating Y at each value of X within a range, and if the function was linear, quadratic, etc. you could approximate it based on the points generated, but that's about all you could do.
Hope this helps. If you'd like some pseudo-code to help explain what I mean, let me know.
The code would be nice. I sort of understand what you're saying though.
Ti-Basic~Learned Most Concepts in 1 Week!
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
Okay, let's see if I can figure this out. Haven't programmed TI-BASIC in a while...
Code:
Do you see how this works? It goes through Str1 character by character, and copies it to Str2, unless it's an X or a Y, in which case it switches it to invert the formula. At the end, the inverted formula is stored in Str2.
Code:
Input Str1
"->Str2
For(X,1,len(Str1
If sub(Str1,X,1)="X
Then
Str2+"Y->Str2
Else
If sub(Str1,X,1)="Y
Then
Str2+"X->Str2
Else
Str2+sub(Str1,X,1->Str2
End
End
End
magicdanw wrote:
Okay, let's see if I can figure this out. Haven't programmed TI-BASIC in a while...
Code:
Do you see how this works? It goes through Str1 character by character, and copies it to Str2, unless it's an X or a Y, in which case it switches it to invert the formula. At the end, the inverted formula is stored in Str2.
Code:
Input Str1
"->Str2
For(X,1,len(Str1
If sub(Str1,X,1)="X
Then
Str2+"Y->Str2
Else
If sub(Str1,X,1)="Y
Then
Str2+"X->Str2
Else
Str2+sub(Str1,X,1->Str2
End
End
End
I think you have some mistakes in there.
Ti-Basic~Learned Most Concepts in 1 Week!
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
Swoll_Monkey wrote:
I think you have some mistakes in there.
Quite possibly! As I said, I haven't programmed TI-BASIC in a while, and the code I posted is untested. If you spot mistakes, please post them, or try to correct them, so we can help out the OP.
if you just want the graph of the function, you should be able to do that by hand with string manipulation, expr(), line() and a for loop. if you actually want to find the inverse of a function in y=f-1(x) form that's a good deal trickier
magicdanw wrote:
Okay, let's see if I can figure this out. Haven't programmed TI-BASIC in a while...
Code:
Do you see how this works? It goes through Str1 character by character, and copies it to Str2, unless it's an X or a Y, in which case it switches it to invert the formula. At the end, the inverted formula is stored in Str2.
Code:
Input Str1
"->Str2
For(X,1,len(Str1
If sub(Str1,X,1)="X
Then
Str2+"Y->Str2
Else
If sub(Str1,X,1)="Y
Then
Str2+"X->Str2
Else
Str2+sub(Str1,X,1->Str2
End
End
End
heres a partially optimized version...
Code:
Equ>Str(Y1, Str1
"X=->Str2
For(X,1,length(Str1
sub(Str1,X,1
Str2 + sub(Ans+"Y",1+(Ans="X),1) --> Str2
End
this will take whatever equation you have in Y1 (equation 1) and store the inverse to Str2
uhm making it find the true inverse could basically be done is a two ways
a.) create a plot and try various "lines of best fit" until r = 0, with a system to handle square-roots, exponents, logs, and the inverse key
b.) undo the operators of the equation (as a human would do). This would be far more complicated but it would yield a more accurate answer. Basically you would be writing a program that can solve ANY solvable, single variable algebric problem
if you really want a program to do this I would be happy to do it for you; however it would of course be in your interest to write it yourself and improve your programming skills
Code:
Equ>Str(Y1, Str1 ****Somethings Wrong With This Part****
"X=->Str2
For(X,1,length(Str1
sub(Str1,X,1
Str2 + sub(Ans+"Y",1+(Ans="X),1) --> Str2
End
Ti-Basic~Learned Most Concepts in 1 Week!
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
Yes but it appears he want it to solve for Y which would be next to impossible.
@ swoll Whats wrong with that part it does everything it should.
@ swoll Whats wrong with that part it does everything it should.
- rthprog
- Expert (Posts: 726)
- 01 Nov 2008 08:40:25 pm
- Last edited by rthprog on 01 Nov 2008 08:50:19 pm; edited 1 time in total
noahbaby94 wrote:
Yes but it appears he want it to solve for Y which would be next to impossible.
@ swoll Whats wrong with that part it does everything it should.
@ swoll Whats wrong with that part it does everything it should.
I believe I addressed that in parts A and B
btw SwollMonkey, "Equ>Str" is a command that you can find in the catalog (2nd + 0 I believe). Oh, and "Y1" is found by hitting Var, Y-Vars, "Y1".
Anyways just replace that line with a
Code:
Input "Y=",Str1
again, I stress, i would be happy to write one for you if you want... it would give me a break from other projects...
rthprog wrote:
noahbaby94 wrote:
Yes but it appears he want it to solve for Y which would be next to impossible.
@ swoll Whats wrong with that part it does everything it should.
@ swoll Whats wrong with that part it does everything it should.
I believe I addressed that in parts A and B
btw SwollMonkey, "Equ>Str" is a command that you can find in the catalog (2<sup>nd</sup> + 0 I believe)
Anyways just replace that line with a
Code:
Input "Y=",Str1
again, I stress, i would be happy to write one for you if you want... it would give me a break from other projects...
I found the equ>solve thingy, it's just that The Y1 didn't work.
Ti-Basic~Learned Most Concepts in 1 Week!
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
- rthprog
- Expert (Posts: 726)
- 01 Nov 2008 08:51:00 pm
- Last edited by rthprog on 01 Nov 2008 08:52:32 pm; edited 1 time in total
Oh, and "Y1" is found by hitting Var, Y-Vars, "Y1".
I added that JUST as you posted...
Anyways; do you want a program that
a.) graphs the inverse?
b.) gives the inverse in y= form?
c.) all of the above in some super-inverse-program?
I added that JUST as you posted...
Anyways; do you want a program that
a.) graphs the inverse?
b.) gives the inverse in y= form?
c.) all of the above in some super-inverse-program?
rthprog wrote:
Oh, and "Y1" is found by hitting Var, Y-Vars, "Y1".
I added that JUST as you posted...
I added that JUST as you posted...
Lol, I wrote it in. SOrry.
Ti-Basic~Learned Most Concepts in 1 Week!
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
It's saying somethings wrong with the: sub(Str1,X,1 part. It's an invalid dimensions error.
Ti-Basic~Learned Most Concepts in 1 Week!
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
nah, it was my fault ...
anyways ooh I'm getting excited... I could like add transformation,translation, and simplification tools to this... (!!!)
fdamn. I feel like such a nerd now...
anyways ooh I'm getting excited... I could like add transformation,translation, and simplification tools to this... (!!!)
fdamn. I feel like such a nerd now...
rthprog wrote:
nah, it was my fault ...
anyways ooh I'm getting excited... I could like add transformation,translation, and simplification tools to this... (!!!)
fdamn. I feel like such a nerd now...
anyways ooh I'm getting excited... I could like add transformation,translation, and simplification tools to this... (!!!)
fdamn. I feel like such a nerd now...
Huh? How come it gives a invalid dimension error?
Ti-Basic~Learned Most Concepts in 1 Week!
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
Swoll_Monkey wrote:
It's saying somethings wrong with the: sub(Str1,X,1 part. It's an invalid dimensions error.
it sounds like Str1 isnt being stored properly; what's your first line?
anyways, hmm....did you
a.) enter "Str1" via the VAR menu? I'm assuming you did if the start works....
b.) use the right "sub(" command? it too is from the catalog
c.) you DID use capital X in the for loop AND the sub command, right?
rthprog wrote:
Swoll_Monkey wrote:
It's saying somethings wrong with the: sub(Str1,X,1 part. It's an invalid dimensions error.
it sounds like Str1 isnt being stored properly; what's your first line?
anyways, hmm....did you
a.) enter "Str1" via the VAR menu? I'm assuming you did if the start works....
b.) use the right "sub(" command? it too is from the catalog
c.) you DID use capital X in the for loop AND the sub command, right?
My first line is ClrHome.
Yes, I entereed "str1" via the Var menu.
Yeah, I got sub( from the catalog
and I typed in a capital X for it.
Ti-Basic~Learned Most Concepts in 1 Week!
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
When I press Goto from the error menu, it goes to this line:
Code:
Code:
sub(str1,X,1
Ti-Basic~Learned Most Concepts in 1 Week!
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
http://www.youtube.com/watch?v=ONnIjTQ_YK0 <-- Must Watch
I Have Saved A Life! =D
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
» Go to Registration page
» Goto page 1, 2 Next
» View previous topic :: View next topic
» View previous topic :: View next topic
Page 1 of 2
» 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
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