Skip to content

Calling the DSolve function in Python #22

@sambaPython24

Description

@sambaPython24

Hello,
this is a problem regarding the DSolve function from Mathematica, called in Python.

When I try to call an integration statement
`from wolframclient.evaluation import WolframLanguageSession
from wolframclient.language import wl, wlexpr
session = WolframLanguageSession()

alpha = wlexpr("Integrate[1/(x^3 + 1), {x, 0, 1}]")
result = session.evaluate(alpha)
print(result," ",type(result))`
everything works fine in Mathematica and in Mathematica called by Python.

When I try to run this
`from wolframclient.evaluation import WolframLanguageSession
from wolframclient.language import wl, wlexpr
session = WolframLanguageSession()

diff_0 = "DSolve[y'[x] + y[x] == a Sin[x], y[x], x]"
diff_1 = "DSolve[{y'[x] + y[x] == a Sin[x], y[0] == 0}, y, x]"
diff_2 = "DSolve[y'[x] + y[x] == a Sin[x], y[x], x]"

alpha = wlexpr(diff_0)
result = session.evaluate(alpha)
print(result," ",result)`

I get the error
String expected at position 1 in StringForm[MessageName[General, pkspec1], Slot[1]]. The expression Slot[1] cannot be used as a part specification. String expected at position 1 in StringForm[MessageName[General, pkspec1], i]. The expression i cannot be used as a part specification. String expected at position 1 in StringForm[MessageName[General, pkspec1], Slot[1]]. The expression Slot[1] cannot be used as a part specification. String expected at position 1 in StringForm[MessageName[General, pkspec1], i]. The expression i cannot be used as a part specification.
in Python while it works in Mathematica and I don't understand, why.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions