| Author |
Message |
madmanfrommars
Joined: 17 Apr 2007 Posts: 1
|
Posted: April 17, 2007 7:10 PM Post subject: How to write basic equation solving programs? |
|
|
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 |
|
 |
baseballdude_

Joined: 20 Sep 2006 Posts: 76 Location: Wisconsin
|
Posted: April 19, 2007 11:14 PM Post subject: |
|
|
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 |
|
 |
buffalodan
Joined: 20 Apr 2007 Posts: 1
|
Posted: April 20, 2007 11:58 AM Post subject: |
|
|
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 |
|
 |
mellamokb
Joined: 10 May 2007 Posts: 100
|
Posted: May 17, 2007 3:52 PM Post subject: |
|
|
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 |
|
 |
|
|
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
|
Powered by phpBB © 2001, 2005 phpBB Group
|
Saphic 1.5 // Theme created by Sopel
|
|