473,656 Members | 2,921 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Math equation

MrPickle
100 New Member
I want to take a math equation in a string format then translate this into code.

For example;
sin(x+2)^4 would translate into: std::pow(4, std::sin(x+2))

but I'm not sure where to start, at first I decided to follow the order of operations, breaking down the equation and putting it into an array this gave me two problems
a) Do I remove the selection from the string as I add it to the array?
b) I wouldn't know where to go from there.

Could someone give me a pointer in the right direction?
Jul 27 '09 #1
2 2388
MrPickle
100 New Member
I can't find the edit button so I'm having to post again;

I've been looking into postfix notation, but I'm not sure whether this works with trig functions?

Okay, trig does work with postfix notation, I know how to do this now.
Jul 27 '09 #2
JosAH
11,448 Recognized Expert MVP
You either have to write an interpreter for your formulas or if you want to go for the whole nine yards you could write an actual compiler and leave the code generation to LLVM; it's a fun package to use.

kind regards,

Jos
Jul 27 '09 #3

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

Similar topics

89
5097
by: Radioactive Man | last post by:
In python 2.3 (IDLE 1.0.3) running under windows 95, I get the following types of errors whenever I do simple arithmetic: 1st example: >>> 12.10 + 8.30 20.399999999999999 >>> 1.1 - 0.2 0.90000000000000013
17
3514
by: Just | last post by:
While googling for a non-linear equation solver, I found Math::Polynomial::Solve in CPAN. It seems a great little module, except it's not Python... I'm especially looking for its poly_root() functionality (which solves arbitrary polynomials). Does anyone know of a Python module/package that implements that? Just
1
1289
by: qwweeeit | last post by:
Another math problem easier to solve by hand, but, IMHO, difficult to program in a concise way like the solution of Bill Mill (linalg_brute.py) to the problem of engsol. I appreciated very much the Bill Mill's solution and that inspired in a certain way the solution for my problem. # Problem and solution: # ab * cb = dab 35 * 26 = 936
4
1482
by: Brad Brening | last post by:
Hello; I am working in VB.NET and am trying to come up with an equation. I think my math skills have degraded due to lack of use! Here is my problem. I have, say Z amount of credits to assign a user. Lets say Z = 500 credits. I want to assign those credits over a span of, say, 10 days.
4
13373
by: John B. | last post by:
I'm self teaching myself C on a Linux box but I can't get a simple program to recognize math functions. I start the program with: #include <stdio.h> #include <math.h> but when I compile the program, it does not recognize sin(x); or pow(x,y) etc, in any equation. /usr/include does have a math.h file. Any help or things to try would be greatly appreciated!!!!. (I do alot of graphic things with trig.) thanks ...
4
1422
by: TS | last post by:
I have this simple equation that returns a boolean: if( ti.NumberIncorrect > (TotalQuestions - (TotalQuestions * FailurePercentage) )) ti.NumberIncorrect is int : 4 TotalQuestions is int : 20 FailurePercentage is float : 80 When the code runs, it evaluates to true incorrectly. When I put this exact expression in the watch or immediate window, it evaluates correctly to
3
5475
by: perfactmind | last post by:
Hi Friends, i am using asp.net 2.0 with c#. i am developing a page for enter maths questions. these all questions stored in a database. i have a problem how can i write the math equation in the text box. i have been seen a product 'MathType' equation editor for that but with the help of this we can get a image of this equation. so i think this is not a right way. please give me advise ..... thnaks in advance
1
2155
by: =?ISO-8859-1?Q?Andr=E9?= | last post by:
Would anyone have a "quick and dirty" code sample to create an svg output of a sample math equation using matplotlib? André
2
4846
by: zxry | last post by:
I'm new to C++ and need to write a program that reads and calculates math equations from a char string. My question: is there a way to convert a char math symbol such as '+' into a + the compiler can use in an equation? Right now I'm using a bunch of If statements to handle this, but would like to know if there's a way to work the char sign directly into the equation. i.e. char num1 = '5'; char sign = '+'; char num2 = '2';
0
8296
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8710
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7310
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5627
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4150
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4299
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.