Axel Vogt

5936 Reputation

20 Badges

20 years, 252 days
Munich, Bavaria, Germany

MaplePrimes Activity


These are replies submitted by Axel Vogt

There was a reason why not to set always _EnvAllSolutions:= true at starting Maple ... but I can not remember ... would somebody mind to recall it? And: still I would like to know whether TI89 replies by symbolic answers for the roots and the integral.
Do not know TI: do you say it gives a *symbolic* solution?

The 1st one is a bit strange, but there are stronger solvers than
the pure 'fsolve'. Anyway 

  RootOf( (sqrt(2)+1)^x+(sqrt(2)-1)^x - 3,x); allvalues(%); 

should not give 

  RootOf((2^(1/2)+1)^_Z+(2^(1/2)-1)^_Z-3,-1.0919588064509)

Since I almost always plot I would use

  sqrt(2)+1)^x+(sqrt(2)-1)^x = 3; fsolve(%,x=1.0);

to get the symmetric positive root.



The integration is nasty ... I killed my Maple in inpatience ...
A formal antiderivative is very long, 764324 characters ~ 160 pages

But a numerical values is identified as Pi/4 ... so I plotted the
stuff ... seems one could try to use the inverse to compute that:

  'sqrt(sin(x))/(sqrt(sin(x))+sqrt(cos(x))) = y'; L:=[solve(%,x)];

gives a warning and 4 solutions - but which one?

For x=Pi/4 the original function equals 1/2, so using

  eval(L);

    [1/4*Pi, -3/4*Pi, 1/4*Pi, -3/4*Pi]

tells me, which of the 4 solutions to take, it is L[1] (take care
the index may change in different runs).

Now int(L[1],y=0..1); responds quickly with a symbolic answer,
which is summing (the antiderivative I think) over the roots of
a polynomial of 4th order.

One can force the system to drop that abbreviation, since roots
up to 4th order can be given explicitly by applying allvalues(%)
after the integration.

That results in a longer expression having log and sqrt involved.
Playing with it brought me to use

  convert(%,exp); evalc(%); evala(%);

And I get Pi/4.

Of course a purely numerical answer is much quicker and easy.
Using your presentation I call the integrand K(t).

