sand15

1319 Reputation

15 Badges

11 years, 18 days

MaplePrimes Activity


These are answers submitted by sand15

... and the answer remains the same: How can expect that solve will find the the solution of a non linear system of 17 equations in 8 unknowns?
Unless the rank of this system is 8 (and there is no guarantee solve will even succeed) his is a dead end.
So you will find in the attached file an alternative method which enables finding a solution "in the least squares sense" (something I already told you about a couple of times several months ago).

test-F-p_sand15.mw

As several members already told you the result is unevaluated in some "ancient" Maple versions.

Nevertheless evaluation can be obtained if you observe that the exponent 

2*sqrt(tau^2-1)/(sqrt(tau-1)*sqrt(tau+1))

is equal to 2 if tau > -1 and -2 otherwise and if you use proper simplification assumptions. 
Evaluation.mw

PS: I suppose someone smarter than me could achieve the same result in a simpler way.

try

Sol := unapply(sol, x):
eval(convert(IC, diff), Sol(x0));

Or in a row

eval(convert(IC, diff), unapply(sol, x)(x0))

Download A_way.mw

By the way, why are you so prudish that you refuse to call  this "other software" MMA ?

The  modulus of solnum is the simplest case to deal with.
Given it's theoritical range of variation [0, +oo) the effective range the grid size "captures" can go from 0 to 104 with a [300, 300] grid.

So it is impossible to get a smart representation of the level curves unless you lessen this range of variation. One simple way to do this is to apply the log function (or some surd function) to the expression to plot.
Using a "compressor"  such as log, for instance, introduces extra issues because the quantity to plot must be strictly positive (whichis why I concentrated on |solnum| ).
Note that a "compressor" is a trick which enables to get a smart plot, but the level curves or the colored region do not give a faithful representation.

The main idea to have a good spacing between level curves is to aggregate pieces of |solnum| contourplorts instead of |solnum| ina row.
Examples are provided in the attached file.

To reduce the size of the grids and still get a nice picture I suggest you to account for the z-periodicity of solnum (see the attached file).

At the end you will be able to get something like this by tuning the regularizer (f), the ranges of |solnum| pieces (r1, r2, r3), the contour lists or the coloring.


The plots are removed in the the attached worksheet (size 66 Mb instead)
plot-help_sand15.mw

This is not because Maple is powerfull that not using what  one does by hand is a useless strategy. Which in your case means that replacing k by a complex expression before trying to simplify this latter is a very bad way to proceed.

BTW: A syntax like  f(x) := something is not accepted in Maple 2015 (the version I use), So I used these f := x -> something notations instead. Feel free to modify them in your own code.

More of this there is no need to define Phi(x, t) the way you did because Phi(x, t) = C*Omega(x, t) where C is some constant

restart

_local(gamma):

with(PDEtools):

undeclare(prime)

`There is no more prime differentiation variable; all derivatives will be displayed as indexed functions`

(1)

U := proc (xi) options operator, arrow; B[1]*sec(xi) end proc:

xi := k*x-t*v:

 

case1 := [k = v*(l*q*v^2-l*q*w^2-2*l*s*w+lambda*q)/(q*w+s), l = l, q = q, r = -2*l*v^2/B[1]^2, s = s, v = v, w = w, A[0] = 0, A[1] = 0, B[1] = B[1]]:

Omega := proc (x, t) options operator, arrow; B[1]*sec(k*x-v*t)*exp(I*(lambda*x-w*t)) end proc:

# You could write instead:
#
# Phi := Omega(x, t) * C
#
# Where C is some constant that explicit value does nothing but comlicate the simplification process.

pde := l*(diff(Phi(x, t), `$`(t, 2)))+I*(diff(Phi(x, t), x)+q*(diff(Omega(x, t), t)))+r*V(xi)^2*Phi(x, t)+s*Omega(x, t) = 0:

simplify(pde, trig):

simplify(%, size)

(-v^2*q^2*(2*l^2*w*v^3+k*l*v^2+(2*l^2*w^3+2*l*lambda*w-q^2*w-q*s)*v+k*(l*w^2+lambda))*cos(k*x-t*v)^2+I*sin(k*x-t*v)*v^2*q^2*((2*l*w-q)*v+k)*((2*l*w+q)*v+k)*cos(k*x-t*v)+(2*l*v*w+k)*(4*l^2*r*v^2*w^2*B[1]^2+4*k*l*r*v*w*B[1]^2+2*l*q^2*v^4+k^2*r*B[1]^2))*exp(I*lambda*x-I*t*w)*B[1]/(cos(k*x-t*v)^3*q^3*v^3) = 0

