Items tagged with evalf

Feed

The link below has my code for generating 2 matrices.  The 1st one does not generate flfoating point numerical data; whereas, the 2nd one does.  What is wrong with the 1st case?  I am attempting to single out one harmonic which works in the 2nd case.  Also, is there a way I can generate a spectrum of S2(k= 1 to 100, t= 0 to 1)?

?untitled6.mw

 

It seems that simplify uses some transformations that aren't generically valid, and evalf relies on those transformations too:

 

nint := (fz, zrng) -> evalf(add(
  int(fz, op(1, zrng) = op([2, i], zrng) .. op([2, i+1], zrng)),
  i = 1 .. nops(op(2, zrng))-1));
f1 := z -> MeijerG([[1/2], []], [[], []], z);

simplify(f1(z));
                       sqrt(1/z) exp(-1/z)

evalf(f1(-1));
                              -9                
               -1.672586379 10   + 2.718281828 I

f1(-1.);
                              -9                
               -1.672586379 10   - 2.718281828 I

nint(GAMMA(1/2+y)*(-1)^y, y = [-infinity-I, -I, I, -infinity+I])/(2*Pi*I);
                             -11                
               6.652676619 10    - 2.718281828 I

So it seems that evalf uses the simplified form, but that form doesn't agree with the definition of MeijerG for negative z. The form that does would be 1/sqrt(z)*exp(-1/z).

 

f2 := z -> MeijerG([[], [1]], [[0, 2], []], z);

simplify(f2(z));
                    exp(-z) z + exp(-z) - 1

evalf(f2(1));
                         -0.2642411177

f2(1.);
                          0.7357588823

nint(GAMMA(-y)*GAMMA(2-y)/GAMMA(1-y), y = [infinity-I, -1-I, -1+I, infinity+I])/(2*Pi*I);
                      0.7357588823 - 0. I

The result of simplify is off by -1. Just evaluating f2(1) doesn't use that transformation rule, but evalf apparently does.

 

solve(z^(1+I) = 1, z, allsolutions = true);
                      exp((1 + I) Pi _Z1)
getassumptions(_Z1);
                         {_Z1::integer}

Since this is a single-valued power function, there is only a finite number of solutions. evalc correctly gives exp(-2*Pi) for _Z1=-1.

evalf doesn't help here regardless of the level of precision, I think because it always generates a non-zero imaginary part for exp(-(1+I)*Pi):

seq(print(evalf(evalf[d]((exp((-1-I)*Pi))^(1+I)))), d = 10 .. 3010, 300);
                                             -12  
              0.001867442732 - 1.361179007 10    I
                                            -312  
             0.001867442732 - 1.674479874 10     I
                                           -610  
               1.000000000 + 2.386571217 10     I
                                           -910  
               1.000000000 + 8.502509375 10     I
                                            -1212  
             0.001867442732 - 1.646483173 10      I
                                            -1514  
             0.001867442732 - 4.556560265 10      I
                                            -1812  
             0.001867442732 - 1.287611101 10      I
                                            -2112  
             0.001867442732 - 1.072784224 10      I
                                          -2410  
              1.000000000 + 8.162729354 10      I
                                            -2713  
             0.001867442732 - 7.375390371 10      I
                                          -3010  
              1.000000000 + 1.988371005 10      I

Unrelated, but it would be nice to have a simple way to display lists/matrices with specified width and alignment.

 

when I enter a trig function as cos(pi/2) I get as a return the same input.  What I would like is the numeric answer displayed. also there are times when I don't want pi in the answer but a numeric value calculated based on pi * whatever.

Thanks

Bill

I am interested to know difference between eval and evalf. Will evaluating a function at a point using these commands gives the same answer or not. I mean will there will be any exception or not. How can I evaluate the value of  a series using eval instead of evalf without the problem of memory running out (No comprimise in accuracy).

I have many integrals which I would like to calculate the value. The one in attachment is the simpliest example.

It shows 'too many level of recursion',

I know that it has something to do with the piecewise, however, it shouldn't, right? Any insights?

evalfandintPerformance.mw

evalfandintPerformance.pdf


 

restart;

Digits:=10;
to 10 do
evalf(add(sin(k), k = 1 .. 10000)) od;

10

 

1.633891035

 

1.633891035

 

1.633891035

 

1.633891046

 

1.633891046

 

1.633891046

 

1.633891012

 

1.633891012

 

1.633891012

 

1.633891049

(1)

restart;   # execute several times to obtain randomness

interface(version);

`Standard Worksheet Interface, Maple 2016.2, Windows 7, January 13 2017 Build ID 1194701`

(2)

Digits:=18;

18

(3)

to 10 do  
evalf(add(sin(k), k = 1 .. 10000)) od;

1.63389102179246197

 

1.63389102179246223

 

1.63389102179246223

 

1.63389102179246233

 

1.63389102179246233

 

1.63389102179246242

 

1.63389102179246242

 

1.63389102179246371

 

1.63389102179246371

 

1.63389102179246410

(4)

 

when i use the command evalf(Int(f(y),y=-b..b)), i expect that the output of this command to be an integer. but the output is to form of below:

i think that the problem is because of the form of the function f(y) that is the form of below:

f(y) = a*10^354*(b*10^-356*g(sin(y) , cos(y) and exp(y)))

