Why doesn't Maple take into account that x != 8 when solving a simple inequality?
Inequality
I'm just learning to work with Maple, I read the documentation, looked at the sites, but I could not find the answer.
Related
My problem is similar to this one Numerical Integration, and I have already calculated the numerical solution of my ODEs using bvp4c, with the boundary conditions imposed at rmin=1e-5 (near r=0) and rmax=50. I do not have to keep the infinite interval, since even for $\frac{\lambda}{e^2}<<1$ the solution reaches the asymptotic behavior really fast.
So, I calculated my integral using trapz, but I would like to know if Matlab has a preciser way of doing this. I searched the methods user #drjrm3 mentioned in the question above, but I didn't understand what method I can implement when the integrand involves a combination of components of a vector which keeps the solution.
What I have so far is something like this:
f=trapz(xint,Sxint(3,:).^2. + 0.5*(1-Sxint(1,:).^2.).^2./xint.^2. + 0.5*xint.^2.*Sxint(4,:).^2. + ...
Sxint(1,:).^2.*Sxint(2,:).^2. + 0.1*0.25*xint.^2.*(Sxint(2,:).^2. - 1).^2.)
Thanks in advance for any hint!
integral() and quadqk().
The exact method of integral() in Matlab changes over time. I haven't followed it for a while. A few years ago, I remember reading how it uses adaptive quadrature and were a slightly more advanced version of Guass-Kronrod. Now it seems Matlab doesn't talk about its integration method in the official documentation. Maybe they developed something good and proprietary. You can read the paper they linked the the documentation page and see if what they do is to your liking.
This question already has an answer here:
How to set the objective function when using linprog in Matlab to solve a system of linear inequalities? [closed]
(1 answer)
Closed 6 years ago.
I want to solve a system of linear inequalities in Matlab, where the unknowns are x(1), x(2), x(3), x(4). I want the entire set of solutions x(1), x(2), x(3), x(4). Hence, I can't use linprog because it gives me just one feasible point.
Clarification: This question https://stackoverflow.com/questions/37258835/how-to-set-the-objective-function-when-using-linprog-in-matlab-to-solve-a-system was about linprogr which however gives only one possible solution. Here I'm asking how to find the entire set of solutions.
This is the set of inequalities. Any suggestion?
5x(1)+3x(2)+3x(3)+5x(4)<5
-5x(1)-3x(2)-3x(3)-5x(4)<-3
-x(2)-x(3)<0
x(2)+x(3)<1
-x(1)-x(4)<0
x(1)+x(4)<1
-3x(3)-5x(4)<-1
3x(3)+5x(4)>3
x(3)<1
-x(3)<0
x(4)<1
-x(4)<0
-5x(1)-3x(2)<0
5x(1)+3x(2)<2
x(2)<1
-x(2)<0
x(1)<1
-x(1)<0
With continuous variables we basically have zero, one or infinitely many solutions. Of course showing all the solutions is not possible for this. However, there is a concept of corner points in linear programming, and those points we can enumerate, although with much effort.
Here are some links for tools that can do this:
cdd
ppl
A different approach is to enumerate the optimal bases using extra binary variables. (You have a zero objective so this becomes effectively: enumerating all feasible LP bases). This approach makes the problem a MIP. We can enumerate this by an algorithm like:
solve mip
if infeasible: stop
add constraint to forbid current point
goto step 1
Here is a link that illustrates this approach to enumerate all optimal bases of a (continuous) LP problem.
Note that enumerating all integer solutions of a system of inequalities is easier. Many constraint programming tools will do that for you automatically. In addition we can use the "cutting plane" technique described above.
I read at a few places (in the doc and in this blog post : http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/ ) that the use of inv in Matlab is not recommended because it is slow and inaccurate.
I am trying to find the reason of this inaccuracy. As of now, Google did not give m interesting result, so I thought someone here could guide me.
Thanks !
The inaccuracy I mentioned is with the method INV, not MATLAB's implementation of it. You should be using QR, LU, or other methods to solve systems of equations since these methods don't typically require squaring the condition number of the system in question. Using inv typically requires an operation that loses accuracy by squaring the condition number of the original system.
--Loren
I think the point of Loren's blog is not that MATLAB's inv function is particularly slower or more inaccurate than any other numerical implementation of computing a matrix inverse; rather, that in most cases the inverse itself is not needed, and you can proceed by other means (such as solving a linear system using \ - the backslash operator - rather than computing an inverse).
inv() is certainly slower than \ unless you have multiple right hand side vectors to solve for. However, the advice from MathWorks regarding inaccuracy is due to a overly conservative bound in a numerical linear algebra result. In other words, inv() is NOT inaccurate. The link elaborates further : http://arxiv.org/abs/1201.6035
Several widely-used textbooks lead the reader to believe that solving a linear system of equations Ax = b by multiplying the vector b by a computed inverse inv(A) is inaccurate. Virtually all other textbooks on numerical analysis and numerical linear algebra advise against using computed inverses without stating whether this is accurate or not. In fact, under reasonable assumptions on how the inverse is computed, x = inv(A)*b is as accurate as the solution computed by the best backward-stable solvers.
I need to find the roots from the equations as follows (Mathematica):
Sqrt[3]/2*x-(I-x*Sqrt[3]/2*c^2)*I/Sqrt[2*Pi]/d^3*Integrate[t*Exp[-t^2/2/d^2]/(Sqrt[3]/2*x+I*(t+b0)),{t,-Inf,Inf}]=0
i.e. as the picture shows:
where c, d, and b0 is given parameters, x is a complex root needs to find.
I have tried several methods, including scanning the real and imagine part of x and the iteration approach, but non of them could resolve all the cases.
Are there any general approaches that could solve such kind of equation efficiently, or by MATLAB/Mathematica?
did you try Matlab's mupad? it is a powerful symbolic tool, very similar to Maple wich gives really good results in non-numerical mathematics. Try there. declare the equation, give assumptions to the software ,i.e assume c real positive (don't copy this, I dont remember the proper syntax) and then solve! It will very likely find a solution if it exits (sometimes in some mathematical cases that you even don't know!)
I read at a few places (in the doc and in this blog post : http://blogs.mathworks.com/loren/2007/05/16/purpose-of-inv/ ) that the use of inv in Matlab is not recommended because it is slow and inaccurate.
I am trying to find the reason of this inaccuracy. As of now, Google did not give m interesting result, so I thought someone here could guide me.
Thanks !
The inaccuracy I mentioned is with the method INV, not MATLAB's implementation of it. You should be using QR, LU, or other methods to solve systems of equations since these methods don't typically require squaring the condition number of the system in question. Using inv typically requires an operation that loses accuracy by squaring the condition number of the original system.
--Loren
I think the point of Loren's blog is not that MATLAB's inv function is particularly slower or more inaccurate than any other numerical implementation of computing a matrix inverse; rather, that in most cases the inverse itself is not needed, and you can proceed by other means (such as solving a linear system using \ - the backslash operator - rather than computing an inverse).
inv() is certainly slower than \ unless you have multiple right hand side vectors to solve for. However, the advice from MathWorks regarding inaccuracy is due to a overly conservative bound in a numerical linear algebra result. In other words, inv() is NOT inaccurate. The link elaborates further : http://arxiv.org/abs/1201.6035
Several widely-used textbooks lead the reader to believe that solving a linear system of equations Ax = b by multiplying the vector b by a computed inverse inv(A) is inaccurate. Virtually all other textbooks on numerical analysis and numerical linear algebra advise against using computed inverses without stating whether this is accurate or not. In fact, under reasonable assumptions on how the inverse is computed, x = inv(A)*b is as accurate as the solution computed by the best backward-stable solvers.