I've developed an equation parser using a simple stack algorithm that will handle binary (+, -, |, &, *, /, etc) operators, unary (!) operators, and parenthesis.
Using this method, however, leaves me with everything having the same precedence - it's evaluated left to right regardless of operator, although precedence can be enforced usin...
Learning to program, trying to do this
I have a string like this
2+24*48/32
and I want to split it into a list like this
['2', '+', '24', '*', '48', '/', '32']
I have messed around with .split() but that's messy as it returns a list, which means I would now have to iterate over two strings, etc
...
How do I calculate the position of an accelerating body (e.g. a car) after a certain time (e.g. 1 second)?
For a moving body that it not accelerating, it is a linear relationship, so I presume for an accelerating body it involves a square somewhere.
Any ideas?
...
I need to solve a few mathematical equations in my application. Here's a typical example of such an equation:
a + b * c - d / e = a
Additional rules:
b % 10 = 0
b >= 0
b <= 100
Each number must be integer
...
I would like to get the possible solution sets for a, b, c, d and e.
Are there any libraries out there, either open source...
I'm working on a programming problem which boils down to a set of an equation and inequality:
x[0]*a[0] + x[1]*a[1] + ... x[n]*a[n] >= D
x[0]*b[0] + x[1]*b[1] + ... x[n]*b[n] = C
I want to solve for the values of X that will give the absolute minimum of C, given the input D and lists and A and B consisting of a[0 - n] and b[0 - n ].
...
Someone asked me a question via e-mail about integer partitions the other day (as I had released a Perl module, Integer::Partition, to generate them), that I was unable to answer.
Background: here are all the integer partitions of 7 (the sum of each row equals 7).
7
6 1
5 2
5 1 1
4 3
4 2 1
4 1 1 1
3 3 1
3 2 2
3 2 1 1
3 1 1 1 1
2 2 2 1
...
I wrote this scheme code to compute one solution of the quadratic equation a*x2 + b*x + c = 0
(define (solve-quadratic-equation a b c) (define disc (sqrt (- (* b b) (* 4.0 a c)))) (/ (+ (- b) disc) (* 2.0 a)))
However, someone told me that this procedure is hard to understand. Why?
What would a cleaned up version of this procedure lo...
I have the following equation
1 - ((.5 * 0.83333333333333) ^ 2 + (.5 * 0.83333333333333) ^ 2 + (.5 * (1 - 0.83333333333333)) ^ 2 + (.5 * (1 - 0.83333333333333)) ^ 2)
In Php5, this results in an answer of 1 as opposed to .63 (on two machines, OSx and Centos). Should I be exclusively using the bc math functions of Php to do equations l...
Does anyone have any good references for equations which can be implemented relatively easily for how to compute the transfer of angular momentum between two rigid bodies?
I've been searching for this sort of thing for a while, and I haven't found any particularly comprehensible explanations of the problem.
To be precise, the question ...
Is there a programmatic way to extract equations (and possibly images) from an MS Word document? I've googled all over, but have yet to find anything that I can sink my teeth into and work from. If possible, I'd like to be able to do this with VB.NET or C#, but I can pick up enough of any language to hack out a DLL. Thanks!
EDIT: Rig...
We are using a programming language that does not have a linear regression function in it. We have already implemented a single variable linear equation:
y = Ax + B
and have simply calculated the A and B coefficents from the data using a solution similar to this Stack Overflow answer.
I know this problem gets geometrically harder ...
Trying to figure out an equation to get the current group a page would be in if they were grouped like below.
Variables:
PageSize = 5
PageIndex = 21
GroupSize = 5
TotalItems = 1000
CurrentPage = PageIndex + 1
Find:
**CurrentGroup = ?**
If there are 1000 items and you have a group size of 5 then there are 200 groups (TotalItems / G...
I want to use a variable name containing dash in TeX equation. However, dash gets interpreted as minus sign. Anyone any idea of how to escape the character?
...
I'm trying to solve three simultaneous nonlinear equations in the unknowns x, y, z with Matlab's symbolic toolbox. What's wrong with the following code?
solve( '(x/4 + y/2 + z/4)*(1/(8*x) + 1/(16*y) + 1/(8*z)) = 0.5774', ...
'(x/4 + y/4 + z/2)*(1/(4*x) + 1/(16*y) + 1/(16*z)) = 0.5774', ...
'(x/2 + y/4 + z/4)*(1/(8*x) + ...
How can I (easily) take a string such as
'sin(x)*x^2'
which might be entered by a user at runtime and produce a python function that could be evaluated for any value of x? Does anyone know of any libraries or modules that takes care of this sort of thing?
...
Is there such a thing as a small, self-contained library that will render an equation written in a text-based format (e.g. LaTeX or MathML) to an image (either vector or raster)?
It would be preferable if it's in Python or Python-friendly.
(One possibility that I've found: Matplotlib has Python code to parse and display LaTeX equation...
I have two form fields money and years that need to output a number into a third field cv .
Ideally while the first numbers are being entered but I'm OK with it happening after a button is pressed as well
<FORM name="salary">
<input type="number" size=12 name="money">
<input type="number" size=12 name="years">
<input type...
I am considering parsing simple math equations by compiling from source at runtime. I have heard that there are security considerations that I should be aware of before using this approach, but I can’t find any info on this.
Thanks
C# .net 2.0, winforms
...
For simplicity say we have a sample set of possible scores {0, 1, 2}. Is there a way to calculate a mean based on the number of scores without getting into hairy lookup tables etc for a 95% confidence interval calculation?
dreeves posted a solution to this here: How can I calculate a fair overall game score based on a variable number o...
Hello all,
I am trying to write a function in C++ that solves for X using the quadratic equation. This is what I have written initially, which seems to work as long as there are no complex numbers for an answer:
float solution1 = (float)(-1.0 * b) + (sqrt((b * b) - (4 * a * c)));
solution1 = solution1 / (2*a);
cout << "Solution 1: " <...