Omnimaga

General Discussion => Other Discussions => Math and Science => Topic started by: sjasogun1 on January 12, 2012, 02:31:59 am

Title: Rewriting Formulas
Post by: sjasogun1 on January 12, 2012, 02:31:59 am
I’m trying to create a program that is able to solve certain physics problems (right now they’re all related to circular motion) for school. The problem is that the program doesn’t cover everything. I have rewritten all of the formula’s by hand and put them in the program’s code to let it process the data.

My problem is that it is unable to combine two formula’s in a way some variables get cancelled out.

For example, take a rollercoaster in a theme park. The track of the rollercoaster contains a looping with a radius of 2,0 metres (r=2,0). We assume that the gravitational accelleration is 9,81 m/s^2. How fast does it have to go at the top of the looping to prevent the carts from falling out? (we ignore the weight-shift of the cart train as it moves a along the track, as well as the friction)

We can solve this by equaling two formula’s: the one for the centrifugal force and the one for the gravitational force. F(centrifugal)=F(gravitational) Because the centrifugal force points directly from the center of the circle to the cart which is straight up when it is at the top, the opposite of the gravitational force’s direction.

We get (m*v^2)/r = m*g
Multiply with r
m*v^2 = m*g*r
divide by m
v^2 = g*r
v = sqrt(g*r)
filling that in gives
v = sqrt(9,81*2,0) = 4,3 m/s

This equation crosses the m out of the equation, something my program isn’t able to do. I can’t figure out how to make it do that. Does anybody know an algorithm for crossing out variables like this?
Title: Re: Rewriting Formulas
Post by: ruler501 on January 12, 2012, 07:59:39 am
I don't know of an algorithm to do this but I think it would just be a relatively simple set of rules.

If you want I'll see if I can write up a quick python program to do this.
Title: Re: Rewriting Formulas
Post by: sjasogun1 on January 14, 2012, 04:20:50 am
If you'd want to do that that'd be awesome! An example in any language will do since I don't think stuff like pointers will be necessary to do this.
Title: Re: Rewriting Formulas
Post by: chattahippie on January 14, 2012, 05:45:08 am
You really don't need to cross it out.  As long as you both multiply and divide by m, the equation will work fine, as it cancels out itself automatically
Title: Re: Rewriting Formulas
Post by: sjasogun1 on January 15, 2012, 04:52:23 am
The problem is that I can't simply multiply and then divide by m because my calculator can't have no value assigned to a variable. Thus I use 0 to indicate an 'empty' variable. In this case m would be 0 so I can't multiply by it and then divide again.

I did think of a method to do this though; if I fill in two random numbers (say between 1 and 10^6) for m and see if the answers match it must mean I can cross it out of the equation. To do that for every variable in every equation every single time will make the program work far more slowly though.

To get back to my question, is there an algorithm that crosses out variables from an equation like this?
Title: Re: Rewriting Formulas
Post by: Nick on January 15, 2012, 12:48:51 pm
isn't it possible to detect them on both sides of the equation, and if it's in a multiplication, initialize them as zero, if it's in aproduct, initialize them as 1?

that might do it i think, since when you should work with reall cross out, you would have to make them strings, detect them, erase them out of the string, and make the string an equation again xs
Title: Re: Rewriting Formulas
Post by: ruler501 on January 20, 2012, 08:16:12 am
Sorry I was gone for a while I'll probably try and type up a quick python example of my idea later
Title: Re: Rewriting Formulas
Post by: phenomist on February 02, 2012, 12:53:28 am
Not sure if this works, but you could treat each exponent as a number and add/subtract.
Title: Re: Rewriting Formulas
Post by: ruler501 on February 02, 2012, 11:00:28 pm
I'm very sorry for not getting on this. I've been really busy with school and band. I will try to get on it as soon as I have time