>> Waldek writes:
>>> Another question is what we should generate for products,
>>> sums and integrals. The current result is _not_ valid as input...

On Tue, Oct 27, 2009 at 7:15 PM, Martin Rubey wrote:

> why not similar to
>
> (9) -> integrate(f i, i)::INFORM
>
>   (9)  (integral (fun i) (:: i Symbol))
>                                                              Type: InputForm
> just replacing "integral" by "product" or "summation"?
> ...
> the right thing to do is to set a %specialInput property, as in
>
> fspace.spad.pamphlet:596:      setProperty(opdiff,SPECIALINPUT,indiff@(List % 
> -> InputForm) pretend None)
> liouv.spad.pamphlet:198:      setProperty(opint, SPECIALINPUT, inint@(List F 
> -> INP) pretend None)
> liouv.spad.pamphlet:199:      setProperty(opdint, SPECIALINPUT, indint@(List 
> F -> INP) pretend None)
>

Martin,

I have attached a patch 'combfunc.spad.pamphlet' that implements
InputForm as you suggest above.

    if F has ConvertibleTo(I) then
      setProperty(opdprod, SPECIALINPUT, indprod@(List F -> I) pretend None)
      setProperty(opdsum,  SPECIALINPUT, indsum@(List F -> I) pretend None)

...

    if F has ConvertibleTo(I) then
      indprod l ==
        convert([convert(_product)$I, convert(summand l)@I, _
          convert([convert("="::Symbol)$I, convert(third l)@I, _
            convert([convert('SEGMENT)$I, _
            convert(fourth l)@I, convert(fourth rest l)@I]$List(I)) _
            ]$List(I)) _
          ]$List(I))
      indsum l ==
        convert([convert(_summation)$I, convert(summand l)@I, _
          convert([convert("="::Symbol)$I, convert(third l)@I, _
            convert([convert('SEGMENT)$I, _
            convert(fourth l)@I, convert(fourth rest l)@I]$List(I))@I _
            ]$List(I))@I _
          ]$List(I))@I

 With this patch I get:

(1) -> summation(factorial(i+1),i=0..n)::InputForm

   (1)  (summation (factorial (+ i 1)) (= i (SEGMENT 0 n)))
                                                              Type: InputForm
(2) -> interpret %

          n
         --+
   (2)   >   (i + 1)!
         --+
        i = 0
                                                    Type: Expression(Integer)
(3) -> product(sin x,x=1..n+1)::InputForm

   (3)  (product (sin x) (= x (SEGMENT 1 (+ n 1))))
                                                              Type: InputForm
(4) -> interpret %

        n + 1
        ++-++
   (4)   | | sin(x)
         | |
        x = 1
                                                    Type: Expression(Integer)

---

However I still have problems with a crash in 'unparse' for example:

(5) -> product(sin x,x=1..n+1)::InputForm

   (5)  (product (sin x) (= x (SEGMENT 1 (+ n 1))))
                                                              Type: InputForm
(6) -> unparse %

debugger invoked on a SIMPLE-CONDITION: break

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [CONTINUE] Return from BREAK.

(BREAK "break")
0]

I am up to date with the FriCAS repository:

wsp...@debian:~/fricas-sources/src/algebra$ svn diff
combfunc.spad.pamphlet > ~/algebra-combfunc-1.patch
wsp...@debian:~/fricas-sources/src/algebra$
wsp...@debian:~/fricas-sources/src/algebra$ svn update
At revision 711.

which includes Waldek's recent related patch:

Modified: trunk/src/interp/format.boot
===================================================================
--- trunk/src/interp/format.boot        2009-10-26 22:48:47 UTC (rev 708)
+++ trunk/src/interp/format.boot        2009-10-27 02:44:28 UTC (rev 709)
@@ -461,7 +461,6 @@
    $curExpr : local := x
    x is ["=", arg1, arg2] or x is ['"=", arg1, arg2] =>
        concat(sumOrParen(arg1), '"=", sumOrParen(arg2))
-        sumOrParen(x)
    sumOrParen(x)

 sumOrParen(x) ==

---

Perhaps there is another bug lurking there?

Regards,
Bill Page.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to fricas-devel@googlegroups.com
To unsubscribe from this group, send email to 
fricas-devel+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to