(2)

eval((-v^2*q^2*(2*l^2*w*v^3+k*l*v^2+(2*l^2*w^3+2*l*lambda*w-q^2*w-q*s)*v+k*(l*w^2+lambda))*cos(k*x-t*v)^2+I*sin(k*x-t*v)*v^2*q^2*((2*l*w-q)*v+k)*((2*l*w+q)*v+k)*cos(k*x-t*v)+(2*l*v*w+k)*(4*l^2*r*v^2*w^2*B[1]^2+4*k*l*r*v*w*B[1]^2+2*l*q^2*v^4+k^2*r*B[1]^2))*exp(I*lambda*x-I*t*w)*B[1]/(cos(k*x-t*v)^3*q^3*v^3) = 0, case1):

``

Download pdetest2_sand15.mw

After the M, b := ... line insert these to verify what b is:

b;


# So b[3] is not assigned:

b[3];
Error, Vector index out of range


The error comes from you writting

M, b := GenerateMatrix(eqs, [lambda[1], lambda[2]])

Which redefines b as a zero vector of dimension 2: thus  b = <0 | 0> and the b[3] term in M generates an error.

Cure: write instead

M, B := GenerateMatrix(eqs, [lambda[1], lambda[2]])

to keep b unchanged

S_sand15.mw

@nm 

As far as I can remember, exportplot, called from cmaple, has never worked properly for versions 15 through 2021, whether on Windows or Mac OS.

I always used this kind of workaround:

d := currentdir()

# f := cat(d, "/test.png »);  # doesn't work with maple 2015 (driver unknown)

f := cat(d, "/test.jpeg");

p:=plot(x^3, x = -8 .. 8, color = "blue",axis=[gridlines=[10,color="red"]]):

g := seq(plot(y, x=-8..8, color=red), y=[seq](-500..500, 100)), seq(plot([[x, -500], [x, 500]], color=red), x=[seq](-8..8, 2)):

pg := plots:-display(p, g):    

plottools:-exportplot(f, pg);  


Here is the file exported from Cmaple (Max OSX)

Note that the rendering still remains quite bad.


... which is probably non optimal and whose efficiency could likely be enhanced by someone who have enough time to spend on it.
Note that an obvious way to fasten this code is to add the numpoints option in the plot command. For instance numpoints=30 makes the code about seven times faster.

The code is generic in the sense it will enable you to

  • plot any of your 6 functions
  • versus any of one of the 4 parameters,
  • giving to any one of the 3 remaining ones a list of values,
  • and to the last 2 parameters a single value.

Generic_2d_plot_sand15.mw

The plots below are those you asked for


But as I said earlier the code enables you to draw any expression built from traceable quantities (those  listprocedure contains):


Several examples are given in the attached file, among them:

@Teep 

From Optimization/General/Options help page:

depthlimit = posint
Set the maximum depth of the branch-and-bound tree. This option is only used by the Optimization[LPSolve] command for integer programs. 
The default is the maximum of 2 and ceil(3*n/2).
The internal workspace allocated by the integer programming solver depends on the value of depthlimit.  If, during the computation, the workspace is found to be insufficient, an error is issued indicating that depthlimit must be increase
d.

The attached worksheet presents some tracks on a simplified problem (5 jobs and 5 machines):

  1. For this n=26 variable problem the default value of depthlimit is 114 and wasn't large enougth to avoid the

    Error, (in Optimization:-LPSolve) maximal depth, 500, of branch and bound search is too small; use depthlimit option to increase depth

  2. Using depthlimit=1000 returns a solution with performances

    memory used=3.47MiB, alloc change=1.93MiB, cpu time=3.70m, real time=3.71m, gc time=0ns

  3. Using depthlimit=600 returns the same solution with better performances

    memory used=2.21MiB, alloc change=1.62MiB, cpu time=5.10m, real time=5.13m, gc time=0ns
    Which suggests to use only the necessary depthlimit value, no more (which is rethorical)

  4. Using depthlimit=500 returns the same error as with the default depthlimit value

  5. Using again the same depthlimit=500 value but restricting the number of nodes to explore (nodelimit=10^5)
    gives almost the same solution than depthlimit=600 with nodelimit=0 ... but it's  about seven times faster:
    memory used=1.97MiB, alloc change=1.55MiB, cpu time=43.61s, real time=43.67s, gc time=0ns

