This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. 68k Calculator Basic => TI-BASIC
Author Message
nactownag


Newbie


Joined: 31 Mar 2009
Posts: 12

Posted: 31 Mar 2009 11:22:11 pm    Post subject:

Howdy,

This is my first post on this board, but I am by no means a n00b when it comes to the interwebz. I'm glad I found this forum! Seems like people actually hang out here and there's lots of good information.

Now on to my question:

First, I'll kind of explain in words what I'm trying to accomplish.

What I'd like to be able to do is run the program and have a dialog box or something of the sort come up and ask me to specify what variable I'm wanting to solve for.

For example, take the equation below:




Let's say I want to solve for M, so next the program should create a new dialog box and ask me to specify the values for the other variables. So in this particular case, it would ask me (preferably all in one dialog) to tell it the value of F, N, INT, T, and k. And obviously, if I choose to solve for a different variable at the beginning, the function should accommodate for that. So if instead of selecting M, if I tell it to solve for INT, then it should ask me to specify values for F, N, M, T, and k.

I don't want this to be like where I type "abc(3500, .05, 10)" to get an answer. This is cool and useful and all but I'm trying to learn more advanced stuff. I'm sure someone here knows what I mean!

One last thing, is there a software available that will allow me to edit .89p files and the like. Surely there is a way to edit the programs I have installed already.

Thank you!

Jason
College Station, Texas
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 01 Apr 2009 12:11:42 am    Post subject:

Well, it's all possible. What specifically have you tried doing? It wouldn't help you in the slightest if we just gave you a finished program. Try it, and then ask for help with specific problems you run into. The Dialog..EndDlog and solve() commands are of course a good start.

Also, the numeric equation solver does a lot of what you want already, with the one drawback that it doesn't give exact solutions.
Back to top
nactownag


Newbie


Joined: 31 Mar 2009
Posts: 12

Posted: 01 Apr 2009 12:15:27 am    Post subject:

Hey,

Yeah I've tried several different things but I always seem to get stuck. I understand that it doesn't do good to just do it all for me but I sure could use a template of sorts to work with. I'm mainly getting stuck with all the conditions that are involved. I truly believe that once I see it done right one time I will forever be cured on this disease they call confusion.
Back to top
nactownag


Newbie


Joined: 31 Mar 2009
Posts: 12

Posted: 01 Apr 2009 12:17:07 am    Post subject:

Do you think this needs to be a function or a program?
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 01 Apr 2009 12:45:27 am    Post subject:

If it were a function, your input and output would generally be in the style you said you wanted to avoid. Programs are generally the ones that deal with dialogs.

So to get you started: First, you want a Dialog box. The variable you want to solve for is one of a few options, so it should be in a DropDown menu; the values of the other variables can be anything, so make them Requests. There's some tricky stuff here. First of all, everything entered into a Request is a string: so you'll have to use the expr() command afterwards to turn them from strings into numbers. Second, the result of the DropDown is a number equal to the option selected. So maybe you have a variable called "var" to determine which variable you want to solve for: if var=1, then you're solving for M, if var=2 you're solving for F, and so on (depending on the order you list them in, in the menu).

