703 Reputation

8 Badges

18 years, 79 days

MaplePrimes Activity

These are answers submitted by DuncanA

The call to dsolve produces both numeric and non-numeric output. Use eval(sol); to see the dsolve output.

 "The writedata function writes *numeric* data from a Maple vector, matrix, list, or list of lists into a text file fileID." See ?writedata   Part of the data you are trying to write to the file is non-numeric, i.e.

[ d ]
[eta, G(eta), ----- G(eta)]
[ deta ]

The command you may wish to use, which will write only the numeric data to the file, is

writedata(fd, sol[2,1]);




I think what you are looking for is something along the lines of
C := A union B;
{x = 0, y = 0, -y = 0}
{x = 0, y = 0}




I have been able to recover some of the contents that was previously hidden within the file, but not displayed in Maple; the "Lab 3 Report" section is now visible.

There are mismatched XML tags in the original file, i.e., opening tags without matching closing tags, so I deleted the <Output> field at the end of the file and added closing </Group></Section> and </Worksheet> tags.




?combine/range is one possibility, but its limitations mean that it cannot combine the two sums as they currently are. However, the correct result can be achieved by changing the two sums into three sums with overlapping ranges.

s1 := Sum(x(i), i = n-1 .. m):
s2 := Sum(x(i), i = n .. m):
s3 := Sum(x(i), i = n .. m+1):

s1 - s2:
c1:=combine(%, 'range'):

s3 - s2:
c2:=combine(%, 'range'):

                             x(n - 1) + x(m + 1)



I'm not sure whether it is necessary or correct to assume that k is an integer when calling int. The correct result can of course be obtained by other means:

1) Using limit:

limit(int(exp(-I*x*k), x = -Pi .. Pi), k=0);
                                    2 Pi

2) By implementation of L'Hopital's rule

int(exp(-I*x*k), x = -Pi .. Pi):

eval(diff(numer(%), k) / diff(denom(%), k), k=0);
                                    2 Pi

What I wonder is whether the original poster was in fact looking for a fourier integral transform

fourier(1, x, k);
                                2 Pi Dirac(k)
fourier(Dirac(x), x, k);
fourier(exp(I*k0*x), x, k) assuming k0::real;
                             2 Pi Dirac(k - k0)



It is possible to pass a list of equations to a procedure. The problem in the example is that the argument is not algebraic. The expression [f[1], f[2], f[3]] is a list and each individual entry in the list has type equation. The type of an expression can be obtained by calling whattype ?whattype 


g := proc(a)
end proc:
g([f[1], f[2], f[3]]);
            [x[2] + 3 x[4] + x[5] - x[6] = 2, 

              x[1] + 2 x[2] - x[3] + x[4] + 3 x[6] + x[7] = 13, 

              x[1] + x[2] - 3 x[3] - x[4] + x[5] - x[8] = 26]



?applyrule has featured in a few posts recently (e.g., this) and can be used to sort the operators

applyrule([b[1].ap.b[2]=ap.b[1].b[2], b[1].am.b[2]=am.b[1].b[2]], p);

        Physics:-*(a+, b[2], b[1]) + Physics:-*(a-, b[2], b[1])
           - Physics:-*(a+, b[1], b[2]) - Physics:-*(a-, b[1], b[2])



Extract the right-hand side of each solution using rhs()

dernier:= rhs(sol[1])/rhs(sol[2]);

dernier := ((1/2)*b+(1/2)*a)/(-(1/2)*b+(1/2)*a)



I passed the original worksheet through an XML parser and it found invalid tokens in the worksheet. The attached file has the invalid tokens removed.

The invalid tokens are at lines 114 and 166 in the source file.  The error messages from the parser and the corresponding worksheet text are below.

not well-formed (invalid token) at line 114, column 85, byte 21842 at C:/Perl/lib/XML/Parser.pm line 187


not well-formed (invalid token) at line 166, column 113, byte 34379 at C:/Perl/lib/XML/Parser.pm line 187


not well-formed (invalid token) at line 166, column 214, byte 34480 at C:/Perl/lib/XML/Parser.pm line 187

(de nitionen, rkkeoperationsmetoden, udviklingsmetoden) der er bedst egnet til at producere et sadant





"Extract entries in [a Vector] V by using the command V[L]."


> XbIndets := Vector([6,7,8]):

> XbIndets[3];





The assignment operator in Maple is := instead of =

> solu := solve({x+y=a, x-y=b}, {x, y});

                   solu := {x = b/2 + a/2, y = - b/2 + a/2}
> solu[1];

                                 x = b/2 + a/2




If A and B were lists then remove can be used 



remove(has, A, B);

                               [1, 3, 4, 5, 6]

If A and B are Vectors then they can be converted to lists prior to using remove. The output from remove will be a list that can be used to initialise a new Vector.



v := remove(has, convert(A, list), convert(B, list));

                               [1, 3, 4, 5, 6]





The coeff or coeffs functions can be used to return the coefficients.  coeffs doesn't return coefficients whose value is zero.  coeff does return zero-valued coefficients, but must be combined with seq to return all coefficients.  If your equation was expressed as a polynomial then PolynomialTools[CoefficientVector] or PolynomialTools[CoefficientList] could also be used. Instead of hard-coding the number of elements of 'x' into the seq expression the value can be determined programmatically, but this depends on what type x is.

z:= 7*x[1]+11*x[3]-10*x[4]+26*x[6]:
                               7, 11, -10, 26
seq(coeff(z, x[i]), i = 1 .. 6);
                            7, 0, 11, -10, 0, 26



To select the minimum positive integers from R[1], R[2], and R[3], combine Maple's min function with the select function:

min(select(type, [R[1], R[2], R[3]], 'posint'));

If only positive values are required instead of positive integers then select for 'positive':

min(select(type, [R[1], R[2], R[3]], 'positive'));

If R is itself a list then [R[1], R[2], R[3]] can be replaced with R 

min(select(type, R, 'positive'));



@amrramadaneg I suspect it may be impossible to identify the problem from the extract of code you have posted. If you post a larger extract or a complete worksheet then it will be easier to identify the problem.

1 2 3 4 5 6 7 Page 3 of 7