acer

33193 Reputation

29 Badges

20 years, 216 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

The addition and subtraction of the same multiple of x in the last equation (and other absence of automatic simplification) is indication of a cut&paste job.

It remains to be seen whether the OP might have made a transcription mistake, or might want a best fit (LeastSquares, say, easy enough after using GenerateMatrix).

@Gillee On my 64bit Linux the Threads:-Map is somewhat faster than the map instances, in Maple 2018.2 and 2020.1.

Keep in mind that n=100 is small, and Threads:-Map often needs a large number of items before the thread management overhead is small compared to the overall computation time. With n=100 there might not be any benefit, and the relative performance situation could even be switched on some platforms. That's not unreasonable.

You could also run with n=1000 or n=10000 and iterations=1. For n=10000 I see Threads:-Map being about twice as fast as map.

I should probably also have used a larger n to illustrate. The Original Poster had size equivalent to n=100 in his Question.

How accurately do you want to know evalf(R5)?

@radaar I wrote the FFG procedure so that I could Compile it. The Compiler will translate an `add` call to a loop anyway, so I doubt it'd improve much when compiled.

Moreover,  I've seen problems where the compiled translation messes up (casting floats to integers), so that's another reason I wrote out the loop myself.

What do you mean by, "I found out that my exact results are not correct"?

ps. I deleted one duplicate posting of this question. If you want to include a worksheet then attach it to a Comment here, instead of unhelpfully posting it in a new and separate Question thread.

You can check the exact result symbolically:

restart;
de:=diff(y(x), x) = 2*(1+x)-y(x):
Y:=dsolve({de, y(2) = 5});
                                                         
                          exp(-x)
        Y := y(x) = 2 x + -------
                          exp(-2)

eval(Y,x=2);

                y(2) = 5

evalb(eval(de, Y));

                  true

Are you trying to say that you had difficulty with your numeric computations?

@sepbergliaffa I didn't state that you ought to use just simplify(...,radical). I was trying to point out the difference between it as simplify(...,radical,symbolic), which is germane here.

The use of assumptions, and aspects of the symbolic option, is mentioned in the Help. That's why I referred to the Help.

@panke The code has to be such that the plots would be printed, or else it won't get sent to either the worksheet or any file.

