tomleslie

13876 Reputation

20 Badges

15 years, 169 days

MaplePrimes Activity


These are answers submitted by tomleslie

is shown in the attached

A:=Matrix(2, 2, [[-0.0001633261895*z[1, 2]^2 + 0.0002805135275*z[1, 2]*z[2, 2] - 0.0001200583046*z[2, 2]^2 + 0.0006934805795*z[1, 1]^2 - 0.001190280265*z[1, 1]*z[2, 1] + 0.00007689977894*z[1, 1]*z[1, 2] - 0.00009937418547*z[1, 1]*z[2, 2] + 0.0005090615773*z[2, 1]^2 - 0.00003303758400*z[2, 1]*z[1, 2] + 0.00005683264925*z[2, 1]*z[2, 2] + 0.7021232886*z[1, 1] - 0.3171553245*z[1, 2] - 0.08291569324*z[2, 1] + 0.04647270631*z[2, 2] - 0.1436869545, 0.0002939068385*z[2, 1]^2 + 0.4237544799*z[1, 1] - 0.03129537402*z[1, 2] - 0.06276282411*z[2, 1] + 0.02529757039*z[2, 2] + 0.0004003811990*z[1, 1]^2 + 0.0002177682527*z[1, 1]*z[1, 2] - 0.0006872086309*z[1, 1]*z[2, 1] - 0.0001976167183*z[1, 1]*z[2, 2] - 0.0001764013184*z[2, 1]*z[1, 2] + 0.0001600777394*z[2, 1]*z[2, 2] - 0.1237363898], [0.00006763201108*z[2, 1]*z[1, 2] - 0.0001020812322*z[1, 2]*z[2, 2] - 0.00001554113990*z[2, 1]*z[2, 2] - 0.00003577693711*z[1, 1]*z[1, 2] + 0.0004330743651*z[1, 1]*z[2, 1] - 0.00001941220415*z[1, 1]*z[2, 2] - 0.01736180925 + 0.5623450996*z[2, 1] - 0.2353707048*z[2, 2] - 0.0003226356619*z[1, 1]^2 + 0.00007598605473*z[1, 2]^2 - 0.0001392051452*z[2, 1]^2 + 0.00003283047567*z[2, 2]^2 + 0.04653058230*z[1, 1] - 0.03026711709*z[1, 2], -0.00008037012799*z[2, 1]^2 + 0.03994641178*z[1, 1] - 0.02291248064*z[1, 2] + 0.3140461555*z[2, 1] + 0.01853659924*z[2, 2] - 0.0001862737861*z[1, 1]^2 - 0.0001013147396*z[1, 1]*z[1, 2] + 0.0002500356011*z[1, 1]*z[2, 1] + 0.00005403916772*z[1, 1]*z[2, 2] + 0.00008206914192*z[2, 1]*z[1, 2] - 0.00004377396755*z[2, 1]*z[2, 2] - 0.01370765196]]):

#
# Obtain a solution
#
  sol1:=fsolve([entries(A, 'nolist')]);
#
# Obtain a solution and insert into matrix
# in the required order
#
  Z:=Matrix(2,2,(i,j)->eval(z[i,j], sol1 ));

sol1 := {z[1, 1] = .3117132485, z[1, 2] = .2328518749, z[2, 1] = 0.2064174947e-1, z[2, 2] = 0.7118281938e-2}

 

Matrix(%id = 18446744074441697150)

(1)

 

Download matSol.mw

First of all, I more-or-less agree with you that it *ought* to be possible to perform an elementwise operation on an n x 1 matrix and an n-element vector. However (as far as Maple is concerned), the matrix is a 2-Dimensional object and the vector is a 1-Dimensional object. The error message you are getting is about the number of dimensions, not their values.

This leaves the "philosophical" question - is there a reason for the distinction between an n x 1 matrix and an n-element vector?? Intuitively (never a great guide!!), I would have expected a "vector" to be defined/implemented as a "matrix" one of whose dimensions "happens" to be 1. Thus for practical purposes, a "vector" would be regarded as "special case" of a "matrix"

is to download/install the (free) DirectSearch package from the Maple Applications Centre. This package contains some worthwhile routines for Optimization problems, and also performing numerical solution of equations.

In gernal I find the DirectSearch() package a little slower than in-built Maple commands, but it does (sometimes) work on problems which cannot be addressed by the in-built MAple commands.  For this particular example, it has the great advantage that it really doesn't mind in which order you enter the equations ;-)

