vv

14027 Reputation

20 Badges

10 years, 43 days

MaplePrimes Activity


These are replies submitted by vv

Why don't you post the worksheet?

restart;

#f:=tanh(x);

f:=tanh(x+1);

tanh(x+1)

(1)

The truncated power series:

series(f, x=0, 5);evalf(%);

series(((exp(1))^2-1)/((exp(1))^2+1)+(4*(exp(1))^2/((exp(1))^2+1)^2)*x-(4*(exp(1))^2*((exp(1))^2-1)/((exp(1))^2+1)^3)*x^2+((8/3)*(exp(1))^2*((exp(1))^4-4*(exp(1))^2+1)/((exp(1))^2+1)^4)*x^3-((4/3)*(exp(1))^2*((exp(1))^6-11*(exp(1))^4+11*(exp(1))^2-1)/((exp(1))^2+1)^5)*x^4+O(x^5),x,5)

 

series(.7615941559+.4199743416*x-.3198500042*x^2+.1036044469*x^3+0.2771212690e-1*x^4+O(x^5),x,5)

(2)

You want formal power series.
The command to obtain the formal power series for tanh(x) is

convert(f, FPS);

Warning,  computation interrupted

 

Unfortunately it does not work.
But it can be computed using symbolic integer order derivatives

a:=eval(diff(f,x$n)/n!, x=0) assuming n>=1;

I*I^(n+1)*2^n*(-tanh(1)-1)*(Sum((-1)^_k1*factorial(_k1)*Stirling2(n, _k1)*(-tanh(1)+1)^_k1/2^_k1, _k1 = 0 .. n))*I^n/factorial(n)

(3)

ff:= eval(f,x=0) + sum(a*x^n, n=1..infinity);

tanh(1)+sum(I*I^(n+1)*2^n*(-tanh(1)-1)*(Sum((-1)^_k1*factorial(_k1)*Stirling2(n, _k1)*(-tanh(1)+1)^_k1/2^_k1, _k1 = 0 .. n))*I^n*x^n/factorial(n), n = 1 .. infinity)

(4)

# Check

simplify( series(value(ff),x,5) );evalf(%);

series(tanh(1)+(1/cosh(1)^2)*x-(sinh(1)/cosh(1)^3)*x^2+((1/3)*(2*cosh(1)^2-3)/cosh(1)^4)*x^3-((1/3)*(cosh(1)^2-3)*sinh(1)/cosh(1)^5)*x^4+O(x^5),x,5)

 

series(.7615941560+.4199743415*x-.3198500042*x^2+.1036044468*x^3+0.2771212683e-1*x^4+O(x^5),x,5)

(5)

# Numeric check

evalf( eval(f,x=1/2) = eval(ff,x=1/2) );

.9051482536 = .9051482537

(6)

 


Download tanh.mw

@asa12 

For f(x)=tanh(x+1) , f(0)  <> 0  sou you must add f(0) (or let n >= 0, n = 0 .. infinity).

@asa12 

Is "a" computed? AFAIK diff(f, x$n) exists in Maple 12.

assuming n>=1 is not necessary but the result is simpler, and n=0 is not useful as tanh(0)=0.

@Rouben Rostamian  

My point was that in our case the problem can be formulated and solved easily without differential inclusions.
(I do not reject the subject, I know something about it, I work in Convex Analysis).
Note also that a similar question may be asked for differential inclusions whenever the solution is not unique.

The solution of the ode has exactly x(0)=A, x'(0)=0. We are looking for x() having the stationary points isolated, so x'(0)=0 can be replaced by limit(x'(t), t=0) = 0. It is not unusual for an ode defined in an open interval to have conditions at the endpoints.

@Rouben Rostamian  

But in this particular case, the classical ode has a C^1 solution which is C^2 except a finite set of points (in a bounded interval).
This solution obviously satisfies the differential inclusion.

@Preben Alsholm 

The formula

sol:=(A-n*C)*cos(omega*t)+(-1)^n*C/2;

is valid only for t < tmax = A*Pi*sqrt(k/m)/(2*mu*g)

because after that   A - nC  becomes <0.
That is why the graph obtained by dsolve is different from sol for t>tmax.

Another interesting thing. sol is only an approximation! A rather good one.
It is possible to compute the exact solution but this will be of the form

A(t)*cos(omega*t + alpha(t)) + S(t)  where A(t), alpha(t) , S(t) are locally (piecewise) constant.

I like this problem!   :-)

Edit. I was intrigued and I have computed by hand the solution. sol is correct (i.e. alpha(t)=0), it is dsolve which makes the difference (for t<tmax of course).

 

 

@Preben Alsholm 

