Solved

Calculating Complex Equations...

Posted on 2003-11-07
3
392 Views
Last Modified: 2010-04-16
Hi,

I am developing a mathematical application that involves the storage and process of equations of cubic and quartet order. I am storing the data in an MSDE database. The equation is stored in the database in the following format, (all equations are structured this way at the moment);

3.5604e-3*x(3) + 4.5394e-2*x(2) + 2.9238e+1*x(1) + 2223

The x(3) is interperated as x cubed, x(2) x squared.

The UI extracts this equation and has to break it into its atomic parts substituting x with a user input and calculating it accordingly.

Can anyone advise me on a more efficient storage format of the equations and a technique to break the equation into its constituent parts for ease of calculation.

kind regards Imran Farooq
0
Comment
Question by:imran89
3 Comments
 
LVL 44

Expert Comment

by:Arthur_Wood
Comment Utility
1) you can use the SPLIT function to break up each member of the polynomial :

Split(strFormula,"+")

you can then split each part, into the two factors, using the *

Split(Part, "*")

then extract the power of x from the (...) (if the () is present)

actually rather close to a problem I solved a long time ago (1963 - in FORTRAN, after my Freshman year in college, worked as a Summer Intern at what is now UCSD, in La Jolla, Calif)...and no, I do not have the code.

AW
0
 
LVL 1

Accepted Solution

by:
jdauie earned 60 total points
Comment Utility
You could easily make a class for it that would hold an array of coefficients.  You wouldn't even need to include the variable and the exponent if you have similar equations.
You can then save the object using serialization.
0
 

Author Comment

by:imran89
Comment Utility
That seems a good idea, how would I hold the coefficients in a class, could you elaborate for me please as this is my first project in c#.

kind regards Imran
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now