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

laplace wrong answer in t*sin() or t*cos() transforms #1295

Closed
Ale-AR opened this issue May 2, 2024 · 4 comments · Fixed by #1298
Closed

laplace wrong answer in t*sin() or t*cos() transforms #1295

Ale-AR opened this issue May 2, 2024 · 4 comments · Fixed by #1298
Milestone

Comments

@Ale-AR
Copy link

Ale-AR commented May 2, 2024

# Package symbolic v.3.1.1 in GNU Octave Version: 9.1.0
pkg load symbolic
syms t s

laplace(3*t*sin(4*t))
##
##ans = (sym)
##
##        8⋅s
##  ────────────────
##   4       2
##  s  + 32⋅s  + 256

# ERROR - The answer is for laplace(t*sin(4*t))
#         (24·s) was expected in the numerator.

# Now let's edit it and recalculate:

laplace(5*t*sin(4*t))
##
##ans = (sym)
##
##        8⋅s
##  ────────────────
##   4       2
##  s  + 32⋅s  + 256

# ERROR - Same previous answer is repeated.
#         (40·s) was expected in the numerator.

# Same behavior is observed in t*cos():

laplace(5*t*cos(2*t))
##
##ans = (sym)
##
##       2
##      s  - 4
##  ──────────────
##   4      2
##  s  + 8⋅s  + 16

# ERROR - The answer is for laplace(t*cos(2*t))
#         (5·s²-20) was expected in the numerator.

laplace(2*t*cos(2*t))
##
##ans = (sym)
##
##       2
##      s  - 4
##  ──────────────
##   4      2
##  s  + 8⋅s  + 16

# ERROR - Same previous answer is repeated.
#         (2·s²-8) was expected in the numerator.`
@cbm755
Copy link
Collaborator

cbm755 commented May 13, 2024

I cannot reproduce any of these, at least on SymPy v1.12. Perhaps its a bug in an earlier SymPy?

>> syms t s
Symbolic pkg v3.1.1+: Python communication link active, SymPy v1.12.

>> simplify(laplace(3*t*sin(4*t)))
ans = (sym)
        24⋅s      
  ────────────────
   4       2      
  s  + 32⋅s  + 256

>> simplify(laplace(5*t*sin(4*t)))
ans = (sym)
        40⋅s      
  ────────────────
   4       2      
  s  + 32⋅s  + 256

I'll see if I can get these running on our CI tests, which will test over a wider range of versions... but I suspect you'll need to upgrade SymPy, Octave, and/or Symbolic (most likely the first)

@cbm755
Copy link
Collaborator

cbm755 commented May 13, 2024

I see you gave your Octave and Symbolic versions so most likely its SymPy that is too old...

@cbm755 cbm755 added this to the 3.2.0 milestone May 13, 2024
@cbm755
Copy link
Collaborator

cbm755 commented May 14, 2024

Seems it was broken in SymPy 1.10 and 1.11. I figure you were using one of those.

image

Tests in place so it shouldn't happen again! Thanks for the note. "Fixed" in #1298.

@Ale-AR
Copy link
Author

Ale-AR commented May 14, 2024

You are correct, Octave seems to use Sympy version 1.10.1:

>> pkg load symbolic
>> syms t s
Symbolic pkg v3.1.1: Python communication link active, SymPy v1.10.1.

However, I have version 1.12 installed on my system:

$ pip show sympy
Name: sympy
Version: 1.12

I guess the problem is that I use Flatpak's Octave.

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

Successfully merging a pull request may close this issue.

2 participants