# runs in Octave (tested) but not SageMathCloud (errors) 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 close merge delete

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

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

Sort by » oldest newest most voted
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.

more

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.

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.

more