• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Formula Converter

 
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am looking for an open Source Formula Converter API or project.
For example I specify a set of rules to this API like follows :

sin ( x ) ^ 2 + cos ( x )^ 2 = 1
1 + tan (x) ^ 2 = cos ( 2 ) ^ 2

After those rules I enter an input text, and I want the API to convert the input according to the supplied rules

Pleeeese help

Thanks in advance
 
Ranch Hand
Posts: 357
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't know what exactly are the mathmatics operation you really need to calculate, but it seems that they are sin, cos ...etc and power, sqrt. i think that in one or two hours you could already have your simple calculator up and working.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it looks like you're trying to write something where you input the trig identities, and use that to solve/simplify other equations, yes?
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes that's what I want fred

I didn't find any open source tool or api in Java to do what I want.

Do you any if any exists ???
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You mean you want something which will solve those equations? That sounds awkward. If you can do it with pencil and paper, then you can program a method/methods to use the same algorithm.

By the way: I can give you the solution for sin^2(x) + cos^2(x) = 1 easily. It is true for every value of x!

Try Googling for "algebra formula solver"; I did and got several promising links.

Another approach would be to guess a solution and use Newton's approximation. That will give an answer, but will be awkward to program.
 
Campbell Ritchie
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
. . . and look at these equivalences; you will find other equalities true for every value here.
 
Campbell Ritchie
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is a solution for 1 + tan^2(x) = cos^2(x). You should be able to work it out in your head. Remember the solution will repeat every PI radians, or every 2PI radians!
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems you all misunderstood what I want.
I want to able to define the rules I want for example before instructing the program to solve the equation I give it a set of rules (Equations) the simplifing based on.

For example I want sin ( x ) ^ 2 + cos ( x ) ^ 2 = log(x) + 5

I want to be able to dynamically enter the rules the application will solve or simplify the equation according to the rules I enter.





 
Campbell Ritchie
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Difficult. You actually need to parse what you are writing. Same procedure as if you were writing a compiler.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you give an example of a "rule" the user would enter, and how it would specify how to simplify an expression?
 
Khaled Mahmoud
Ranch Hand
Posts: 361
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I already posted an example

A rule :

sin ( x ) ^ 2 + 1 = log( x ) + 20



The string I enter should be searched and any equation in the form sin ( x ) ^ 2 + 1 to should be converted against the specified rule.

I can enter as many rules as I want.


 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, that's the realm of packages like Maple and Mathematica. I doubt that anything like this is available in Java, and if it is, it's probably going to cost a substantial amount of money.
 
reply
    Bookmark Topic Watch Topic
  • New Topic