Ali Hassani

115 Reputation

4 Badges

9 years, 81 days

MaplePrimes Activity


These are questions asked by Ali Hassani

Dear All,

I want all calculations in Maple code to be done with double precision. Using Digits:=18 and evalf greatly affects the calculation speed. But using the evalhf performs calculations much faster. The problem is that the evalhf cannot work with expressions that contain symbolic terms. For example, the evalhf(1/3*x+1/5*exp(-x^2)) generates an error. How can I perform calculations on expression with double-precision floating point without significantly slowing down the calculation speed? Is there a method that can be used at the beginning of the code to use double precision (preferably hardware) in all computation steps without slowing down the computations, unlike software floating-point computations?
Best wishes
 

Digits:=18;
evalf(1/3.);
evalhf(1/3.);


str:=time[real]();
for i from 1 to 100000 do
evalf(sqrt(3)*i):
end do:
time[real]()-str;

 

str:=time[real]();
for i from 1 to 100000 do
evalhf(sqrt(3)*i):
end do:
time[real]()-str;

 

Dear All,

I have the following algebraic function. In vibrations, it is common to write the functions exp(alpha[i]*I*t) as separate terms of cos(alpha[i]*t) and sin(alpha[i]*t). While exp(-beta[i]*t) remains without converting to sinh and cosh. How can I find the solution given for T(t) as the sum of terms C1[i]*sin(alpha[i]*t)*exp(-beta[i]*t) and C2[i]*cos(alpha[i]*t)*exp(-beta[i]*t) with non-complex (real) coefficients C1[i] and C2[i].

Can anyone help me to achieve my goal in the following expression?

 

T(t):=(1.450761945*10^(-11) + (3.836655196*10^(-14))*I)*exp((-0.5000000000 + 222.6866468*I)*t) + (-3.770333746*10^(-9) + (2.179000257*10^(-6))*I)*exp((-0.5000000000 - 924.5904413*I)*t) + (-2.584086158*10^(-12) + (4.273321932*10^(-13))*I)*exp((-0.5000000000 + 326.7549627*I)*t) + (1.986287340*10^(-9) + (1.330623218*10^(-11))*I)*exp((-0.5000000000 - 74.63720909*I)*t) + (-5.980910367*10^(-12) + (5.816480027*10^(-11))*I)*exp((-0.5000000000 - 453.7574402*I)*t) + (1.450761945*10^(-11) - (3.836655196*10^(-14))*I)*exp((-0.5000000000 - 222.6866468*I)*t) + (8.923968224*10^(-10) - (8.844466162*10^(-9))*I)*exp((-0.5000000000 + 637.9999953*I)*t) - (1.217986141*10^(-10) + (4.431771836*10^(-13))*I)*exp((-0.5000000000 - 138.7904660*I)*t) + (-1.217986141*10^(-10) + (4.431771836*10^(-13))*I)*exp((-0.5000000000 + 138.7904660*I)*t) + (0.0002537882980 + 0.00002277791755*I)*exp((-0.5000000000 - 5.570928456*I)*t) - (3.770333746*10^(-9) + (2.179000257*10^(-6))*I)*exp((-0.5000000000 + 924.5904413*I)*t) + (-0.0001618723219 + 0.01288449595*I)*exp((-0.5000000000 - 1638.001654*I)*t) + (8.923968224*10^(-10) + (8.844466162*10^(-9))*I)*exp((-0.5000000000 - 637.9999953*I)*t) + (-1.153529195*10^(-7) + (1.908444485*10^(-9))*I)*exp((-0.5000000000 + 30.22171212*I)*t) - (1.153529195*10^(-7) + (1.908444485*10^(-9))*I)*exp((-0.5000000000 - 30.22171212*I)*t) - (0.0001618723219 + 0.01288449595*I)*exp((-0.5000000000 + 1638.001654*I)*t) + (1.986287340*10^(-9) - (1.330623218*10^(-11))*I)*exp((-0.5000000000 + 74.63720909*I)*t) + (0.0002537882980 - 0.00002277791755*I)*exp((-0.5000000000 + 5.570928456*I)*t) - (5.980910367*10^(-12) + (5.816480027*10^(-11))*I)*exp((-0.5000000000 + 453.7574402*I)*t) - (2.584086158*10^(-12) + (4.273321932*10^(-13))*I)*exp((-0.5000000000 - 326.7549627*I)*t);

Dear All,

I have the given expression f as follows. I want to extract terms with sin, sinh, and exp in this expression. For example, for sin, cos, sinh and exp, I want the outputs to be -4*sin(x), -5*cos(x^3)*sin(y^2), 5*sinh(x^2) and 2*exp(y^2), respectively. Also, if I want to get terms having sin(x) and sin(y^2), I like to receive -4*sin(x) and -5*cos(x^3)*sin(y^2), respectively. And also, for terms including sinh(x^3), I want to get Void output. The above goals cannot be achieved with the following commands. Can anyone help me?

f := -4*sin(x) + 2*exp(y^2) + 5 - 5*cos(x^3)*sin(y^2) + 5*sinh(x^2);

indets(f, trig);

selectfun(f, exp);

selectremove(has, f, trig);

Deal All,

I have a system of linear differential equations with unknown functions T[1](t) to T[n](t). In the attached example, I considered the value of n equal to 10, but depending on the problem, the value of n may be higher. Maple is not able to solve this problem analytically with the ‘dsolve’. 

Does anyone have an idea to analytically solve for such a set of linear differential equations?

Best wishes

Set_of_Linear_DEs.mw

I want to get the unknown function whose Taylor expansion I have. For example, giving x - 1/6*x^3 + 1/120*x^5 - 1/5040*x^7 + 1/362880*x^9 will return sin(x). The following algorithm can be implemented for this simple function:

with(inttrans):

with(numapprox):

convert(taylor(sin(x),x, 10),polynom);

laplace(%, x, s1);

eval(%, s1=1/s2);

pade(%, s2, [3,3]);

eval(%, s2=1/s1);

invlaplace(%, s1, x);

But this approach does not lead to the correct solution for slightly more complex functions. For example, if I have the Taylor expansion of the function sin(x^2), I cannot reach the function sin(x^2) with the above algorithm. Note that before extracting the sin(x^2) function, this function is unknown to us and we only have its Taylor expansion:

with(inttrans):

with(numapprox):

convert(taylor(sin(x^2),x, 15),polynom);

laplace(%, x, s1);

eval(%, s1=1/s2);

pade(%, s2, [3,3]);

eval(%, s2=1/s1);

invlaplace(%, s1, x);

Also, the Taylor expansion of the simple function exp(-x^2) with the above algorithm is returned as a trigonometric function:

with(inttrans):

with(numapprox):

convert(taylor(exp(-x^2),x, 10),polynom);

laplace(%, x, s1);

eval(%, s1=1/s2);

pade(%, s2, [3,3]);

eval(%, s2=1/s1);

invlaplace(%, s1, x);

The importance of solving this problem becomes clear when we want to solve the differential equation or the set of differential equations by applying the ‘series’ option. If the variable t expresses time, it can never be obtained with a polynomial function u(t) in sufficiently large times. For example, the exact solution of the following differential equation is u(t)=exp(-a*t^2):

Order:=12;

ode:=t*diff(u(t),t,t)+8*diff(u(t),t)+18*a*t*u(t)=-4*a*t*u(t)*ln(u(t));

ic1:=u(0)=1;

ic2:=D(u)(0)=0;

dsolve({ode, ic1,ic2}, u(t), series);

Does anyone have an idea to extract the unknown function from its taylor expansion?

Best wishes

1 2 3 4 Page 1 of 4