So I suggest you not to keep increase depthlimit (which penalizes the computational time), but set it to  a value reasonably larger than the default one (182) and increase progressively nodelimit until the  optimal solution no longer evolves.

5 jobs and 5 machines  Some_tracks_5_5.mw   !!! read red text below
5 jobs and 8 machines  Some_tracks_5_8.mw   !!! read red text below

When opening again those same files with Maple 2015 (the version I use) suprious errors appear due to some invisible character in some command blocks.
Here is the (partially) rewritten code for the 5 jobs and 8 machines case 

Some_tracks_5_8_(new).mw

XT_sand15.mw provides a very simple solution.

Nevertheless changing the x range or the tvalue will very likely make this error to appear

Error, (in dsolve/numeric/bvp) Newton iteration is not converging

Despite it is a very classical error for which some recipes do exist to fix it, see dsolve/numeric_bvp/advanced help page and the so-called continuation method, it can be hard to find the correct way to use this trick.
I blindly tried some possibilities but even I can't say any of them gave satisfaction.
Another possibility might be ti initoiate the dsolve process by giving some approximate solution  (search for approsoln in dsolve/numeric/BVP help page).

Generaly this kind of issue cannot be fixed by applying blindly those recpes and the one which is best placed to use them in an enlightened manner is the one who understands the physics underlying the differential system to be solved, i.e., you.

When several quantities have the same range of variation and this range is much greater than the relative variations between these same quantities, there is no choice but to represent the absolute or relative differences in order to highlight the differences.

Q_SEPARATE_sand15.mw

(if this suits you change the vertical label accordingly)

You wrote "i have four equations i want make them be bigger or smaller than zero" which does mean anything.
Do you mean "I want their solutions to be larger or smaller than 0"?
More precisely doyou mean "I want all w, p, chi and beta[1] to be positive or all w, p, chi and beta[1] to be negative" ?

If it is so there is no 6-uple (S1, S2, S3, T1, beta[2], k) such that all w, p, chi and beta[1] have the same sign.
It is indeed very simple toprove that chi*p is always negative, meaning chi and p have different signs:
 

restart

NULL

eq1 := S__1 = sqrt((-beta[1]+sqrt(4*k^2*p*beta[2]+4*w*beta[2]+beta[1]^2))/beta[2]):

sol := solve(eqs, {chi, p, w, beta[1]})

{chi = -(1/4)*beta[2]*(S__1^2*S__2^2-S__1^2*T__1^2-2*S__2^2*T__1^2+2*T__1^4)/S__3^2, p = (1/2)*T__1^2*beta[2]*(S__1^2*S__2^2-S__1^2*T__1^2-2*S__2^2*T__1^2+2*T__1^4)/S__3^2, w = -(1/2)*beta[2]*(S__1^2*S__2^2*T__1^2*k^2-S__1^2*T__1^4*k^2-2*S__2^2*T__1^4*k^2+2*T__1^6*k^2+S__1^2*S__2^2*S__3^2)/S__3^2, beta[1] = -(1/2)*S__1^2*beta[2]-S__2^2*beta[2]}

(1)

eval(chi*p, sol);

-(1/8)*beta[2]^2*(S__1^2*S__2^2-S__1^2*T__1^2-2*S__2^2*T__1^2+2*T__1^4)^2*T__1^2/S__3^4

(2)

 

NULL

 

Download condition-parameters_sand15.mw


If you want to find a 6-uple (chi, w, p, k, beta[1], beta[2]) such that botg S1, S2, S3, T1 are positive look here condition-parameters_2_sand15.mw
 


 

First point: avoid using multiple restart command in your worksheet.

In my answer I deleted all which is before the second restart and focused on this error

p1 := contourplot(P, u=-1..1, v=-1..1, scaling=constrained,
    colorscheme="DivergeRainbow", contours=[seq](x, x=-0.5..0.5,0.05)):
Error, (in plot/iplot2d:-Levels) could not evaluate expression

When you get such a message the first thing to do is to display tha quantity to plot (P) to try and see if it is plottable.

