Re: [fricas-devel] interoperability with sage again

2018-07-22 Thread 'Martin R' via FriCAS - computer algebra system
Perhaps as follows? Besides, it seems that this was dead code before my 
patch...

Martin

diff --git a/src/interp/format.boot b/src/interp/format.boot
index fc2de70..4748d9e 100644
--- a/src/interp/format.boot
+++ b/src/interp/format.boot
@@ -394,7 +394,7 @@ form2String1 u ==
 lo := form2String1 first argl
 argl := rest argl
 (null argl) or null (first argl) => [lo, '".."]
-[lo, '"..", form2String1 first argl]
+concat(lo, '"..", form2String1 first argl)
   op = "MATRIX" => matrix2String argl
   u1 is ["ROOT", arg1] =>
  concat("sqrt(", appOrParen(arg1),")")


-- 
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.


Re: [fricas-devel] interoperability with sage again

2018-07-22 Thread Waldek Hebisch
Martin R wrote:
> unfortunately, I just discovered a problem:
> 
> (18) -> unparse(sum(1/factorial(k), k=1..n+m)::INFORM)
>  
>>> Error detected within library code:
>strsym: form is neither a string or symbol
> 
> I am trying to fix it...

There is a bug in unparse of SEGMENT:

PRETTYPRINT(unparseInputForm(sum(1/factorial(k), k=1..n+m)::INFORM)$Lisp)$Lisp
(|sum| |(| "1" "/" "factorial" "(" #1="%C" ")" |,| "equation" "(" #1#
  "," "1" ".." ("n" "+" "m") ")" |)|)

Fix for this is easy, but I would like to check if there are no
related problems.

-- 
  Waldek Hebisch

-- 
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.


Re: [fricas-devel] interoperability with sage again

2018-07-22 Thread 'Martin R' via FriCAS - computer algebra system
Thank you!

unfortunately, I just discovered a problem:

(18) -> unparse(sum(1/factorial(k), k=1..n+m)::INFORM)
 
   >> Error detected within library code:
   strsym: form is neither a string or symbol

I am trying to fix it...

Martin

-- 
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.


Re: [fricas-devel] interoperability with sage again

2018-07-22 Thread Waldek Hebisch
Martin R wrote:
> 
> If possible, could you please commit for me?

OK, commited.

-- 
  Waldek Hebisch

-- 
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.


Re: [fricas-devel] interoperability with sage again

2018-07-22 Thread 'Martin R' via FriCAS - computer algebra system
Wonderful, thank you!

If possible, could you please commit for me?

Otherwise I'll try tomorrow...

Martin

-- 
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.


Re: [fricas-devel] Expressing erf as cumulative normal

2018-07-22 Thread Waldek Hebisch
Slawomir Kolodynski wrote:
> 
> I am learning FriCAS so please excuse my basic questions and point me to 
> better place to ask them is such exists.
> 
> FriCAS is able to evaluate some integrals in terms of the Gauss error 
> function (erf). For example 
> 
> (1/(sqrt(2*%pi)))*integrate(exp(-t^2/2),t=%minusInfinity..x)
> 
> returns an expression involving erf. I would prefer such integrals to be 
> evaluated in terms of cumulative distribution function of the standard 
> normal distribution. 
> To achieve that I tried to define a rewriting rule
> 
> phirule: rule erf(%x)==2*N(x*sqrt(2))-1
> 
> hoping that applying that on the result of integration will express the 
> result in terms of N (the CDF of standard normal). However, I get 
> 
> rule(erf(QUOTE(%x)),2*applyQuote(QUOTE(N),QUOTE(x)*sqrt(2))-1,[
>   QUOTE(N)]) is not a valid type.
> 
> when I try to define the rule. 
> What I am doing wrong when defining the rule?

1) ':' means type declaration.  You need ':=' for assignment
2) You need to declare 'N' befor use

Below is working version:

(1) -> N := operator 'N

   (1)  N
  Type: BasicOperator
(2) -> phirule := rule erf(%x)==2*N(x*sqrt(2))-1

 +-+
   (2)  erf(%x) == 2 N(x\|2 ) - 1
   Type: RewriteRule(Integer,Integer,Expression(Integer))
(3) -> (1/(sqrt(2*%pi)))*integrate(exp(-t^2/2),t=%minusInfinity..x)

  +-+  x  +-+  +---+
(\|2 erf() + \|2 )\|%pi
  +-+
 \|2
   (3)  
+-+
 2 \|2 %pi
Type: Expression(Integer)
(4) -> phirule(%)

 +-++-+  +---+
\|2 N(x\|2 )\|%pi
   (4)  --
  +-+
 \|2 %pi
Type: Expression(Integer)


Note that for FriCAS 'N' is an arbitrary functions with unknown
properties.  The first line tells FriCAS that 'N' is being
used as function name (operator), otherwise FriCAS would complain
about undefined function.


-- 
  Waldek Hebisch

-- 
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.


[fricas-devel] Expressing erf as cumulative normal

2018-07-22 Thread Slawomir Kolodynski
I am learning FriCAS so please excuse my basic questions and point me to 
better place to ask them is such exists.

FriCAS is able to evaluate some integrals in terms of the Gauss error 
function (erf). For example 

(1/(sqrt(2*%pi)))*integrate(exp(-t^2/2),t=%minusInfinity..x)

returns an expression involving erf. I would prefer such integrals to be 
evaluated in terms of cumulative distribution function of the standard 
normal distribution. 
To achieve that I tried to define a rewriting rule

phirule: rule erf(%x)==2*N(x*sqrt(2))-1

hoping that applying that on the result of integration will express the 
result in terms of N (the CDF of standard normal). However, I get 

rule(erf(QUOTE(%x)),2*applyQuote(QUOTE(N),QUOTE(x)*sqrt(2))-1,[
  QUOTE(N)]) is not a valid type.

when I try to define the rule. 
What I am doing wrong when defining the rule?
Is defining such rule the best way to convert the result of integration so 
that it is expressed in terms the CDF of standard normal rather than the 
erf function?

Thanks,

Slawomir

-- 
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.