-1
import sympy as sp
sp.init_printing()
%matplotlib notebook
import numpy as np
import matplotlib.pyplot as plt
from IPython.display import display

Problem

Can somebody help me please?

fuglede
  • 17,388
  • 2
  • 54
  • 99
  • Welcome to SO. [Don't screenshot code](https://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-or-errors) – Crispin Mar 19 '17 at 09:23

2 Answers2

0

The variable y is a numpy.ndarray, not a callable, which means it cannot be used like a function (or other callable) would: y(); only indexed, like y[]. You probably meant to write sp.Derivative(y[x],x).

Community
  • 1
  • 1
Crispin
  • 2,070
  • 1
  • 13
  • 16
0

I suspect that you want to solve a differential equation involving only scalar variables.

>>> import sympy as sp
>>> sp.var('x')
x
>>> f = sp.Function('f')
>>> sp.dsolve(sp.Derivative(f(x),x)-(1/(1+x**2)-2*f(x)**2))
Eq(f(x), x**3*(2*C1*(C1 - 1) - 1)/3 + x**5*(C1*(16*C1*(-9*C1 + 1) - 13*C1 + 2) - 20*C1 + 12)/30 + C1 + C1*x + C1*x**4*(13*C1 + 2)/6 - C1**2*x**2 + O(x**6))

If you have an initial condition and need to solve for the arbitary constant then Represent a first order differential equation in numpy might help. (I don't know for sure.)

Community
  • 1
  • 1
Bill Bell
  • 21,021
  • 5
  • 43
  • 58