The following graph (yours) includes (-1)^n in red. It is obvious now that the ode refers to signum(x') not signum(x'');

@tomleslie 

It depends on how the ode is understood. A natural assumption is that x''() exists and is nonzero except on a discrete set A.
In this case x() cannot be continuous.
Otherwise any piecewise linear function is a solution because x''() = 0 except on a discrete set, so we don't have any condition for x(). So, it can even oscillate:

@Preben Alsholm 

The ode is given but the problem is that x() cannot be continuous.
So, the desired shape of the solution is out of the question.

This direct consequence of Green's formula is used:

     ∫∫D f(x,y) ddy = ∫C Q(x,y) dy,  where Q := ∫ f(x,y) dx

It remains to compute the curvilinear integral.
We must find a positively oriented parametrization (by hand!):

x=X(t), y=Y(t), t ∈ [a,b] of the (closed) curve C.

Then the curvilinear integral reduces to the usual Riemann integral

       ∫ab Q(X(t),Y(t))·Y(t) dt

The boring (sometimes difficult) part is to write the parametrization (usually piecewise).

@Kitonum 

I have used a compiled procedure.
BTW, I have corrected the comment which was wrong.
X(10^9)  needed several minutes but X(100000) only 65ms.

@rlopez 

It is solve which returns infinitely many solutions. Yes, if only the principal branch of ln is to be considered (as Maple does) then there are only two solutions, because the equation is equivalent to  ln(z) = k*Pi + k*Pi*I  (k in Z), which is possible only for k=0 and k=1 (argument(z) = k*Pi must be in (-Pi,Pi]).

 

# X(10^7) = 29529388;
# X(10^8) = 213554980;
# X(10^9) = 92599500093871447;

(Edited)

@Earl 

You may fine-tune the dsolve parameters. E.g. adding method=bvp[midrich]
is enough to work for a smaller speed.

 

@Christopher2222 

The following list has a simple and clear pattern. But probably it is (almost) impossible to find (guess) the next number.

1, 4, 10, 19, 31, 41, 49, 59, 78, 109, 143, 166, 173, 178, 204, 259, 328, 378, 388, 377, 388, 457, 570, 668, 701, 672, 647, 703, 850, 1018, 1106, 1078, 1004, 1009, 1161, 1401, 1582, 1596, 1483, 1403, 1509, 1797, 2096, 2210, 2097, 1922, 1923, 2201, 2613, 2882, 2841, 2594, 2445, 2634, 3111, 3565, 3681, 3433, 3124, 3137, 3592, 4215, 4566, 4421, 3996, 3773, 4087, 4806, 5429, 5511, 5072, 4605, 4659, 5346, 6215, 6628, 6325, 5678, 5390, 5881, 6893, 7688, 7687, 7002, 6362, 6498, 7477, 8618, 9061, 8538, 7632, 7301, 8031, 9382, 10338, 10197, 9210, 8396, 8665, 9999, 11426, 11856, 11045, 9853, 9513, 10551, 12280, 13375, 13027, 11686, 10707, 11174, 12923, 14642, 14999, 13834, 12336, 12037, 13455, 15596, 16793, 16161, 14420, 13300, 14040, 16263, 18263, 18479, 16889, 15080, 14883, 16758, 19334, 20580, 19585, 17405, 16183, 17277, 20028, 22286, 22280, 20200, 18085, 18066, 20474, 23497, 24726, 23282, 20635, 19365, 20903, 24226, 26704, 26386, 23754, 21355, 21601, 24618, 28084, 29217, 27237, 24106, 22857, 24933, 28866, 31508, 30781, 27541, 24897, 25503, 29202, 33092, 34037, 31436, 27818, 26673, 29384, 33950, 36687, 35446, 31554, 28718, 29792, 34237, 38517, 39168, 35864, 31772, 30830, 34272, 39482, 42226, 40363, 35786, 32829, 34486, 39733, 44351, 44594, 40508, 35973, 35344, 39613, 45461, 48110, 45517, 40234, 37245, 39603, 45697, 50583, 50293, 45358, 40427, 40236, 45421, 51883, 54320, 50888, 44898, 41982, 45163, 52133, 57199, 56246, 50405, 45146, 45524, 51708, 58743, 60837, 56462, 49778, 47057, 51183, 59046, 64183, 62432, 55641, 50141, 51232, 58486, 66031, 67640, 62225, 54881, 52492, 57683, 66433, 71518, 68832, 61063, 55428, 57380, 65764, 73735, 74705, 68162, 60214, 58308, 64677, 74291, 79182, 75425, 66669, 61026, 63990, 73547, 81840, 82011, 74263, 65788, 64528, 72182, 82615, 87152, 82194, 72461, 66956, 71084, 81838, 90328, 89533, 80520, 71618, 71178, 80211, 91393, 95405, 89120, 78445, 73240, 78683, 90639, 99178, 97248, 86927, 77721, 78281, 88773

First 110 111 112 113 114 115 116 Last Page 112 of 177