Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are answers submitted by Joe Riel

The problem specification is lacking in detail.  For example,

  f := () -> 0;

satisfies the requirements in that the output is always an odd or even integer (here it's always even).

Maple's printf command does not provide an explicit repeat flag.  There are a few ways around this. One way is to use ?cat with the $ operator to duplicate the format string:

printf(cat("\n", "-+8.4f%" $ 10), e[5], ... );

Note: I don't know why MaplePrimes inserted newlines when formatting that line.

Another possiblity is to insert the output into a Vector

printf("\n-+8.4f%", < e[5], ... > );

To specify a dos path in Maple, as a string, which is what the ?system command uses, you have to escape the backslashes used as component separators.  That means preceding them with another backslash.  Thus

system("dir c:\\Users\\joe\\maple");

I've done a quick profile of your code. It is immediately apparent that almost all the time is being spent in the calls to CurveFitting:-ArrayInterpolation. While I haven't looked closely enough to be sure, it appears as though you could remove those calls from the loops and pass the vector of x-coordinates (as the second argument), rather than calling the function with a single x-coordinate.  That should save a huge amount of time.

That is, do not do this

for i to 1000 do
    y := ArrayInterpolation(xy_data, x[i]);
    ... y ...
end do;

Instead, do this

y := ArrayInterpolation(xy_data, x);
for i to 1000 do
   ... y[i] ....
end do;

I'd probably do

add(add(`if`(i+j<=8, A[i]*B[j],0),i=1..6),j=1..6);

Use ?evalc:

evalc(Re(5*Dirac(x)+3*I));
                                                5*Dirac(x)

Your computation of the transfer function is correct, however, that is only a partial answer. One way to compute it is to use ?DynamicSystems:

deq := diff(y(t),t,t)+1/4*diff(y(t),t)+y(t)=g(t):
sys := DynamicSystems:-TransferFunction(deq,g,y):
sys:-tf;

I suspect that you want to find the complete solution, using the definition of g and the initial conditions.  That can be done with ?dsolve:

dreq := g(t) = piecewise(t<=5,0,4);
ini := {y(0)=0, D(y)(0)=0};
dsolve( eval({deq},dreq) union ini );


On Linux, Ctrl-Shift-Tab works.  Alternatively, you can do Alt-w #, where # is the tab number.

What sort of plot are you trying to create? Maple raises an error because the plot command does not recognize that list as valid input. It isn't clear what you want. Why do the ranges have zero measure?

A statement that raises an error doesn't return the error as a string.  It is possible to use ?traperror, a deprecated procedure, to return the string. The preferred method, as you know, is to use try/catch. For example

is(traperror(tan((1/2)*Pi)) = "numeric exception: division by zero"); 
                                         true

Note that the string does not include "Error, (in tan)".

I'm investigating this. In the meantime, removing the diodes allows it to simulate.  That should, of course, not be necessary.

There is a bug in the handling of the initial conditions.  I'm submitting an SCR against this.  To work around it, assign initialconditions to the empty list:

initialconditions := []:

Then, after generating the component, edit the Modelica source.  Above the 'equation' statement, add

initial equation
   Tgo = Tgi;
   Two = Twi;

Then click the "Generate Component from Source" button.

While I'm not sure the precise cause (it has to do with Maple commands being used by the GUI itself), to work around it I temporarily unassign print/rtable with

`print/rtable` := NULL:

That will break the display of some rtables, but avoids the problem with stoperror in the GUI. 

It isn't practically possible to maintain a DC voltage across an inductor.  The DC voltage has to be 0. You can add a resistor from the base of the transistor to ground to prevent the simulation problems, but basically you will need to rethink what is being accomplished.

 

You should be able to solve that manually.  When does y^x = 1?

 

First 42 43 44 45 46 47 48 Last Page 44 of 114