-1

I have been given an Excel file. The Excel file has rows in it. The first column of each row has a formula that looks something like this:

'4.75+-3.12*log(x)+1.25*log(x)^2

I need to "load" this formula into C# so that I can do some calculations with it. My question is, if I had the text above, how do I convert it into a mathematical formula I can use in C#? I am successfully reading my Excel file. Yet, I'm not sure how to parse the formula into something I can actually use.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Some User
  • 5,257
  • 13
  • 51
  • 93
  • Are you asking how to parse each piece of the function into multiple parts and solve the equation?. I'm not aware of there being a quick and dirty way without some special rules parsing out the variables using orders of operations. – Rafiki Feb 11 '16 at 13:19
  • I'm trying to load the function so that I can pass different values in for X dynamically. Currently, when I use Mathos, I get an error that says `Input string was not in a correct format." – Some User Feb 11 '16 at 13:28

1 Answers1

0

You have to use infix and postfix notations, as well as using the Shunting Yard algorithm will help you solve your issue.

CodeNotFound
  • 22,153
  • 10
  • 68
  • 69
Johnaudi
  • 257
  • 1
  • 23