acer

32333 Reputation

29 Badges

19 years, 323 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@pgordon1998 Your output shows that you have not yet assigned anything to list_to_set (or set_to_list).

Did you write previous code for a procedure for list_to_set? That's the task. Perhaps you've written a procedure for it, but did not assign it properly?

@susanhl I've tried to tell you that I think that your original method (and Tom's "fix" for it) has several dubious aspects to it.

You could use dsolve(...,numeric) to find the first time t at which the displacements match their targets.

I've edited my Answer to illustrate how your original could be used to try and find the solution with smallest positive t.

@susanhl I'm now supposing that you're simply trying to solve eindx and eindy together. That is, to find values for t and v0 which satisfy both those equations.

This can be done directly in your worksheet, without any weird indexing, any use of fixed accuracty approximations of Pi, etc. And especially without any dubious looking RootOfs or float coefficients with very large exponents.

I've used Maple 16 below, like your original.

Perhaps you'd want to supply ranges for t or v0 in the call to fsolve? And there may be more than one solution.

restart

kernelopts(version);

`Maple 16.01, X86 64 LINUX, May 6 2012, Build ID 744592`

mbal := 0.28e-2:

rbal := 0.2e-1:

Cw := .47:

g := 9.81:

A := Pi*rbal^2:

beta := 3.33*Pi*(1/180):

s0x := .2:

s0y := .25:

rho := 1.293:

l := 2:

vx := diff(sx(t), t);

diff(sx(t), t)

vy := diff(sy(t), t);

diff(sy(t), t)

ax := diff(sx(t), `$`(t, 2));

diff(diff(sx(t), t), t)

ay := diff(sy(t), `$`(t, 2));

diff(diff(sy(t), t), t)

v0x := cos(beta)*v0;

cos(0.1850000000e-1*Pi)*v0

v0y := sin(beta)*v0;

sin(0.1850000000e-1*Pi)*v0

`ΣFx` := -Fdx = mbal*ax;

-Fdx = 0.28e-2*(diff(diff(sx(t), t), t))

`ΣFy` := -Fz-Fdy = mbal*ay;

-Fz-Fdy = 0.28e-2*(diff(diff(sy(t), t), t))

Fz := mbal*g;

0.27468e-1

Fdx := .5*rho*vx^2*A*Cw;

0.1215420e-3*(diff(sx(t), t))^2*Pi

Fdy := .5*rho*vy^2*A*Cw;

0.1215420e-3*(diff(sy(t), t))^2*Pi

ics1 := sx(0) = s0x, (D(sx))(0) = v0x;

sx(0) = .2, (D(sx))(0) = cos(0.1850000000e-1*Pi)*v0

ics2 := sy(0) = s0y, (D(sy))(0) = v0y;

sy(0) = .25, (D(sy))(0) = sin(0.1850000000e-1*Pi)*v0

verplaatsingx := dsolve({ics1, `ΣFx`}, sx(t)):

verplaatsingy := dsolve({ics2, `ΣFy`}):

eindy := rhs(verplaatsingy) = rbal:

eindx := rhs(verplaatsingx) = l:

S1 := fsolve({eindx,eindy}, {t,v0}, {t=0..infinity});

{t = 2.505529244, v0 = .8156407228}

eval(t,S1);

2.505529244

S2 := fsolve({eindx,eindy}, {t,v0}, {t=0..eval(t,S1)}, avoid={S1});

{t = .2655908244, v0 = 7.694586917}

S3 := fsolve({eindx,eindy}, {t,v0}, {t=0..eval(t,S2)}, avoid={S1, S2}):
op(0,eval(S3,1)); # unevaluted return, ie. no earlier root

fsolve

#
# Let's write a loop to try and find the least
# positive value of t which solves {eindx,eindy}.
# This stops when no solution with smaller positive
# value for t is found.

continue := 'continue': found := {}: lastT := infinity:
while continue <> false do
  printf("searching on %a\n",t=0..lastT);
  S := fsolve({eindx,eindy}, {t,v0}, {t=0..lastT}, avoid=found);
  if op(0,eval(S,1)) <> fsolve then
    lastT,lastv0 := eval(t,S),eval(v0,S);
    printf("  solution found for %a\n",t=lastT);
    found := S;
  else
    printf("  no smaller solution found");
    continue := false;
  end if;
end do:

searching on t = 0 .. infinity
  solution found for t = 2.505529244
