Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

1. using the following matlab script as a guide, fix the script so that…

Question

  1. using the following matlab script as a guide, fix the script so that we evaluate x^2 from the values of -1 to 1 using 100 steps. start=0; stop=0; steps=0; changex = (start - stop)/steps; ultima = 0; for value = start:changex:stop - changex val1 = x; val2 = x; temp = 0.5changex(val1 + val2); ultima = ultima + temp; end ultima (long answer)

Explanation:

Step1: Set correct start, stop and steps values

start = -1;
stop = 1;
steps = 100;

Step2: Calculate change in x

changex=(stop - start)/steps;

Step3: Initialize the sum variable

ultima = 0;

Step4: Loop through the values

for value = start:changex:stop - changex
    val1 = value^2;
    val2 = (value + changex)^2;
    temp = 0.5*changex*(val1 + val2);
    ultima = ultima + temp;
end

Step5: Display the result

ultima

Answer:

start = -1;
stop = 1;
steps = 100;
changex=(stop - start)/steps;
ultima = 0;
for value = start:changex:stop - changex
    val1 = value^2;
    val2 = (value + changex)^2;
    temp = 0.5*changex*(val1 + val2);
    ultima = ultima + temp;
end
ultima