Code Monkey home page Code Monkey logo

ratfun.jl's Introduction

RatFun.jl

RatFun is a package for working with functions expressible as a Fun divided by another Fun. The numerator and denominator may be different types of Funs.

Example usage

Define two functions on an interval using ApproxFun:

using ApproxFun
using RatFun
p = Fun(x->exp(-10x^2))
q = Fun(x->-1+.5x*sin(100x^2)

You can define a RationalFun, representing p/q, as follows.

r = p // q

We use Plots.jl to plot it.

using Plots
plot(plot(p,title="p"),plot(q,title="q"),plot(r,title="r=p/q"),layout=grid(3,1))

You can also do the same for Funs with more exotic types, such as those with Dirac deltas, as follows.

p2 = .7*DiracDelta(-1.25) - .9*DiracDelta(.5) + p
q2 = .5*KroneckerDelta(-1.25) - .7*KroneckerDelta(.5) + q
r2 = p2 // q2
plot(plot(p2,title="p2"),plot(q2,title="q2"),plot(r2,title="r2=p2/q2"),layout=grid(3,1))

RationalFuns with Dirac deltas in the numerator are used in the SpectralMeasures package.

ratfun.jl's People

Contributors

marcusdavidwebb avatar dlfivefifty avatar juliatagbot avatar

Stargazers

 avatar  avatar

Watchers

James Cloos avatar  avatar Alex Townsend  avatar  avatar Mikael Slevinsky avatar  avatar

Forkers

ymardoukhi

ratfun.jl's Issues

roots() not working for RatFun

Can not use roots() on a rational function.

MWE:

using ApproxFun,RatFun
function mwe()
	t = Fun(identity,0..pi)
	f = (2-2*cos(t))^2
	g = 2-2*cos(t)
	r = f//g
	display(roots(f-3.5))
	display(roots(g-3.5))
	display(roots(r-3.5))
end

Output:

julia> mwe()
1-element Array{Float64,1}:
 1.5061656879014247
1-element Array{Float64,1}:
 2.41885840577638
ERROR: MethodError: no method matching -(::RationalFun{Fun{Chebyshev{Interval{:closed,:closed,Float64},Float64},Float64,Array{Float64,1}},Fun{Chebyshev{Interval{:closed,:closed,Float64},Float64},Float64,Array{Float64,1}}}, ::Float64)
Closest candidates are:
  -(::Float64, ::Float64) at float.jl:397
  -(::Complex{Bool}, ::Real) at complex.jl:298
  -(::Missing, ::Number) at missing.jl:93
julia> versioninfo()
Julia Version 1.0.3
Commit 099e826241 (2018-12-18 01:34 UTC)
Platform Info:
  OS: Linux (x86_64-pc-linux-gnu)
  CPU: Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, haswell)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.