Axel Vogt

5936 Reputation

20 Badges

20 years, 251 days
Munich, Bavaria, Germany

MaplePrimes Activity


These are replies submitted by Axel Vogt

you can use g:=codegen[makeproc](f(x),x) to get a procedure from the function f, it will behave as desired
I never understood that layout, but whatever was said up to now it was ignored by Maplesoft (it looks like a school magazin) there is pretty much place in the header for the login fields, the 'overviews' are easily put into some 'drop downs' in the menu bar as well (and those polls should disappear for ever). Then there would be space enough.
Write it as follows:

  eq2:=(Y+sqrt(Y^2-X^2*c^2))/2 - c;
  L2:=[Y=(b^2+a^2), X=2*a];

Evaluating with L2 gives the original equation.

Now solve it with 'paper and pencil' using Maple:

  isolate(eq2, (Y^2-X^2*c^2)^(1/2));
  lhs(%)^2=rhs(%)^2;
  lhs(%)-rhs(%)=0;
  collect(%,c);

You achieve at (-X^2-4)*c^2+4*Y*c = 0.

It has c=0 as solution. Dividing for c != 0 will
give the other solution 4*Y/(X^2+4), which Maple
gives as well and which has to be understood 
(evaluating in L2 gives the initial problem).

  sol2:=[solve(%,c)];

                                      4 Y
                         sol2 := [0, ------]
                                      2
                                     X  + 4


First that is formal, i.e. as far as it exists.

Second it means: it is necessary for eq2 = 0.

You want it to be sufficient as well. It is not:

  tst2:=subs(a=2,b=2,L2); # plot original problem

                        tst2 := [Y = 8, X = 4]

  eval(sol2,tst2);
                                [0, 8/5]

  eval(eq2,tst2); eval(%, c=8/5): simplify(%);

                                     2 1/2
                           (64 - 16 c )
                       4 + --------------- - c
                                  2


                                 24/5

I hope I made not too many errors ...
May be, because the quite general answer is based on an algorithms and Maple does not know about any way to simplify it to a number? How about this:

rationalize(A(x,1)): 
a:=numer(%): b:=denom(%%):

a*convert(1/b,fullparfrac) 
int(%,x=0..infinity);
                                   1/2
                               -2 2
... i should have thought first and thanks for showing a geeky way :-)
... i should have thought first and thanks for showing a geeky way :-)
is there a similar way to replace each local variable in a procedure, so that it is considered as float (before compiling)? what i want here: say i have my procedure so far and i want it to be compiled - but i want to avoid to edit it manually to declare each of the variables as float (only floats, no other types).
is there a similar way to replace each local variable in a procedure, so that it is considered as float (before compiling)? what i want here: say i have my procedure so far and i want it to be compiled - but i want to avoid to edit it manually to declare each of the variables as float (only floats, no other types).
Thank you, very elegant! It reminds me, that it is really time for me to learn that functional stuff in Maple ... sigh PS: as my code could be longer (and exponents are quite various) I prefer it over an ad-hoc-solution (while it is also a nice idea what Tim Van Dusen wrote).
Thank you, very elegant! It reminds me, that it is really time for me to learn that functional stuff in Maple ... sigh PS: as my code could be longer (and exponents are quite various) I prefer it over an ad-hoc-solution (while it is also a nice idea what Tim Van Dusen wrote).
type in "?Mathematica", a short way is to use convert( yourExpression, FromMma);
have not tried it, but it seems to be the very thing for interactive graphics from Maple for the web ... only the light version is selectable to be loaded by the user to let him display & work? the only odd thing from the examples was: it wanted a specific Java version (which is a mess, especially if you do not have a very fast connection ... and I have a modem at home)
have not tried it, but it seems to be the very thing for interactive graphics from Maple for the web ... only the light version is selectable to be loaded by the user to let him display & work? the only odd thing from the examples was: it wanted a specific Java version (which is a mess, especially if you do not have a very fast connection ... and I have a modem at home)
Here are some variants:

time(add(isprime(n), n = 1 .. 11112)); # yours, my PC is slower

                                0.061

time(`+`(op(select(isprime,[$1..11112]))));

                                0.062

numtheory:-pi(11112):
time(`+`(ithprime(i) $ i=1..%));

                                0.014

The last version is a bit unfair: to find that number Maple needs
about the same time, so it is actually ~ 0.03 sec. Up to 10^5 it
is faster.

Note however that this usage of 'time' does not measure the time
needed to create necessary data structures, see the help.

If you want it faster search the board for 'alec' and 'isprime'
and http://www.mapleprimes.com/blog/alec/the-eratosthenes-sieve
will show you related compiled versions (of course numbers must
fit into a compiled integer), ES2 is from the link.

Then after compiling (which is very quick and only once): 

time(`+`(op(convert(ES2(10^5),listlist)))); 

                                0.016

time(`+`(op(convert(ES2(10^6),listlist)))); 

                                0.125

while the non-compiled versions from the beginning would need
7 - 8 seconds for the last result.

Of course you could do adding in a compiled version as well and
that should be even faster.

Here are some variants:

time(add(isprime(n), n = 1 .. 11112)); # yours, my PC is slower

                                0.061

time(`+`(op(select(isprime,[$1..11112]))));

                                0.062

numtheory:-pi(11112):
time(`+`(ithprime(i) $ i=1..%));

                                0.014

The last version is a bit unfair: to find that number Maple needs
about the same time, so it is actually ~ 0.03 sec. Up to 10^5 it
is faster.

Note however that this usage of 'time' does not measure the time
needed to create necessary data structures, see the help.

If you want it faster search the board for 'alec' and 'isprime'
and http://www.mapleprimes.com/blog/alec/the-eratosthenes-sieve
will show you related compiled versions (of course numbers must
fit into a compiled integer), ES2 is from the link.

Then after compiling (which is very quick and only once): 

time(`+`(op(convert(ES2(10^5),listlist)))); 

                                0.016

time(`+`(op(convert(ES2(10^6),listlist)))); 

                                0.125

while the non-compiled versions from the beginning would need
7 - 8 seconds for the last result.

Of course you could do adding in a compiled version as well and
that should be even faster.

First 189 190 191 192 193 194 195 Last Page 191 of 209