DuncanA

703 Reputation

8 Badges

18 years, 223 days

MaplePrimes Activity


These are answers submitted by DuncanA

?singular will find the singularities of the expression.  

singular(s2);
{Q = 0, beta = beta, u = -I}, {Q = 0, beta = beta, u = I},

{Q = Q, beta = beta, u = -I}, {Q = Q, beta = beta, u = I},

/ / 2\ \
| 2 I Pi \1 + u / |
< Q = Q, beta = - -----------------, u = u >,
| 2 |
\ 1 + u + 4 Q u Pi /

/ / 2\ \
| 2 I Pi \1 + u / |
< Q = Q, beta = -----------------, u = u >
| 2 |
\ 1 + u + 4 Q u Pi /
 

 The result of the call to singular differs from the result found by solving the denominator of s2

{singular(s2)} minus {solve(denom(s2)=0)};
{{Q = 0, beta = beta, u = -I}, {Q = 0, beta = beta, u = I}}

---

Duncan

?allvalues will compute all possible values of expressions involving RootOfs 

allvalues(s4);
2 beta Q Pi (-beta + 2 I Pi) 1 // 4 2 2
---------------------------- + ------------- \\4 beta Q Pi
2 2 2 2
4 Pi + beta 4 Pi + beta

3 2 3 2 2 4 4 2 2 4\
- 16 I beta Q Pi - 16 beta Q Pi - 16 Pi - 8 beta Pi - beta /^(1/2)

\ 2 beta Q Pi (-beta + 2 I Pi) 1 // 4 2 2
/, ---------------------------- - ------------- \\4 beta Q Pi
2 2 2 2
4 Pi + beta 4 Pi + beta

3 2 3 2 2 4 4 2 2 4\
- 16 I beta Q Pi - 16 beta Q Pi - 16 Pi - 8 beta Pi - beta /^(1/2)

\ 2 beta Q Pi (beta + 2 I Pi) 1 // 4 2 2
/, - --------------------------- + ------------- \\4 beta Q Pi
2 2 2 2
4 Pi + beta 4 Pi + beta

3 2 3 2 2 4 4 2 2 4\
+ 16 I beta Q Pi - 16 beta Q Pi - 16 Pi - 8 beta Pi - beta /^(1/2)

\ 2 beta Q Pi (beta + 2 I Pi) 1 // 4 2 2
/, - --------------------------- - ------------- \\4 beta Q Pi
2 2 2 2
4 Pi + beta 4 Pi + beta

3 2 3 2 2 4 4 2 2 4\
+ 16 I beta Q Pi - 16 beta Q Pi - 16 Pi - 8 beta Pi - beta /^(1/2)

\
/

 

 

---

Duncan

There is the  ?frem function 
frem(23.4, 5.2);
2.6

 

---

Duncan

?DynamicSystems/StateSpace is most probably the command you are looking for. The input can be specified as a transfer function for SISO systems, a transfer function matrix for MIMO systems, or a system object for converting an existing system to the state space representation.

---

Duncan

You're trying to print Q1[i] as a floating point variable, but Q1[i] is not a floating point variable. 

nops(Q1);
1
Q1[1];
[[0., 1.], [0.00272464427083333321, 0.945879132646984422],

...,

[0.978272101875000022, 0.0464172516182955047], [1., 0.0454545454545454558]]

 Another problem is that you do not open the file for writing, for example:

fd := fopen("c:/temp/implotdata.txt", WRITE);

 The file descriptor, fd, returned by fopen should then be used as the first argument to fprintf.

I'm not sure what it is you are trying to print, but you may want to use a different output format in fprintf, e.g., the %v format:

fprintf(fd,"%v\n", Q1);
fclose(fd);

 

---

Duncan

Re() returns the real part of a complex expression.

Re(27293.1844462+1.42305652280*10^(-84)*I);
27293.1844462

 

---

Duncan

I have solved a similar problem by having a procedure myplot() that gets the values from each slider and returns the plot so the code for each slider is Do(%Plot0=myplot()); There are five sliders in the attached worksheet which all call myplot() when updated.

 

 

# Standing Wave

restart;

y01*sin(omega*t-k*x) + y02*sin(omega*t+k*x);

(1)

myplot := proc()
    uses DocumentTools;
    local y01, y02, omega, t, k, y1, y2, p1, p2, p3;
    y01 := GetProperty('y01Slider', 'value');
    y02 := GetProperty('y02Slider', 'value');
    omega :=  GetProperty('omegaSlider', 'value');
    t := GetProperty('tSlider', 'value');
    k := GetProperty('kSlider', 'value');
    y1 := y01*sin(omega*t-k*x);
    y2 := y02*sin(omega*t+k*x);
    p1 := plot(y1, x = 0 .. 5, color=red);
    p2 := plot(y2, x = 0 .. 5, color=green);
    p3 := plot(y1 + y2, x = 0 .. 5, color=blue);
    plots:-display([p1, p2, p3], scaling=constrained);
end proc:

#DocumentTools:-Do(%Plot0=myplot()): # Each slider contains Do(%Plot0=myplot()) as the action when the slider value changes.

 

 

 
 
 
 

 

 

 

 

 

 

Download Standing_Wave.mw

 

---

Duncan

I don't see any error in the output produced using the Bits package.

The logic of binary AND is that a bit will be set in the output if the corresponding bit is set in both of the inputs. The truth table of bitwise AND is 

A B C

0 0 0

0 1 0

1 0 0

1 1 1

i.e. C is set if both A and B are set.

For example, the bitwise AND of 7 and 12 is 4 because only the third bit is set in both 7 and 12 as shown below.

7; Split(%);

                                      7

                                [1, 1, 1, 0]