This is not the case in your worksheet because P depends on 6 parameters k1, s1, ..., s5 beyond u and v.
So give them all numeric values and and plot. Illustration below:

restart:

with(plots):

Let's write diff(u(x), x) = f(u(x), v(x)), diff(v(x), x) = g(u(x), v(x)) for the two differential equations.

f := (u,v) -> v*(2*chi*u^2 + p):
g := (u,v) -> -beta[2]*u^5 - 2*chi*u*v^2 + u*p*k^2 - beta[1]*u^3 + u*w:

# i have to change parameter for more simplicity work, so i change the parameter of equation and i use another letter

#k[1]=2*chi,k[2]=p, s[1]=-beta[2], s[2]=2*chi, s[3]=p*k^2, s[4]=beta[1], s[5]=w

f := proc (u, v) options operator, arrow; v*(k[1]*u^2+k[2]) end proc:

g := proc (u, v) options operator, arrow; s[1]*u^5-s[2]*u*v^2+u*s[3]-s[4]*u^3+u*s[5] end proc:

The equilibria:

equilibria := solve({f(u,v)=0, g(u,v)=0}, {u,v},explicit):

The differential equations (not needed in this worksheet)

de1 := diff(u(t),t) = f(u(t),v(t)):
de2 := diff(v(t),t) = g(u(t),v(t)):

PDEtools:-ConservedCurrents({de1, de2}, [u(t), v(t)]):

The conserved quantity

P := -((-s[1]*s[2]*(k[1] + s[2])*u^4/2 + s[2]*(k[1]*s[4] + k[2]*s[1] + 1/2*s[2]*s[4])*u^2 + s[2]*(k[1] + s[2])*(k[1] + s[2]/2)*v^2 + ((-s[3] - s[5])*s[2]^2)/2 + ((3*(-s[3] - s[5])*k[1] - k[2]*s[4])*s[2])/2 + (-s[3] - s[5])*k[1]^2 - k[1]*k[2]*s[4] - k[2]^2*s[1])*(k[1]*u^2 + k[2])^(s[2]/k[1]))/(2*s[2]*(k[1] + s[2])*(k[1] + s[2]/2)):

#Let's take F__1 = 1, F__2 = -1NULL

#F__1, F__2 := 1, -1:

Here are the equilibra now

equilibria:

 

EE := subs({sqrt(-k[1]*k[2])/k[1] = X[1], sqrt(s[2]*(k[1]^2*s[3]+k[1]^2*s[5]+k[1]*k[2]*s[4]+k[2]^2*s[1]))/(s[2]*k[1]) = T[3], (1/2)*sqrt(2)*sqrt((s[4]+sqrt(-4*s[1]*s[3]-4*s[1]*s[5]+s[4]^2))/s[1]) = T[1], (1/2)*sqrt(-(2*(-s[4]+sqrt(-4*s[1]*s[3]-4*s[1]*s[5]+s[4]^2)))/s[1]) = T[2]}, equilibria)

{0 = -T[3], 0 = -X[1]}

(1)

U := v*(u^2*k[1]+k[2])

v*(u^2*k[1]+k[2])

(2)

V := u^5*s[1]-u^3*s[4]-u*v^2*s[2]+u*s[3]+u*s[5]

u^5*s[1]-u^3*s[4]-u*v^2*s[2]+u*s[3]+u*s[5]

(3)

var := u, v:

J := Student:-MultivariateCalculus:-Jacobian([U, V], [var], 'output' = 'matrix'):

LinearAlgebra:-Determinant()

Error, invalid input: LinearAlgebra:-Determinant uses a 1st argument, A (of type `~Matrix`), which is missing

 

J := Student:-MultivariateCalculus:-Jacobian([U, V], [var] = [0, 0], 'output' = 'matrix'):

LinearAlgebra:-Determinant()

Error, invalid input: LinearAlgebra:-Determinant uses a 1st argument, A (of type `~Matrix`), which is missing

 

s__3 := 1; -1; s__5 := 1; -1; k[2] := 1

1

(4)

#det := Determinant(J):    # the determinant
#tra := Trace(J):          # the trace
#dsc := tra^2 - 4*det:     # the discriminant (Delta)
#Eigenvalues(J):           # the eigenvalues

x(t)

x(t)

(5)

diff~(<x(t),y(t)>, t) =~ J . <x(t),y(t)>:
sys := {seq}(%):

