tomleslie

13876 Reputation

20 Badges

15 years, 164 days

MaplePrimes Activity


These are replies submitted by tomleslie

@raj2018 

You have four equations and seven unknowns - see the attached.

You want to solve for three of the unknowns (ie  phi[d0], u[i10], u[i20] ) which means that you have to supply numerical values for the other four unknowns (ie alpha, delta[d], delta[e], delta[i] ).

The first line of your worksheet states (emphasis added)

How to solve the following set of nonlinear equations and plot variation of u[i01],u[i02] and phi[d0] versus delta[d] for alpha=0.01,delta[d]=1e-4?

Two obvious questions

  1. What values should be used for the variables delta[e], delta[i] ?
  2. How do you plan to produce a plot "versus delta[d]" for a fixed value of delta[d] (ie delta[d]=1e-4)? It doesn't make sense!

NULL

#   How to solve the following set of nonlinear equations and plot variation of u[i01],u[i02] and phi[d0] versus delta[d] for alpha=0.01,delta[d]=1e-4?
#
#

restart;
Eq1:=1.359375000*10^36*delta[d]*phi[d0]-delta[e]+delta[i]+1 = 0:

Eq2:=7.217742610*10^14*u[i10]*(1-2*phi[d0]/u[i10]^2)+2.282450621*10^15*delta[i]*u[i20]*(1-2*phi[d0]/u[i20]^2)-2.206601886*10^17*sqrt(2)*delta[e]*(4*alpha*phi[d0]^2/(3*alpha+1)-16*alpha*phi[d0]/(3*alpha+1)+(24*alpha+1)*exp(phi[d0])/(3*alpha+1)) = 0:

Eq3:=5.882341298*10^8*u[i10]^2+1.203367844*10^9*delta[e]/u[i10]-8.823511948*10^7*u[i20]^2-9.633614643*10^7*delta[e]/(delta[i]*u[i20]) = 0:

Eq4:=2.406735687*10^10*delta[e]/u[i10]+9.633614644*10^8*delta[e]/u[i20]-(delta[e]*(4*alpha/(3*alpha+1)-1)+1.510416667*10^37*delta[d]*phi[d0]^2)*(5.882341298*10^8*u[i10]^2+1.203367844*10^9*delta[e]/u[i10])-1.359375000*10^36*delta[d]*phi[d0]*((1.157401021*10^(-25)*Pi)*u[i10]*sqrt(u[i10]^2+8/Pi)*(1-2*phi[d0]/(u[i10]^2+0.4244131815e-1))^1.0+1.395921345*10^(-54)*u[i10]*sqrt(u[i10]^2+8/Pi)*phi[d0]^2*ln((phi[d0]^2/(1000000000000*(u[i10]^2+0.4244131815e-1)^2)+2.005078125*10^14/(1+0.1666666667e-1*delta[e]+.5000000000*delta[i])^1.0)/(phi[d0]^2/(1000000000000*(u[i10]^2+0.4244131815e-1)^2)+(1/1000000000000)*(1-2*phi[d0]/(u[i10]^2+0.4244131815e-1))^1.0))/(u[i10]^2+0.4244131815e-1)^2+(1.157401021*10^(-25)*Pi)*delta[i]*u[i20]*sqrt(u[i20]^2+8/Pi)*(1-2*phi[d0]/(u[i20]^2+0.8488263632e-1))^1.0+1.395921345*10^(-55)*delta[i]*u[i20]*sqrt(u[i20]^2+8/Pi)*phi[d0]^2*ln((phi[d0]^2/(1000000000000*(u[i20]^2+0.8488263632e-1)^2)+2.005078125*10^14/(1+0.1666666667e-1*delta[e]+.5000000000*delta[i])^1.0)/(phi[d0]^2/(1000000000000*(u[i20]^2+0.8488263632e-1)^2)+(1/1000000000000)*(1-2*phi[d0]/(u[i20]^2+0.8488263632e-1))^1.0))/(u[i20]^2+0.8488263632e-1)^2-4.484955822*10^(-6))+6.240139645*10^(-20)*delta[d]*(7.217742610*10^14*u[i10]*(1-2*phi[d0]/u[i10]^2)+2.282450621*10^15*delta[i]*u[i20]*(1-2*phi[d0]/u[i20]^2)-2.206601886*10^17*sqrt(2)*delta[e]*(4*alpha*phi[d0]^2/(3*alpha+1)-16*alpha*phi[d0]/(3*alpha+1)+(24*alpha+1)*exp(phi[d0])/(3*alpha+1))) = 0:
 

