LMSouq
moodle-core Open

How to sum two Maxima/LISP-lists elementwise, in order to use them in a JSXgraph embedded in a Moodle STACK-exam?

SE
sesodesa
1 month ago
3 views
Problem Description
What the title says. I'm trying to build a graphical, two-variable optimization problem for students to solve using the [STACK-type](https://github.com/maths/moodle-qtype_stack) [Moodle-question](https://docs.moodle.org/35/en/Main_page), which uses Maxima as a backend for dealing with the math. I've tried the following: /*Constants*/ c1 : rand_with_step(0,15,0.1); c2 : c1 + 2; c3 : c1 + 1; c4 : c1; /*Solutions*/ OptimiPa : [c3,c1]; za : -1 * OptimiPa[1] + 2 * OptimiPa[2]; OptimiPb : [c3 + 1/2,c3 - 1/2]; zb : 2 * OptimiPb[1] + OptimiPb[2]; OptimiPc : [c1,c1]; zc : OptimiPc[1] + 3 * OptimiPc[2] OptimiPd : []; zd : inf; /*Variables for drawing*/ a : 1000000; b : a - 1; /*Variables for drawing lines*/ OptimiPa2 : OptimiPa + [1,0.5]; This, however does not produce the desired result when plugged into a JSXgraph: <jsxgraph style="width=500em;height=500em"; box="uniqueName">(function() { var board = JXG.JSXGraph.initBoard('uniqueName', {boundingbox:['{#c3-5#}','{#c2+2#}','{#c3+3#}', '{#c1-2#}'], keepaspectratio: true,zoom:false}); /*Axes*/ var axis1 = board.create('axis', [['{#c3-5#}','{#c1#}'], ['{#c3+3#}', '{#c1#}']]); var axis2 = board.create('axis', [['{#c1#}','{#c1-5#}'], ['{#c1#}', '{#c2+3#}']]); /*Polygon angles*/ var k1 = board.create('point', ['{#c3#}','{#c1#}'],{visible:false}); var k2 = board.create('point', ['{#c1#}','{#c1#}'],{visible:false}); var k3 = board.create('point', ['{#c1-a#}','{#-(-c1-a)#}'],{visible:false}); var k4 = board.create('point', ['{#c1-b#}','{#2 - (-c1 - b)#}'],{visible:false}); var k5 = board.create('point', ['{#c1+3/2#}','{#(c1 + 3/2) - 1#}'],{visible:false}); /*Optimization area as a polygon*/ var optAl = board.create('polygon',[k1,k2,k3,k4,k5],{borders: {visible: true},vertices: {visible: false}}); /*Points for drawing lines*/ var pa1 = board.create('point', '{#OptimiPa#}',{visible:false}); var pa2 = board.create('point', '{#OptPa2#}',{visible:false}); /*Lines*/ var suoraA = board.create('line',[pa1,pa2]); })(); </jsxgraph> What am I doing wrong here? The rest of the image appears just fine, but the line `suoraA` doesn't appear inside the figure. EDIT: Fixed the code in accordance with @jkiiski's points, but the issue still persisted. Look below for a partial answer.

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base