tomleslie

13876 Reputation

20 Badges

15 years, 175 days

MaplePrimes Activity


These are answers submitted by tomleslie

The following *seems* to work irrespective of whether the worksheets contain the character sequence 'Variational Calculus' in plaintext or not - so it works when 'grep' or 'editor-based' approaches do not.

Structure is similar to the code I posted before, but rather than using FileTools:-ReadFile, the main difference is to use WorksheetToMapleText() from the Worksheet package.

On the tests I have run (in both 1D input and 2D-input), it will detect any files using

with(VariationalCalculus)

as well as any case where commands in the VariationalCalculus package have been referenced in 'long form', eg

VariationalCalculus[someCommand], or

VariationalCalculus:-someCommand

What it will not detect is the case where the VariationalCalculus package is loaded by the target worksheet reading/referring to additional files.

  restart;
  with(Worksheet):
  with(FileTools):
  with(StringTools):
#
# Specify the directory where files are stored.
# Obviously OP will need to chnge this to something
# relevant for his/her machine.
#
  dirName:="D:/Users/TomLeslie/myMaple/SearchTest":
#
# Get the names of all the files in the specified
# directory. Possible also that one might want to
# filter this list, so that only files with
# appropriate extensions (eg ".mw", ".mws", ".mpl")
# are retained
#
  contents:=ListDirectory( dirName );
#
# Intialise a sequence which will store the names
# of the files which *do* contain the string
# with(VariationalCalculus)
#
  contains:=NULL:
#
# Process each of the files in turn
#
  for j in contents do
    #
    # Check if the file contains the string
    # "with(VariationalCalculus)"
    #
      astr:=  WorksheetToMapleText(cat( dirName, "/", j)):
      if Search( "with(VariationalCalculus)",
                 astr
               )
         +
         Search( "VariationalCalculus:-",
                 astr
               )
         +
         Search( "VariationalCalculus[",
                 astr
               )
         >0
    #
    # If it does, add the file name to the
    # contains sequence
    #
      then contains:=contains, j;
      fi;
  od:
  contains;

 

Download search2.mw

Maple has two major types of commands  - one of which is 'builtin' and the other is not usually named, but can be thought of as 'not builtin'. It is actually slightly easier to explain what a 'not builtin' function is!!

A function which is 'not builtin is actually written as a procedure in the Maple language, and the code of this procedure can be examined. For example you might think that the sine function sin() is a very low-level function which just 'gets evaluated". However if you execute the command

showstat(sin);

this will display the Maple procedure which is run every time you use sin(). This procedure mainly does a lot of argument checking whilst it figures out what to do with whatever argument you have supplied. It may call sub-procedures etc etc until eventually a decision  can be made on exactly what calls to the kernel (if any) are necessary.

Consider as a trivial example the simple case where the argument of sin() is the unassigned name 'x'. Simply passing this directly to C would just result in an error, because the latter (like most programming languages)generally doesn't know what to do with the 'sine' of an 'unknown'

On the other hand 'builtin' commands are not written as Maple procedures: They can access sort-of-equivalent C commands in the kernel more or less direclty, because it is safe to do so

I tend to agree with Joe Riel that other tools may be more appropriate for the job.

As well as 'grep', assorted hack tools like perl/python would work. In fact any decent programmer's editor (emacs/notepad++) would do the job very efficiently - and one of those previously mentioned would probably be my first choice!

But it can be done using only Maple, if you really want to.

Consider a "toy" example where I have two Maple (ie .mw) files

with(VariationalCalculus):
f := (diff(x(t),t)^2 + diff(y(t),t)^2)^(1/2):
EulerLagrange( f, t, [x(t),y(t)]):
g := (1 + diff(y(t),t)^2)^(1/2)/y(t)^(1/2):

and

f := (diff(x(t),t)^2 + diff(y(t),t)^2)^(1/2):
EulerLagrange( f, t, [x(t),y(t)]):
g := (1 + diff(y(t),t)^2)^(1/2)/y(t)^(1/2):

stored as foo.mw and bar.mw respectively - so one want to "read" these with Maple, figure out which one contains the 'with(VariationalCalculus)' command, and return the file name, in this case 'foo.mw'  This can be achieved with the attached, although there are a few provisos

  1. The directory where the files are stored, specified as dirName in the attached will have to be chenged to something appropriate for your machine: ie the directory where all your files are stored
  2. It would not be difficult to modify the following to handle files in multiple directories - just needs two loops rather than one, with the outer loop being a list of directories
  3. The code makes no distinction between Maple files and any other files you might have the same directory(ies). Again it would not be very difficult to restrict the file processing to only those files with .mw, .mws, .mpl extensions

 

  restart;
  with(FileTools):
  with(FileTools[Text]):
  with(StringTools):
