Questions tagged [simplify]

This tag refers to the process of making something simpler or smaller in order to increase its efficiency, usability, or operation speed.

Use this tag for questions related to making something simpler or smaller in order to increase its efficiency, usability, or operation speed.

770 questions
76
votes
6 answers

Strategies for simplifying math expressions

I have a well-formed tree that represents a mathematical expression. For example, given the string: "1+2-3*4/5", this gets parsed into: subtract(add(1,2),divide(multiply(3,4),5)) Which is expressed as this tree: What I'd like to be able to do is…
Dave DeLong
  • 242,470
  • 58
  • 448
  • 498
53
votes
11 answers

Is there a way to shorten this while condition?

while (temp->left->oper == '+' || temp->left->oper == '-' || temp->left->oper == '*' || temp->left->oper == '/' || temp->right->oper == '+' || temp->right->oper == '-' || temp->right->oper == '*' || …
25
votes
27 answers

Can you simplify this expression?

One for the mathematicians. This has gone around the office and we want to see who can come up with a better optimised version. (((a+p) <= b) && (a == 0 || a > 1) && (b >= p)) && ((b - (a + p) == 0) || (b - (a + p) > 1)) Edit: all data is…
Adam Naylor
  • 6,172
  • 10
  • 49
  • 69
23
votes
2 answers

How to reduce the number of points in a curve while preserving its overall shape?

I have a list of points that make a curve, and I would like to reduce the number of points, but still keep the overall shape of the curve. Basically, I want to go from this: To this: So the algorithm would remove the points that are redundant but…
laurent
  • 88,262
  • 77
  • 290
  • 428
18
votes
3 answers

Get mathematica to simplify expression with another equation

I have a very complicated mathematica expression that I'd like to simplify by using a new, possibly dimensionless parameter. An example of my expression is: K=a*b*t/((t+f)c*d); (the actual expression is monstrously large, thousands of characters).…
vector07
  • 339
  • 1
  • 3
  • 12
13
votes
9 answers

Simplify replacement of date object with "today" and "yesterday" strings in Java static method

I have following method that I would like to make shorter or faster if nothing else. Please all comments are welcome: Bellow method takes a date object, formates it ("EEE hh:mma MMM d, yyyy") and then figures out if the date is today or yesterday…
MatBanik
  • 26,356
  • 39
  • 116
  • 178
12
votes
2 answers

Sympy Simplification with Square Root

I have an expression that I think could be simplified somewhat and for some reason sympy is not performing what I think are simple simplifications. My code with the example is as follows: # coding: utf-8 # In[1]: from __future__ import…
Justace Clutter
  • 2,097
  • 3
  • 18
  • 31
12
votes
8 answers

Most elegant combinations of elements in F#

One more question about most elegant and simple implementation of element combinations in F#. It should return all combinations of input elements (either List or Sequence). First argument is number of elements in a combination. For example: comb 2…
The_Ghost
  • 2,070
  • 15
  • 26
10
votes
2 answers

Best way to determine the equality of two data sets in python?

Do you know a simpler way to achieve the same result as this? I have this code: color1 = input("Color 1: ") color2 = input("Color 2: ") if ((color1=="blue" and color2=="yellow") or (color1=="yellow" and color2=="blue")): print("{0} +…
10
votes
1 answer

Have any simplified YAML formats become widespread?

I love YAML. Wait, let me back up. I love YAML that looks like this, even more than JSON: Projects: C/C++ Libraries: - libyaml # "C" Fast YAML 1.1 - Syck # (dated) "C" YAML 1.0 - yaml-cpp # C++ YAML 1.2 implementation …
Andy
  • 7,885
  • 5
  • 55
  • 61
9
votes
2 answers

Leaflet polyline SmoothFactor range

According to LeafLet documentation PolyLine has a "smoothFactor" parameter : http://leafletjs.com/reference.html#polyline which allows polyline simplification to improve performance. Does anyone know what is the range (e.g. min and max values) and…
eagle2
  • 91
  • 1
  • 3
9
votes
1 answer

Matlab/Mupad symbolic simplification for pretty output

I need to automatically simplify some symbolic expressions but the simplify function of matlab can't do everything i need. Example: simplify(expand((ax + bx)^2 + (ay + by)^2)) Which results in the output ax^2 + 2*ax*bx + ay^2 + 2*ay*by + bx^2 +…
Daniel
  • 2,993
  • 2
  • 23
  • 40
8
votes
2 answers

How do I force Mathematica to include user defined functions in Simplify and FullSimplify?

Let's say I have a relation r^2 = x^2 + y^2. Now suppose after a calculation i get a complicated output of x and y, but which could in theory be simplified a lot by using the above relation. How do I tell Mathematica to do that? I'm referring to…
H. Arponen
  • 547
  • 1
  • 8
  • 18
8
votes
1 answer

Analytical way of speeding up exp(A*x) in MATLAB

I need to calculate f(x)=exp(A*x) repeatedly for a tiny, variable column vector x and a huge, constant matrix A (many rows, few columns). In other words, the x are few, but the A*x are many. My problem dimensions are such that A*x takes about as…
bers
  • 4,817
  • 2
  • 40
  • 59
8
votes
1 answer

Is there an algorithm to "simplify" a dependency graph?

My problem is very simple but I don't really know its name and therefore, it's hard to find a solution by myself : How to simplify a dependency graph like (where -> means depends): A -> B -> C & A -> C to A -> B -> C
Maxime
  • 1,776
  • 1
  • 16
  • 29
1
2 3
51 52