searching on t = 0 .. 2.505529244
  solution found for t = .2655908244
searching on t = 0 .. .2655908244

  no smaller solution found

t=lastT, v0=lastv0;

t = .2655908244, v0 = 7.694586917

 

Download ttbuddymaple_ac4.mw

Why don't you show us how far you managed to get with this so far.

Why don't you show us how far you managed to get with this so far.

If the problem occurs even without your using PackageTools:-Install then remove that aspect from your upload.

Some people may execute your workbook's worksheet without realizing that doing so installs your module into their harddrive (thus affecting the Maple namespace for all future sessions, unless they realize that it should be uninstalled.)

@Carl Love For singular values it can depend on the size. By that I mean that an iterative technique for computing only selected singular values might be slower that a highly optimized dedicated routine for finding all singular values of a dense Matrix. One piece of Matlab documentation say, "Using svds is not the most efficient way to find a few singular values of small, dense matrices. For such problems, using svd(full(A)) might be quicker. For example, finding three singular values in a 500-by-500 matrix is a relatively small problem that svd can handle easily."

The singular value functions in the MKL implementation of LAPACK are fast, and difficult to beat for modestly sized Matrices. That's true even for the DGESVD that Maple 2019's SingularValues uses, which does not provide for computing only a selection of singular values. There is a newer Jabobi implementation DGEJSV available in MKL, computing a range of singular values, but no direct link to it in Maple as yet. (See also here. And the older Jacobi implementation DGESVJ without the range functionality, also without a direct link from Maple.)

The most important things to keep in mind here, for performance of this computation in Maple, is to have the Matrix with datatype=float[8] and shape=symmetric. Here's a comparison of SingularValues versus Eigenvalues (the latter done with and without shape=symmetric). The very small singular values are computed by Eigenvalues less accurately for this example. But perhaps the small speed improvement over SingularValues might make it attractive for computing only a selection of the "larger" singular values.

singvals.mw

I made an old Post about computing only a selection of eigenvectors, for a real symmetric Matrix. That code can be modified to compute only eigenvalues. It needs revision and updating, on account of how the external compiled functions are named and accessed in modern Maple. It may not be possible to compare properly, because since the date of that Post Maple's Eigenvalues has switched from using a generic LAPACK DSYEVX (with MKL BLAS) to the MKL DSYEVD. The former allows computation of only a selection of eigenvalues, while the latter does not. But their performance difference is significant, with the MKL being so optimized that a partial eigenvalue computation with that DSYEVX against the full eigenvalue computation with MKL DSYEVD still favors the latter. It's also complicated since it may not be possible to define_external from Maple to the MKL functions directly. I'll add a comment if I find a performance breakthrough for selected eigenvalues or singular values.

(It may still be able to edge out the selected eigenvectors computation, although that's off-topic.)

@emendes Again, I'm not sure that I understand what form you're after.

Here's another idea.

Download example1_eqns_ac.mw

@Stretto It's pointless to state such an objection without supply the full example that goes unexpectedly for you. You latest objection is meaningless without adequate context to tell us precisely what code utilizes this approach and then proceeeds contrary to what you extect.

Please don't post close duplicate Question threads related to evaluations rules and instances where your code is evaluating prematurely. Please keep you followups to the original threads (such as this one). Read the Programming Guide. Try to understand the point of the answers people give you. Supply full code-to-reproduce for your problematic examples.

@digerdiga Using evala at that place happens to accomplish the same step as would radnormal here (for this example).

The radnormal command is supposed to serve by putting radical numbers into a "normal" or canonical form. The evala or evala(Normal(...)) command may serve to do something similar for algebraic numbers (eg, RootOf). The evala command is strong enough to handle your example's explicit radicals as well.

My last pair of successful calls above appear the same -- except for the calls to evala versus radnormal. Both happen to work, for your particular example.  And this is not that rare a situation for examples containing radicals -- but of course not always so.

There are quite a few known examples for which a mix of evala, expand, radnormal, rationalize, combine, simplify and evalc do better than simplify alone.

Knowledge of the existence of such examples is not novel.

@arpana Put such very similar queries in the same post.

Yes, please provide an example which illustrates the difficult case. You can attach a worksheet to your response (green up-arrow).

Either post the full code here as valid plaintext Maple, or upload an attachment .mw file that contains it.

Please stop submitting duplicate Questions.

You submitted this three time within an hour. I've deleted the other two.

First 202 203 204 205 206 207 208 Last Page 204 of 591