but i dont know how i solve this problem:(

please help me. thank you

Dear All

For six parameters, I have corresponding list of their values and there are eight values for every parameter. I need to put these values in a formula to obtain a list of output values. There are two formulas one for 'P' and next is for 'RL'. I have used value of 'P' to calculate value of 'RL'. There are some complex number too, for which I have used modulus and final value is calculated by using 'evalf', but this command is not returning proper values for list as required. But this command works fine when I use single value from every list to calculate RL.

The Maple sheet attached herewith.

List.mw

Regards

Hello,

a=number      b=number

=maple("Qm:=x->(diff(KelvinBei(0,x),x)*psi2(x)-(diff(KelvinBer(0,x),x)*psi1(x)))/&1";B11)

=maple("Qv:=x->(&1*psi2(x)-(&2*psi1(x)))/(&3*&4)";B6;B7;B2;B11)

=maple("Fm:=x->(Qv(x)+(&1*Qm(x)))/2";B3)

I need abs(max(Fm(x))) and abs(min(Fm(x))) values of function Fm(x), locals, for a<x<b in excel.

Now I use a vector to do this, but I need an exact values not an approximation of a fuction evaluated with n values of x.

what I do:

=maple("seq(i,i=&1..&2,&3)";N2;N3;N4)

=maple("A:=&1";N5)

=maple("G:=map(g->evalf(eval(Fm(x),x=g)),[A])")

=maple("max(abs~(G))")

Someone can help me??

This question is related to the recent post
http://www.mapleprimes.com/questions/211460-Series-Of-Bessel-Functions

1. Consider the following fast convergent series:

f:=n->(-1)^(n+1)*1/(n+exp(n));
S1:=Sum(f(n),n=1..infinity);
evalf(S1);
S2:=Sum(f(2*n-1)+f(2*n),n=1..infinity);
evalf(S2);

As expected, the sum of the series is obtained very fast (with any precision), same results for S1 and S2.


2. Now change the series to a very slowly convergent one:

f:=n->(-1)^(n+1)/sqrt(n+sqrt(n));

evalf(S1) is computed also extremely fast, because the acceleration algorithm works here perfectly.
But evalf(S2) demonstrates a bug:

Error, (in evalf/Sum1) invalid input: `evalf/Sum/infinite` expects its 2nd argument, ix, to be of type name, but received ...


3. Let us take another series:

f:=n->(-1)^(n+1)/sqrt(n+sqrt(n)*sin(n));

Now evalf(S1) does not evaluate numerically and evalf(S2) ==> same error.
Note that I do not know whether this series is convergent or not, but the same thing happens for the obviously convergent series

f:=n->(-1)^(n+1)/sqrt(n^(11/5)+n^2*sin(n));

(because it converges slowly (but absolutely) and the acceleration fails).
I would be interested to know a method to approximate (in Maple) the sum of such series.

Edit. Now I know that the mentioned series 

converges (but note that Leibniz' test cannot be used).

In Maple 17, I had

evalf(5^1.25, 30);
7.476743906

evalf(5^(5/4), 30);
7.47674390610610270955949497070

evalf(evalf(5^1.25, 30)-evalf(5^(5/4), 30), 30);
-1.0610270955949497070 *10^(-10)

I would expect the two results to be the same. 

I am using Maple 17 and windows 7 operating system. 

Is there a reason that  evalf(5^1.25, 30) will not compute 30 decimal places?

 

 

Dear all,

Thank you for helping me  to generate a table of values of f(x) starting with x=0 to 100 in steps of 1, that is for x=0,1,2,3,...,100.

 

I tried:

f:=x->2*sqrt(3)*a1*a2*(sum(pochhammer(1/3,k)*3^k*x^(3*k)/(3*k)! ,k=0..infinity)*sum(pochhammer(2/3,k)*3^k*x^(3*k+2)/(3*k+2)!  ,k=0..infinity)-sum(pochhammer(2/3,k)*3^k*x^(3*k+1)/(3*k+1)!  ,k=0..infinity)*sum(pochhammer(1/3,k)*3^k*x^(3*k+1)/(3*k+1)!  ,k=0..infinity));

tab_values:=[evalf(simplify(seq(Ni1(xx),xx=0..100)))];

But I the result is amazing.... I don't understand the problem.

Thanks

 

Dear all;

I need you to understand this problem...

when i plot the function, using the graph i see that the function is above the x-axis but when I compute some values of this function I get a negative values....like
evalf(y(99.6));  is a negative value, but in the graph it is possible... I don't  undertand the problem...

restart:
with(plots):

# funciton

y:=x->-4.1123583570*10^281*exp(-(2/3)*x^(3/2))/(x^(1/4)*sqrt(Pi))+1.6554662320*10^(-289)*exp((2/3)*x^(3/2))/(x^(1/4)*sqrt(Pi))+(16/153)*x^(7/6)*sqrt(Pi)*exp((2/3)*x^(3/2))+Pi*((1/2)*exp(-(2/3)*x^(3/2))*(-1+exp((2/3)*x^(2/3)))/(x^(1/4)*Pi)-(16/153)*x^(7/6)*exp((2/3)*x^(3/2))/sqrt(Pi)):

#I plot this function in the interval (a,b)

a:=99;b:=100; # interval (a,b)
 forget(evalf): Digits:=20:
P1:=plottools:-transform((x,y)->[x+a,y])(plot(expand(y(x+a)),x=0..1,color=blue)):
forget(evalf): Digits:=4000:
P2:=plot(ysol, a..b, style=point, adaptive=false, numpoints=25, symbol=solidcircle, symbolsize=20, color=blue):
Digits:=20:
plots:-display(P1,P2);
evalf(y(99.6)); 

 Thank you in advantage for your remarks

 

 

1 2 3 4 5 Page 1 of 5