`union`(indets~([Eq1,Eq2,Eq3,Eq4], name)[]) minus {constants};

{alpha, delta[d], delta[e], delta[i], phi[d0], u[i10], u[i20]}

(1)

 

NULL


 

Download nonL.mw

@sk04 

Obvious question - should Maple produce an 'Error'?  Obvious answer, No!

Less obvious question - why does this happen? I'm not really sure, but I think it probably has something to do with the fact that you do not *really* have a system of PDEs - you actually have a system of ODEs, which are "disuguised" ro look like PDEs.

In the system

  sys:= [ diff(y(t), t) = k*y(t),
          diff(x(r, t), t) = y(t) * exp(r^2/2*sigma^2)
        ];
  ibc:= [ y(0) = 0,
          x(r, 0) = 0
        ];

 

it is obvious that the first equation in 'sys' is an ODE. One could also argue that the second equation is also an ode, since nothing in the system changes if I simply rewrite it as

  sys:= [ diff(y(t), t) = k*y(t),
          diff(x(t), t) = y(t) * exp(r^2/2*sigma^2)
        ];
  ibc:= [ y(0) = 0,
          x(0) = 0
        ];

The attached shows to to solve both of the above cases. The answer is always {x(r, t) = 0, y(t) = 0}.

Whether Maple's difficulty arises from the fact that the solution is identically zero, or the fact that the system is actually ODE rather than PDE is not obvious to me

  restart;
#
# Keep the system as general as possible -ie don't
# assign values for 'k' and 'sigma'
#
# k := 0.1:
# sigma := 0.1:
#
  sys:= [ diff(y(t), t) = k*y(t),
          diff(x(r, t), t) = y(t) * exp(r^2/2*sigma^2)
        ];
  ibc:= [ y(0) = 0,
          x(r, 0) = 0
        ];
 

[diff(y(t), t) = k*y(t), diff(x(r, t), t) = y(t)*exp((1/2)*r^2*sigma^2)]

 

[y(0) = 0, x(r, 0) = 0]

(1)

#
# Compute symbolic solution with no boundary conditions
#
  pdsymbolic:=pdsolve( sys);
#
# Now evaluate this solution when t=0
#
  stage1:=eval(%, t=0);
#
# Notice that the IC on y(t) has y(0)=0, which has the effect
# of requiring that _C1=0
#
  stage2:=eval(stage1, y(0)=0 );
#
# Substitute this requirement in the expression for x(r,t)
#
  stage3:=eval( pdsymbolic, isolate(stage2[1], _C1));
#
# Now include the boundary condition x(r,0)=0
#
  stage4:=isolate( eval(eval(stage3[1], t=0), x(r,0)=0), _F1(r));
#
# So applying thes conditions to the original symbolic
# solution results in the complete solution with ics
# included as
#
  eval( pdsymbolic, [_C1=0, stage4]);

{x(r, t) = _C1*exp(k*t+(1/2)*r^2*sigma^2)/k+_F1(r), y(t) = _C1*exp(k*t)}

 

{x(r, 0) = _C1*exp((1/2)*r^2*sigma^2)/k+_F1(r), y(0) = _C1}

 

{0 = _C1, x(r, 0) = _C1*exp((1/2)*r^2*sigma^2)/k+_F1(r)}

 

{x(r, t) = _F1(r), y(t) = 0}

 

_F1(r) = 0

 

{x(r, t) = 0, y(t) = 0}

(2)

