TI-89 HomeGames ArchiveTitanium GamesGames How ToProgramsFAQForumTI-89 WikiLinks

How to write basic equation solving programs?

 
Post new topic   Reply to topic    Your TI-89 Resource Forum Index -> BASIC Programming
Author Message
madmanfrommars



Joined: 17 Apr 2007
Posts: 1

PostPosted: April 17, 2007 7:10 PM    Post subject: How to write basic equation solving programs? Reply with quote

Hey I'm a chemical engineering student, and the TI-89 titanium is great in my thermodynamics class.

What I would like however, is to design programs to solve various complicated equations that we solve in the class. What I've been doing is using the solve() function, however it can get annoying to constantly having to type and retype it in again and again.

I'm just looking to figure out how to make a program that when you run it, it asks for the various variables, and you enter them in and it spits out the answers. Nothing toooo complicated I hope.

Can anyone help? I looked around but I haven't found a simple how to get started programming page. I tried winging it on my own, but never really got anywhere.

Thanks
Back to top
View user's profile Send private message
baseballdude_



Joined: 20 Sep 2006
Posts: 76
Location: Wisconsin

PostPosted: April 19, 2007 11:14 PM    Post subject: Reply with quote

Hi there and welcome to the forum!

This is very basic programming stuff. You'll want to look into either using Input or Prompt to input the data and then calculating results and storing them into variables and displaying them accordingly with Disp.

You can look at the Wiki for more information on this.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger AIM Address
buffalodan



Joined: 20 Apr 2007
Posts: 1

PostPosted: April 20, 2007 11:58 AM    Post subject: Reply with quote

I have a similar problem that i cannot figure out

I use the solve function to solve this formula alot

Solve(a=x cos(h) + y sin (h) + z sin(h) cos(h) and b=x cos(i) + y sin (i) + z sin(i) cos(i) and c=x cos (j) + y sin(j) + z sin(j) cos(j),x)

I give it a,b,c,h,i,j. it give me x,y,z

I then use x,y,z in a ton of other simple equations. I want to make a program in which i input all 6 varibles then it solves for x,y,z and then uses those varibles for all the other functions. I have figured out how to use x,y,z, but not how to get them

I think that is what the OP is looking for also.
Back to top
View user's profile Send private message
mellamokb



Joined: 10 May 2007
Posts: 124

PostPosted: May 17, 2007 3:52 PM    Post subject: Reply with quote

Hi buffalodan,

You can use a function for repetitive tasks like this. Type the following in on the home screen:

Code:

Define myfunc(a,b,c,h,i,j)=Solve(a=x cos(h) + y sin(h) + z sin(h) cos(h) and b=x cos(i) + y sin (i) + z sin(i) cos(i) and c=x cos(j) + y sin(j) + z sin(j) cos(j), {x,y,z})



This will define a function "myfunc" in terms of all six variables. The values of the three variables (x, y, z) would be outputted from the function when run on the homescreen like this:

Code:

myfunc(2,4,3.3,133,9,45)



You'll also notice that I supplied a list "{x, y, z}" instead of just a variable "x" as the second argument of the solve function. This will solve simultaneously for all three variables.

Here is a simple program where you would need to supply the missing pieces--the other formulas you mentioned:

Code:

ClearIO
Prompt a
Prompt b
Prompt c
Prompt h
Prompt i
Prompt j

Solve(a=x cos(h) + y sin (h) + z sin(h) cos(h) and b=x cos(i) + y sin (i) + z sin(i) cos(i) and c=x cos (j) + y sin(j) + z sin(j) cos(j),x)->xsol
Solve(a=x cos(h) + y sin (h) + z sin(h) cos(h) and b=x cos(i) + y sin (i) + z sin(i) cos(i) and c=x cos (j) + y sin(j) + z sin(j) cos(j),y)->ysol
Solve(a=x cos(h) + y sin (h) + z sin(h) cos(h) and b=x cos(i) + y sin (i) + z sin(i) cos(i) and c=x cos (j) + y sin(j) + z sin(j) cos(j),z)->zsol

xsol/ysol+zsol^5-xsol*ysol-xsol+zsol^3->d
Disp "Temperature:"
Disp d

(xsol+ysol+zsol)/(xsol*ysol*zsol)->e
Disp "Convergence:"
Disp e

(xsol+ysol+zsol)/2->f
Disp "Average:"
Disp f



Note that you will have a problem with the lines that use "Solve(" because the result will be in an unexpected format (an equation with constraints, as "x=4.4453 and y>0" rather than an expression like "4.4453"). Look into the "part(" function in a manual and use that to split out the expression from the equations. Do a few tests to get the number out, and then write the code that seems to work consistently into the above program snippet I gave you.

Hope this helps!

~ mellamokb
Back to top
View user's profile Send private message
Display posts from previous:    View previous topic : View next topic  
Post new topic   Reply to topic    Your TI-89 Resource Forum Index -> BASIC Programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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

Contact Us | Privacy Policy | Disclaimer | Trademarks

Copyright ©2006 All rights reserved.


Free Greeting Cards | Girly Myspace Layouts | Myspace Unblocker |