Joe Riel

9530 Reputation

23 Badges

20 years, 26 days

MaplePrimes Activity


These are answers submitted by Joe Riel

There is an issue with the pseudo-code: the internal summation uses the index i, which is also the index of the outer loop.  That cannot work properly, however, it is not entirely clear what is intended.

FPackage :=  module()
option package;
export `*`;
    `*` := overload([NULL
                     , proc(a::algebraic, b::specfunc(anything, f))
                       option overload;
                           map2(procname, a, b);
                       end proc      
                     , proc(b::specfunc(anything, f), a::algebraic)
                       option overload;
                           map2(procname, a, b);
                       end proc
                    ]
                   );
end module:

with(FPackage);
a*f(b,c,d,f(e,g));
                               f(a*b,a*c,a*d,f(a*e,a*g))

One way is to delay the evaluation of the function call norma by quoting it with single forward quotes:

int( 'norma'(...), ..., numeric )

 

A slightly different approach is to use ?solve/identity

ex := R*d^2 / ( R*d^2 + s*L + s^2*R*L*C ):

solve(identity(ex = 1/(1 + 2*zeta*(s/omega)  + (s/omega0)^2), s), {zeta,omega0});
               d             omega L                  d             omega L
  {omega0 = --------, zeta = -------}, {omega0 = - --------, zeta = -------}
                 1/2            2                       1/2            2
            (L C)            2 d  R                (L C)            2 d  R

y := 23.45*sin((360*(x+284))/284):
seq('y'(x) = evalf(y), x = 1..365);

Create a system with both systems.  For example

with(DynamicSystems):
sys1 := TransferFunction(1/(s+2)):
sys2 := TransferFunction(s/(s+3)):
sys12 := TransferFunction(<sys1:-tf,sys2:-tf>):
BodePlot(sys12);

 



Use a ?piecewise expression to represent y in terms of x.  Thus

y := piecewise(x<=4, 9/10, 1-1/10*exp(-x/10)):

You can integrate and plot this expression as usual.

solve(alpha*x - conjugate(alpha)*x=1);
                                          1
              {alpha = alpha, x = - --------------}
                                             _____
                                    -alpha + alpha

It would help to have the actual worksheet.  You can upload it with the green arrow.  It looks as though you are creating symbols, sCR, rather than products, s*C*R, etc.

I looked at the model (tdk7.msim) , which as you suggested, is rather complicated.  It appears as there is a more fundamental problem than the event iteration.  I temporarily prevented that message from occuring by forcing the boolean input to S4 (selector on middle-left) to be constantly true. With that we get the error message "index-1 and derivative evaluation failure on event at t=40.540882".  The cause of that is that the "denominator" to divider D5 (left side of schematic) is going to zero.  Note that its output is from switch S2, one of whose inputs is tied to 0.  You need to figure out how to prevent a division by zero.  I don't know what the model is doing to suggest something.

Your condition is correct.  What is the full error message?  Note that the call to print is invalid, use double-quotes (not single forward quotes) to create a string.

In general, fsolve has more than one way to indicate it didn't find a solution.  It may return NULL.  It may also return the unevaluated call, fsolve(...).

Off the cuff:

- a working concept of Maple's Simplification table
- familarity with the ?debugger
- ?CodeTools package.
- ?debugopts (esoteric, but traceproc and procdump are useful when CodeTools stuff doesn't do what you want)
- ?numelems
- ?_passed, _npassed, _rest, _nrest, _options, etc...
- ?upperbound, lowerbound

If the goal is to be able to manipulate an inert function call and various symbolic parameters, then later evaluate them, you could use the following technique.

s := 1;
U := proc(c) if s = 1 then log(c) else 1/(s-1) end if; end proc: # or whatever ...
y := %U(c)^2 + %s;   # use %U and %s rather than U and s
                                                    2
                                            y := %U(c)  + %s
value(y);
                                                    2
                                               ln(c)  + 1



Rather then assigning Functions2, I'd consider doing

U := proc(c)
global s;
  if not [args]::list(numeric) then return 'procname'(args) end if;
  if s = 1 then
     return log(c);
  else
     return (c^(1-s)-1)/(1-s);
  end if;
end proc:

Then

eval(U(c),Parameters2);
                                  0

By total derivative I assume you mean the gradient.

> y:=(a-3)/(b+3);
                                       a - 3
                                  y := -----
                                       b + 3

> eval(y,[a=r*t,b=s*t]);
                                    r t - 3
                                    -------
                                    s t + 3

> VectorCalculus:-Gradient(%,[r,t]);
                       t    _    /   r      (r t - 3) s\ _
                    ------- e  + |------- - -----------| e
                    s t + 3  r   |s t + 3            2 |  t
                                 \          (s t + 3)  /

First 49 50 51 52 53 54 55 Last Page 51 of 114