#
# Another way to achieve the same comclusion Note that the
# first equation in 'sys' and the associated initial condition
# is actually an ORDINARY differential equation - there is no
# dependence on 'r' anywhere!
#
# This equation can be solved with 'odesolve()'
#
  dsolve( [sys[1], ibc[1]]);
#
# Substituting this expression in the second differential equation
# and solving it - agina using only dsolve()
#
  dsolve(  eval(sys[2], %), x(r,t) );
#
# Consider the impact of the condition x(r,0)=0 on this solution.
# The only possibility is _F1(r)=0!!

y(t) = 0

 

x(r, t) = _F1(r)

(3)

#
# Equivalently, since the second euation in the system isn't
# really a PARTIAL differetnil equation, because the quantity
# 'r'  isn't re\ally any more *significant* than 'k' or 'sigma',
# then one could equally well write
#
  sys:= [ diff(y(t), t) = k*y(t),
          diff(x(t), t) = y(t) * exp(r^2/2*sigma^2)
        ];
  ibc:= [ y(0) = 0,
          x(0) = 0
        ];
  dsolve( [ sys[], ibc[]]);

[diff(y(t), t) = k*y(t), diff(x(t), t) = y(t)*exp((1/2)*r^2*sigma^2)]

 

[y(0) = 0, x(0) = 0]

 

{x(t) = 0, y(t) = 0}

(4)

 

Download oddPDE.mw

 

 

 

@sk04 

see the attached

sys:=[ diff(y(t), t) = k*y(t),
       diff(x(r, t), t) = y(t)*exp(r^2/2*sigma^2)
     ];
pdsolve(sys);

[diff(y(t), t) = k*y(t), diff(x(r, t), t) = y(t)*exp((1/2)*r^2*sigma^2)]

 

{x(r, t) = _C1*exp(k*t+(1/2)*r^2*sigma^2)/k+_F1(r), y(t) = _C1*exp(k*t)}

(1)

 

Download pdsol.mw

@Muhammad Usman 

  1. using sum() commands rather than add(). Please read the help to understand why the latter would be faster.
  2. computing NN^9 triple integrals - thus it runs in polynomial time, in fact O(NN9) Hence NN=3 will take 38X the time for NN=2, and NN=4 will take 512X the time for NN=2 .and so on........

https://www.mapleprimes.com/questions/230841-Problem-In-Execution-Of-Summation-Symbol-

????

@jalal 


 

Série sur les statistiques

NULL

 

NULL

restart

randomize()

NULL

NULL

do V := LinearAlgebra[RandomVector](6, generator = 4 .. 20); if nops(convert(V, set)) = 6 then break end if end do; V1

V1 := sort(V)

V2 := LinearAlgebra[RandomVector](6, generator = 50 .. 100)

M := `<|>`(V1, V2)

Matrix(%id = 18446744074397947054)

(1)

Obs := M[1 .. 6, 1]

Vector[column](%id = 18446744074397942598)

(2)

Eff := M[1 .. 6, 2]

Vector[column](%id = 18446744074397945358)

(3)

df := DataFrame([Obs, Eff], columns = [x[i], n[i]])

_m670093824

(4)

Remove(df, [x[i]])

Vector(1, {(1) = 1})

 

_m672625088

(5)

DocumentTools:-Tabulate(df, widthmode = pixels, width = 100, exterior = none)

Moyenne := evalf[6](Statistics:-Mean(Obs, weights = Eff, ignore = true))

13.9070

(6)

NULL

NULL

 

 

NULL


 

Download frame2.mw

@Anthrazit 

the attached


 

  restart;
  div1:= proc(a, b)
              local d:
              d:=a/b:
              return d
         end proc:
#
# A divide by zero error
#
  try ans:=div1(6,0)
  catch:
        printf("Oooops - There was a problem\n")
  end try:
  

Oooops - There was a problem

 

 


 

Download trycat4.mw

 

@aoakindele 

I suggest that you think very carefully about your first boundary condition, ie

F(0)=((-eta^2)/2)*d*Ma

