954,529 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

manipulation of maths formula

MY problem is related to entry of research data.

The researchformula is entered into a textbox alongwith other usual form entries like title,subject,startdate etc.

The formula consists of alzebra, trignometric, otherfunctions etc.

Example

<strong>x = 12;
y = 24 + tit[x] + mixer[x];
z = x + sin(x) + tan(x+y) - max[x,y];

#final result is 24.778273666352;</strong>


The program is not concerned with the syntax or result of these formulas.

The form must however display some details of the formula in the following format in textbox on buttonclick

a) variableused name and characterlocation of variables like x(1,19) y(8,)
since x is at 1,19 position and y starts at 8 position

b) functioused name,location - same as above


> variablenames and functionname always start with a alphabet
> the only difference is functionname is always followed by a parenthesis( ) ot bracket[ ]
> # symbol denotes a comment and need not be considered
> all statements are separated with a semicolon including #


would greatly appreciate any guidance related to this query.

apals
Newbie Poster
17 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 
Maybe you can find some ideas here: http://www.daniweb.com/software-development/csharp/code/217185

the above method does not find positions of a text within another text.

thanx , but i am working on the following methods

a solution with an approach of finding text within a text using regular expression

OR

even a for loop that can first generate a list of present variables and functions

apals
Newbie Poster
17 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 
Look for the members of the String class: http://msdn.microsoft.com/en-us/library/system.string_members(v=vs.90).aspx e.g. the IndexOf method : http://msdn.microsoft.com/en-us/library/system.string.indexof(v=vs.90).aspx


thank you, i think indexOf is the key because it gives the exact position of the text.

Infact, i have asked the question incorrect way. My question was as simple as

How to find occurances of a Text in a Text ? of which i found a very common solution however the problem occur when it matches to a textpart for ex.

x does occur many times in a equation and it Also occurs in function max[1,2,3,]

that is where i am stuck now.

apals
Newbie Poster
17 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 
ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 
So, perhaps you want more something like this: http://www.dijksterhuis.org/manipulating-strings-in-csharp-finding-all-occurrences-of-a-string-within-another-string/

Thanx again,

This was a good example, I wrote a for loop with indexOf but this class seems hi-tech.

The problem is that it also fails to omit char within a word

for ex.

if a text is x = x + max[y,x];

the char x is show to occur four times in place of 3 i.e. it counts the x within the word max.

I wrote a if statement to omit it, but the combinations of a letter being standalone is high like it may have a space as prefix or postfix , it may also have a symbol like + - etc. as prefix or postfix.

apals
Newbie Poster
17 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

You could try, that if x is at least prefixed or at least postfixed by a letter it is not a standalone x.
Use the IsLetter method of the Char class : http://msdn.microsoft.com/en-US/library/system.char_members(v=vs.90).aspx

ddanbe
Senior Poster
3,829 posts since Oct 2008
Reputation Points: 2,070
Solved Threads: 661
 

i am working on a solution that uses regex to find if it is within another text. because it covers whitespace,a-z,A-Z,0-9,_,() that is what there is at the most.

this solution is for a research based project that uses advanced mathemathics.

thanx for all the replies.

apals
Newbie Poster
17 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: