Giter Club home page Giter Club logo

Comments (8)

fremling avatar fremling commented on May 29, 2024

Hi. The code as you type will have no chance of working because the HypergeometricFunctions is not a defined function within MathLink. What would be the corresponding Mathematica code that you would run in this instance?

Or is there some other Julia library also at work in this example?

from mathlink.jl.

Li-shiyue avatar Li-shiyue commented on May 29, 2024

Hi. The code as you type will have no chance of working because the HypergeometricFunctions is not a defined function within MathLink. What would be the corresponding Mathematica code that you would run in this instance?

Or is there some other Julia library also at work in this example?

I also used HypergeometricFunctions in Julia
the Full code is
using MathLink
using HypergeometricFunctions
a=weval(W"Series"(HypergeometricFunctions.pFq((2,), (0.2,),W"z"),(W"z",-1,50)))

from mathlink.jl.

fremling avatar fremling commented on May 29, 2024

Hi. Your problem is that the HypergeometricFunctionspackage does no accept MathLink arguments.

using MathLink
using HypergeometricFunctions

julia> HypergeometricFunctions.pFq((2,), (0.2,),1)
35.11151422002346

julia> HypergeometricFunctions.pFq((2,), (0.2,),W"z")
ERROR: MethodError: no method matching AbstractFloat(::MathLink.WSymbol)

If you want to use the Mathematica hypergeoemtric functions your need to use the HypergeometricPFQ function wich is builtin to Mathematica.

from mathlink.jl.

Li-shiyue avatar Li-shiyue commented on May 29, 2024

How can I define HypergeometirvPFQ in julia,while I see connection between Julia and mathematic through a char "W"

from mathlink.jl.

fremling avatar fremling commented on May 29, 2024

The syntac change is usually simple. Replace any Matematica function <fun> with W"<fun>" and the [<arg>] with (<arg>). If you are unsure what it should look like you can always use the ' construction as

W`<fun>`

Here follows a series of eamples of how to works figures out the correct syntax

Test that numerics values work

julia> weval(W`HypergeometricPFQ[{1, 1}, {3, 3, 3}, 2.]`)
1.0789344020671878

Test that algebraic expressions work

julia> weval(W`HypergeometricPFQ[{1, 1}, {3, 3, 3}, z]`)
W"HypergeometricPFQ"(W"List"(1, 1), W"List"(3, 3, 3), W"z")

Note that the weval is not nencarry. Mathlink does the translation anyway:

julia> W`HypergeometricPFQ[{1, 1}, {3, 3, 3}, z]`
W"HypergeometricPFQ"(W"List"(1, 1), W"List"(3, 3, 3), W"z")

Here the same thing with weval

julia> weval(W"HypergeometricPFQ"([1, 1],[3, 3, 3], W"z"))
W"HypergeometricPFQ"(W"List"(1, 1), W"List"(3, 3, 3), W"z")

And if you run the series you will get more data back:

julia> weval(W"Series"(W"HypergeometricPFQ"([1, 1],[3, 3, 3], W"z"),(W"z",-1,2)))
W"SeriesData"(W"z", -1, W"List"(W"HypergeometricPFQ"(W"List"(1, 1), W"List"(3, 3, 3), -1), W"Plus"(-8, W"Times"(8, W"HypergeometricPFQ"(W"List"(1, 1), W"List"(2, 2, 2), -1)), W"HypergeometricPFQ"(W"List"(1, 1), W"List"(3, 3, 3), -1)), W"Plus"(-16, W"Times"(4, W"BesselJ"(0, 2)), W"Times"(16, W"HypergeometricPFQ"(W"List"(1, 1), W"List"(2, 2, 2), -1)), W"HypergeometricPFQ"(W"List"(1, 1), W"List"(3, 3, 3), -1))), 0, 3, 1)

I hope this clarifies things.

from mathlink.jl.

Li-shiyue avatar Li-shiyue commented on May 29, 2024

Thanks! That helps a lot,I am not familiar with MathLink,I tried the method above and successfully get the result.
My goal is get the TaylorSeries coefficients, how can I access W"List"(-2.0401353687919177, 1.6538235838749207, 0.9454567962158056, 0.33340658574157367, 0.08626703289712206, 0.017680673659342557) the coefficient as I understand it?here is my code
a=weval(W"Series"(W"Hypergeometric1F1"(0.1,0.02, W"z"),(W"z",-1,5)))
W"SeriesData"(W"z", -1, W"List"(-2.0401353687919177, 1.6538235838749207, 0.9454567962158056, 0.33340658574157367, 0.08626703289712206, 0.017680673659342557), 0, 6, 1)

from mathlink.jl.

fremling avatar fremling commented on May 29, 2024

Hi @Li-shiyue, you can access the series data by looking at the args of a. The trick is to access the third argument which i a W"List". We then access the arguments of the list to get the coefficients we want.

julia> a=weval(W"Series"(W"Hypergeometric1F1"(0.1,0.02, W"z"),(W"z",-1,5)))
W`SeriesData[z, -1, List[-2.0401353687919177, 1.6538235838749207, 0.9454567962158056, 0.33340658574157367, 0.08626703289712206, 0.017680673659342557], 0, 6, 1]`
julia> series =a.args[3].args
6-element Vector{Float64}:
 -2.0401353687919177
  1.6538235838749207
  0.9454567962158056
  0.33340658574157367
  0.08626703289712206
  0.017680673659342557

from mathlink.jl.

fremling avatar fremling commented on May 29, 2024

I think that this solves the original question, and I will close this ticket.

from mathlink.jl.

Related Issues (20)

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.