In your system F() is a function of 'eta', and F(0) means compute F() when eta=0 - so what exactly does the right-hand-side of this boundary condition mean? You want it to evaluate to zero (because eta=0), or you want something else? It confuses the hell out of me, and I suspect that Maple isn't going to like it either!

@tomleslie 

If my interpretation of the requirement is correct then the attached does the same thing but is (probably?) marginally more efficient

  restart:
  interface(rtablesize=20):
  poly:=x^4+3*x^3+x^2+2*x+1:
  f:= (p,c)-> Matrix
              ( [ seq
                  ( ListTools:-Reverse
                    ( [  0$(c-degree(p)-1-j),
                         coeffs(p),
                         0$j
                      ]
                    ),
                    j=0..c-degree(p)-1
                  )
                ]
            ):
  f(poly, 5);
  f(poly, 10);
  f(poly, 20);

Vector[row](5, {(1) = 1, (2) = 2, (3) = 1, (4) = 3, (5) = 1})

 

Matrix(6, 10, {(1, 1) = 1, (1, 2) = 2, (1, 3) = 1, (1, 4) = 3, (1, 5) = 1, (1, 6) = 0, (1, 7) = 0, (1, 8) = 0, (1, 9) = 0, (1, 10) = 0, (2, 1) = 0, (2, 2) = 1, (2, 3) = 2, (2, 4) = 1, (2, 5) = 3, (2, 6) = 1, (2, 7) = 0, (2, 8) = 0, (2, 9) = 0, (2, 10) = 0, (3, 1) = 0, (3, 2) = 0, (3, 3) = 1, (3, 4) = 2, (3, 5) = 1, (3, 6) = 3, (3, 7) = 1, (3, 8) = 0, (3, 9) = 0, (3, 10) = 0, (4, 1) = 0, (4, 2) = 0, (4, 3) = 0, (4, 4) = 1, (4, 5) = 2, (4, 6) = 1, (4, 7) = 3, (4, 8) = 1, (4, 9) = 0, (4, 10) = 0, (5, 1) = 0, (5, 2) = 0, (5, 3) = 0, (5, 4) = 0, (5, 5) = 1, (5, 6) = 2, (5, 7) = 1, (5, 8) = 3, (5, 9) = 1, (5, 10) = 0, (6, 1) = 0, (6, 2) = 0, (6, 3) = 0, (6, 4) = 0, (6, 5) = 0, (6, 6) = 1, (6, 7) = 2, (6, 8) = 1, (6, 9) = 3, (6, 10) = 1})

 

Matrix(%id = 18446744074374786454)

(1)

 

Download genMat3.mw

@coopersj 

Within the VectorCalculus package a "vector" is interpreted as a quantity which represents magnitude and direction in some "space". So an obvious(?) thing you might want to know is the length/magnitude of this "vector", because in ths context, length/magnitude means something

Within the LinearAlgebra package a "vector" is a 1-dimensional data container, which could represent (say) the number of cabbages you manage to produce in your garden in successive years. Do you really want to know the"length/magnitude" of this particular "vector"? What would it mean?

@Muhammad Usman 

This prblem scales very badly.

Just because you want a calculation to be performed more quickly does not mean that it can be performed more quickly. You can't always get what you want!!

Essentially you have two choices

  1. Come up with a much better algorithm for your calculation - this will require you to think!
  2. Since the calculations of the integrals appear to be independent, you can rewrite the code to parallelize the problem. Although the number of processors (eg say 8) on a single machine is probably not going to gain you enough to make your problem tractable. The only solution is then to purchase the Maple 'Grid' toolbox and spread the problem over a "gazillion" processors. Various cloud computing companies will provide the 'gazillion processors" - for a fee

@dim____ 

As you can see from the worksheet I originally posted - everythng works perfectly

So what exactly are you doing?

Two suggestions

  1. Specify precise Maple version
  2. Upload the "failing" Maple worksheet using the big green up-arrow in the Mapleprimes toolbae

this time (I think?!)

  restart;
  randomize():
  L:=[ [-1,0],[1,0],[0,-1],[0,1]];
  r:=rand(1..4):
  numpts:=10000:

[[-1, 0], [1, 0], [0, -1], [0, 1]]

(1)

  A:=Array(1..2, 0..numpts):
  A[1,0]:=[0,0]:
  A[2,0]:=[0,0]:
  for j from 1 by 1 to numpts do
      for i from 1 by 1 to 2 do
          A[i,j]:=A[i,j-1]+L[r()];
      od:
  od:
  plot( [ convert(A[1,..], list),
          convert(A[2,..], list)
        ],
        style=line,
        color=[red, blue],
        scaling=constrained
     );

 

 


 

Download rWalk2.mw

@tomleslie 

For a bonus point, spot the logical error in the above!!

@Felipe_123 

Nothing wrong with prevoiusly supplied methods, but I'd probably use the 'combinat' package to generate the original list of vectors, rather than  the 'StringTools' approach. - as in the attached
 

  restart;

  map[2]
  ( LinearAlgebra:-Modular:-Multiply,
    5,
    Vector[row]~( combinat:-permute
                            ( [0$3, 1$3,2$3],
                              3
                            )
                ),
    Matrix( [ [2,1,0,0],
              [0,2,1,0],
              [0,0,2,1]
            ]
          )
  )

[Vector[row](4, {(1) = 0, (2) = 0, (3) = 0, (4) = 0}), Vector[row](4, {(1) = 0, (2) = 0, (3) = 2, (4) = 1}), Vector[row](4, {(1) = 0, (2) = 0, (3) = 4, (4) = 2}), Vector[row](4, {(1) = 0, (2) = 2, (3) = 1, (4) = 0}), Vector[row](4, {(1) = 0, (2) = 2, (3) = 3, (4) = 1}), Vector[row](4, {(1) = 0, (2) = 2, (3) = 0, (4) = 2}), Vector[row](4, {(1) = 0, (2) = 4, (3) = 2, (4) = 0}), Vector[row](4, {(1) = 0, (2) = 4, (3) = 4, (4) = 1}), Vector[row](4, {(1) = 0, (2) = 4, (3) = 1, (4) = 2}), Vector[row](4, {(1) = 2, (2) = 1, (3) = 0, (4) = 0}), Vector[row](4, {(1) = 2, (2) = 1, (3) = 2, (4) = 1}), Vector[row](4, {(1) = 2, (2) = 1, (3) = 4, (4) = 2}), Vector[row](4, {(1) = 2, (2) = 3, (3) = 1, (4) = 0}), Vector[row](4, {(1) = 2, (2) = 3, (3) = 3, (4) = 1}), Vector[row](4, {(1) = 2, (2) = 3, (3) = 0, (4) = 2}), Vector[row](4, {(1) = 2, (2) = 0, (3) = 2, (4) = 0}), Vector[row](4, {(1) = 2, (2) = 0, (3) = 4, (4) = 1}), Vector[row](4, {(1) = 2, (2) = 0, (3) = 1, (4) = 2}), Vector[row](4, {(1) = 4, (2) = 2, (3) = 0, (4) = 0}), Vector[row](4, {(1) = 4, (2) = 2, (3) = 2, (4) = 1}), Vector[row](4, {(1) = 4, (2) = 2, (3) = 4, (4) = 2}), Vector[row](4, {(1) = 4, (2) = 4, (3) = 1, (4) = 0}), Vector[row](4, {(1) = 4, (2) = 4, (3) = 3, (4) = 1}), Vector[row](4, {(1) = 4, (2) = 4, (3) = 0, (4) = 2}), Vector[row](4, {(1) = 4, (2) = 1, (3) = 2, (4) = 0}), Vector[row](4, {(1) = 4, (2) = 1, (3) = 4, (4) = 1}), Vector[row](4, {(1) = 4, (2) = 1, (3) = 1, (4) = 2})]

(1)

 


Download cv2.mw

First 41 42 43 44 45 46 47 Last Page 43 of 207