Carl Love

Carl Love

28035 Reputation

25 Badges

12 years, 320 days
Himself
Wayland, Massachusetts, United States
My name was formerly Carl Devore.

MaplePrimes Activity


These are answers submitted by Carl Love

The procedure isqrt (integer square root) is built-in and extremely fast. So here's a procedure that uses it:

NextSquare:= proc(zahl::integer)
local IS:= isqrt(zahl), IS2:= IS^2;
     `if`(IS2 > zahl, IS2, IS2+2*IS+1)
end proc:

NextSquare(1234567);

     1236544

 

The following procedure will take any procedure defining a function on a given real interval and return a procedure which extends the definition of that function periodically over the whole real line.

Periodic:= proc(f::appliable, ab::range(realcons))
local a, b, F, P, S;
     (a,b):= op(evalf(ab));
     subs(
          [F= eval(f), P= b-a, S= (a+b)/2],
          x-> `if`(x::realcons, F(frem(x-S,P)+S), 'procname'(args))
     )
end proc:

Example of use:

F:= Periodic(x-> piecewise(x <= 1, x^2, (2-x)^2), 0..2):
plot(F, -5..5);

A drawback of my procedure is that the procedure that it produces is not amenable to symbolic analysis; it's only good for numerics such as plotfsolveevalf(Int(...)). If you need the resulting periodic function to be amenable to symbolic analysis, let me know.

What you have is properly called a set, not a list. Nonetheless, the exact same command will work for both sets and lists. That command is

remove(hastype, S, {specfunc(anything, RootOf), And(complexcons, Not(realcons))});

where has been assigned your set above.

In Maple 2015, the anything (and its following comma) can be omitted.

