Creating arbitrary function with expression builder
Source code name: "func_exp2.py"
Programming language: Python
Topic: Function/Custom
DMelt Version 1. Last modified: 12/11/2015. License: Pro
https://datamelt.org/code/cache/func_exp2_1803.py
To run this script using the DataMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.


from java.awt import* 
from jhplot  import * 
from jhplot.math.exp4j import *
from jhplot.math.exp4j.function import * 


class cf2(Function):
     def  apply(self,val):
         a=val[0]*val[0]*val[0] 
         if (val[0]<0): return 0
         if (val[0]>0): return a
         return 0


e=ExpressionBuilder("cf2(x)")
func=cf2("cf2",1);
e.function(func)
e.variables("x")
fff=e.build()
fff.setVariable("x", 10);
print fff.evaluate()

Ads help maintain this website.