See the attached -which you won't be able to execute until you have the DirectSearch package installed

  restart:
  kernelopts(version);
  with(DirectSearch):
  S:=t->c*exp(-a*t)+18;

`Maple 2016.2, X86 64 WINDOWS, Jan 13 2017, Build ID 1194701`

 

proc (t) options operator, arrow; c*exp(-a*t)+18 end proc

(1)

  SolveEquations( [S(2)=55,S(8)=36]);
  SolveEquations( [S(8)=36,S(2)=55])

[6.34675036051061*10^(-21), Vector(2, {(1) = HFloat(-6.008349373587407e-11), (2) = HFloat(-5.2313708920337376e-11)}), [a = .120091025791557, c = 47.0447823593713], 208]

 

[6.34675036051061*10^(-21), Vector(2, {(1) = HFloat(-5.2313708920337376e-11), (2) = HFloat(-6.008349373587407e-11)}), [a = .120091025791557, c = 47.0447823593713], 208]

(2)

 

Download useDS.mw

the attached covers all of your requirements - eg solutions for M=0,10, 20 in grahical and numeric formats

  restart;
  ode1 := diff(f(eta), eta$3)+(diff(f(eta), eta$2))*f(eta)-(diff(f(eta), eta))^2-(1-lambda)*M*(diff(f(eta), eta))-A*(diff(f(eta), eta)+(1/2)*(eta*(diff(f(eta), eta$2)))) = 0:
  ode2 := diff(theta(eta), eta$2)+Pr*(f(eta) * (diff(theta(eta), eta))-(diff(f(eta), eta)) * theta(eta)-A * (theta(eta)+1/2 . eta . (diff(theta(eta), eta)))) = 0:
  bcs := f(0) = 0,
         D(f)(0) = 1,
         (D@@2)(f)(myInf) = 0,
         theta(0) = 1,
         theta(myInf) = 0:

  interface(rtablesize=25):
  myInf:=20: Pr:=7: A:=1:
  getRes:= proc( myProc )
                 uses plots:
                 local j:
                 return [ Matrix
                         ( 22,3,
                           [ [eta, f(eta), theta(eta)],
                              seq( rhs~([ myProc(j)[1],
                                          myProc(j)[2],
                                          myProc(j)[5]
                                        ]
                                       ),
                                   j=0..2,0.1
                                 )
                           ]
                         ),
                         odeplot( myProc,
                                  [ [eta, f(eta)],
                                    [eta, theta(eta)]
                                  ] ,
                                  eta=0..myInf,
                                  color=[red, blue]
                                )
                       ];
           end proc:
  sol1:=dsolve( eval( [ode1,ode2,bcs],
                      [M=10, lambda=0]
                       ),
                numeric,
                maxmesh=2048
              ):
  ans:=getRes(sol1):
  plots:-display( ans[2],
                 title="M=10",
                 titlefont=[times, bold, 20]
               );
  ans[1];
  sol2:=dsolve( eval( [ode1,ode2,bcs],
                      [M=20, lambda=0]
                    ),
                  numeric,
                  maxmesh=2048
            ):
  ans:=getRes(sol2):
  plots:-display( ans[2],
                  title="M=20",
                  titlefont=[times, bold, 20]
                );
  ans[1];
  sol3:=dsolve( eval( [ode1,ode2,bcs],
                      M=10
                    ),
                    numeric,
                    continuation=lambda,
                    maxmesh=2048
              ):
  ans:=getRes(sol3):
  plots:-display(ans[2],
                 title="M=0",
                 titlefont=[times, bold, 20]
               );
  ans[1];

 

