Why I can't plot the integral function with SymPy and Plots?

I don’t think this does what you think it does:

julia> f(x) = integrate((5 + sin(x))^4)
f (generic function with 1 method)

julia> f(1)
ERROR: MethodError: no method matching integrate(::Float64)

when you pass x, (5 + sin(x))^4 is just a nuber - e.g. for x = pi you get 5^4 = 625 so you are essentially doing

julia> integrate(625.0)
ERROR: MethodError: no method matching integrate(::Float64)

which doesn’t make a lot of sense. integrate is expecting a function rather than a value, so you probably meant:

julia> g = integrate(y -> (5 + sin(y))^4)
       4             2       2                            4
3⋅x⋅sin (x)   3⋅x⋅sin (x)⋅cos (x)           2      3⋅x⋅cos (x)           2
─────────── + ─────────────────── + 75⋅x⋅sin (x) + ─────────── + 75⋅x⋅cos (x)
     8                 4                                8

               3                                             3
          5⋅sin (x)⋅cos(x)         2             3⋅sin(x)⋅cos (x)
+ 625⋅x - ──────────────── - 20⋅sin (x)⋅cos(x) - ──────────────── - 75⋅sin(x)⋅
                 8                                      8

               3
         40⋅cos (x)
cos(x) - ────────── - 500⋅cos(x)

Now you can pass a value which will be substituted to derive the integral:

julia> g(2)
     4                  3           3                  2       2           4
3⋅cos (2)   3⋅sin(2)⋅cos (2)   5⋅sin (2)⋅cos(2)   3⋅sin (2)⋅cos (2)   3⋅sin (2
───────── - ──────────────── - ──────────────── + ───────────────── + ────────
    4              8                  8                   2               4

          3
)   40⋅cos (2)         2                    2                                2
─ - ────────── - 20⋅sin (2)⋅cos(2) + 150⋅cos (2) - 75⋅sin(2)⋅cos(2) + 150⋅sin
        3



(2) - 500⋅cos(2) + 1250
2 Likes