#
# Specify the directory where files are stored.
# Obviously OP will need to chnge this to something
# relevant for his/her machine.
#
  dirName:="D:/Users/TomLeslie/myMaple/SearchTest":
#
# Get the names of all the files in the specified
# directory. Possible also that one might want to
# filter this list, so that only files with
# appropriate extensions (eg ".mw", ".mws", ".mpl")
# are retained
#
  contents:=ListDirectory( dirName );
#
# Intialise a sequence which will store the names
# of the files which *do* contain the string
# with(VariationalCalculus)
#
  contains:=NULL:
#
# Process each of the files in turn
#
  for j in contents do
    #
    # Check if the file contains the string
    # "with(VariationalCalculus)"
    #
      if Search( "with(VariationalCalculus)",
                 ReadFile
                 (cat( dirName, "/", j))
               )>0
    #
    # If it does, add the file name to the
    # contains sequence
    #
      then contains:=contains, j;
      fi;
  od;
  contains;

["bar.mw", "foo.mw"]

 

"foo.mw"

(1)

 


 

Download search.mw

  1. Lists can contain duplicate elements, but sets cannot, so Maple will preserve the list [1,1,2,3], but if you enter the set {1,1,2,3}, then Maple will 'simplify' this to {1,2,3}. An element is either a 'member' of a set or it is not: it makes no sense to say that an element is a member of set "more than once"
  2. Lists preserve order of elements, but sets do not. Generally, set elements will be displayed in lexicographic order, although it is always bad programming practice to rely on element ordering in sets, the only thing whihc can be guaranteed is membership

There are other, (more subtle) differences: for example you can reassign the values of elements in a set with

a:=[1,2,3,4];
a[1]:=7;
a;

but this is not possible with sets: probably because Maple considers it bad practice to do anything *significant* to a set, based on element ordering

