It sort of helps in the sense that the hint about specifying the types is 
useful. 
I could not apply the solution directly because it lead to another very 
surprising (to me) quirk of FriCAS: lack of a basic form of referential 
transparency between variables and literals. Namely if you assign a literal 
to a variable and later in code use a variable, the result may be different 
than if you had used the literal instead. For example:

Let's assign an expression to a variable:

BS := 
((S*erf(((2*log((S/K))+T*s^2+2*T*r)/(2*s*sqrt(2)*sqrt(T))))-K*%e^((-T*r))*erf(((2*log((S/K))-T*s^2+2*T*r)/(2*s*sqrt(2)*sqrt(T))))-K*%e^((-T*r))+S)/2)

define an abbreviation for DoubleFloat

F:=DoubleFloat

Now define a function using the literal

C0(S:F,r:F,T:F,K:F,s:F):F == 
((S*erf(((2*log((S/K))+T*s^2+2*T*r)/(2*s*sqrt(2)*sqrt(T))))-K*%e^((-T*r))*erf(((2*log((S/K))-T*s^2+2*T*r)/(2*s*sqrt(2)*sqrt(T))))-K*%e^((-T*r))+S)/2)

And another one using the variable which stores that literal

C1(S:F,r:F,T:F,K:F,s:F):F == BS

Now the first function can be evaluated

C0(10.0,0.05,0.8,11.0,0.05)
0.023903294619544546

But the second cannot

C1(10.0,0.05,0.8,11.0,0.05)
Cannot convert the value from type Expression(Integer) to  DoubleFloat .

It seems the only way to create a function when the expression is stored in 
a variable is to first declare the function 

C2:(F,F,F,F,F) -> F

Then use the function operation to create the function from the expression

function(BS,'C2,['S,'r,'T,'K,'s])

Then such function can be evaluated

C2(10.0,0.05,0.8,11.0,0.05)
0.023903294619544546


On Saturday, November 10, 2018 at 12:07:44 PM UTC+1, Ralf Hemmecke wrote:

> > Is there a way to force the evaluation of erf so that the function   
> > s+->C(11.0,s)  can be plotted? 
>
> Does the following help? 
>
> The idea is that you specify the type so that the result is not 
> Expression(Float) (and must later be converted to (Double)Float, but 
> rather an element of DoubleFloat. 
>
> Ralf 
>
> F ==> DoubleFloat 
>
> C0(S:F,r:F,T:F, 
> K:F,s:F):F==((S*erf(((2*log((S/K))+T*s^2+2*T*r)/(2*s*sqrt(2)*sqrt(T))))-K*%e^((-T*r))*erf(((2*log((S/K))-T*s^2+2*T*r)/(2*s*sqrt(2)*sqrt(T))))-K*%e^((-T*r))+S)/2)
>  
>
>
> C(K:F, s:F):F==C0(10.0, 0.05, 0.8, K, s) 
>
> CC(s:F):F==C(11.0, s) 
>
> draw(CC, 2.0..3.0) 
>

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To post to this group, send email to fricas-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.

Reply via email to