473,387 Members | 1,530 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Declare any mathematical equation

Guyz, I really need help on this.

I'm trying to make some mathematical programming.

We can input any equation and then the compiler will detect how many variables was (on the equation). After that, we'll input the variable value to get the final solution.

Example:
Please input an equation,f =
= (x*x)+(4*y)-(4*z*z*z) // ( f ) = x² + 4y - 3z³ = 0

Output:
There were 3 variables = x, y and z. Please insert the value for every variable.
x= 1
y= 2
z= 3

Solution: f = -101

Sorry for my bad english ;-/
Sep 25 '07 #1
3 5227
Meetee
931 Expert Mod 512MB

Example:
Please input an equation,f =
= (x*x)+(4*y)-(4*z*z*z) // ( f ) = x² + 4y - 3z³ = 0

Output:
There were 3 variables = x, y and z. Please insert the value for every variable.
x= 1
y= 2
z= 3

Solution: f = -101
Hi,

It's not tough to solve. You just need to take three variables and one variable for f. and direct put the eqation in code and print f as output.

You need to learn for some basic fundamentals of C++. Also read posting guidelines as we are not allowed to put whole code.

Regards
Sep 25 '07 #2
Hi,

It's not tough to solve. You just need to take three variables and one variable for f. and direct put the eqation in code and print f as output.

You need to learn for some basic fundamentals of C++. Also read posting guidelines as we are not allowed to put whole code.

Regards
Dear sir, actually I just wondering how to write the pseudocode to enable the computer can detect/read variable exist if I type any formula as input.

Example:
Please input any formula for f(x) =
> a³ + b² + c

Output:
There was 3 variables on the formula given, a,b & c.
Please insert the value for a:
>1
Please insert the value for b:
>2
Please insert the value for c:
>3
The answer for f(x) = 8

Appreciate if somebody can solve this matter.
Apr 23 '08 #3
weaknessforcats
9,208 Expert Mod 8TB
Use a token parser. As the tokens are extracted from the equation, the ones that are not + - () , etc would be variables. You could then ask for the variable value before evaluating.

Probably you will need syntax to help you.

a³ + b² + c

might have to be entered as

a * a * a + b * b + c

or maybe

a^3 + b^2 + c

for example.

Here if the operands of the * operator are not numbers, they are variables.

I would stick with simple stuff first and then try to generalize it.

You might check out reverse Polish notation and push-down stacks for evaluation.

If you are going to try this in C++ consider a finite state automoton for State machine. There is an article in the C/C++ HowTos on the State design pattern.
Apr 23 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: gelong | last post by:
Hi there, I have a problem in writing a mathematical function using C++ programming. How to write an input that can insert whole equation? Example is the input are x² + 3y - 4z³ = 0. In maple, it...
3
by: tobimarq | last post by:
hi all, I wonder if the following is possible in php: I want php to 'interpret' a string that contains (a simple kind of) mathematical calculation, like $var='25*3'; $result= (int) $var;...
0
by: Juan R. | last post by:
I have updated some basic requirements for a generic mathematical markup language for scientific requirements at the next link. ...
4
by: Xah Lee | last post by:
i've long time been interested in algorithmic mathematical art. That is, mathematical or algorithmic visual art works that are generated by computer such that the program's source code reflects the...
1
by: tests | last post by:
Hi I would like to store mathematical euqations that can be typed by Microsoft Equation 3.0 in MySQL. Is there any way this can be achieved. Thanks
6
by: reshmidoudou | last post by:
I am new to c++ and have to write a program that takes a line of characters as its inout and represents a mathematical eqaution of the form a + b = c and checks whether it is correct. example 2 + 3 =...
5
w33nie
by: w33nie | last post by:
My table is pretty well complete, but I would prefer it if the value for Points could be turned into a mathematical equation, and this equation would use the data from the other fields in the table...
6
by: Trev17 | last post by:
Hello, I am new to C++ and i have tried for several hours to make a program my teacher has given me as a lab. Here is the Lab question: the roots of the quadratic equation ax^2 + bx + c = 0, a...
3
by: newbprogrammer | last post by:
I just started programming in c++ and i tried to explore and do programs on my own... So i wanted to do a program that would help me in my daily school work ... a program to solve quadratic...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.