with a few edits to your original (assuming I haven't made a type somewhere!), you can use pdetest(), but this suggests that your supplied function is not a solution of the pde! See attached


 

  restart;
  assume(r::real, a::real, b::real, upsilon::real, sigma::real, x::real, y::real, t > 0);
  assume(sigma > 0);
  assume(-b^2-r+2 > 0);
#
# define equation
#
  pde:=I*(diff(V(x,y,t), t))+diff(V(x,y,t), x, x)+diff(V(x,y,t), y, y)+sigma*abs(V(x,y,t)^2)*V(x,y,t) = 0;
#
# "Supplied solution"
#
  sol:=V(x, y, t) = -2*exp(I*(sqrt(-b^2-r+2)*x+b*y+r*t))*sqrt(1/sigma)*sech(-t*(-2*sqrt(-b^2-r+2)-2*b)-x-y);
#
# Test this solution in the pde
#
  pdetest( sol, pde);

I*(diff(V(x, y, t), t))+diff(diff(V(x, y, t), x), x)+diff(diff(V(x, y, t), y), y)+sigma*abs(V(x, y, t))^2*V(x, y, t) = 0

 

V(x, y, t) = -2*exp(I*((-b^2-r+2)^(1/2)*x+b*y+r*t))*sech(-t*(-2*(-b^2-r+2)^(1/2)-2*b)-x-y)/sigma^(1/2)

 

-64*exp(I*(-b^2-r+2)^(1/2)*x+I*b*y+I*r*t+x+y+2*t*(-b^2-r+2)^(1/2)+2*t*b-2*y*Im(b)-2*t*Im(r))*(-exp(2*y+2*y*Im(b)+2*t*Im(r)+4*t*(-b^2-r+2)^(1/2)+4*t*b+2*x)*abs(exp(2*t*(-b^2-r+2)^(1/2)+2*t*b-x-y)+exp(-2*t*(-b^2-r+2)^(1/2)-2*t*b+x+y))^2+exp(8*t*((-b^2-r+2)^(1/2)+b))+2*exp(2*y+4*t*(-b^2-r+2)^(1/2)+4*t*b+2*x)+exp(4*y+4*x))/(sigma^(1/2)*(exp(4*t*((-b^2-r+2)^(1/2)+b))+exp(2*x+2*y))^3*abs(exp(2*t*(-b^2-r+2)^(1/2)+2*t*b-x-y)+exp(-2*t*(-b^2-r+2)^(1/2)-2*t*b+x+y))^2)

(1)

 


 

Download pdtest.mw

 

On the Maple toolbar

File->Export as->

In the pop-up window use "Files as type" and choose pdf

for determining how Maple deals with branch cuts. This is explaine don the help page for LegendreQ(), LegendreP() - although you have to read very, very carefully (at least I did!). However if one sets _EnvLegendreCut:=1..infinity, then the answer you desire is obtained. See attached.

 

restart;
ode:=(1-x^2)*diff(y(x),x$2)-2*x*diff(y(x),x)+y(x)=0:
sol:=dsolve(ode,y(x));
_EnvLegendreCut:=1..infinity;
plot(LegendreQ((1/2)*sqrt(5)-1/2, x),x=-1..1);
plot(LegendreP((1/2)*sqrt(5)-1/2, x),x=-1..1);

y(x) = _C1*LegendreP((1/2)*5^(1/2)-1/2, x)+_C2*LegendreQ((1/2)*5^(1/2)-1/2, x)

 

1 .. infinity

 

 

 

 


 

Download LegProb.mw

and usually one cannot just choose ics - they are a fundamental part of the problem. Having said that, solutions are possible for some ics - for example the following

restart;

sys := [6*(diff(a(t), t))^2+12*a(t)*(diff(a(t), t$2))-3*a(t)^2*phi(t)^(-2*c)*sqrt(1-alpha*(diff(phi(t), t))^2), 2*c*a(t)^3*phi(t)^(-2*c-1)*sqrt(1-alpha*(diff(phi(t), t))^2)-3*alpha*a(t)^2*phi(t)^(-2*c)*(diff(a(t), t))*(diff(phi(t), t))/sqrt(1-alpha*(diff(phi(t), t))^2)-alpha*a(t)^3*phi(t)^(-2*c)*(diff(phi(t), t$2))/sqrt(1-alpha*(diff(phi(t), t))^2)+2*c*alpha*a(t)^3*phi(t)^(-2*c-1)*(diff(phi(t), t))^2/sqrt(1-alpha*(diff(phi(t), t))^2)-alpha^2*a(t)^3*phi(t)^(-2*c)*(diff(phi(t), t))^2*(diff(phi(t), t$2))/(1-alpha*(diff(phi(t), t))^2)^(3/2), R(t) = 6*((diff(a(t), t))^2/a(t)^2+(diff(a(t), t$2))/a(t)), W(t) = -phi(t)^(-2*c)*sqrt(1-alpha*(diff(phi(t), t))^2)/(1/a(t)^3+a(t)^3+phi(t)^(-2*c)/sqrt(1-alpha*(diff(phi(t), t))^2))]:

ics:=[a(0)=1, D(a)(0)=1, phi(0)=1, D(phi)(0)=0];


sol:=dsolve( [eval(sys, {c=1, alpha=1})[], ics[]], numeric);
plots:-odeplot( sol,
                [ [t, a(t), color=red],
                  [t, phi(t), color=green],
                  [t, R(t), color=blue],
                  [t, W(t), color=black]
                ],
                t=0..10
              );

 

The attached code will return the minimum value attained by each curve, but

  1. I'm not sure if this is what you want
  2. There are probably better ways to do this, but until (1) above is resolved.....


 

with(Optimization); mu := .5

"f1(r):=(diff(p(r),r))/(r*p(r)):"

"f2(r):=((diff(p(r),r))^(2))/(4*p(r)^(2)):"

"f3(r):=(diff(p(r),r,r))/(2*p(r)):"

ode := 2*(diff(f1(r), r)-(diff(f2(r), r))+diff(f3(r), r))/r+diff(f1(r), r, r)-(diff(f2(r), r, r))+diff(f3(r), r, r)-mu(2*(diff(p(r), r))/r+diff(p(r), r, r)) = p(r)

ic3 := Array([seq(-.9 .. -.8, 0.1e-1)])

curve := Array(1 .. 11); mincurve := Array(1 .. 11)

for i to 11 do ics := p(0.1e-4) = 1, (D(p))(0.1e-4) = 0, ((D@@2)(p))(0.1e-4) = ic3[i], ((D@@3)(p))(0.1e-4) = 0; sol := dsolve({ics, ode}, p(r), numeric, output = listprocedure); curve[i] := rhs(sol[2]); mins[i] := op([2, 2, 1], plottools[getdata](plot(curve[i](r), r = 0 .. 10, y = 0 .. 1.05, labels = [r, rho]))) end do

mins()

(table( [( 1 ) = 0.361234603115666458e-8, ( 2 ) = 0.134435429115665306e-9, ( 3 ) = 0.245841439663303178e-7, ( 4 ) = 0.207477623327257724e-8, ( 5 ) = 0.290360383695426342e-8, ( 6 ) = 0.119537188195598031e-8, ( 7 ) = 0.167038797461898573e-2, ( 9 ) = 0.101769800276362513e-1, ( 8 ) = 0.536893198663344114e-2, ( 11 ) = 0.226106455737484641e-1, ( 10 ) = 0.159457058184886806e-1 ] ))()

(1)

NULL


 

Download getmins.mw

I stored your Matlab script on my "Desktop", as C:/Users/TomLeslie/Desktop/covMarket.m.

I executed the the following code in Maple

restart;
with(Matlab):
FromMFile("C:/Users/TomLeslie/Desktop/covMarket.m",
                    "C:/Users/TomLeslie/Desktop/covMarket.mpl");

This created the following ".mpl" file on my desktop

covMarket := proc( x, shrink )
    uses ArrayTools, LinearAlgebra;
    local sigma, shrinkage;
    # function sigma=covmarket(x)
    # x (t*n): t iid observations on n random variables
    # sigma (n*n): invertible covariance matrix estimator
    #
    # This estimator is a weighted average of the sample
    # covariance matrix and a "prior" or "shrinkage target".
    # Here, the prior is given by a one-factor model.
    # The factor is equal to the cross-sectional average
    # of all the random variables.
    # The notation follows Ledoit and Wolf (2003)
    # This version: 04/2014
    #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    # This file is released under the BSD 2-clause license.
    # Copyright (c) 2014, Olivier Ledoit and Michael Wolf
    # All rights reserved.
    #
    # Redistribution and use in source and binary forms, with or without
    # modification, are permitted provided that the following conditions are
    # met:
    #
    # 1. Redistributions of source code must retain the above copyright notice,
    # this list of conditions and the following disclaimer.
    #
    # 2. Redistributions in binary form must reproduce the above copyright
    # notice, this list of conditions and the following disclaimer in the
    # documentation and/or other materials provided with the distribution.
    #
    # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
    # IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
    # THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
    # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
    # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
    # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
    # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
    # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    #%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    # de-mean returns
    t := ArrayTools[Size](x, 1);
    n := ArrayTools[Size](x, 2);
    meanx := mean(x);
    x := x -~ meanx(rtable(proc(A)
    local j, n;
    if A :: rtable[row] then
       n := ArrayTools:-NumElems(A);
       if n = 1 then
           1..A(1), 1..A(1), fill = 1, subtype = Matrix;
       elif n = 2 then
           1..A(1), 1..A(2), fill = 1, subtype = Matrix;
       else
           seq(1..A(j), j = 1..n), fill = 1, subtype = Array;
       end if;
    else
       seq(1..args[i], i = 1..2), fill = 1, subtype = Array;
    end if;
end proc(t, 1)), ..);
    xmkt := HermitianTranspose(mean((HermitianTranspose(x))));
    sample := MTM[mrdivide](cov(Concatenate(2, x, xmkt)) . (t -~ 1),t);
    covmkt := sample(1..n, (n +~ 1));
    varmkt := sample((n +~ 1), (n +~ 1));
    sample(.., (n +~ 1)) := Vector();
    sample((n +~ 1), ..) := Vector();
    prior := covmkt . HermitianTranspose(covmkt) /~ varmkt;
    prior(map(proc(x) if not x::realcons then error("real input expected"); fi; `if`(x = 0, 0, 1); end, LinearAlgebra[IdentityMatrix]((A->`if`(A::rtable,entries(A,'nolist'),A))(n),'compact'=false))) := evalf(ArrayTools:-Diagonal(sample));
    if ArrayTools[AllNonZero]((evalhf(zip(`or`,eval((evalhf(zip(`<`,eval(nargs),eval(2))))),eval((evalhf(zip(`=`,eval(shrink),eval((-1)))))))))) then
        c := evalf(LinearAlgebra[MatrixNorm]((sample -~ prior),'Frobenius'))^2;
        y := x ^~ 2;
        p := MTM[mrdivide](1,t) . AddAlongDimension(AddAlongDimension(((HermitianTranspose(y)) . y))) -~ AddAlongDimension(AddAlongDimension((sample ^~ 2)));
        # r is divided into diagonal
        # and off-diagonal terms, and the off-diagonal term
        # is itself divided into smaller terms
        rdiag := MTM[mrdivide](1,t) . AddAlongDimension(AddAlongDimension((y ^~ 2))) -~ AddAlongDimension((evalf(ArrayTools:-Diagonal(sample)) ^~ 2));
        z := x *~ xmkt(.., rtable(1..1, 1..n, fill = 1, subtype = Matrix));
        v1 := MTM[mrdivide](1,t) . HermitianTranspose(y) . z -~ covmkt(.., rtable(1..1, 1..n, fill = 1, subtype = Matrix)) *~ sample;
        roff1 := MTM[mrdivide](AddAlongDimension(AddAlongDimension((v1 *~ (HermitianTranspose(covmkt(.., rtable(1..1, 1..n, fill = 1, subtype = Matrix))))))),varmkt) -~ MTM[mrdivide](AddAlongDimension((evalf(ArrayTools:-Diagonal(v1)) *~ covmkt)),varmkt);
        v3 := MTM[mrdivide](1,t) . HermitianTranspose(z) . z -~ varmkt . sample;
        roff3 := MTM[mrdivide](AddAlongDimension(AddAlongDimension((v3 *~ (covmkt . (HermitianTranspose(covmkt)))))),varmkt^2) -~ MTM[mrdivide](AddAlongDimension((evalf(ArrayTools:-Diagonal(v3)) *~ (covmkt ^~ 2))),varmkt^2);
        roff := 2 . roff1 -~ roff3;
        r := rdiag +~ roff;
        # compute shrinkage constant
        k := MTM[mrdivide]((p -~ r),c);
        shrinkage := max(0, min(1, (MTM[mrdivide](k,t))));
    else
        shrinkage := copy(shrink);
    end if;
    # compute the estimator
    sigma := shrinkage . prior +~ (1 -~ shrinkage) . sample;
    # compute the estimator
    if _nresults = 2 then
        return sigma, shrinkage;
    else
        return sigma;
    end if;
end proc;

Does it work? No idea, because I don't know what arguments to provide:-(

 

I assume that when you write e^() you mean exp() - OK?

With this assumption, you can produce a basic field plot over the required range with

with(VectorCalculus):
F := VectorField( < y*z*exp(x*y*z)+3*x^(2),
                                x*z*exp(x*y*z)+2*y*z+cos(y),
                                x*y*exp(x*y*z)+y^(2)+1
                             >
                          ):
plots:-fieldplot3d( F,
                                x=-1..1,
                                y=-1..1,
                                z=-1..1
                           );

Ther are many options available for the fieldplot3d() which you can play with

as in the following. This will provide one solution. If you believe there are further solutions (and there may be) then post back here and someone will take another look at it.

A := 2500

2500

(1)

alpha := 4

4

(2)

beta := 0.2e-1

0.2e-1

(3)

c := 5

5

(4)

x[w] := 10

10

(5)

x[1] := 8

8

(6)

delta := 5

5

(7)

t[d] := .5

.5

(8)

a := 20

20

(9)

b := 25

25

(10)

theta := .5

.5

(11)

m := theta*(1-exp(-.5*xi))

.5-.5*exp(-.5*xi)

(12)

TC(t[1], t[2], xi) := (A+alpha*((1/2)*a*t[d]^2+(1/3)*a*t[d]^3)+beta*((1/6)*a*t[d]^3+(1/8)*a*t[d]^4)+t[d]*(a/(theta-m)+b*(t[d]-1/(theta-m))/(theta-m)-exp((theta-m)*(t[1]-t[d]))*(a/(theta-m)+b*(t[1]-1/(theta-m))/(theta-m)))-a*(-6*beta*b-(6*(theta-m))*(-a*beta+alpha*b)+6*(theta-m)^2*(a*beta*t[1]+alpha*b*t[d])+3*b*beta*(theta-m)^2*(-t[1]^2+t[d]^2)+6*a*alpha*(theta-m)^2+2*b*beta*(theta-m)^3*(t[1]^3-t[d]^3)+3*a*beta*(theta-m)^3*(t[1]^2-t[d]^2)+3*b*alpha*(theta-m)^3*(t[1]^2-t[d]^2)+6*a*alpha*(theta-m)^3*(t[1]-t[d])+6*exp((theta-m)*(t[1]-t[d]))*((6*(theta-m))*(-a*beta+alpha*b)-6*b*beta*(theta-m)*(t[1]-t[d])-6*((theta-m)^2*(-b*beta*t[1]*t[d]+a*beta*t[d]+alpha*b*t[1]+a*alpha)+beta*b)))/(6*(theta-m)^4)+x[1]*(2*a*t[2]*delta^2+2*b*t[1]*t[2].(delta^2)+b*t[2]*delta-2*a*delta*ln(delta*t[2]+1)-2*b*ln(delta*t[2]+1)-2*b*t[1]*delta*ln(delta*t[2]+1)-2*b*t[2]*delta*ln(delta*t[2]+1)+2*b*t[2]*delta)/(2*delta^2)+x[w]*(2*a*t[2]*delta^2+b*t[2]^2*delta^2+2*b*t[1]*t[2].(delta^2)+2*a*delta*t[2]+2*b*t[2]*delta*ln(1/(delta*t[2]+1))+2*b*ln(1/(delta*t[2]+1))+2*a*delta*ln(1/(delta*t[2]+1))+2*b*t[1]*delta*ln(1/(delta*t[2]+1)))/(2*delta^3)+c*(a*t[d]+(1/2)*b*t[d]^3+a/(theta-m)+b*(t[d]-1/(theta-m))/(theta-m)-exp((theta-m)*(t[1]-t[d]))*(a/(theta-m)+b*(t[1]-1/(theta-m))/(theta-m))-a*ln(1/(delta*t[2]+1))/delta-b*(1+delta*(t[1]+t[2]))*ln(delta*t[2]+1)/delta^2-b*t[2]/delta))/(t[1]+t[2])

(2571.157291+220.0000000/exp(-.5*xi)+275.0000000*(.5-2.000000000/exp(-.5*xi))/exp(-.5*xi)-5.5*exp(.5*exp(-.5*xi)*(t[1]-.5))*(40.00000000/exp(-.5*xi)+50.00000000*(t[1]-2.000000000/exp(-.5*xi))/exp(-.5*xi))-53.33333333*(-3.00-298.800*exp(-.5*xi)+1.50*(exp(-.5*xi))^2*(.40*t[1]+50.0)+.3750*(exp(-.5*xi))^2*(-t[1]^2+.25)+120.00*(exp(-.5*xi))^2+.12500*(exp(-.5*xi))^3*(t[1]^3-.125)+37.65000*(exp(-.5*xi))^3*(t[1]^2-.25)+60.000*(exp(-.5*xi))^3*(t[1]-.5)+6*exp(.5*exp(-.5*xi)*(t[1]-.5))*(298.800*exp(-.5*xi)-1.500*exp(-.5*xi)*(t[1]-.5)-1.50*(exp(-.5*xi))^2*(99.750*t[1]+80.200)-3.00))/(exp(-.5*xi))^4+243*t[2]+250*t[1]*t[2]-40*ln(5*t[2]+1)-40*t[1]*ln(5*t[2]+1)-40*t[2]*ln(5*t[2]+1)+25*t[2]^2+10*t[2]*ln(1/(5*t[2]+1))-10*ln(1/(5*t[2]+1))+10*t[1]*ln(1/(5*t[2]+1))-5*(1+5*t[1]+5*t[2])*ln(5*t[2]+1))/(t[1]+t[2])

(13)

NULL

NULL

eq1 := diff(TC(t[1], t[2], xi), t[1]) = 0

-(2571.157291+220.0000000/exp(-.5*xi)+275.0000000*(.5-2.000000000/exp(-.5*xi))/exp(-.5*xi)-5.5*exp(.5*exp(-.5*xi)*(t[1]-.5))*(40.00000000/exp(-.5*xi)+50.00000000*(t[1]-2.000000000/exp(-.5*xi))/exp(-.5*xi))-53.33333333*(-3.00-298.800*exp(-.5*xi)+1.50*(exp(-.5*xi))^2*(.40*t[1]+50.0)+.3750*(exp(-.5*xi))^2*(-t[1]^2+.25)+120.00*(exp(-.5*xi))^2+.12500*(exp(-.5*xi))^3*(t[1]^3-.125)+37.65000*(exp(-.5*xi))^3*(t[1]^2-.25)+60.000*(exp(-.5*xi))^3*(t[1]-.5)+6*exp(.5*exp(-.5*xi)*(t[1]-.5))*(298.800*exp(-.5*xi)-1.500*exp(-.5*xi)*(t[1]-.5)-1.50*(exp(-.5*xi))^2*(99.750*t[1]+80.200)-3.00))/(exp(-.5*xi))^4+243*t[2]+250*t[1]*t[2]-40*ln(5*t[2]+1)-40*t[1]*ln(5*t[2]+1)-40*t[2]*ln(5*t[2]+1)+25*t[2]^2+10*t[2]*ln(1/(5*t[2]+1))-10*ln(1/(5*t[2]+1))+10*t[1]*ln(1/(5*t[2]+1))-5*(1+5*t[1]+5*t[2])*ln(5*t[2]+1))/(t[1]+t[2])^2+(-2.75*exp(-.5*xi)*exp(.5*exp(-.5*xi)*(t[1]-.5))*(40.00000000/exp(-.5*xi)+50.00000000*(t[1]-2.000000000/exp(-.5*xi))/exp(-.5*xi))-275.0000000*exp(.5*exp(-.5*xi)*(t[1]-.5))/exp(-.5*xi)-53.33333333*(.6000*(exp(-.5*xi))^2-.7500*(exp(-.5*xi))^2*t[1]+.37500*(exp(-.5*xi))^3*t[1]^2+75.30000*(exp(-.5*xi))^3*t[1]+60.000*(exp(-.5*xi))^3+3.0*exp(-.5*xi)*exp(.5*exp(-.5*xi)*(t[1]-.5))*(298.800*exp(-.5*xi)-1.500*exp(-.5*xi)*(t[1]-.5)-1.50*(exp(-.5*xi))^2*(99.750*t[1]+80.200)-3.00)+6*exp(.5*exp(-.5*xi)*(t[1]-.5))*(-1.500*exp(-.5*xi)-149.62500*(exp(-.5*xi))^2))/(exp(-.5*xi))^4+250*t[2]-65*ln(5*t[2]+1)+10*ln(1/(5*t[2]+1)))/(t[1]+t[2]) = 0

(14)

eq2 := diff(TC(t[1], t[2], xi), t[2]) = 0

-(2571.157291+220.0000000/exp(-.5*xi)+275.0000000*(.5-2.000000000/exp(-.5*xi))/exp(-.5*xi)-5.5*exp(.5*exp(-.5*xi)*(t[1]-.5))*(40.00000000/exp(-.5*xi)+50.00000000*(t[1]-2.000000000/exp(-.5*xi))/exp(-.5*xi))-53.33333333*(-3.00-298.800*exp(-.5*xi)+1.50*(exp(-.5*xi))^2*(.40*t[1]+50.0)+.3750*(exp(-.5*xi))^2*(-t[1]^2+.25)+120.00*(exp(-.5*xi))^2+.12500*(exp(-.5*xi))^3*(t[1]^3-.125)+37.65000*(exp(-.5*xi))^3*(t[1]^2-.25)+60.000*(exp(-.5*xi))^3*(t[1]-.5)+6*exp(.5*exp(-.5*xi)*(t[1]-.5))*(298.800*exp(-.5*xi)-1.500*exp(-.5*xi)*(t[1]-.5)-1.50*(exp(-.5*xi))^2*(99.750*t[1]+80.200)-3.00))/(exp(-.5*xi))^4+243*t[2]+250*t[1]*t[2]-40*ln(5*t[2]+1)-40*t[1]*ln(5*t[2]+1)-40*t[2]*ln(5*t[2]+1)+25*t[2]^2+10*t[2]*ln(1/(5*t[2]+1))-10*ln(1/(5*t[2]+1))+10*t[1]*ln(1/(5*t[2]+1))-5*(1+5*t[1]+5*t[2])*ln(5*t[2]+1))/(t[1]+t[2])^2+(243+250*t[1]-150/(5*t[2]+1)-250*t[1]/(5*t[2]+1)-65*ln(5*t[2]+1)-250*t[2]/(5*t[2]+1)+50*t[2]+10*ln(1/(5*t[2]+1))-25*(1+5*t[1]+5*t[2])/(5*t[2]+1))/(t[1]+t[2]) = 0

(15)

eq3 := diff(TC(t[1], t[2], xi), xi) = 0

(110.0000000/exp(-.5*xi)+137.5000000*(.5-2.000000000/exp(-.5*xi))/exp(-.5*xi)-275.0000000/(exp(-.5*xi))^2+1.375*exp(-.5*xi)*(t[1]-.5)*exp(.5*exp(-.5*xi)*(t[1]-.5))*(40.00000000/exp(-.5*xi)+50.00000000*(t[1]-2.000000000/exp(-.5*xi))/exp(-.5*xi))-5.5*exp(.5*exp(-.5*xi)*(t[1]-.5))*(20.00000000/exp(-.5*xi)+25.00000000*(t[1]-2.000000000/exp(-.5*xi))/exp(-.5*xi)-50.00000000/(exp(-.5*xi))^2)-106.6666667*(-3.00-298.800*exp(-.5*xi)+1.50*(exp(-.5*xi))^2*(.40*t[1]+50.0)+.3750*(exp(-.5*xi))^2*(-t[1]^2+.25)+120.00*(exp(-.5*xi))^2+.12500*(exp(-.5*xi))^3*(t[1]^3-.125)+37.65000*(exp(-.5*xi))^3*(t[1]^2-.25)+60.000*(exp(-.5*xi))^3*(t[1]-.5)+6*exp(.5*exp(-.5*xi)*(t[1]-.5))*(298.800*exp(-.5*xi)-1.500*exp(-.5*xi)*(t[1]-.5)-1.50*(exp(-.5*xi))^2*(99.750*t[1]+80.200)-3.00))/(exp(-.5*xi))^4-53.33333333*(149.4000*exp(-.5*xi)-1.500*(exp(-.5*xi))^2*(.40*t[1]+50.0)-.37500*(exp(-.5*xi))^2*(-t[1]^2+.25)-120.000*(exp(-.5*xi))^2-.187500*(exp(-.5*xi))^3*(t[1]^3-.125)-56.475000*(exp(-.5*xi))^3*(t[1]^2-.25)-90.0000*(exp(-.5*xi))^3*(t[1]-.5)-1.50*exp(-.5*xi)*(t[1]-.5)*exp(.5*exp(-.5*xi)*(t[1]-.5))*(298.800*exp(-.5*xi)-1.500*exp(-.5*xi)*(t[1]-.5)-1.50*(exp(-.5*xi))^2*(99.750*t[1]+80.200)-3.00)+6*exp(.5*exp(-.5*xi)*(t[1]-.5))*(-149.4000*exp(-.5*xi)+.7500*exp(-.5*xi)*(t[1]-.5)+1.500*(exp(-.5*xi))^2*(99.750*t[1]+80.200)))/(exp(-.5*xi))^4)/(t[1]+t[2]) = 0

(16)

NULL       

fsolve({eq1, eq2, eq3}, {xi, t[1], t[2]})

{xi = 8.906818845, t[1] = -64.35385212, t[2] = -.1999803845}

(17)

NULL

Download getSols.mw

but since you can't be bothered, I will try to summarise for you. Given

H:=[0, 4, 8, 1, 2, 1, 4, 2, 8];

it is rather obvious (to me at least) that H is of type list. So

type(H, list);

will return true. But you can't be both a list and an integer - so which would you expect? Now if you want to check whether the list contains entries of type integer, then that would be a completely different question - and relatively easy to test

Now if you read the help entry for the has() command, it checks whether the first expression 'contains' the second expression. Importantly, the second argument has to be an expression, not a type. Thus has(h,2) will return true and has(h, integer) will return false. What is difficult about this distinction?

approxint := proc (expr, r::(name = numeric .. numeric), { numsamples::integer := 1000 })
                  local f, randvals;
                  f := `if`(type(expr, procedure), expr, unapply(expr, lhs(r)));
                  randomize();
                  randvals := LinearAlgebra:-RandomVector(numsamples, generator = evalf(rhs(r)), datatype = float[8]);
                  add(f(randvals[i]), i = 1 .. numsamples)*(rhs(rhs(r))-lhs(rhs(r)))/numsamples
             end proc;
approxint(x^2, x = 1 .. 3);

In your original (2D) input, it seems as if you inadvertently inserted multiple "implied multiplications" by having spaces in the wrong places

 

latex(a[p, q] = Sum(cos(2*Pi*(p+1)*(n-1)/q), n = 1 .. q));


a_{{p,q}}=\sum _{n=1}^{q}\cos \left( 2\,{\frac {\pi\, \left( p+1
 \right)  \left( n-1 \right) }{q}} \right)

 

First 136 137 138 139 140 141 142 Last Page 138 of 207