Axel Vogt

5936 Reputation

20 Badges

20 years, 254 days
Munich, Bavaria, Germany

MaplePrimes Activity


These are replies submitted by Axel Vogt

In this special case one can use a method which is part of 'identify':

  Digits:=20:
  k/Pi^4; subs(k=104,%); a:=evalf(%);

  w := [a, Pi, Pi^2, Pi^3, Pi^4, 1/Pi, 1/(Pi^2), 1/(Pi^3), 1/(Pi^4)]

  u:=IntegerRelations:-LinearDependency(evalf(w), method=LLL);

  'A'*u[1]+'Sum( u[i]*w[i],i=2..nops(w))': value(%); 
  eval( isolate(%,A), A=a);

  `error` = evalf(lhs(%)-rhs(%));


                                             104
                     1.0676621544871708597 = ---
                                               4
                                             Pi

                              error = 0.

This is very fast (but weaker than 'identify', it fails with 1/a).

Playing with it (higher precision, larger base) gives examples,
where it will be difficult to find a 'correct' presentation, the
precision may be up to the last decimals - but are not correct
(mainly because of rational representations of floats).

A nice technique!

BTW: the help in Maple 12 does not find 'DFactorLCLM' while it does in Maple 11
and it does not find 'Change' (for the quite natural way shown by Robert Israel)

This is more than sad, there seem to be lost help links in the new version :-(((

ExportMatrix does more or less what I would expect:

P := plot3d(2*x-3*y+4, x = 0 .. 2, y = 0 .. 2, grid = [5, 5]);
Q := op(indets(P, Array));
Q:=convert(Q,Matrix);
ExportMatrix("D:/temp/My_File8.txt", Q,  format=rectangular);

However the quite silly and dump help does not find a way
to guide the user, try F1help on write or export ... a mess.

 

ExportMatrix does more or less what I would expect:

P := plot3d(2*x-3*y+4, x = 0 .. 2, y = 0 .. 2, grid = [5, 5]);
Q := op(indets(P, Array));
Q:=convert(Q,Matrix);
ExportMatrix("D:/temp/My_File8.txt", Q,  format=rectangular);

However the quite silly and dump help does not find a way
to guide the user, try F1help on write or export ... a mess.

 

do not know the English expression ... it means something like "artifically complicated"

But - if your user is not able to hit the run button in Maple - why do you not simpliy start
Maple from C++ through a shell command? That should be possible (even in Windows)?

Working in (software) industry for several years I had to learn: the most expensive solutions
arise, if you want to do soemthing through programs, which is quite easily achived through
re-organisation work (i.e. short intro to handling Maple in about 30 minutes).

and: do not mind for your English ... this is not for a test ... which would fail as well :-)

do not know the English expression ... it means something like "artifically complicated"

But - if your user is not able to hit the run button in Maple - why do you not simpliy start
Maple from C++ through a shell command? That should be possible (even in Windows)?

Working in (software) industry for several years I had to learn: the most expensive solutions
arise, if you want to do soemthing through programs, which is quite easily achived through
re-organisation work (i.e. short intro to handling Maple in about 30 minutes).

and: do not mind for your English ... this is not for a test ... which would fail as well :-)

If I understand it correctly then I would write a Maplesheet, which receives its data and parameters from a (text) file, where that comes from the shell script (to be run before)

If I understand it correctly then I would write a Maplesheet, which receives its data and parameters from a (text) file, where that comes from the shell script (to be run before)

After some 3rd thoughts ... the term exp(((d-u)/(d*u))^2)*(1-erf((d-u)/(d*u)))
is Mills' ratio I think, for which *good* numerics are available (I did that
in the code of my blog posts on exact computations for Black-Scholes and the
computation of implied volatility).

So the integrand is like Gaussian * Mills ratio and for proper integration now
I would code the ratio as separate function (it is a friendly one) and the
task should be done in usual double precision, i.e. with 14 Digits.
After some 3rd thoughts ... the term exp(((d-u)/(d*u))^2)*(1-erf((d-u)/(d*u)))
is Mills' ratio I think, for which *good* numerics are available (I did that
in the code of my blog posts on exact computations for Black-Scholes and the
computation of implied volatility).

