Author Topic: Rewriting Formulas  (Read 5092 times)

0 Members and 1 Guest are viewing this topic.

Offline sjasogun1

  • LV3 Member (Next: 100)
  • ***
  • Posts: 88
  • Rating: +8/-1
    • View Profile
Rewriting Formulas
« 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?
« Last Edit: January 12, 2012, 02:43:38 am by leafiness0 »
Veni, vidi, cecidi
(I came, I saw, I fell down dead)
MSPAFORUMS: http://www.mspaforums.com/
HOMESTUCK: http://www.mspaintadventures.com/?s=6&p=001901

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Rewriting Formulas
« Reply #1 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.
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline sjasogun1

  • LV3 Member (Next: 100)
  • ***
  • Posts: 88
  • Rating: +8/-1
    • View Profile
Re: Rewriting Formulas
« Reply #2 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.
Veni, vidi, cecidi
(I came, I saw, I fell down dead)
MSPAFORUMS: http://www.mspaforums.com/
HOMESTUCK: http://www.mspaintadventures.com/?s=6&p=001901

Offline chattahippie

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +27/-0
  • Super Member! :D
    • View Profile
Re: Rewriting Formulas
« Reply #3 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

Offline sjasogun1

  • LV3 Member (Next: 100)
  • ***
  • Posts: 88
  • Rating: +8/-1
    • View Profile
Re: Rewriting Formulas
« Reply #4 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?
Veni, vidi, cecidi
(I came, I saw, I fell down dead)
MSPAFORUMS: http://www.mspaforums.com/
HOMESTUCK: http://www.mspaintadventures.com/?s=6&p=001901

Offline Nick

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1166
  • Rating: +161/-3
  • You just got omnom'd
    • View Profile
    • Nick Steen
Re: Rewriting Formulas
« Reply #5 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

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Rewriting Formulas
« Reply #6 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
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline phenomist

  • LV4 Regular (Next: 200)
  • ****
  • Posts: 132
  • Rating: +46/-3
    • View Profile
Re: Rewriting Formulas
« Reply #7 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.
Level Designer for Graviter

[Disclaimer: I can't program for my life.]

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Rewriting Formulas
« Reply #8 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
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y