Carl Love

Carl Love

28045 Reputation

25 Badges

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

MaplePrimes Activity


These are answers submitted by Carl Love

Like this:

PlotEllipseFromMatrix:= proc(H::Matrix(2, realcons), C::Vector(2, realcons))    
local x, y, X:= <x,y>-C;
    if LinearAlgebra:-IsDefinite(H) = true then 
        algcurves:-plot_real_curve(X^+.H.X - 1, x, y)
    else
        error "not an ellipse, or it can't be determined"
    fi
end proc
:

 PlotEllipseFromMatrix(<3,1;1,1>, <1,2>);

One may wonder What is the difference between an explicit logarithmic plotting command and a simple plot with option axis= [mode=log]? The answer is that the explicit command chooses the points to plot so that the independent variable values will become roughly evenly spaced after the logarithm is applied; whereas the axis= [mode= log] option chooses exactly the same points as would've been chosen if the option weren't there and then applies the logarithm. Thus, your plot command sees the subrange 10^6..10^7 as an insignificant part (less than 1/1000th) of the overall range 10^6..10^10.

Here's the same thing using plots:-loglogplot:

restart:
Z__target:= 50e-3*Unit(ohm):
f__roll_off:= 35e6*Unit(Hz):
f__range:= 1e6..1e10:
Z__target_ac:= f-> Z__target*sqrt(1+(f/f__roll_off)^2):
plots:-loglogplot(
    Z__target_ac(f*Unit(Hz)), f= f__range, color= red,
    gridlines, axes= boxed, title= "    Target Impedance\n",
    labels= ["Frequency (Hz)", "Impedance (&Omega;)"],
    axis[2]= [tickmarks= [3, subticks= 4]],
    labeldirections= [horizontal, vertical]
);

Also, regardless of your plot command, there's no need for the log[10]10^20, or evalf in Z__target_ac.

Note how I controlled the tickmarks on the vertical axis with
axis[2]= [tickmarks= [3, subticks= 4]]

You say that expr is always a sum of terms. Then this should do what you want:

for item in [op](expr) do ... od

It may come as a suprise that the complex-valued function (-2)^x is a very smooth, continuous function of its real argument x, but here it is:

plot([(Re,Im)((-2.)^x), x= -2..2], scaling= constrained);

The fact that the integral signs are gray rather than blue suggests that there's a possibility of evaluating them with the value command. Try value(%) after pdsolve.

It's possible to automate this process so that starting with any univariate procedure f we can obtain a parameter-shifted g without needing to explicitly compute the inverse of the shift (that inverse is found automatically, and only once). Like this:

f:= (n::algebraic)-> `if`(n::complexcons, `if`(n=0,1,0), 'procname'(n))
:
shift:= proc(F::uneval, N::name)
local
    f:= eval(F,1), e:= eval(op(f)), 
    n:= `if`(nargs=2, N, indets(e, And(name, Not(constant)))[])
;
    subs(_f= op(0,f), _s= {solve}(e= _n, n), _n= n, _n-> _f~(_s)[])
end proc
: 
g:= shift(f(n+1/3)):
g(1/3), g(1), g(x);
                         1, 0, f(x - 1/3)

 

Change the first argument of the eval to

:-`.`(I__b, diff(`&omega;_`(t), t))

This restores (temporarily, for this statement only) the default matrix multiplication operator, which has been overloaded by Physics

An alternative is

use `.`= :-`.` in
    eval(
...
exactly what you had ...)
end use;

My personal choice for this very common situation is return with no argument, as in

set_r:= proc(r::integer) thismodule:-r:= r; return end proc;

I usually do this even if the result of the previous command is always NULL.

I was about to give you the patfunc answer, but you beat me to it. So, here's a shortcut syntax:

evalindets[2](expr, 'patfunc(identical(R0), anything)', 1= r0, subsop);

Yes, that help page is on my "speed dial", so to speak. Surely I've read it a few hundred times. So let me know if you have any questions about it.

Did you see the Reply that I made to your previous Question earlier today? 
https://www.mapleprimes.com/questions/234951-How-To-Obtain-This-Simplification-In-Maple
I wonder if you had any comment about that.

Yes, it's suprisingly easy:

evala(Norm(x - (2^(1/2)+2^(1/3))));

Or, equivalently,

evala(Minpoly(2^(1/2)+2^(1/3), x));

Both of these commands will accept extra arguments allowing you to specify a larger field of coefficients. The default field is the rationals, of course.

Yes, you can define your own type-conversion procedures to be used with convert, like this:

`convert/coefflist`:= (s::series)-> local k, S:= [op](s), L:= S[2]; 
    ([seq](Array(L..S[-3], {seq}(S[k+1]=S[k], k= 1..nops(S)-3, 2))), subs(0= (), L))
:

Usage:

convert(series(cos(x), x, 10), coefflist);
convert(series(x^2*sin(x), x, 10), coefflist);
convert(series(x^(-2)*sin(x), x, 10), coefflist);

In the 2nd and 3rd examples, the integer returned after the list is the lowest exponent, which is returned when it's other than 0.

The procedure makes use of the fact that array entries that aren't explicitly set are automatically 0.
 

Try this:

GainQ1:= 8*wx^2*(m-1)/(Pi^2*sqrt((m*wx^2-1)^2+Q1^2*wx^2*(wx^2-1)^2*(m-1)^2));
params:= [m= 6.3, Q1= 1];
a:= eval(GainQ1, params);
Top_of_Q1:= maximize(a, wx= 0.1..2., location);

 

In the procedure, replace print(eq) with 

entries(eq, 'nolist')

The print command is never an appropriate way for a procedure to return its results.

I don't think that Preben or Tom explicitly said this, so I guess that it's worth saying: In this case, assumptions on the parameters can't help. That's a mathematical fact, not a Maple limitation, because the Fundamental Theorem of Algebra tells you that there'll always be 4 solutions for w(x) that are constant with respect to x.

My general personal opinion about Maple assumptions is that they shouldn't be used (even when they're mathematically true) in cases where it's known that they can't help. This is because they occasionally prevent you from getting valid solutions, which you'll then never know about.

An easy way to select only the nonconstant solution is to include an initial condition that includes a constant of integration, like this:

dsolve({q, w(0)=C1})

Your command array should be Array. The lowercased array is a "deprecated" command, meaning that it's a long-obsolete command that shouldn't be used any more. Indeed, it was obsolete before the ExcelTools package even existed.

While that's certainly true, I don't think that it will fix your problem. It looks like Export automatically converts an array to an Array.

First 36 37 38 39 40 41 42 Last Page 38 of 395