So the integrand is like Gaussian * Mills ratio and for proper integration now
I would code the ratio as separate function (it is a friendly one) and the
task should be done in usual double precision, i.e. with 14 Digits.
May be, because I use erf instead of his approximation 'erfy'
and was working with rationals ...

I think the numerical problem can be understood: He uses a term
1 - erf(  (((d-u)/(d*u))) ) in a range 0.13 ... 0.55 where the
inner term is (2.4-u)/u/2.4 and plotting let it reach infinity
towards u ~ 0, it is falling from ~ 7 to 0 in that range.

My ~1.6 above is a typo - it is ~ 0.16. This for the one point
is, where his 'erfy' switches. The other is: then one gets some
precision & cancellation  problems by 1 - erf(_large_) ~ 0 and
it is better to use the complementary erfc.

Additionally that is multiplied by exp( innerTerm^2 ) achieving
exp(7^2) ~ 10^22 and multiplied a Gaussian exp(-(u-a)^2/b^2),
which is ~ 1 in the range and erfc falls down to 10^(-24).

Now Maple is going to evaluate that functions ... and the exp
almost explodes at the left boundary with flat erfc.

After that feeling says, that for integration it must be handled
as a numerical singularity.

Note that a plot will not care to much for it (using precision
high enough), but an integrator may got trapped.


For the task exp(-(1/d)^2)*d*g is a constant, which should be
done outside the integral.

Note that the parameter n=3 in the function 'core' is *not used*.
May be, because I use erf instead of his approximation 'erfy'
and was working with rationals ...

I think the numerical problem can be understood: He uses a term
1 - erf(  (((d-u)/(d*u))) ) in a range 0.13 ... 0.55 where the
inner term is (2.4-u)/u/2.4 and plotting let it reach infinity
towards u ~ 0, it is falling from ~ 7 to 0 in that range.

My ~1.6 above is a typo - it is ~ 0.16. This for the one point
is, where his 'erfy' switches. The other is: then one gets some
precision & cancellation  problems by 1 - erf(_large_) ~ 0 and
it is better to use the complementary erfc.

Additionally that is multiplied by exp( innerTerm^2 ) achieving
exp(7^2) ~ 10^22 and multiplied a Gaussian exp(-(u-a)^2/b^2),
which is ~ 1 in the range and erfc falls down to 10^(-24).

Now Maple is going to evaluate that functions ... and the exp
almost explodes at the left boundary with flat erfc.

After that feeling says, that for integration it must be handled
as a numerical singularity.

Note that a plot will not care to much for it (using precision
high enough), but an integrator may got trapped.


For the task exp(-(1/d)^2)*d*g is a constant, which should be
done outside the integral.

Note that the parameter n=3 in the function 'core' is *not used*.
I see ... then probably you only work with the Maple kernel and not
in an actual worksheet.

The following might be a way: save the plots to a file, read them
in later in an actual sheet for manual export:

  myDir:= "d:\\temp\\";         # your working directory

  plot(exp(x), x=-2 .. 1);      # some plot
  P:=%:                         # save plot as structure


  save P, cat(myDir,"tst.txt"); # then save into a file, that's an ASCII file

  P:='P';                       # refresh variable for a test

  read cat(myDir,"tst.txt"):    # read it
  plots[display](P);            # show the graphic


I played with 'writeto' and 'appendto', but was too stupid for that.
I see ... then probably you only work with the Maple kernel and not
in an actual worksheet.

The following might be a way: save the plots to a file, read them
in later in an actual sheet for manual export:

  myDir:= "d:\\temp\\";         # your working directory

  plot(exp(x), x=-2 .. 1);      # some plot
  P:=%:                         # save plot as structure


  save P, cat(myDir,"tst.txt"); # then save into a file, that's an ASCII file

  P:='P';                       # refresh variable for a test

  read cat(myDir,"tst.txt"):    # read it
  plots[display](P);            # show the graphic


I played with 'writeto' and 'appendto', but was too stupid for that.

for k=1 the inverse is not a function, see above ... I think there is no name for it (as already said)

may be you can use Langrange inversion in t=Pi or Pi/2 to write down a series

First 175 176 177 178 179 180 181 Last Page 177 of 209