12; Split(%);

                                     12

                                [0, 0, 1, 1]

And(7, 12); Split(%);

                                      4

                                [0, 0, 1, 0]

 

The bitwise AND of 4 and 3 is correctly output as zero because none of the corresponding bits in [0,0,1,0] and [1,1,0,0] is set. I don't understand why you conclude that the result should be [0,0,0,1].

 

---

Duncan

To overcome the problems with the derivative at x=0, 0.00576 and 0.12, one option is to perform the calculations symbolically and only evaluate numerically when ready to plot.

 

# NACA airfoil

restart;

interface(displayprecision=4):

# http://en.wikipedia.org/wiki/NACA_airfoil

# http://www.aerospaceweb.org/question/airfoils/q0041.shtml

# http://www.mapleprimes.com/questions/119679-Drawing-A-Standard-Airfoil-NACA-4412

# Equation for a symmetrical 4-digit NACA airfoil

y := t/.2*c*(0.2969*sqrt(x/c)-0.1260*(x/c)-0.3516*(x/c)^2+0.2843*(x/c)^3-0.1015*(x/c)^4);

(1)

p1 := plot(eval(y, [c=1, t=.25]), x = 0 .. 1, color=red):
p2 := plot(eval(-y, [c=1, t=.25]), x = 0 .. 1, color=blue):
plots:-display([p1, p2], scaling=constrained);

 

# Equations for a cambered 4-digit NACA airfoil

yc := piecewise(0 <= x and x <= p, m*(x/p^2)*(2*p - x/c), p <= x and x <= c, m*(c-x)/(1-p)^2 * (1 + x/c -2*p));

(2)

theta := arctan(diff(yc, x));

(3)

xU := x - 'y' * sin('theta');

(4)

xL := x + 'y' * sin('theta');

(5)

yU := 'yc' + 'y' * cos('theta');

(6)

yL := 'yc' - 'y' * cos('theta');

(7)

upper := op( eval( [xU, yU], [c=1, t=0.25, m=4./100, p=6./10] ) ):

lower := op( eval( [xL, yL], [c=1, t=0.25, m=4./100, p=6./10] ) ):

p1 := plot([upper, x = 0 .. 1], color=red):
p2 := plot([lower, x = 0 .. 1], color=blue):
plots:-display([p1, p2], scaling=constrained);

 

 

 

Download NACA_airfoil.mw

 

---

Duncan

?print can be used to display the body of a procedure. You may need to set the verboseproc user interface variable (?interface) to see the procedure body. For example to print the body of the sin function:

print(sin);
proc(x::algebraic)  ...  end;
interface(verboseproc=3);
1
print(sin);
proc(x::algebraic)
local res, n, t, pull_out, keep_in, tmp;
option builtin = HFloat_sin, automap(1),
`Copyright (c) 1992 by the University of Waterloo. All rights reserved.`;
if nargs <> 1 then
error "expecting 1 argument, got %1", nargs
elif type(x, 'complex(float)') then
return evalf('sin'(x))
 ...

 

---

Duncan

Matrices in Maple are 2D objects and I assume you mean 3D objects constructed using the Array data structure.

The Browse Matrix dialog  ?worksheet/expressions/structuredview can be used to view large matrices or cross sections of multi-dimensional, e.g., 3D, arrays. 

To launch the Browse Matrix tool, right-click on the object in summary format and select Browse from the menu. The tool has three tabs: Table, Image and Options. The Table tab shows a 2D cross section of the data structure. The Options tab can be used to configure the rows and columns of the 2D view and the 'Fixed' index of the third dimension.

---

Duncan

 

M2 := remove(x->x=[], M);
[[0], [0]]
ListTools:-Interleave(L, M2);
[[1, 1, 1, 1, 1], [0], [1, 1, 1, 1, 1], [0], [1, 1]]

 

---

Duncan

1. Place an  ?assuming statement after solve() to find the solutions assuming the variables are non-negative

equations := {(1-3*q2)*(1+lambda) = 0, 
r1*q1-2*r2*XA*(1+lambda) = 0, (1-2*q2)*q2-r2*XA^2 = 0, 1-3*q1+r1*XA = 0}:
variables := {XA, q1, q2, lambda}:
solutions := solve(equations, variables) assuming q1 >= 0, q2 >= 0, XA >= 0, r1 >= 0, r2 >= 0;

2. ?RootOf is a placeholder to represent the roots of an equation and _Z is the indeterminate in the equation. The value in your equations is undefined until values of the other variables are provided. For example

eval({solutions}, [r1=1, r2=4]);
{{XA = -1, lambda = -1, q1 = 0, q2 = RootOf(4-_Z+2*_Z^2, label = _L1)}, 
{XA = RootOf(-1+36*_Z^2), lambda = (3/2)*RootOf(-1+36*_Z^2)-23/24, 
q1 = 1/3+(1/3)*RootOf(-1+36*_Z^2), q2 = 1/3}}

evalf({%});
{{{XA = -1., lambda = -1., q1 = 0., q2 = .2500000000+1.391941091*I}, 
{XA = .1666666667, lambda = -.7083333333, q1 = .3888888889, q2 = .3333333333}}}

  

---

Duncan

?StringTools/HammingDistance may also be useful.

x:="0.1243134710481":
y:="0.1243234710571":
with(StringTools):
HammingDistance(x,y);
3
Length(x);
15
Length(y);
15
max(Length(x), Length(y)) - HammingDistance(x, y);
12

 

---

Duncan

 ?unapply can be used to obtain an operator from an expression and arguments: 
m := (x(q))^2 + x(q);
2
x(q) + x(q)
eq := unapply(m, q);
2
q -> x(q) + x(q)

 

---

Duncan

1 2 3 4 5 6 7 Page 2 of 7