Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are answers submitted by Joe Riel

I'm guessing you did something like

x := fsolve(x^2+x,x);

and then attempted to use x in an expression.  However, since x is assigned an expression sequence of two numbers, that fails.

There are several ways around this one. One is to refer to just one of the solutions using index notation:

x[1];
         -1.
x[2];
          0.

Use sort( poly, x);

On the other hand, do you really want evalf(x^2) to return x^(2.00)?

While it is intended more for searching, you can use the mgrep tool with the -c option.

The transformations are different.  If you use

tr := {y(a) = a+1+1/u(a)}:

you get the same result

I didn't see the call to f in conscongs, but no matter.  The error message that Maple is raising is informative:

final value in for loop must be numeric or character.

In f, the final value of the for loop is the variable numccs. That variable is local to conscongs, so its value will be unknown to f. Actually, in the context of f, numccs is a global variable (because it wasn't declared), one that is different from the variable of the same name that is local to conscongs. You could declare numcss as a global variable inside of conscongs, however, that usually isn't the best way to go. 

To better understand this behavior, consider the following

proc()
local a,v;
global g;
    a := v;
    g := v;
    assume(v,positive);
    subs(v=1,[a,g,v]);
end proc();
                                   [v, 1, 1]

The substitution "works" for the global variable, g, but not the local variable, a. The reason for this is that global variables are fully evaluated, while local variables are not, they are evaluated only one level (cf. ?procedure). Because a is not fully evaluated, in the subs operation it evaluates to v, which is a different variable than v~. The v's in the call to subs evaluate to v~.

The same thing is happening with the substitution into a Vector (more generally, an ?rtable) even though you are doing so at top-level (i.e. not inside a proceure).  For efficiency, the content of an rtable is not fully evaluated unless you force it to be.

 

Are you sure it is the call to A:-Simulate() that is leaving the file handles open?  I haven't been able to reproduce that behavior.  However, repeated calls to MapleSim:-LinkModel() does create more open file handles.  I'll submit this as an SCR.

This isn't generally possible; the zeros of the numerator are the problem.  You can use two equations, d(x) = u, y = p(x,u), where d(x) is a differential expression in x(t) and p is an algebraic equation in x(t) and u(t).  Consider, for example, the simpler G = Y/U = s/(s+1).  You can represent that as

diff(x(t),t) + x(t) = u(t)
y(t) = -x(t) + u(t)

Change the ?sum to an ?add and remove the forward quotes.

You can use ?evalc to evaluate this.  Note that ?Re and ?Im are the real and imaginary operators, respectively. Let's introduce inert functions re and im for the real and imaginary parts of a complex.  Then

cmplx := z -> re(z) + I*im(z):
Hz := cmplx(H);
                             Hz := re(H) + im(H) I

Ez := cmplx(E);
                             Ez := re(E) + im(E) I

evalc(Re(Ez*conjugate(Hz)));
                           re(E) re(H) + im(E) im(H)

x := g(t,s):
y := h(t,s):
A := f(x,y):
diff(A,t$4);

The output is a bit complicated.  Here is the first derivative, which is considerably shorter

diff(A,t);
                              /d         \                             /d         \
    D[1](f)(g(t, s), h(t, s)) |-- g(t, s)| + D[2](f)(g(t, s), h(t, s)) |-- h(t, s)|
                              \dt        /                             \dt        /

D[1](f) means the partial derivative of f with respect to the first argument (here, x).

To obtain a more compact display, consider using ?PDEtools[declare]:

PDEtools:-declare(g(t,s),h(t,s)):
diff(A,t);
                        D[1](f)(g, h) g[t] + D[2](f)(g, h) h[t]



I don't understand the equations with nu and the conditional.  Disregarding that, you could do

params := { h = 6.6e-34, c = ..., T=..., etc }:
B := 2*h*ν3/(c2 *(exp(h*ν/k/T)-1):
plot(eval(B, params), nu=1..10);

Rather than starting a new thread it is generally better to continue the old.  Regardless, a few comments.

My suggestion to use ?add instead of ?sum was incomplete.  The forward quotes which you used are not needed and not appropriate when using add.  A more serious problem is that you are using the name of the procedure (f), in the procedure.  While Maple can recurse, the recursion must eventually halt, and there is nothing in the procedure that does that.  The real problem is that you want f[1] to be a different procedure than f.  Alas, Maple treats them as the same.  For example

f := x -> f[1](x):
f(3);
Error, (in f[1]) too many levels in recursion

It isn't clear why you are calling f[1](x).  Is that supposed to be a completely inert call.  In that case, you would be better naming it as f1. That is, you could do

N := 2:
f := eta -> add(cat('f',i)(eta)*m^i, i=0..N):
f(3);
                                                       2
                              f0(3) + f1(3) m + f2(3) m


B1 is a list, not a vector.  One way to enter a vector is to use angle brackets: 

B1 := <1,2,0,-1>:
First 44 45 46 47 48 49 50 Last Page 46 of 114