Matrix(22, 3, {(1, 1) = eta, (1, 2) = f(eta), (1, 3) = theta(eta), (2, 1) = 0., (2, 2) = 0., (2, 3) = 1.0000000000000002, (3, 1) = .1, (3, 2) = 0.8469521136877543e-1, (3, 3) = .7128036551941977, (4, 1) = .2, (4, 2) = .14495885300011446, (4, 3) = .5181092989079952, (5, 1) = .3, (5, 2) = .18794633394148974, (5, 3) = .384018102077815, (6, 1) = .4, (6, 2) = .2186872083482885, (6, 3) = .2900767948996101, (7, 1) = .5, (7, 2) = .24072529460722789, (7, 3) = .2231023614048568, (8, 1) = .6, (8, 2) = .256563634420171, (8, 3) = .1745180460989132, (9, 1) = .7, (9, 2) = .26797446848361006, (9, 3) = .13867606409911182, (10, 1) = .8, (10, 2) = .276215666018462, (10, 3) = .11180586720209136, (11, 1) = .9, (11, 2) = .2821821885084663, (11, 3) = 0.9135309607911385e-1, (12, 1) = 1.0, (12, 2) = .2865123369847998, (12, 3) = 0.7556126246842225e-1, (13, 1) = 1.1, (13, 2) = .2896624574015104, (13, 3) = 0.6320445220881145e-1, (14, 1) = 1.2, (14, 2) = .2919595925622171, (14, 3) = 0.5341454432273346e-1, (15, 1) = 1.3, (15, 2) = .29363867891827616, (15, 3) = 0.4556810698443834e-1, (16, 1) = 1.4, (16, 2) = .2948688870663453, (16, 3) = 0.3921137833869159e-1, (17, 1) = 1.5, (17, 2) = .2957723185003876, (17, 3) = 0.340098414901454e-1, (18, 1) = 1.6, (18, 2) = .2964373079392262, (18, 3) = 0.29713880226289898e-1, (19, 1) = 1.7, (19, 2) = .29692790976199773, (19, 3) = 0.26135082878403576e-1, (20, 1) = 1.8, (20, 2) = .2972906788949985, (20, 3) = 0.23129686632925986e-1, (21, 1) = 1.9, (21, 2) = .29755952896940313, (21, 3) = 0.20586869997355848e-1, (22, 1) = 2.0, (22, 2) = .2977592209257375, (22, 3) = 0.18420377159301744e-1})

 

 

Matrix(22, 3, {(1, 1) = eta, (1, 2) = f(eta), (1, 3) = theta(eta), (2, 1) = 0., (2, 2) = 0., (2, 3) = .9999999999999994, (3, 1) = .1, (3, 2) = 0.7995021404940386e-1, (3, 3) = .7247814139190237, (4, 1) = .2, (4, 2) = .130222273737289, (4, 3) = .5386020899539825, (5, 1) = .3, (5, 2) = .16191220164638778, (5, 3) = .40929217231463266, (6, 1) = .4, (6, 2) = .18193850118679233, (6, 3) = .31727630886645636, (7, 1) = .5, (7, 2) = .1946255667325781, (7, 3) = .25034666970868885, (8, 1) = .6, (8, 2) = .20268302458153278, (8, 3) = .20069463382429192, (9, 1) = .7, (9, 2) = .20781289225133903, (9, 3) = .1632012110516929, (10, 1) = .8, (10, 2) = .21108690311952386, (10, 3) = .13443249255236073, (11, 1) = .9, (11, 2) = .21318156672912356, (11, 3) = .11203573071670406, (12, 1) = 1.0, (12, 2) = .21452495928548254, (12, 3) = 0.9436759981964479e-1, (13, 1) = 1.1, (13, 2) = .21538861421020697, (13, 3) = 0.8026003005238463e-1, (14, 1) = 1.2, (14, 2) = .21594518496030585, (14, 3) = 0.688694403733103e-1, (15, 1) = 1.3, (15, 2) = .216304716858631, (15, 3) = 0.5957767354480718e-1, (16, 1) = 1.4, (16, 2) = .2165375182122312, (16, 3) = 0.5192567357219416e-1, (17, 1) = 1.5, (17, 2) = .2166886162037964, (17, 3) = 0.4556831551059662e-1, (18, 1) = 1.6, (18, 2) = .2167869156542555, (18, 3) = 0.4024315418931192e-1, (19, 1) = 1.7, (19, 2) = .21685101547101474, (19, 3) = 0.3574848859556741e-1, (20, 1) = 1.8, (20, 2) = .21689291121253687, (20, 3) = 0.3192775896876152e-1, (21, 1) = 1.9, (21, 2) = .216920357554585, (21, 3) = 0.28658311021027096e-1, (22, 1) = 2.0, (22, 2) = .21693837920933381, (22, 3) = 0.25843211938398974e-1})

 

 

Matrix(%id = 18446744074433121206)

(1)

 


 

Download odeSol.mw

as in the attached.

NB when the execution time is really short - it is probably a good idea to use the "iterations" option which will cause the  command to be executed the specified number of times and "average" the results

p:=1367:
q:=1259:
n:=p*q:
phi:=(p-1)*(q-1):
e:=2467:

gcd(e,phi);
d:=e^(-1) mod phi;

