 |
Showing a custom function using exp4j
Source code name: "func_exp3.py"
Programming language: Python
Topic: Function/Custom
DMelt Version 1. Last modified: 12/11/2015. License: Pro
https://datamelt.org/code/cache/func_exp3_4298.py
To run this script using the DMelt 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):
if (val[0]<100):
return val[0]*val[0]
if (val[0]>=100):
return val[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()
c1 = HPlot()
c1.visible(1)
c1.setAutoRange()
f=F1D(e.build(), 10,1000)
c1.draw(f)
You see the box below because you did not login.