ic := [x(0)=1,y(0)=1], [x(0)=-1,y(0)=1], [x(0)=1,y(0)=-1], [x(0)=-1,y(0)=-1]:

DEplot(sys, [x(t),y(t)], t=0..8, [ic], axes=normal, tickmarks=[0,0], labels=["",""], dirfield=[10,10], arrows=comet, color="DarkCyan"):

equilibria:

Plot the phase portrait

p1 := contourplot(P, u=-1..1, v=-1..1, scaling=constrained,
    colorscheme="DivergeRainbow", contours=[seq](x, x=-0.5..0.5,0.05)):

Error, (in plot/iplot2d/levelcurve) could not evaluate expression

 

# What is P?

P;

# Does P contain some undefined quantities other than 'u' and 'v'?

Pind := convert(indets(P, name) minus {u, v}, list);

# P contains 6 unknown quantities and thus cannot be plotted

-(1/2)*(-(1/2)*s[1]*s[2]*(k[1]+s[2])*u^4+s[2]*(k[1]*s[4]+s[1]+(1/2)*s[2]*s[4])*u^2+s[2]*(k[1]+s[2])*(k[1]+(1/2)*s[2])*v^2+(1/2)*(-s[3]-s[5])*s[2]^2+(1/2)*(3*(-s[3]-s[5])*k[1]-s[4])*s[2]+(-s[3]-s[5])*k[1]^2-k[1]*s[4]-s[1])*(u^2*k[1]+1)^(s[2]/k[1])/(s[2]*(k[1]+s[2])*(k[1]+(1/2)*s[2]))

 

[k[1], s[1], s[2], s[3], s[4], s[5]]

(6)

# Correction: give Pind numeric values BEFORE plotting, for instance

eval(P, Pind =~1);
contourplot(eval(P, Pind =~1), u=-1..1, v=-1..1, scaling=constrained, colorscheme="DivergeRainbow");

-(1/6)*(-u^4+(5/2)*u^2+3*v^2-17/2)*(u^2+1)

 

 
 

 

Download Why_cannot_P_be_plotted.mw

What do the regions labelled  TM1, TM2, TM3 are aimed to represent?

Did you mean this: Regions_where_each_TMi_is_the_largest.mw

restart;

with(geometry):

with(StringTools):

interface(worksheetdir):

currentdir(%):

toX := proc(e)
  if e::list then
    cat(
      "\\left(",
      seq( cat(latex(u, 'output' = 'string'), "; "), u in e[1..-2]),
      latex(e[-1], 'output' = 'string'),
      "\\right)"
    )
  else
    latex(e, 'output' = 'string')
  end if:
end proc:

printf("\\documentclass[12pt]{article}\n"):

printf("\\usepackage{amsmath,amssymb}\n"):

printf("\\usepackage{enumitem}\n"):

printf("\\begin{document}\n\n"):

f := x -> (x^2 + 4*x + 7)/(x + 1):

df := simplify(diff(f(x), x)):

cuctri := sort([solve(df = 0, x)], key = evalf):

g := simplify(diff(df, x)):

xcd := rhs(solve([df = 0, g(x) < 0], x)[1]):

xct := rhs(solve([df = 0, 0 < g(x)], x)[1]):

ycd := simplify(f(xcd)):

yct := simplify(f(xct)):

mycd := coordinates(point(A, xcd, ycd)):

myct := coordinates(point(B, xct, yct)):

L := [cat("Let a function be given: $y = ", toX(f(x)), "$."), cat("Its derivative is: $y' = ", toX(df), "$."), cat("The maximum point of the graph  $ ", toX(mycd), "$.")]:

 

printf("\\begin{enumerate}[label=\\arabic*)]\n");

for item in L do

    printf("\\item %s\n", item);

end do;

printf("\\end{enumerate}\n\n");

printf("\\end{document}\n\n");

 

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\begin{document}

\begin{enumerate}[label=\arabic*)]
\item Let a function be given: $y = {\frac {{x}^{2}+4\,x+7}{x+1}}$.
\item Its derivative is: $y' = {\frac {{x}^{2}+2\,x-3}{ \left( x+1 \right) ^{2}}}$.
\item The maximum point of the graph  $ \left(-3; -2\right)$.
\end{enumerate}

\end{document}

 

 

Download One_way.mw

1 2 3 4 5 6 7 Last Page 1 of 9