kfli

65 Reputation

4 Badges

5 years, 238 days

MaplePrimes Activity


These are questions asked by kfli

Hello,

I'm having some difficulty solving a set of equations. For example

dn/dt = Const*(phi - n)

ds/dt= Const*(phi-n)

s = d2 phi/dx2 + d2 phi/dy2

How do you solve a system like this? It is 2 equations with 2 unknowns, but it is the s variable that is evolved, i.e. ds/dt, instead of phi.

Anyone know of some code that could do this? (periodic boundary conditions)

Better yet, how do you formulate this as a regular ODE for n and phi?

 

Hello,

I have tried to get a simple matlab example of a fourier transform code to work in Maple. This is just to understand a simple fourier transform and eventually try some more difficult 2D transforms.

restart:
with(LinearAlgebra):
with(RandomTools):
with(orthopoly):
with(plots):
with(ArrayTools):
with(DiscreteTransforms):
Digits:=15:

# 1D Fourier Transform

Fs := 1000;                       # Sampling frequency                    
T := 1/Fs;                        # Sampling period       
L := 1500;                        # Length of signal
t := Vector(L, i -> i-1)*T:       # Time vector

f := Fs*Vector(floor(L/2)+1, i-> i-1)/L:   # Frequency                 


S:= Vector(L, i -> 0.7*sin(2.0*Pi*50*t[i]) + sin(2.0*Pi*120*t[i])):    # Signal


Z1 := FourierTransform(Vector(L, j->S[j])):              # DFT 
Z2 := Vector(L, i-> sqrt(Re(Z1[i])**2 + Im(Z1[i])**2)):  # Amplitude
                

FP1 := pointplot({seq([f[n],Z2[n]],n=1..floor(L/2)+1)}, labels=["Frequency","Amplitude"], connect=true, color=green):

display(FP1, axes=boxed);

The right answer should be a plot with frequencies at 50Hz and 120Hz, with amplitudes at 0.7 and 1.0, respectively. However my amplitude axes is off somehow and I don't understand why. 

Hello,

I'm compiling a maple procedure to a C code with the Compiler command. I was wondering if it is possible to change the optimization flag, for example -03  for gcc? Is there a way to maybe change a file in the Maple directory that specifies the compiler options?

Hello,

I am trying to generate a compiled c function

dc_test := proc( a :: Array(datatype=float[8]), b :: Array(datatype=float[8]), c :: Array(datatype=float[8]) ) 

c[..,..] := a . b;

return 0

end:

cdc_test:=Compiler:-Compile(dc_test, optimize):

a := Array(1..2, 1..2, fill=1.0, datatype=float[8]);
b := Array(1..2, 1..2, fill=1.0, datatype=float[8]);
c := Array(1..2, 1..2, datatype=float[8]);
                           
dc_test(a, b, c);

cdc_test(a, b, c);

This doesn't work because it doesn't recognize the "." symbol. Also if I were to take the transpose, for example Transpose(a), then it doesn't recognize that either. Are there commands for this that I'm unware of or do you have to program them from scratch?

Hello,

is it possible to send compiled Maple functions (C function) to the nodes with the Grid toolbox? I can run the non-compiled function on the nodes but when I try to send a compiled version of the same function I get segmentation error. I have run the compiled function just fine in other nonparallel codes, and also with the Threads package. So I was wondering if there is something else you need to do to get it to work? Maybe compile on each node?

 

1 2 3 Page 1 of 3