13 votes
Accepted

RandomInteger with equal number of 1 and -1

A combination of IntegerPartitions, RandomChoiceand RandomSample: ...
kglr's user avatar
  • 395k
11 votes
Accepted

Finding "nice" solution for under-determined system with constraint?

If I understand the question correctly, you wish to obtain a parameterized solution {U2[U1], W2[W1]} from the equation in the question, so that you can vary that ...
bbgodfrey's user avatar
  • 61.5k
11 votes
Accepted

Creating a random symmetric matrix with a particular rank

Documentation There is a ResourceFunction calledRandomMatrix contributed by Dennis M Schneider. The documentation reads For ...
rhermans's user avatar
  • 36.5k
9 votes
Accepted

How do I plot a function subject to a constraint?

Try MeshFunction Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}, MeshFunctions -> Function[{x, y}, g[x, y]], Mesh -> {{0}}]
Ulrich Neumann's user avatar
8 votes

How do I plot a function subject to a constraint?

Or use RegionFunction and only display it's boundary. ...
cvgmt's user avatar
  • 73k
7 votes
Accepted

NonlinearModelFit Returns Without Evaluating

The eighth data point is {2.18395, 4.16667} and the parameter tl starting value is 2.17. So, this data point will give a complex value for the starting parameter ...
LouisB's user avatar
  • 12.5k
7 votes
Accepted

Finding most general matrices $A$ and $B$ such that $A\cdot B=1$

Problem. Let $A$ be an $n \times m$ matrix and $B$. To find all $m \times n$ matrices $B$ satisfying $AB = I$. Let $p,q$ be the rank, nullity (respectively) of $A$ so that $p+q=m$. The condition $AB =...
Michael E2's user avatar
  • 236k
7 votes
Accepted

Solving for coefficients in a polynominal

Solve[ CoefficientList[(56 - 85689 x)^2 - 3136, x] == CoefficientList[-2 a b x + b^2 x^2, x], {a, b}] ...
ulvi's user avatar
  • 1,808
7 votes

Compute a certain "separability probability" via a constrained 4D integration over $[-1,1]^4$

Numerically stable integrand First thing we have to do is make the integrand numerically stable, if we look at the vanilla expression ...
Thies Heidecke's user avatar
7 votes
Accepted

Constraint of NDSolve with an integral of the solution

Can be used ParametricNDSolveValue ...
Alex Trounev's user avatar
  • 44.7k
6 votes
Accepted

Switching Differential Equation in NDSolve

Changing parameter values during integration works better with DiscreteVariables. But I think the problem with OP's code, in the question and the OP's answer, has ...
Michael E2's user avatar
  • 236k
6 votes

Cutting a section from a sphere by planes

ClipPlanes does exactly what you need: You can use ClipPlanes in two different ways: (1) As an option to clip all the 3D ...
kglr's user avatar
  • 395k
6 votes

RandomInteger with equal number of 1 and -1

If you want to sample uniformly from all possible tuples that sum to 0, you can do the following: ...
Carl Woll's user avatar
  • 131k
6 votes

How to set a tolerance level for equality constraints

You can use Congruent. ...
Anton Antonov's user avatar
6 votes

How to set a tolerance level for equality constraints

Some more ways, with the relative error e = 0.05: ...
Michael E2's user avatar
  • 236k
6 votes

Constraint of NDSolve with an integral of the solution

Knowing f[x]==FF'[x] you can expand your ode and solve without need of additional NMinimize. Only additional constraints ...
Ulrich Neumann's user avatar
6 votes
Accepted

ArgMin over intervals and discrete sets

...
Bob Hanlon's user avatar
  • 158k
6 votes

How to randomly generate a positive semidefinite matrix?

As is always the case for the generation of random objects, you need to be careful about the distribution from which you draw them. In the case of random positive semi-definite matrices I would try to ...
Roman's user avatar
  • 47.5k
6 votes
Accepted

How do I tell FindMinimum to only work with positive, real numbers?

This seemed to do the trick: ...
Quark Soup's user avatar
  • 1,610
6 votes

How to find a numerical solution for a differential equation with constraints?

First hint: This side is "mathematica.stackexchange.com" (not python ;-) ) Second hint: Try to introduce a new function z[x]=Integrate[y[u],{u,0,x}] from ...
Ulrich Neumann's user avatar
6 votes

Draw a (1/4) partial 3D cylinder in a quadrant

Region @ RegionProduct[Disk[{0, 0}, 1/2, {0, Pi/2}], Line[{{0}, {1}}]] ...
kglr's user avatar
  • 395k
6 votes
Accepted

How to find constrains on variables that make a system of inequalities not have a solution

I am not sure if I have full understand the problem. Here just provide a thinking. ...
cvgmt's user avatar
  • 73k
6 votes
Accepted

ContourPlot -- coloring the plot lines

...
cvgmt's user avatar
  • 73k
6 votes
Accepted

LinearOptimization - how to solve with vector constraints?

Note: I have assumed that $p_k = \delta^k(1-\delta)^{n-k}$, as in OPs code. Solution 1. One could use Minimize: ...
user293787's user avatar
  • 11.8k
6 votes
Accepted

How to define variables $a$,$b$,$c$,$d$ are all elements of set $\{2,3,5,7\}$?

And @@ Or @@@ (Thread[# == {2, 3, 5, 7}] & /@ {a, b, c, d}) ...
cvgmt's user avatar
  • 73k
5 votes

sum + Integral involving dirac delta function

There is no need for numeric techniques, this can be done analytically Sum[ Integrate[x^2 DiracDelta[x - n], {x, 0, 100}], {n, 0, 10}] (* 385 *) Since <...
Bob Hanlon's user avatar
  • 158k
5 votes
Accepted

How to plot a volume for triple integral enclosed by surfaces

...
kglr's user avatar
  • 395k
5 votes
Accepted

ParametricPlot3D etc. with parameters satisfying an implicit relation

One way is to use MeshFunctions to plot F[..] = 0: ...
Michael E2's user avatar
  • 236k
5 votes
Accepted

Solving a stiff nonlinear ODE system

The computation can be performed as follows. First, solve for {x, y} instead of {F, G}, because the ODEs are simpler, and then ...
bbgodfrey's user avatar
  • 61.5k
5 votes

Problems with solving PDEs

As noted in the question, the computation fails when v[x, t] >= 1. This is easy to fix by replacing (1 - v[x, t]) by ...
bbgodfrey's user avatar
  • 61.5k

Only top scored, non community-wiki answers of a minimum length are eligible