Ask Your Question
0

runs in Octave (tested) but not SageMathCloud (errors)

asked 2015-10-29 03:17:20 -0600

thetha gravatar image

updated 2016-06-06 14:48:31 -0600

FrédéricC gravatar image

Hi, this is my assignment in numerical mathematics, this runs in Octave but unfortunately not in SageMath, can someone see what the problem is?

See the SageMathCloud worksheet https://cloud.sagemath.com/projects/6...

Here is the code

# a)

function y=f(x)  
    y=3/(2+x)
endfunction

function a=p(x)  
    y1=x^2
    y2=x
    y3=1
    a=[y1,y2,y3]
endfunction

# b)

# Stützstellen vector x

x=[-1 0 1]
f(x(1))
f(x(2))
f(x(3))

# Anzahl der Stützstellen bestimmer

d=length(x)
A=zeros(d,d)

for i=1:3
    A(i,:)=p(x(i))
endfor

b=zeros(3,1)

for i=1:3
    b(i)=f(x(i))
endfor

b
[L,U,P] = lu(A)
invL=inv(L)
y=invL*P*b
invU=inv(U)
z=invU*y
A*z
b
edit retag flag offensive close merge delete

Comments

The syntax of Octave and Sage languages are different. You should not expect that a file working for one of them would work with the other. Or perhaps I misunderstood your question...

vdelecroix gravatar imagevdelecroix ( 2015-10-29 07:37:52 -0600 )edit

Hi, from what I have understood, this IS the big point about sagecloud. If stated in the beginnig, that this is octave worksheet, every thing should work. Heres is an example: https://cloud.sagemath.com/projects/6... This is in octave but unfortunatelly there are no functions included

thetha gravatar imagethetha ( 2015-10-29 08:47:25 -0600 )edit

2 answers

Sort by » oldest newest most voted
0

answered 2015-10-29 12:20:16 -0600

William Stein gravatar image
  1. This is a bug in Sage itself, and can be reported as such. Just put the above code in a python string at the terminal and do octave.eval(s) and it hangs forever. I hope somebody reports it to http://trac.sagemath.org/

  2. A workaround in SageMathCloud is to (a) put your code in a file, e.g., mycode.m, then (b) load that file in a worksheet by typing sh('octave mycode.m'). Here's a working example:

    https://cloud.sagemath.com/projects/4...

Since you're editing a big script anyways, you'll get nice syntax highlighting, etc. using .m file, so this shouldn't be too bad.

edit flag offensive delete link more

Comments

Thank you. The "downside" to run it via command,is that i cannot use the results with sagemath cloud right? The error was posted again. I was thinking to turn my home work this way. The idea was send the m file and include a link to sagemathcloud with comment, "hit run" :) if he sees the results, every thing should be fine. They using octave and matlab here in Germany a lot. I think this is solved the error is reported.

thetha gravatar imagethetha ( 2015-10-29 14:37:37 -0600 )edit
0

answered 2015-10-29 10:15:22 -0600

haraldschilly gravatar image

your "default mode" setup needs to be in a separate cell. that's a bit of a bug, but on the other hand kind of self-referential and therefore doesn't work.

despite that, it somehow fails to evaluate which is probably an issue with how octave is embedded. I suggest you to open up a terminal and run octave directly. there it works fine.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-10-29 03:17:20 -0600

Seen: 137 times

Last updated: Oct 29 '15