I mentioned before (in two responses!) that you might want to wrap with a print call (if the plots wouldn't normally be printed due to further nesting, being inside a procedure, etc...).

If you terminate the loop with a full colon (or nest further, etc) then the plots wouldn't get printed inline either.That's why I suggested print(plot(...)) which you ignored when you used display(...).

@aoakindele What do you intend by  (D@@(F))(0)  in the boundary conditions?

@aoakindele 

You have a term
   F*(diff(theta(eta), eta))
in your DEs. Did you intend it to be, say,
   F(eta)*(diff(theta(eta), eta))

The error message states that "F(eta) and F cannot both appear in the given ODE". Doesn't that explain the problem?

@Carl Love He has inf=1 in the upper BCs (which happens to exceed the plotting range), but it's not clear yet whether he'll eventually want a greater value and run into convergence issues.

@panke Why don't you upload and attach your worksheet?

(Btw, why not utilize print around display?) [edit] Why ignore my earlier advice?

 

@pik1432 If you had asked that question about structure and representation on its own then I might just point you to the Help pages on:
  dismantle
  ToInert
and the Programming Guide sections:
  Internal Representation
  Types and Operands

But given your original Question in this thread, I'll explain some of the steps, from an "operand" point of view.

restart;

subexp := M__a*sin(omega*t + alpha)*I__a*sin(omega*t + phi);

M__a*sin(omega*t+alpha)*I__a*sin(omega*t+phi)

# As mentioned before, this factors out the 2, and
# it seems you don't want that. So an alternate approach
# involves splitting the product into the multiplicands
# which are trig calls from those which are not.
#
combine(subexp);

(1/2)*M__a*I__a*(cos(alpha-phi)-cos(2*omega*t+alpha+phi))

op(0, subexp);  # It is a product

`*`

op(subexp);     # A sequence of the operands

M__a, sin(omega*t+alpha), I__a, sin(omega*t+phi)

nops(subexp);   # The number of operands

 

4

for i from 1 to nops(subexp) do
  print(op(i,subexp));
end do;

M__a

sin(omega*t+alpha)

I__a

sin(omega*t+phi)

# Select only those operands of a certain type.
# Note the the result has the same 0-th (zeroth)
# operand, it result is also of type `*`.
#
select(type, subexp, trig);

sin(omega*t+alpha)*sin(omega*t+phi)

# Remove only those operands of a certain type.
#
remove(type, subexp, trig);

M__a*I__a

# Split only the operands according to a certain type.
# Note: this returns a pair of `*` expressions -- one from
# the `select` and one from the `remove`.
#
selectremove(type, subexp, trig);

sin(omega*t+alpha)*sin(omega*t+phi), M__a*I__a

# Perform an operation on the two separate pieces.
# (I could has assigned them to temp names and acted
# differently on each. But the `combine` happens to not
# do anything to the other, here.
#
map(combine, [selectremove(type, subexp, trig)]);

[(1/2)*cos(alpha-phi)-(1/2)*cos(2*omega*t+alpha+phi), M__a*I__a]

# Multiply those two results.
#
`*`( op(map(combine, [selectremove(type, subexp, trig)])) );

M__a*I__a*((1/2)*cos(alpha-phi)-(1/2)*cos(2*omega*t+alpha+phi))

 

# And now, just in case you find it interesting...
dismantle(subexp);


PROD(9)
   NAME(4): M__a
   INTPOS(2): 1
   FUNCTION(3)
      NAME(4): sin #[protected, _syslib]
      EXPSEQ(2)
         POLY(6)
            EXPSEQ(4)
               NAME(4): alpha
               NAME(4): omega
               NAME(4): t
            DEGREES(HW): ^2 ^0 ^1 ^1
            INTPOS(2): 1
            DEGREES(HW): ^1 ^1 ^0 ^0
            INTPOS(2): 1
   INTPOS(2): 1
   NAME(4): I__a
   INTPOS(2): 1
   FUNCTION(3)
      NAME(4): sin #[protected, _syslib]
      EXPSEQ(2)
         POLY(6)
            EXPSEQ(4)
               NAME(4): omega
               NAME(4): phi
               NAME(4): t
            DEGREES(HW): ^2 ^1 ^0 ^1
            INTPOS(2): 1
            DEGREES(HW): ^1 ^0 ^1 ^0
            INTPOS(2): 1
   INTPOS(2): 1
 

ToInert(subexp);

_Inert_PROD(_Inert_NAME("M__a"), _Inert_FUNCTION(_Inert_ASSIGNEDNAME("sin", "PROC", _Inert_ATTRIBUTE(_Inert_EXPSEQ(_Inert_NAME("protected", _Inert_ATTRIBUTE(_Inert_NAME("protected"))), _Inert_NAME("_syslib")))), _Inert_EXPSEQ(_Inert_SUM(_Inert_PROD(_Inert_NAME("omega"), _Inert_NAME("t")), _Inert_NAME("alpha")))), _Inert_NAME("I__a"), _Inert_FUNCTION(_Inert_ASSIGNEDNAME("sin", "PROC", _Inert_ATTRIBUTE(_Inert_EXPSEQ(_Inert_NAME("protected", _Inert_ATTRIBUTE(_Inert_NAME("protected"))), _Inert_NAME("_syslib")))), _Inert_EXPSEQ(_Inert_SUM(_Inert_PROD(_Inert_NAME("omega"), _Inert_NAME("t")), _Inert_NAME("phi")))))

 

Download op_example.mw

@Katatonia I suggest that you upload and attach your complete code and worksheet to a Reply.

(The failure of the numeric integration involving Y5 may be just a matter of working precision and tolerance, but why guess?)

@pik1432 One of my points is that it's easy to simply type this in:

M__a*I__a*combine(sin(omega*t+alpha)*sin(omega*t+phi));

       M__a I__a (1/2 cos(alpha - phi) - 1/2 cos(2 omega t + alpha + phi))

But doing so (and the same for similar approaches where you have to manually separate or introduce the M__a*I__a factor) is rather ad hoc.

I'd like an ARM port of the kernel and command-line interface.

First 174 175 176 177 178 179 180 Last Page 176 of 608