1

 

1485775

(1)

M:=123:
C:=CodeTools:-Usage(M^e mod n, iterations=1000);

memory used=4.29KiB, alloc change=0 bytes, cpu time=31.00us, real time=28.00us, gc time=0ns

 

760886

(2)

 

Download timing.mw

 

the fsolve() command doesn't like solving sets of equations - it much prefers lists, despite what the help page says.

Consider the attached

  1. equations presented as a set - no solution
  2. equations presented as a list - a solution
  3. and just for fun and because it is one of my favourite Maple "unexplainable quirks" try fsolve() with an "embedded" set->list conversion ie fsolve( convert(SetofEqs, list) ). This too will provide no solution??!! Why this is different from (2) above beats me

  restart:
  kernelopts(version);
  S:=t->c*exp(-a*t)+18;
#
# Equations as a set - No solution
#
  sys1:={S(2)=55,S(8)=36};
  fsolve(sys1);
#
# Now define the equations as a list -
# hey presto! A solution!
#
  sys2:=[S(2)=55,S(8)=36];
  fsolve(sys2);
#
# Notice that using an "embedded" convert(...,list)
# usually(?) won't work! This one I find mind-blowing
#
  fsolve(convert(sys1, list));

`Maple 2016.2, X86 64 WINDOWS, Jan 13 2017, Build ID 1194701`

 

proc (t) options operator, arrow; c*exp(-a*t)+18 end proc

 

{c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55}

 

fsolve({c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55}, {a, c})

 

[c*exp(-2*a)+18 = 55, c*exp(-8*a)+18 = 36]

 

{a = .1200910258, c = 47.04478236}

 

fsolve([c*exp(-8*a)+18 = 36, c*exp(-2*a)+18 = 55], {a, c})

(1)

 

Download setsLists.mw

The original Error mesage occureed becuase in the definition of the set 'de0' you had an extra space - beta[5] was written as beta [5].

Having corrected this problem the (attached) worksheet runs with no errors - but dsolve() obtains a (trivial) solution when the loop index 'k' is zero, and is unable to find solutions for k=1,2,3

In the attached I have highlighted changes
 

restart

de0 := {(1-p)*(diff(f(x), x, x))+p*(beta[9]*f(x)^2*(diff(f(x), x))^3+beta[10]*f(x)*(diff(f(x), x))^4+beta[12]*f(x)^4*(diff(f(x), x))^3+beta[8]*f(x)^4*(diff(f(x), x))+beta[5]*f(x)*(diff(f(x), x))^2+beta[4]*f(x)^2*(diff(f(x), x))-(1/4)*rho*(g(x)^3-3*f(x)^2*g(x))*sin(4*Omega*x)-alpha[1]*f(x)*cos(2*Omega*x)-(1/4)*rho*(3*f(x)*g(x)^2-f(x)^3)*cos(4*Omega*x)-alpha[2]*f(x)^3*cos(2*Omega*x)-(1/2)*alpha[2]*(f(x)^3+3*f(x)^2*g(x))*sin(2*Omega*x)+(3/4)*rho*f(x)*g(x)^2-F*Omega^2*cos(Omega*x+theta)-alpha[1]*g(x)*sin(2*Omega*x)+beta[13]*f(x)*(diff(f(x), x))^6+f(x)+diff(f(x), x, x)+beta[11]*f(x)^7+beta[6]*(diff(f(x), x))^3+beta[7]*f(x)^5+beta[1]*f(x)+beta[2]*(diff(f(x), x))+beta[3]*f(x)^3+mu[1]*(diff(f(x), x))+(3/4)*rho*f(x)^3), (1-p)*(diff(g(x), x, x))+p*((3/4)*rho*g(x)*f(x)^2-alpha[2]*g(x)^3*cos(2*Omega*x)+alpha[1]*g(x)*cos(2*Omega*x)-alpha[1]*f(x)*sin(2*Omega*x)-(1/2)*alpha[2]*(f(x)^3+3*f(x)*g(x)^2)*sin(2*Omega*x)-F*Omega^2*sin(Omega*x+theta)-(1/4)*rho*(3*f(x)*g(x)^2-f(x)^3)*sin(4*Omega*x)-(1/4)*rho*(3*f(x)^2*g(x)-g(x)^3)*cos(4*Omega*x)+beta[4]*g(x)^2*(diff(g(x), x))+beta[9]*g(x)^2*(diff(g(x), x))^3+beta[13]*g(x)*(diff(g(x), x))^6+beta[5]*g(x)*(diff(g(x), x))^2+beta[8]*g(x)^4*(diff(g(x), x))+beta[12]*g(x)^4*(diff(g(x), x))^3+beta[10]*g(x)*(diff(g(x), x))^4+beta[11]*g(x)^7+beta[6]*(diff(g(x), x))^3+beta[7]*g(x)^5+beta[2]*(diff(g(x), x))+beta[3]*g(x)^3+beta[1]*g(x)+mu[2]*(diff(g(x), x))+(3/4)*rho*g(x)^3+g(x)+diff(g(x), x, x))}

ibvc0 := {f(0), g(0), (D(f))(0), (D(g))(0)}

n := 3

F := unapply(add(b[k](x)*p^k, k = 0 .. n), x); G := unapply(add(c[k](x)*p^k, k = 0 .. n), x)

de := map(series, eval(de0, {f = F, g = G}), p = 0, n+1)

for k from 0 to n do if k = 0 then ibvc := expand(eval[recurse](ibvc0, {f = F, g = G, p = 0})) else ibvc := {b[k](0)-1, (D(b[k]))(0)-1, (D(c[k]))(0)-1, ((D@@2)(b[k]))(0)-1, ((D@@2)(c[k]))(0)-1, c[k](0) = 1} end if; sys := `union`(simplify(map(coeff, de, p, k)), ibvc); soln[k] := dsolve(sys) end do

soln()

(table( [( 0 ) = {b[0](x) = 0, c[0](x) = 0}, ( 1 ) = , ( 2 ) = , ( 3 ) =  ] ))()

(1)

 

soln[]

(2)

 


 

Download odeProbs.mw

Is your piecewise function differentiable??? (Hint - it isn't)

Do you think that a non-differentiable function can be the solution of a differential equation?

Does it have any detail manual for Matlab programming using Maple symbolic engine? (Except help documentation of Maple Symbolic Toolbox in Matlab).

As far as I am aware therre is no "manual" available, othere than the Help pages for the Maple symbolic toolbox whihc can be accessed from within Matlab

How to maximize the running speed of the codes programmed by Maple symbolic toolbox? Any Notes?

Ensure that they run "quickly" in stand-alone Maple

How to use the function 'GenerateMatrix' of Maple in Matlab? What's the syntax to use this function in Matlab?

Not possible. From within Matlab you only have access to a pretty limited range of Maple commands. In particular you will not have access to any command which exists with a Maple package (such as LinearAlgebra). The only MAple commands you can access are listed in the help file available for the Maple symbolic toolbox from within Matlab

My usual advice to anyone who wants to run a major software package (eg Maple) from within a copletely different software package (eg Matlab) is - don't. It will involve a lot of extra effort and probably won't work very well. Just pick the single most appropriate package for your problem and use it

 

mean what is implemeted in the attached?

  restart:
  NewtonRaphsonSYS:= proc(X,F,X0,TOL,itmax)
                          local Xn:=X0,
                                m:=LinearAlgebra[Dimension](Vector(X)),
                                H, FX, n, i, J;
                          for n to itmax do
                              FX:=eval(F,[seq(X[i]=Xn[i],i=1..m)]);
                              J:=evalf(VectorCalculus[Jacobian](F,X=convert(Xn,list)));
                              H:=-LinearAlgebra[MatrixInverse](J).Vector(FX);
                              Xn:=Xn+H;
                              if  LinearAlgebra[VectorNorm](H,2)<TOL
                              then return Xn;
                              end if;
                          end do;
                    end proc:

  F:=[x*y-z^2-1,x*y*z+y^2-x^2-2,exp(x)+z-exp(y)-3]:
  X:=[x,y,z]:
  X0:= <1,1,1>:
  TOL:=0.00000001:
  itmax:=10:
  NewtonRaphsonSYS(X,F,X0,TOL,itmax);

Vector(3, {(1) = 1.7776719180107403, (2) = 1.423960597888489, (3) = 1.2374711177317033})

(1)

 

Download NewtRaph.mw

When you load a package using with(packageName) then a whole new set of commands becomes available - that is the point of loading the package!

There are a couple of ways to avoid conflicts between names defined at 'top-level' and names defined in the 'package'

  1. Don't load the whole package using with() - just use the long-form expression for any package command, which in your case would be numtheory:-Omega(),
  2. If you do load a package using with(packageName), then you can prefix 'top-level' names with ':-'

Both methods are illustrated in the attached, where I have used the NumberTheory() package, rather than the long-deprecated numtheory() package

restart:
lambda:=n->(-1)^NumberTheory:-Omega(n);
lambda(667); # Top-level 'lambda' command

proc (n) options operator, arrow; (-1)^NumberTheory:-Omega(n) end proc

 

1

(1)

restart:
with(NumberTheory):
:-lambda:=n->(-1)^Omega(n);
lambda(667); # NumberTheory(lambda) command
:-lambda(667); # Top-level 'lambda' command

proc (n) options operator, arrow; (-1)^NumberTheory:-Omega(n) end proc

 

308

 

1

(2)

 

Download nameSpace.mw

is shown in the attached.

NB 'background' grid lines do not appear in the actual worksheet - they only occur when the worksheet is rendered for this site

  restart:
  xmin:=1: xmax:=3: ymin:=2.5: ymax:=4.5:
  f:= (nx, ny)-> local i, j;
                 plots:-pointplot
                        ( [ seq
                            ( seq
                              ( [i, j],
                                i=xmin..xmax, (xmax-xmin)/nx
                              ),
                              j=ymin..ymax, (ymax-ymin)/ny
                            )
                          ],
                          symbol=solidcircle,
                          symbolsize=20,
                          color=red,
                          scaling=constrained
                        ):

#
# A few test cases for different grid spacings
#
  f(4,4);
  f(4,6);
  f(10,3);

 

 

 

 


 

Download doGrids.mw

see the attached

NULL

restart; with(LinearAlgebra)

eq1 := a^2+b^2 = 1; eq2 := x^2+y^2 = 1; C1 := `<,>`(`<|>`(a), `<|>`(b)); C2 := `<,>`(`<|>`(x), `<|>`(y)); A := Multiply(C1, C1^%T); B := Multiply(C2, C2^%T); D1 := Multiply(A, B); D2 := Multiply(B, A)

eq1 := a^2+b^2 = 1

 

eq2 := x^2+y^2 = 1

 

Vector(2, {(1) = a, (2) = b})

 

Vector(2, {(1) = x, (2) = y})

 

Matrix(2, 2, {(1, 1) = a^2, (1, 2) = a*b, (2, 1) = a*b, (2, 2) = b^2})

 

Matrix(2, 2, {(1, 1) = x^2, (1, 2) = x*y, (2, 1) = x*y, (2, 2) = y^2})

 

Matrix(2, 2, {(1, 1) = a^2*x^2+a*b*x*y, (1, 2) = a^2*x*y+a*b*y^2, (2, 1) = a*b*x^2+b^2*x*y, (2, 2) = a*b*x*y+b^2*y^2})

 

Matrix(%id = 18446744074366897198)

(1)

eqns:=[seq(seq( D1[i,j]=D2[1,j], i=1..2),j=1..2)];
solve(eqns);

[a^2*x^2+a*b*x*y = a^2*x^2+a*b*x*y, a*b*x^2+b^2*x*y = a^2*x^2+a*b*x*y, a^2*x*y+a*b*y^2 = a*b*x^2+b^2*x*y, a*b*x*y+b^2*y^2 = a*b*x^2+b^2*x*y]

 

{a = -y*b/x, b = b, x = x, y = y}, {a = b, b = b, x = x, y = x}

(2)

NULL

``

Download solveEqns.mw

so that they match the entries in the fprintf() format specifier.

I also (mainly for test purposes) entered full path names to the output file, and generated two output files. You will have to change the full path specifications

C:/Users/TomLeslie/Desktop/interim_file
C:/Users/TomLeslie/Desktop/interim_file2

in the attached to a sensible location for your machine. If you choose not to use a full path specification, then the output files will (probably) appear in whatever directory is returned by the command currentdir()

Anyway, the attached now works, and the text files produced have the contents

217
10/10/2019
1
1962 106 244.220306 104.453437 225 500.000000 200.000000

and

218
11/10/2019
2
1963 46 460.660100 40.136986 148 504.913243 92.273973
1964 122 247.406700 40.753425 8 894.463483 40.136986

restart

NULL

tournament_id := "217"

"217"

(1)

d := "10/10/2019"

"10/10/2019"

(2)

``

numGames := 1

1

(3)

``

````

``

Match_ids := ["1962"]

["1962"]

(4)

Games := [[106, 225]]

[[106, 225]]

(5)

ST := [`106` = Record(mu = 244.2203059, sigma = 104.4534372), `225` = Record(mu = 500., sigma = 200.0000000)]

[`106` = Record(mu = 244.2203059, sigma = 104.4534372), `225` = Record(mu = 500., sigma = 200.0000000)]

(6)

parse(tournament_id);
d;
numGames;
for k to numGames do
      parse(op(Match_ids[k])),lhs(ST[2*k-1]),rhs(ST[2*k-1]):-mu,rhs(ST[2*k-1]):-sigma,lhs(ST[2*k]),rhs(ST[2*k]):-mu,rhs(ST[2*k]):-sigma:
end do;

217

 

"10/10/2019"

 

1

 

1962, `106`, 244.2203059, 104.4534372, `225`, 500., 200.0000000

(7)

#Now i try to output a file

# Open output file and output initial information
#local Int_File := fopen('interim_file','WRITE','TEXT');
#
# Enter full path to output file for testing purposes.
# (Don't know why OP declares the file descriptor as
# 'local'
#
  Int_File:="C:/Users/TomLeslie/Desktop/interim_file":

  fprintf(Int_File,"%s\n%A\n%a\n",tournament_id,d,numGames);

for k to numGames do
    #
    # checked the dataypes of quantities being output
    #
    # Based on this check, convert (some) of the
    # entries in the output sequence below so
    # that they match the type in the fprintf format
    # specifier
    #
      convert(parse(op(Match_ids[k])),string),
      convert(lhs(ST[2*k-1]),string),
      rhs(ST[2*k-1]):-mu,
      rhs(ST[2*k-1]):-sigma,
      convert(lhs(ST[2*k]),string),
      rhs(ST[2*k]):-mu,
      rhs(ST[2*k]):-sigma:
      fprintf(Int_File,"%s %s %f %f %s %f %f\n",%);
  end do;
  fclose(Int_File);

17

 

"1962", "106", 244.2203059, 104.4534372, "225", 500., 200.0000000

 

57

(8)

#The file should contain:

 217
10/10/2019
1
1962 106 242.1161963 97.90410959 225 500 200
 

restart

tournament_id := "218"

"218"

(9)

NULL

NULL

d := "11/10/2019"

"11/10/2019"

(10)

numGames := 2NULL

2

(11)

NULLNULL

Match_ids := ["1963", "1964"]

["1963", "1964"]

(12)

Games := [[`46`, `148`], [`122`, `8`]]

[[`46`, `148`], [`122`, `8`]]

(13)

numPlayers := 4NULL

4

(14)

ST := [`46` = Record(mu = 460.6600997, sigma = 40.13698630), `148` = Record(mu = 504.9132434, sigma = 92.27397260), `122` = Record(mu = 247.4066999, sigma = 40.75342466), `8` = Record(mu = 894.4634827, sigma = 40.13698630)]

[`46` = Record(mu = 460.6600997, sigma = 40.13698630), `148` = Record(mu = 504.9132434, sigma = 92.27397260), `122` = Record(mu = 247.4066999, sigma = 40.75342466), `8` = Record(mu = 894.4634827, sigma = 40.13698630)]

(15)

parse(tournament_id);
d;
numGames;
for k to numGames do
      parse(op(Match_ids[k])),lhs(ST[2*k-1]),rhs(ST[2*k-1]):-mu,rhs(ST[2*k-1]):-sigma,lhs(ST[2*k]),rhs(ST[2*k]):-mu,rhs(ST[2*k]):-sigma:
end do;

218

 

"11/10/2019"

 

2

 

1963, `46`, 460.6600997, 40.13698630, `148`, 504.9132434, 92.27397260

 

1964, `122`, 247.4066999, 40.75342466, `8`, 894.4634827, 40.13698630

(16)

#Now i try to output a file


# Enter full path to output file for testing purposes.
#
# Appended a '2' to file name, so it doesn't overwrite
# the one above (OP is not using 'APPEND') option with
# fopen(), so I'm assuming he/she doesn't want to
# append
#
# (Don't know why OP declares the file descriptor as
# 'local'
#
  Int_File:="C:/Users/TomLeslie/Desktop/interim_file2":
#  local Int_File := fopen('interim_file','WRITE','TEXT');

   fprintf(Int_File,"%s\n%A\n%a\n",tournament_id,d,numGames);

for k to numGames do
    #
    # Perform the same type conversions as above
    #
      convert(parse(op(Match_ids[k])),string),
      convert(lhs(ST[2*k-1]),string),
      rhs(ST[2*k-1]):-mu,
      rhs(ST[2*k-1]):-sigma,
      convert(lhs(ST[2*k]),string),
      rhs(ST[2*k]):-mu,
      rhs(ST[2*k]):-sigma:
      fprintf(Int_File,"%s %s %f %f %s %f %f\n",%);
  end do;
  fclose(Int_File);

17

 

"1963", "46", 460.6600997, 40.13698630, "148", 504.9132434, 92.27397260

 

54

 

"1964", "122", 247.4066999, 40.75342466, "8", 894.4634827, 40.13698630

 

53

(17)

 

NULL

Download printProb.mw

if I run your worksheet in Maple 2019, no "imaginary parts" occur and hence no need for fnormal(). The real solutions obtained also don't seem to bear any relation to the real parts of the numbers in your original worksheet!!

So I wouldn't like to bet on the "real" answers you are getting with fnormal()!!

See the attached

restart

kernelopts(version)

`Maple 2019.1, X86 64 WINDOWS, May 21 2019, Build ID 1399874`

(1)

Ec := 32000000

32000000

(2)

Es := 210000000

210000000

(3)

Esch := 210000000

210000000

(4)

bw := .25

.25

(5)

d1 := .45

.45

(6)

d2 := 0.3e-1

0.3e-1

(7)

dch := .504

.504

(8)

As := 0.756e-3

0.756e-3

(9)

As2 := 0

0

(10)

Fych := 150000

150000

(11)

x := (-(As+As2)*Es-Asch*Esch+sqrt(((As+As2)*Es+Asch*Esch)^2+2*Ec*bw*(Es*(As*d1-As2)+Esch*Asch*dch)))/(Ec*bw)

-0.1984500000e-1-26.25000000*Asch+0.1250000000e-6*((158760.0000+210000000*Asch)^2+0.1143072000e13+0.1693440000e16*Asch)^(1/2)

(12)

-(As+As2)*Es-Asch*Esch

-158760.0000-210000000*Asch

(13)

expand(((As+As2)*Es+Asch*Esch)^2)

0.2520473760e11+0.6667920000e14*Asch+44100000000000000*Asch^2

(14)

2*Ec*bw*(Es*(As*d1-As2)+Esch*Asch*dch)

0.1143072000e13+0.1693440000e16*Asch

(15)

Ix := (1/3)*bw*x^2+Es*As*(d1-x)^2/Ec+Es*As2*(x-d2)^2/Ec+Esch*Asch*(dch-x)^2/Ec

0.8333333333e-1*(-0.1984500000e-1-26.25000000*Asch+0.1250000000e-6*((158760.0000+210000000*Asch)^2+0.1143072000e13+0.1693440000e16*Asch)^(1/2))^2+0.4961250000e-2*(.4698450000+26.25000000*Asch-0.1250000000e-6*((158760.0000+210000000*Asch)^2+0.1143072000e13+0.1693440000e16*Asch)^(1/2))^2+(105/16)*Asch*(.5238450000+26.25000000*Asch-0.1250000000e-6*((158760.0000+210000000*Asch)^2+0.1143072000e13+0.1693440000e16*Asch)^(1/2))^2

(16)

Md := Ec*Fych*Ix/(Esch*(dch-x))

(160000/7)*(0.8333333333e-1*(-0.1984500000e-1-26.25000000*Asch+0.1250000000e-6*((158760.0000+210000000*Asch)^2+0.1143072000e13+0.1693440000e16*Asch)^(1/2))^2+0.4961250000e-2*(.4698450000+26.25000000*Asch-0.1250000000e-6*((158760.0000+210000000*Asch)^2+0.1143072000e13+0.1693440000e16*Asch)^(1/2))^2+(105/16)*Asch*(.5238450000+26.25000000*Asch-0.1250000000e-6*((158760.0000+210000000*Asch)^2+0.1143072000e13+0.1693440000e16*Asch)^(1/2))^2)/(.5238450000+26.25000000*Asch-0.1250000000e-6*((158760.0000+210000000*Asch)^2+0.1143072000e13+0.1693440000e16*Asch)^(1/2))

(17)

solve(Md = 1.4*139.2, Asch)

0.6742672449e-3, -0.4026613674e-1

(18)

``

``

Download imPartQuirk.mw

First 88 89 90 91 92 93 94 Last Page 90 of 207