Joe Riel

9660 Reputation

23 Badges

20 years, 3 days

MaplePrimes Activity


These are answers submitted by Joe Riel

[seq(ithprime(i),i=1..100)];
x := 2.: # try with a rational!
to 20 do
    x := exp(-x/2);
end do:
x;

I believe that the most useful answer is to learn to live with these quirks.  Time spent tweaking Maple's output to conform to one's sensibilities is usually better invested elsewhere.  However, the following may achieve what you want:

scalefrac := proc(f,k:=1) expand(k*numer(f))/expand(k*denom(f)) end proc:
y1 := (3+4*i)/(7*i-3);
                                       3 + 4 i
                                 y1 := -------
                                       7 i - 3

y2 := scalefrac(y1,-1);
                                      -3 - 4 i
                                y2 := --------
                                      -7 i + 3

# To flip again, use 1 (the default), which seems counterintuitive, but numer
# and denom don't always return what the you might expect.
scalefrac(y2);
                                    3 + 4 i
                                    -------
                                    7 i - 3

You can use normal to convert v^2/2/a-vo^2/2/a to (v^2 - vo^2)/2/a.  The trick, then, is to apply normal to just those elements (together). For this particular case you can collect on xo and apply normal to the coefficients, that forces it to apply normal to the "constant" cofficient:

eq3 := x = xo-1/2*vo^2/a+1/2/a*v^2;
                                             2    2
                                           vo    v
                           eq3 := x = xo - --- + ---
                                           2 a   2 a

collect(eq3,xo,normal);
                                         2     2
                                        v  - vo
                               x = xo + --------
                                          2 a

Something along these lines:

piecewise(seq([x<=args[2*k+1],k][], k=1..iquo(nargs,2)-1))

You are probably attempting to directly assign elements of a list with more than 100 elements:

L := [seq(1..100)]:
L[1] := 1;
                                   L[1] := 1

L := [seq(1..101)]:
L[1] := 1;    
Error, assigning to a long list, please use Arrays

This is not an efficient technique and is discouraged. 


Once again, the solution is the empty function:

y := (b/c)^2;
                                          2
                                         b
                                   y := ----
                                          2
                                         c

algsubs(b/c=``(b/c),y);
                                          2
                                     (b/c)

expand(%);
                                       2
                                      b
                                     ----
                                       2
                                      c

I don't understand the issue.  Is K a constant?  If so then why not replace i(t) with K/R and get the linear ODE

R*C*diff(v(t),t)+v(t)=K/R.

 

I'm not sure how to get a symbolic solution.  We can, however, symbolically solve the steady-state periodic output:

dsol_ss := dsolve({diff(x,t)+x=Et, eval(x,t=0)=eval(x,t=T)});
dsol_ss :=

        {                 2 exp(-t) (-1 + exp(-1))
        {         t - 1 + ------------------------                 t < 1
        {                       exp(-2) - 1
    x = {
        {          2 exp(-t) (-1 + exp(-1))
        { -t + 3 + ------------------------ - 2 exp(-t + 1)        1 <= t
        {                exp(-2) - 1

plot([rhs(dsol_ss),Eper],t=0..T);

Actually, solving the complete system symbolically isn't much more difficult, since Maple's dsolve returns a result for this diff-eq with a symbolic initial condition.

Sure, at least numerically:

Et := piecewise(t<=1,t,2-t):
T := 2:
Eper := eval(Et, t=t-T*trunc(t/T));
alias(x=x(t)):
deq := diff(x,t) + x = Eper:
ics := eval(x,t=0)=0:
dsol := dsolve({deq,ics},'numeric'):
plots[odeplot](dsol, [[t,x],[t,Eper]],0..5);

Are you trying to simulate (say numerically) the response of the circuit to the periodic waveform, or are you trying to solve the corresponding periodic output?  A usual method for generating a periodic numerical waveform is to use replace the t in the expression with a periodic expression in t:

eval(expr, t=t-T*trunc(t/T)): # T is the period

For example, here is how to make a periodic triangular waveform:

Et := piecewise(t<=1,t,2-t):
T := 2:
Eper := eval(Et, t=t-T*trunc(t/T)):
plot(Eper, t=0..5);

That's just the way Maple works.  It automatically distributes multiplication of numerics over sums.  You can fake the output using the empty function (``):

x := a/2+b/3:
makefrac := (``@numer)/(``@denom):
makefrac(x);
                                  (3 a + 2 b)
                                 ------------
                                      (6)
expand(%);
                                   a/2 + b/3


How 'bout

eq1 := 3*x + y - z = 3:
eq2 := x + 2*y + 4*z = -4:
sol := solve({eq1,eq2},{y,z});
                                                      13 x            5 x
                                        sol := {y = - ---- + 4/3, z = --- - 5/3}
                                                       6               6

line := subs(sol, x=t, <x,y,z>);
                                                         [     t      ]
                                                         [            ]
                                                         [  13 t      ]
                                                         [- ---- + 4/3]
                                                 line := [   6        ]
                                                         [            ]
                                                         [ 5 t        ]
                                                         [ --- - 5/3  ]
                                                         [  6         ]

subs(t=0,line);
                                                         [ 0  ]
                                                         [    ]
                                                         [4/3 ]
                                                         [    ]
                                                         [-5/3]

One could also use LinearAlgebra:-IntersectionBasis to find the coefficients:

S1 := convert(map2(coeff, lhs(eq1), [x,y,z]), 'Matrix'):
S2 := convert(map2(coeff, lhs(eq2), [x,y,z]), 'Matrix'):
N1 := NullSpace(S1):
N2 := NullSpace(S2):
IntersectionBasis([N1,N2]);
                                                         [-6 ]
                                                         [-- ]
                                                         [13 ]
                                                         [   ]
                                                        {[ 1 ]}
                                                         [   ]
                                                         [-5 ]
                                                         [-- ]
                                                         [13 ]

One possibility is to first solve the equation symbolically, before assigning values to the parameters.  In fact, it is usually best to avoid directly assigning values to parameters:

eq := K = S*F^n:
vals := [K=2, S=3, n=-2.4]:
sol := solve(eq, F);
evalf(eval(sol, vals));

Another approach is to use the RealDomain package to restrict solutions to reals:

RealDomain:-solve(eval(eq,vals),F);

 

It isn't clear to me that acer's suggestion does what you ask.  That is, because simplify(u*Dirac(u)) returns 0, applying simplify to den returns 0, while you asked for v*Dirac(v).  To achieve that, you might use frontend and specify that the function Dirac(u) not be frozen:

den := a*u*Dirac(u)+b*u*u*Dirac(u)+c*u^(3/2)*Dirac(u)+v*Dirac(v);
                              2               (3/2)
     den := a u Dirac(u) + b u  Dirac(u) + c u      Dirac(u) + v Dirac(v)

frontend(simplify, [den], [{`*`,`+`,`^`},{Dirac(u)}]);
                                  v Dirac(v)

This might be appliable to your followup question.

First 96 97 98 99 100 101 102 Last Page 98 of 114