DuncanA

698 Reputation

8 Badges

15 years, 144 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.

eval(sol[1,1]);
[ 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]);

 

---

Duncan

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

 

---

Duncan

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.

Lab3_SP11_LogisticG.mw

---

Duncan

?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'):

value(c1+c2);
                             x(n - 1) + x(m + 1)

---

Duncan

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

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

---

Duncan

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)
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]

---

Duncan

?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])

---

Duncan

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)

---

Duncan

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

hj\303\246lp


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

sammenh\303\246ngen


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

 

Mads_Anthon_v2.mw

---

Duncan

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

?LinearAlgebra/General/MVextract 

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

> XbIndets[3];

                                       8

 

---

Duncan

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

 

---

Duncan

If A and B were lists then remove can be used 

A:=[1,2,3,4,5,6,7,8]:

B:=[2,7,8]:

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.

A:=Vector[row]([1,2,3,4,5,6,7,8]):

B:=Vector[row]([2,7,8]);

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

                               [1, 3, 4, 5, 6]

Vector[row](v);

 

---

Duncan

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]:
coeffs(z);
                               7, 11, -10, 26
seq(coeff(z, x[i]), i = 1 .. 6);
                            7, 0, 11, -10, 0, 26

---

Duncan

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'));

---

Duncan

@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