Next is the solving step. You could do this in one command, but it's slightly tricky; using If .. Then .. ElseIf .. EndIf is simpler to understand. Just check for every possible value of var, and in each case, output the result of a solve() expression that solves for the corresponding variable. Here, there's another tricky part: solve() returns an equation or several equations, but Text (the command you'll probably want to use) wants a string. So use the string() command to convert it to one.

Here's a sort of framework:


solveeqn()
Prgm
Dialog
© DropDown for variable to solve for, stored to "var"
© Request for each variable in equation
EndDlog
© Use expr() to format each variable's value
If var=1 Then
© solve for first variable, display solution
ElseIf var=2 Then
© solve for second variable, display solution
...
Else
© solve for last variable, display solution
EndIf
EndPrgm


Obviously this isn't the best code. It's repeating things that only need to be written once, and some things, like the equation, are hardcoded and therefore hard to change. Just start with doing something like this and then we can work on improving it.


Last edited by Guest on 11 Jul 2010 05:56:32 pm; edited 1 time in total
Back to top
nactownag


Newbie


Joined: 31 Mar 2009
Posts: 12

Posted: 01 Apr 2009 01:04:29 am    Post subject:

So then the variable I select from the drop down....won't that still show up in the requests?
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 01 Apr 2009 09:51:06 am    Post subject:

Yes. It will. What you input for it won't mean anything, but it will show up.

The only way to avoid that is to have more than one dialog. I don't know if that's worth it for you. Basically, the first thing you do is choose the variable to solve for, in one dialog. Then you have two options to do the rest. One is another chain of If .. ElseIf .. EndIf statements, with a dialog box omitting the variable being solved for in each one. This is very redundant. The other option is to build up a dialog dynamically: make a string containing "Dialog", then add on ":Request "BLAH",blah" for every variable you plan to include, then finish with adding an ":EndDlog". After that, expr() of that string will give you the dialog you want.

This last method is more advanced and may or may not be actually worth it, at this point. Also, it gives up independence from language localization, since the command Dialog is different in other languages.


Last edited by Guest on 01 Apr 2009 09:51:22 am; edited 1 time in total
Back to top
nactownag


Newbie


Joined: 31 Mar 2009
Posts: 12

Posted: 03 Apr 2009 06:32:07 am    Post subject:

Sorry it's taken me a while to reply back.

Ok....here's just what I've come up with so far. I've simplified it down as far the formula goes. I figure that if I can do this with a simple formula I should be able to do it with a more complicated formula.

I'm sure there are some errors in this but I'm hopeful that it's close to being right.


Code:
solveeqn()
Prgm
Dialog
DropDown "Solve For:",{"x","y"},var
Request "Specify Value of "x":",num1
Request "Specify Value of "y":",num2
EndDlog
Expr(num1)->num1
Expr(num2)->num2
If var=x Then
solve((y=5+x),x), Disp "x"
ElseIf var=y Then
solve((y=5+x),y), Disp "y"
EndIf
EndPrgm


Thanks for your help so far!
Back to top
nactownag


Newbie


Joined: 31 Mar 2009
Posts: 12

Posted: 03 Apr 2009 07:01:12 am    Post subject:

Or should it be more like this:



Code:
solveeqn()
Prgm
Dialog
DropDown "Solve For:",{"x","y"},var
Request "Specify Value of "x":",num1
Request "Specify Value of "y":",num2
EndDlog
Expr(num1)->num1
Expr(num2)->num2
[b]If var=x Then
solve((num2=5+x),x), Disp "x"
ElseIf var=y Then
solve((y=5+num1),y), Disp "y"[/b]
EndIf
EndPrgm
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 03 Apr 2009 10:20:52 am    Post subject:

The second approach is correct (although there are multiple valid ways of solving the problem), and both have a few syntactical problems to address. I urge you to try and fix some of them yourself by, y'know, running the program to see what happens, before reading further.



First of all, the output of DropDown is a number: either 1 (representing the first option) or 2 (representing the second option). This should be reflected in your If..ElseIf code.

Second, you can't separate statements with commas. If you want to put the solve() and Disp on one line, you can use a colon. Or you could just put them on two separate lines.

Third, Disp "x" will not display the value of x that has been solved for. It will just write the letter x. What you want to do is output the result of solve(). Which means you must either save the result of solve(): e.g. solve(...,x)->res: Disp res -- or just output it immediately: Disp solve(...,x)->res.


Last edited by Guest on 11 Jul 2010 05:56:03 pm; edited 1 time in total
Back to top
nactownag


Newbie


Joined: 31 Mar 2009
Posts: 12

Posted: 03 Apr 2009 10:49:12 am    Post subject:

Awesome. I just plugged the following code in and it works perfectly


Code:
solveeqn()
Prgm
Dialog
DropDown "Solve For:",{"x","y"},var
Request "Specify Value of x:",num1
Request "Specify Value of y:",num2
EndDlog
Expr(num1)->num1
Expr(num2)->num2
If var=1 Then
solve((num2=5+x),x)->res1: Disp res1
ElseIf var=2 Then
solve((y=5+num1),y)->res2: Disp res2
EndIf
EndPrgm


Very very cool...

So...how can I go about typing this code up on my computer and sending it to my calculator?
I tried just typing it up in a text editor and saving it as a .89p file but that didn't work.
Any ideas?

THANKS
Back to top
nactownag


Newbie


Joined: 31 Mar 2009
Posts: 12

Posted: 03 Apr 2009 10:58:41 am    Post subject:

Also if I need to add more variables....with regard to the IfThen statements would this be appropriate?


Code:
If var=1 Then
solve((num2=5+x+num3+num4),x)->res1: Disp res1
ElseIf var=2 Then
solve((y=5+num1+num3+num4),y)->res2: Disp res2
ElseIf var=3 Then
solve((num2=5+num1+z+num4),z)->res3: Disp res3
ElseIf var=4 Then
solve((num2=5+num1+num3+t),t)->res4: Disp res4
EndIf


Or can you not put that many ElseIf commands back to back?
Back to top
nactownag


Newbie


Joined: 31 Mar 2009
Posts: 12

Posted: 03 Apr 2009 12:53:46 pm    Post subject:

I've made an attempt at making this a lot more complicated math problem and I'm getting a "too few arguments" error.

Not sure exactly what it could be...



Code:
solveeqn()
Prgm
Dialog
DropDown "Solve For:",{"M","F","N","INT","T","k"},var
Request "Value of M?",num1
Request "Value of F?",num2
Request "Value of N?",num3
Request "Value of INT?",num4
Request "Value of T?",num5
Request "Value of k?",num6
EndDlog
expr(num1)->num1
expr(num2)->num2
expr(num3)->num3
expr(num4)->num4
expr(num5)->num5
expr(num6)->num6
If var=1 Then
solve((M(1-num2)=E(num4(1-num5)/((1+num6)^t)+M/((1+num6)^num3)),t,1,num3),M)->res1: Disp res1
ElseIf var=2 Then
solve((num1(1-F)=E(num4(1-num5)/((1+num6)^t)+num1/((1+num6)^num3)),t,1,num3),F)->res2: Disp res2
ElseIf var=2 Then
solve((num1(1-num2)=E(num4(1-num5)/((1+num6)^t)+num1/((1+num6)^num3)),t,1,N),N)->res3: Disp res3
ElseIf var=2 Then
solve((num1(1-num2)=E(INT(1-num5)/((1+num6)^t)+num1/((1+num6)^num3)),t,1,num3),INT)->res4: Disp res4
ElseIf var=2 Then
solve((num1(1-F)=E(num4(1-T)/((1+num6)^t)+num1/((1+num6)^num3)),t,1,num3),T)->res5: Disp res5
ElseIf var=2 Then
solve((num1(1-F)=E(num4(1-num5)/((1+k)^t)+num1/((1+k)^num3)),t,1,num3),k)->res6: Disp res6
EndIf
EndPrgm



Note: "E" is the summation sign.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 03 Apr 2009 01:08:23 pm    Post subject:

You can't name a variable INT because int() is a built-in operation, and variable names are not case-sensitive. That's part of the problem.

Another problem that you'll run into is that writing M(1-F) makes the calculator think you're evaluating a function called M at the value 1-F. Write M*(1-F) instead, and similarly in all other such cases.
Back to top
nactownag


Newbie


Joined: 31 Mar 2009
Posts: 12

Posted: 03 Apr 2009 02:23:08 pm    Post subject:

I fixed those things but it's still throwing the error. I think that there is something wrong with the parenthesis. But I can't figure out what could be wrong....do you see anything?
Back to top
nactownag


Newbie


Joined: 31 Mar 2009
Posts: 12

Posted: 03 Apr 2009 05:32:37 pm    Post subject:

Got it!


Code:
solveeqn()
Prgm
Dialog
DropDown "Find:",{"M","F","N","I","T","k"},var
Request "Value of M?",num1
Request "Value of F?",num2
Request "Value of N?",num3
Request "Value of I?",num4
Request "Value of T?",num5
Request "Value of K?",num6
EndDlog
Expr(num1)->num1
Expr(num2)->num2
Expr(num3)->num3
Expr(num4)->num4
Expr(num5)->num5
Expr(num6)->num6
If var=1 Then
solve(m*(1-num2)=E(num4*(1-num5)/(1+num6)^x+m/(1+num6)^num3,x,1,num3),m)->res1: Disp res1
ElseIf var=2 Then
solve(num1*(1-f)=E(num4*(1-num5)/(1+num6)^x+num1/(1+num6)^num3,x,1,num3),f)->res2: Disp res2
ElseIf var=3 Then
solve(num1*(1-num2)=E(num4*(1-num5)/(1+num6)^x+num1/(1+num6)^n,x,1,n),n)->res3: Disp res3
ElseIf var=4 Then
solve(num1*(1-num2)=E(i*(1-num5)/(1+num6)^x+num1/(1+num6)^num3,x,1,num3),i)->res4: Disp res4
ElseIf var=5 Then
solve(num1*(1-num2)=E(num4*(1-t)/(1+num6)^x+num1/(1+num6)^num3,x,1,num3),t)->res5: Disp res5
ElseIf var=6 Then
solve(num1*(1-num2)=E(num4*(1-num5)/(1+k)^x+num1/(1+k)^num3,x,1,num3),k)->res6: Disp res6
EndIf
EndPrgm
Back to top
TI-newb


Member


Joined: 24 Dec 2008
Posts: 158

Posted: 07 Apr 2009 08:09:28 pm    Post subject:

is this on Ti-Basic?? i have never encountered.. 'Request' or 'Dialog'. =/
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 07 Apr 2009 08:18:28 pm    Post subject:

It's TI-89 Basic. Come to think of it, I should probably move it to that subforum.
Back to top
Display posts from previous:   
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
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement