Questions tagged [simplification]
249 questions
5
votes
4 answers
Simplifing a nested IF statement
I have a function that is like the following
string Foo(bool A, bool B)
{
if(A)
{
if(B)
{
return "W";
}
else
{
return "X";
}
}
else
{
if(B)
…

Scott Chamberlain
- 124,994
- 33
- 282
- 431
4
votes
6 answers
Tools looking for overly complex boolean expression that can be simplified?
Are there any C++ code parsers that look for boolean expressions that can be simplified using boolean algebra?
I know that compilers do this already, but it would be nice to have a tool giving out such things so that one can actually improve the…

blubberbernd
- 3,641
- 8
- 35
- 46
4
votes
0 answers
Sympy: How to minimize the number of multiplications in multivariate expressions?
I have a lot of expressions which sympy default writes as sums of products of variables. These expressions can get quite long. I would like to simplify these expressions to have as few as possible multiplications.
A reduced example:
from sympy…

JohanC
- 71,591
- 8
- 33
- 66
4
votes
3 answers
How can I combine a conditional with a for loop in Python?
I have a simple example I've drawn up. I thought it was possible to combine if statements and for loops with minimal effort in Python. Given:
sublists = [number1, number2, number3]
for sublist in sublists:
if sublist:
…

feyd
- 185
- 1
- 1
- 11
4
votes
1 answer
Simplification of Dirac delta in xδ(x)
I cannot get sympy to simplify xδ(x) to 0, where δ is DiracDelta.
In : simplify(x*DiracDelta(x))
Out: x⋅δ(x)
Is there another simplification routine that would evaluate the terms in factor of Dirac function at the zeros of its argument and check…

Joce
- 2,220
- 15
- 26
4
votes
1 answer
how to obtain simplified Stanford Bunny model
Some will object that this is not a programming question. I'm willing to defend its relevance to SO, or to take the question elsewhere, if someone has a good suggestion for a better place to get this sort of help.
The classic Stanford Bunny model…

LarsH
- 27,481
- 8
- 94
- 152
4
votes
2 answers
Rendering non-simplified Mapbox Vector Tile using mapbox gl js
I am trying to render a mvt (Mapbox Vector Tile) containing OSM data using Mapbox GL js, but I keep getting some ugly polygons like they were simplified (like in the Simplification section of this documentation!). I don't want those polygons to be…

gnos
- 796
- 1
- 6
- 17
4
votes
4 answers
How to simplify A + 0 > 0 into A > 0?
I'm just a beginner with Coq, and I've been trying to prove a few elementary theorems about natural numbers. I've done a few already, not very elegantly, but completed nether the less. However I'm totally stuck on completing this theorem:
Theorem…

Others
- 2,876
- 2
- 30
- 52
4
votes
1 answer
How to process the fold-over of a triangle in the algorithm Mesh Simplification via Quadratic Error Minimization
Recently I am implementing the QEM mesh simplification algorithm, which was originally from Michael Garland and Paul S. Heckbert's paper Surface Simplification Using Quadric Error Metrics.
According to the algorithm, we should compute a contraction…

C. Wang
- 2,516
- 5
- 29
- 46
4
votes
2 answers
Implementing a basic mathematical expression simplifier
I'm working on a side project for my calc class that differentiates simple functions like y=x^2 in Javascript. To do that, I parsed the expression into an Abstract Syntax Tree, and then hardcoded derivative rules like product rule and chain rule.…

scrblnrd3
- 7,228
- 9
- 33
- 64
3
votes
1 answer
Maxima: Simplify matrix components
in Maxima, how is it possible to simply equations that are components of a matrix? I have a rather big matrix and want to simplify the components of it (e.g. factor out and cancel out).
Thanks.

blubberbernd
- 3,641
- 8
- 35
- 46
3
votes
1 answer
Using ActiveRecord's scope instruction to return a single result
I have the following class that works fine in my unit tests but I feel it could be simpler.
class License < ActiveRecord::Base
scope :active, lambda {
where("active_from <= ?", Date.today).order("version_number DESC")
}
end
def…

Dave Sag
- 13,266
- 14
- 86
- 134
3
votes
1 answer
Model simplification (two way ANOVA)
I am using ANOVA to analyse results from an experiment to see whether there are any effects of my explanatory variables (Heating and Dungfauna) on my response variable (Biomass). I started by looking at the main effects and interaction:
full.model…

Katie Jones
- 61
- 5
3
votes
3 answers
Why does iPhone sample code use so many intermediate variables?
I'm currently working through Apress's "Beginning iPhone 3 Development". A standard they use in their example applications is like the following code:
- (void)viewDidLoad {
BlueViewController *blueController = [[BlueViewController alloc]
…

bearMountain
- 3,950
- 1
- 36
- 44
3
votes
1 answer
Custom simplification (rules and patterns)
Hello I'm very new to maxima.
How could I have something like dot products noticed and simplfied?
Attempt 1:
tellsimpafter(a[1]*b[1]+a[2]*b[2], dot(a,b));
Works for a[1]*b[1]+a[2]*b[2] but not v[1]*w[1]+v[2]*w[2] nor…

GGG
- 295
- 1
- 9