RealDomain is a very fussy package intended primarily for pedagogical use in precalculus mathematics. (Somehow, I think that you're beyond that level :-).) Don't use it unless you know that it'll work for your purpose, and there's nothing else that'll work instead. In this case RealDomain is hindering the simplification. All that you need is

restart;
f:= u/sqrt(u*(u-1));

simplify(f) assuming u > 1;

My guess is that 90% of the time that people use RealDomain and subsequently ask a Question here, its usage was inappropriate. In particular note the following line from the help page ?RealDomain:

The RealDomain package is not compatible with the use of the assume facility.

 

plots:-display([
     plots:-spacecurve(
          [2*cos(t), sin(t), t], t= -6*Pi..6*Pi, thickness= 3, style= line, numpoints= 200
     ),

     plots:-spacecurve([-2*t, 1, Pi/2+t], t= -5..5, color= black, style= line)
     ], axes= frame
);

Note carefully that Pi is spelled Pi, not pi.

I don't know what you were attempting with inttrans and NumericEventHandler, but they're irrelevant to this Question.

Expressions with Heaviside may be converted to abs form, and vice versa. Apparently, int can handle the abs form better.

simplify(convert(int(f(t-q)*g(q), q= -2..10), compose, abs, Heaviside));

     Heaviside(t-1)*t^2-Heaviside(t-4)*t^2-6*t*Heaviside(t-10)-2*Heaviside(t-1)*t+8*Heaviside(t-            
     4)*t+60*Heaviside(t-10)+Heaviside(t-1)-16*Heaviside(t-4)

 Note that this solution is valid for t > 10.

Stating the relationship as a formal analogy, seq is to $ as add is to sum.

Please see this post that I just made: Use Eigenvalues, not fsolve@Determinant. By using Eigenvalues, the computation can be done accurately without increasing Digits.

Your problem is that the coefficients of your characteristic polynomial are already corrupted by round-off error when the determinant is computed. Please see this post that I just made: Use Eigenvalues, not fsolve@Determinant.

I strongly suspect that you are trying to compute eigenvalues of a matrix. Use the command LinearAlgebra:-Eigenvalues for that. Trying to do it by computing the roots of a polynomial derived from a floating-point matrix is highly suspect unless you use a very large value of Digits. Please see this post that I just made: Use Eigenvalues, not fsolve@Determinant.

Please see this post that I just made: Use Eigenvalues, not fsolve@Determinant. The problem with your example is that the coefficients of the polynomial are already corrupted by round-off error.

You asked:

[I]s there other way to solve functions with several real and imaginary solutions?

Yes. Assuming that solve can return a solution that contains expressions of the form RootOf(f(_Z)) where f(_Z) is a polynomial in _Z (this is true in your case) and that you can supply numeric values for all parameters and for x, then you can use a combination of evalf and allvalues to return all real and imaginary values for y.

Your usage of the word "function" is nonstandard here. Your Fun is an expression, and since it is presumed to be set equal to 0, it is also implicitly an equation; but it is not a function. Anyway, one solves equations, not functions.

In my revision of your code below, I changed D to DD because is used for derivatives in Maple. Your use of wasn't causing any problem, but it's best to avoid potential problems later by not using now.

Note that the code below executes in a few seconds and uses minimal memory.

 

 

 

restart:

Fun:= (1/8)*x^2*Y0*sqrt(Zt^2+((3/8)*A*y^2-(1/2)*x+1+(1/4)*G*y^2+(1/4)*DD)^2)/(((1/4)*G*y^2+(1/4)*DD)^2-((3/8)*A*y^2-(1/2)*x+1)^2-Zt^2)-y;

(1/64)*x^2*Y0*(9*A^2*y^4+12*A*G*y^4+4*G^2*y^4+12*A*DD*y^2-24*A*x*y^2+8*DD*G*y^2-16*G*x*y^2+48*A*y^2+32*G*y^2+4*DD^2-16*DD*x+64*Zt^2+16*x^2+32*DD-64*x+64)^(1/2)/(((1/4)*G*y^2+(1/4)*DD)^2-((3/8)*A*y^2-(1/2)*x+1)^2-Zt^2)-y

solveValue:= solve(eval(Fun, [G= 0]), y);  

RootOf(81*A^4*_Z^10+(-432*A^3*x+864*A^3)*_Z^8+(-72*A^2*DD^2+1152*A^2*Zt^2+864*A^2*x^2-3456*A^2*x+3456*A^2)*_Z^6+(-9*A^2*Y0^2*x^4+192*A*DD^2*x-3072*A*Zt^2*x-768*A*x^3-384*A*DD^2+6144*A*Zt^2+4608*A*x^2-9216*A*x+6144*A)*_Z^4+(-12*A*DD*Y0^2*x^4+24*A*Y0^2*x^5-48*A*Y0^2*x^4+16*DD^4-512*DD^2*Zt^2-128*DD^2*x^2+4096*Zt^4+2048*Zt^2*x^2+256*x^4+512*DD^2*x-8192*Zt^2*x-2048*x^3-512*DD^2+8192*Zt^2+6144*x^2-8192*x+4096)*_Z^2-4*DD^2*Y0^2*x^4+16*x^5*DD*Y0^2-64*Zt^2*Y0^2*x^4-16*x^6*Y0^2-32*DD*Y0^2*x^4+64*Y0^2*x^5-64*Y0^2*x^4)

evalf([allvalues(eval(solveValue, [A= 2, x= 3, DD= 5, Y0= 7, Zt= 11]))]);

[.729156354449306, 2.80900869584687+2.70574777512511*I, 2.68464259020886+2.59022505377347*I, -2.68464259020886+2.59022505377347*I, -2.80900869584687+2.70574777512511*I, -.729156354449306, -2.80900869584687-2.70574777512511*I, -2.68464259020886-2.59022505377347*I, 2.68464259020886-2.59022505377347*I, 2.80900869584687-2.70574777512511*I]

``

 Baharm32.mw

Maplesoft conducts several webinars each month. A significant percentage of those are about application development. In Maple, go to the Help menu, then "On the web", then "Stay informed", then "Subscribe to Newsletter".

What I see are three planes plotted in the unit cube: -x+y+z = 1, x-y+z = 1, and x+y-z = 1. It seems logical to me.

max is simply a commutative and associative n-ary arithmetic operation like addition or multiplication. An explanation of max(...) = constant would be as banal as an explanation of a sum of expressions being contant.

Yes, restart should always be in a separate execution group. Various somewhat unpredictable things can happen if it is not. The help page ?restart says that it should always be on a separate "line". This vague concept of a "line" of code is utter nonsense---the parser treats line breaks as white space. The word "line" needs to be replaced with "execution group".

PS: The command with should never be used inside a procedure (unless you really understand how it works). The results are predictable, but usually unexpected and undesirable. Use uses instead of with inside a procedure. It is because of the with that you need to execute twice. The global names used in a procedure need to be bound at the time that the procedure is invoked; they can't be dynamically rebound with with as the procedure executes. Your first execution rebinds the names. Your second execution uses the newly corrected package-bound names.

First 236 237 238 239 240 241 242 Last Page 238 of 395