Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiplying CosSpace() / SinSpace() of different period leads error? #937

Closed
yewalenikhil65 opened this issue Mar 29, 2024 · 6 comments
Closed

Comments

@yewalenikhil65
Copy link

yewalenikhil65 commented Mar 29, 2024

Doing following multiplication of CosSpace/ SinSpace with another CosSpace()/SinSpace() of different period leads to following error. But i do need to find the multiplication. Can anybody please help here ?

julia> G = Fun(CosSpace(), rand(3)) 
Fun(CosSpace(【0.0,6.283185307179586❫), [0.587619, 0.499599, 0.616276]) 
 
 
julia> F = Fun(SinSpace(PeriodicSegment(0, pi)), rand(3));   # sin * cos
 
julia> Multiplication(F, CosSpace())*G 
ERROR: AssertionError: domain(f) == domain(sp) 
Stacktrace: 
 [1] Multiplication(f::Fun{SinSpace{PeriodicSegment{Float64}, Float64}, Float64, Vector{Float64}}, sp::CosSpace{PeriodicSegment{Float64}, Float64}) 
  @ ApproxFunFourier ~/.julia/packages/ApproxFunFourier/lFQDK/src/FourierOperators.jl:222 
 [2] top-level scope 
  @ REPL[11]:1


julia> F = Fun(CosSpace(PeriodicSegment(0, pi)), rand(3));   # cos* cos

julia> Multiplication(F, CosSpace())*G
ERROR: Domain mismatch: cannot multiply function on 【0.0,3.141592653589793❫ to function on 【0.0,6.283185307179586❫
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] ConcreteMultiplication
   @ ApproxFunBase ~/.julia/packages/ApproxFunBase/clvO0/src/Operators/banded/Multiplication.jl:23 [inlined]
 [3] Multiplication(f::Fun{CosSpace{PeriodicSegment{Float64}, Float64}, Float64, Vector{Float64}}, sp::CosSpace{PeriodicSegment{Float64}, Float64})
   @ ApproxFunFourier ~/.julia/packages/ApproxFunFourier/lFQDK/src/FourierOperators.jl:218
 [4] top-level scope
   @ REPL[98]:1

@yewalenikhil65 yewalenikhil65 changed the title Multiplying CosSpace() / SinSpace() of different period ? Multiplying CosSpace() / SinSpace() of different period leads error? Mar 29, 2024
@yewalenikhil65
Copy link
Author

Just to mention my purpose
I wished to create series in following way

a= rand(3);  b= rand(3);  # typically arrays of of n elements

# simplify following multiplication into another cosine series of period 2pi
  (a[1] + a[2]*cos(θ) + a[3]*cos)(2θ) + ...)*(b[1] + b[2]*cos(2θ) + b[3]*cos(4θ) + ...)

@mzaffalon
Copy link
Contributor

mzaffalon commented Apr 1, 2024

If you need the analytical solution, you can use SymPy.jl.

@yewalenikhil65
Copy link
Author

yewalenikhil65 commented Apr 1, 2024

If you need the analytical solution, you can use SymPy.jl.

I don't really want a symbolic solution.. Just the coefficients of the resulting CosSpace when the multiplying CosSpaces have different period

The theta I wrote in earlier comment is just for explanation

@dlfivefifty
Copy link
Member

Just re-expand the one with the larger period in the space with the smaller period

@yewalenikhil65
Copy link
Author

Just re-expand the one with the larger period in the space with the smaller period

Do you mean something like this ?

julia> using ApproxFun

julia> G = Fun(CosSpace(), rand(3)) ;

julia> G
Fun(CosSpace(【0.0,6.283185307179586❫), [0.642775, 0.257448, 0.915413])

julia> F = Fun(CosSpace(), [1,0.0, rand(), 0.0, rand() , 0.0, rand()])
Fun(CosSpace(【0.0,6.283185307179586❫), [1.0, 0.0, 0.297021, 0.0, 0.476742, 0.0, 0.711284])

julia> F*G
 
Fun(CosSpace(【0.0,6.283185307179586❫), [0.778723, 0.295682, 1.32454, 0.0996018, 0.767945, 0.152927, 0.675403, 0.0915593, 0.325559])


@yewalenikhil65
Copy link
Author

@dlfivefifty I am closing this. I managed to do finally as per my previous command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants