Python Forum
Help trying to replace values in a function
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help trying to replace values in a function
#1
The problem is that I want to make a programme which from an inicial function that I defined, makes its partial derivate and then lets me to replace the variables with numeric values in the derivated function.

This is what I have:
from math import *
from sympy import symbols, diff

v,r=symbols('v r', real=True)
i=v/r #This is my initial function

d1=diff(i, v) #the first partial derivate
print d1
d2=diff(i, r) #the second one
print d2
Now what I want to do is to define for example r=1 and v=1 and then obtain the numeric value of d1 and d2.
How can I do that?

EDIT: I use 2.7 version of python
Reply
#2
I'm assuming it'll use the dsolve() function somehow, but I don't know enough about the module (...or math) to help more than that. https://docs.sympy.org/latest/tutorial/s...-equations
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Adding values with reduce() function from the list of tuples kinimod 10 2,637 Jan-24-2023, 08:22 AM
Last Post: perfringo
  function accepts infinite parameters and returns a graph with those values edencthompson 0 857 Jun-10-2022, 03:42 PM
Last Post: edencthompson
  Function - Return multiple values tester_V 10 4,439 Jun-02-2021, 05:34 AM
Last Post: tester_V
  basic random number generator in replace function krug123 2 2,038 Jul-31-2020, 01:02 PM
Last Post: deanhystad
  Function parameters and values as string infobound 1 1,757 Jul-24-2020, 04:28 AM
Last Post: scidam
  Function to return list of all the INDEX values of a defined ndarray? pjfarley3 2 1,961 Jul-10-2020, 04:51 AM
Last Post: pjfarley3
  Return values for use outside of function willowman 1 1,674 Apr-13-2020, 07:00 AM
Last Post: buran
  Function with many arguments, with some default values medatib531 3 2,580 Mar-14-2020, 02:39 AM
Last Post: medatib531
  auto supply values to a python script(function) from text file metro17 4 2,529 Oct-26-2019, 01:25 AM
Last Post: ichabod801
  Beginner problem, replace function with for loop Motley_Cow 9 4,614 Sep-13-2019, 06:24 AM
Last Post: Motley_Cow

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020