One observes that A:=Re(K(t))=1 (first plotting it and then proves it by 
powsubs(1-3*cos(t)^2+3*cos(t)^4 = a,A); simplify(%) assuming (0 LT a,a LT 1);

Denoting B:=Im(K(t) (after simplifying due to the range of t) one sees
that is periodic with period Pi/2 [since B/eval(B, t = t+2*Pi/2) equals 1]
and symmetric [by handwaving], hence Int(B, t=0..Pi/4) is what is needed.

Applying Change(%, t=tau/4); Change(%, 5+3*cos(tau) = (rho)); makes it
an algebraic integral, which quickly evaluates to 0.11017518233813 (had
some sign problem if running twice, but it is positive due to plotting).

So we have 1/3 * (2*Pi + 2*0.11017518233813*4*I) = 2.0943951023932 +
0.29380048623501*I which coincides with your posted result.


PS: Change(%, t=tau/4); Change(%, tau= arccos(2*rho-1)); gives a nicer
presentation for B, but did not see how to solve symbolical - thus only
a numerical result ...
Using your presentation I call the integrand K(t).

One observes that A:=Re(K(t))=1 (first plotting it and then proves it by 
powsubs(1-3*cos(t)^2+3*cos(t)^4 = a,A); simplify(%) assuming (0 LT a,a LT 1);

Denoting B:=Im(K(t) (after simplifying due to the range of t) one sees
that is periodic with period Pi/2 [since B/eval(B, t = t+2*Pi/2) equals 1]
and symmetric [by handwaving], hence Int(B, t=0..Pi/4) is what is needed.

Applying Change(%, t=tau/4); Change(%, 5+3*cos(tau) = (rho)); makes it
an algebraic integral, which quickly evaluates to 0.11017518233813 (had
some sign problem if running twice, but it is positive due to plotting).

So we have 1/3 * (2*Pi + 2*0.11017518233813*4*I) = 2.0943951023932 +
0.29380048623501*I which coincides with your posted result.


PS: Change(%, t=tau/4); Change(%, tau= arccos(2*rho-1)); gives a nicer
presentation for B, but did not see how to solve symbolical - thus only
a numerical result ...
Yes, Maple can do it. However the good thing with something like curveexpert is: you just copy/paste data and then let it run over all the models (as you explain in your other posting for this data it will have no chance) without typing much. Of course the same could be done with Maple, it would only require some coding to have a similar functionality looping through some 'standard' models.
Yes, Maple can do it. However the good thing with something like curveexpert is: you just copy/paste data and then let it run over all the models (as you explain in your other posting for this data it will have no chance) without typing much. Of course the same could be done with Maple, it would only require some coding to have a similar functionality looping through some 'standard' models.
may be, the following from W C Bauldry's homepage is interesting in that context as well: http://www.mathsci.appstate.edu/~wmcb/Maple/parser.html
Georgios, the point is iterated input (3 times) ...
Seems that the inputs are translated just to HTML tables with 2 columns. Using a wysiwyg editor like an old Mozilla they are easily marked and deleted (ok, others may be able to use grep for that ...), especially since some refining of the automatic layout is desirable
In two worksheets "Which vol was paid?" and "Black-Scholes prices for small volatility or times" it was shown, how to compute implied volatility and Black-Scholes prices in few steps and with reasonable exactness. Combining both gives solutions for both pricing and retrieving implied volatility, which work in double precision to almost machine precision if being compiled. For computing option prices one can use a 'scaled' version of for (normed) option premia. That needs an exact computation of Mills Ratio. For small inputs this is done through Chebyshev-Pade approximations, for intermediate inputs a method of Marsaglia is used while for large values an asymptotic series works. Conversely to get implied volatility from prices one can also use the scaled premium: it behaves good enough for 'almost flat' regions and has a simple form for its derivative. So one can apply the Newton-Raphson method - the initial value can be guessed quite accurately. Additionally a feature is given trying to care for the numerical illposed question of implied volatility: refine through bisection, trying to find a 'maximal' solution for the equation. Instead of re-writing all the stuff it is sketched, what has to be done (using Maple) and mainly test results are given, making use of a compiled version through a C DLL. That zipped file contains the worksheet and the needed DLL: Download 102_scaledPremium+Vol.zip (291 KB)
The C sources are provided as part of the sheet, but as separate files, consider this sheet as an explanation for the code. Download 102_BS_exact.C-sources.zip (16 KB)
Since I make use of SUN's implementation of the error function and Wichura's inverse for it (not really needed in that form and certainly none of them, if working within Maple) I am unsure, which licence applies - for me the "3-clause BSD licence" is ok, which is compatible with the GNU GPL.
might be worth to try ... wanted to make my last uploaded sheet readable as HTML ... will see
Thank you both for the ideas, have to think about it ... My motivation for 'hiding': someone not used to Maple would find such things irritating (and even for Maple users it is often more convenient to see only the results), i.e. I would provide the sheet and do not intent to 'protect' something, it's just for some nicer presentation of existing sheets since no easy Maple Reader exists (and looks nicer than a pdf, especially the graphics).
Digits:=14;

# numerical int is ok
Int(1/(1+t^2),t=a..b): subs(b=a+1,%): subs(a=5*10^7,%); evalf(%);

                           50000001
                          /
                         |            1
                         |          ------ dt
                         |               2
                        /           1 + t
                          50000000


                                           -15
                        0.39999999200000 10


# checking the symbolic does not work
int(1/(1+t^2),t=a..b); subs(b=a+1,%); subs(a=5*10^7,%); evalf(%);

                        -arctan(a) + arctan(b)
                      -arctan(a) + arctan(a + 1)
                 -arctan(50000000) + arctan(50000001)
                                  0.

# except after increasing digits significantly
evalf[40](%%): evalf(%);
                                           -15
                        0.39999999200000 10


# or using an equivalent expression
arctan((b-a)/(1+a*b)); subs(b=a+1,%); subs(a=5*10^7,%); evalf(%);

                                   b - a
                           arctan(-------)
                                  1 + a b

                                     1
                        arctan(-------------)
                               1 + a (a + 1)

                      arctan(1/2500000050000001)

                                           -15
                        0.39999999200000 10

The last comes through the additions theorem i think, that example is taken from:
Richard J. Fateman and W. Kahan: Improving Exact Integrals From Symbolic Algebra Systems (2000)
you did have an example some time ago where that would not work, i think it was an integral where liftable singularity (or they have been numerical singular?) have been close to the boundary or similar edited: ... was it Int(cosh(v)/sqrt(sech(v)-sech(vm)),v=0..vm) ?
... there are certainly examples, where numerics will fail (large integer exponents or Gamma), where numerics can be terrible expensive ... and IIRC even conversely
First 185 186 187 188 189 190 191 Last Page 187 of 209